Git Product home page Git Product logo

guardianbeam's Introduction

GuardianBeam

An util to create easily Guardians and Ender Crystal Lasers via Packets and Reflection. No ProtocolLib, compatible from Minecraft 1.9 to Minecraft 1.17.1!

Inspired by the plugin GuardianBeamAPI by Jaxon A Brown, which uses ProtocolLib (https://www.spigotmc.org/resources/guardianbeamapi.18329/)

There is a tutorial on SpigotMC

Static laser gif

How to use ?

First, copy the Laser.java class to your project.

Then, it's extremely simple:

  1. Create Location objects of where do you want your laser starts and ends.
  2. Create a Laser instance: new GuardianLaser(locationStart, locationEnd, duration, visibleDistance) - duration is the time (in seconds) when laser will be visible (if you set it to -1, the laser will exist infinitely), and visibleDistance is the amount of blocks where your laser will be visible. You can also use new CrystalLaser(...) to create an Ender Crystal laser.
  3. After this, call the method laser.start(plugin); - where "plugin" parameter is the instance of your JavaPlugin class.
  4. TA-DAAAM ! Your laser is created and shown to near players !
  5. You can move the laser with the methods laser.moveStart(newLocation); and laser.moveEnd(newLocation);
  6. To remove your laser before his end duration, just call laser.stop();

Demo

Here is something I quickly made to show what you can do with this API: a ray-gun.

Moving laser animation

You can see the system in action on this video, and the class is available here.

Advanced usage

Animations

The Laser#moveStart(Location location, int ticks, Runnable callback and Laser#moveEnd(Location location, int ticks, Runnable callback) methods can be used to make the laser move smoothly from one point to another.

Quick preview of the smooth movement:

Smooth laser animation

End runnable

If you want to execute some actions when the laser comes to its end, use the Laser#executeEnd(Runnable runnable) method.

i.e.:

new Laser(start, end, 10, 60).executeEnd(() -> Bukkit.broadcastMessage("Laser ended!")).start(plugin);

This will start a laser for 10 seconds, after that the message "Laser ended!" will be broadcasted to users.

Duration in ticks

The duration passed into the new Laser(Location start, Location end, int duration, int distance) constructor is in seconds. If you want it to be in ticks, call Laser#durationInTicks().

i.e.:

new Laser(start, end, 10, 60).durationInTicks().start(plugin);

This will start a laser for 10 ticks.

Troubleshooting

Sometimes, Guardian beams only renders as bubbles, the moving color part is invisible. It is not caused by this util but by a Minecraft bug.

It happens when your world gets too old (when its game time value reaches 2800000). The only way to fix it is to open the level.dat file with a NBT editor, and edit manually the Data.Time field to a lower value. Save the file, and start your server.

guardianbeam's People

Contributors

chrisgdt avatar skytasul avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.