Git Product home page Git Product logo

particlelib's Introduction

NO LONGER MAINTAINED. ANY VERSION AFTER 1.19.4 WILL NOT BE SUPPORTED! USE PAPER'S PARTICLEBUILDER


ParticleLib

A spigot library supporting all particles from 1.8 to 1.19.3

codacy maven issues stars license build

SupportFeaturesDownloadUsage

Support

Join the Discord if you have any questions. Don't open an issue to ask for support.

Features

  • Multiversion support from 1.8 - 1.19.3 (All in one Jar)
  • Colored particles
  • Particles with custom velocities
  • Particles with textures
  • Support for every particle in minecraft
  • An easy and fluent API to easily spawn particles with custom data

Download

The latest version can be downloaded on the releases page.

Maven

<dependencies>
    <dependency>
        <groupId>xyz.xenondevs</groupId>
        <artifactId>particle</artifactId>
        <version>1.8.4</version>
    </dependency>
</dependencies>

Gradle

dependencies {
    implementation 'xyz.xenondevs:particle:1.8.4'
}

Note: ParticleLib is on the central repository, so no extra repositories are required.

Usage

For more advanced usage explanations check out the Wiki.

Simple

To spawn particles, you can either use the ParticleEffet#display method, or you can use the ParticleBuilder.
For normal particles without any extra data, the display method is the best choice.

Example:

ParticleEffect.FLAME.display(location);

This code will spawn a flame particle at the specified location.

Some particles can have extra data. This data can contain a range of different properties.
For these special cases, I will only use the ParticleBuilder. Display methods with the specific parameters still exist, but shouldn't be used to avoid confusion.


Directional

Some particles accept a custom velocity. When given a Vector they will travel to the specified offset. The velocity is stored in the offsetX, offsetY and offsetZ properties of the particle.

To see if a particle is Directional check if it has the DIRECTIONAL PropertyType.

Note: The particles Enchantment_Table and Nautilus will be displayed at the offset location and fly to the original location.

Example:

new ParticleBuilder(ParticleEffect.FLAME, player.getLocation())
        .setOffsetY(1f)
        .setSpeed(0.1f)
        .display();

This code will spawn a flame particle that flies to the player's head.

Minecraft's particles can behave quite weirdly, so you may have to tweak the speed parameter when using directional particles.


Colored

A few particles like Redstone can have custom colors applied to them. This color can be set with ParticleColor implementations:

  • RegularColor
  • NoteColor

If your plugin runs on a pre 1.13 server, you can also set the RGB values in the offset properties.

To see if a particle is colorable check if it has the COLORABLE PropertyType.

Note:

  • Since 1.13 Redstone particles are storing their color values in another property. Therefore, the offset properties can be properly used on servers above 1.13.
  • Note particles don't accept a custom color. Instead, they support a note value from 0 to 24. Use NoteColor for this particle.

Regular Example:

new ParticleBuilder(ParticleEffect.REDSTONE, location)
        .setParticleData(new RegularColor(255,255,0))
        .display()

This code will spawn a yellow Redstone particle at the specified location.

setParticleData(new RegularColor(255, 255, 0)) can also be replaced with setColor(Color.YELLOW) in case you want to use java.awt.Color instead.

Note Example:

new ParticleBuilder(ParticleEffect.NOTE, location)
        .setParticleData(new NoteColor(1))
        .display()

This code will spawn a green Note particle at the specified location.


Textured

Several particles even accept textures as custom properties! These textures are modified with implementations of the ParticleTexture class:

  • BlockTexture
  • ItemTexture

Warning: These particles NEED the texture property, or the particle won't be displayed.

To see if a particle supports custom textures check if it has the REQUIRES_BLOCK or the REQUIRES_ITEM PropertyType.

Block texture example:

new ParticleBuilder(ParticleEffect.FALLING_DUST, location)
        .setParticleData(new BlockTexture(Material.STONE))
        .display()

This code will spawn a Falling Dust particle with a stone texture.

Item texture example:

ItemStack item = new ItemStack(Material.DIAMOND_AXE);
new ParticleBuilder(ParticleEffect.ITEM_CRACK, location)
        .setParticleData(new ItemTexture(item))
        .display();

This code will spawn an Item Crack particle with a diamond axe texture.

particlelib's People

Contributors

bytez1337 avatar codacy-badger avatar cubbossa avatar dependabot[bot] avatar nichtstudiocode avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

particlelib's Issues

Stop Task uses Index instead of Integer object

Hey there. I just called the stopTask(taskId) Method in the Taskmanager. It removes the taskId from the running tasks arraylist but as its an int it will be interpreted as index and not as the id. I think casting it to Integer will fix the problem. Whats the idea of the running tasks arraylist? If its not important I would just call getScheduler().cancelTask(id) for now.

    public void stopTask(int taskId) {
        if (this.runningTasks.contains(taskId)) {
            Bukkit.getScheduler().cancelTask(taskId);
            this.runningTasks.remove(taskId);
        }
    }```

Particles duplicate in every world

Spigot Version: 1.8.8 Spigot
ParticleLib Version: 1.6.3

Description:
Using the method ParticleEffect#display(Location, float, float, float, float, int, ParticleData), the particles seem to duplicate to multiple worlds as seen in the pictures below. Worlds "world" and "world_nether" are shown. Each of the methods are called with "world" as the world set in the location parameter.
2021-07-09_15 29 43
2021-07-09_15 30 01

Issue for Spigot version 1.8.8!

Hello! I'm a developer over at mc.renatusnetwork.com and are working on a sequel for one of our top games! Due to the restrictions of combat on minecraft versions past 1.8, we have to run our gamemode off this version because of this, it makes us run spigot on 1.8 as well. As you may know spigot 1.8 simply has little to no particle control and in order to make this game as big as we want, we definitely need to get more particles in the library and running. With that, we found this plugin but got errors when trying to actually use the particles. I would appreciate any help with solving this issue and allowing us to get more particles. Thank you!

image_2022-05-13_214703263

P.S, it should be noted that we are installing the project through maven.

Error on startup

After updating to v1.6.4, I started getting this error on startup:

[22:00:38] [Server thread/ERROR]: Could not load 'plugins/ParticleLib.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
	at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:178) ~[patched_1.16.5.jar:git-Paper-783]
	at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:160) ~[patched_1.16.5.jar:git-Paper-783]
	at org.bukkit.craftbukkit.v1_16_R3.CraftServer.loadPlugins(CraftServer.java:393) ~[patched_1.16.5.jar:git-Paper-783]
	at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:269) ~[patched_1.16.5.jar:git-Paper-783]
	at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1069) ~[patched_1.16.5.jar:git-Paper-783]
	at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291) ~[patched_1.16.5.jar:git-Paper-783]
	at java.lang.Thread.run(Thread.java:831) [?:?]
Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
	... 7 more

The above error occurs every time I start up the server.
I am running Paper 1.16.5.

Support

Hello, is there a installation guide? Its very helpful is there is.

Please reply :)

1.19 particles not displayed

Hello,

I am currently updating my plugin for 1.19 and seems like particles are not rendered
I'm running the latest spigot version and latest version of your dependency
image

My code:

            new ParticleBuilder(ParticleEffect.EXPLOSION_HUGE, player.getLocation())
                    .setOffsetY(1f)
                    .setSpeed(0.1f)
                    .setAmount(10)
                    .display();
            player.sendMessage("particle");

More info:

image
The particle section in f3 mode is always to 0

FIREWORKS_SPARK color

Hello! i want to ask a question
how should I customize the color of FIREWORKS_SPARK?
can it be defined color?
i tried notecolor and RegularColor it doesn't work
may I ask how it should be custom color?
thanks a lot!

Problem with ParticleMappings class

Hello. I have the code from particle library in my code, but since the last update it stopped working and doesn't cooperate at all, please help.

error:

19:45:41[WARN] [RotatingHeadsPRO] Plugin RotatingHeadsPRO v1.0.1 generated an exception while executing task 1762
java.lang.ExceptionInInitializerError: null
at xyz.xenondevs.particle.ParticleConstants.<clinit>(ParticleConstants.java:246) ~[RotatingHeadsPRO.jar:?]
at xyz.xenondevs.particle.ParticleEffect.getNMSObject(ParticleEffect.java:1328) ~[RotatingHeadsPRO.jar:?]
at java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Unknown Source) ~[?:?]
at java.util.stream.ReduceOps$3ReducingSink.accept(Unknown Source) ~[?:?]
at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source) ~[?:?]
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown Source) ~[?:?]
at java.util.stream.AbstractPipeline.copyInto(Unknown Source) ~[?:?]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) ~[?:?]
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source) ~[?:?]
at java.util.stream.AbstractPipeline.evaluate(Unknown Source) ~[?:?]
at java.util.stream.ReferencePipeline.collect(Unknown Source) ~[?:?]
at xyz.xenondevs.particle.ParticleEffect.<clinit>(ParticleEffect.java:1235) ~[RotatingHeadsPRO.jar:?]
at cz.gennario.rotatingheads.particles.ParticleLoader.loadFromString(ParticleLoader.java:22) ~[RotatingHeadsPRO.jar:?]
at cz.gennario.rotatingheads.system.Head.loadParticles(Head.java:194) ~[RotatingHeadsPRO.jar:?]
at cz.gennario.rotatingheads.system.Head.<init>(Head.java:130) ~[RotatingHeadsPRO.jar:?]
at cz.gennario.rotatingheads.Main.loadHeads(Main.java:165) ~[RotatingHeadsPRO.jar:?]
at cz.gennario.rotatingheads.Main$1.run(Main.java:118) ~[RotatingHeadsPRO.jar:?]
at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftTask.run(CraftTask.java:101) ~[server.jar:git-Purpur-1428]
at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:57) ~[server.jar:git-Purpur-1428]
at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[server.jar:git-Purpur-1428]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) ~[?:?]
at java.lang.Thread.run(Unknown Source) ~[?:?]
Caused by: java.lang.RuntimeException: Could not load mappings
at xyz.xenondevs.particle.ParticleMappings.<clinit>(ParticleMappings.java:62) ~[RotatingHeadsPRO.jar:?]
... 23 more
Caused by: java.lang.NullPointerException
at java.util.Objects.requireNonNull(Unknown Source) ~[?:?]
at xyz.xenondevs.particle.ParticleMappings.<clinit>(ParticleMappings.java:53) ~[RotatingHeadsPRO.jar:?]
... 23 more

Add ParticleEffect#getProperties()

Hello, it would be interesting to make the "PropertyType[] properties" variable accessible from a method. I'm currently accessing it from reflection.

Error when using particles in Paper 1.19.3

Hi, yesterday I updated my plugin (https://github.com/I2000C/NewAmazingLuckyBlocks) to support Paper 1.19.3 (https://api.papermc.io/v2/projects/paper/versions/1.19.3/builds/384/downloads/paper-1.19.3-384.jar).
However, when I try to use the VILLAGER_HAPPY particle, the next error happens:

error enderman soup

And this is the line 35 of my class EndermanSoup:
image

This error didn't happen in Paper 1.19.2.
Do you know what could be causing this error?

NOTE: I'm using the latest version (1.8.3) of ParticleLib (with is shaded in my plugin using Gradle).

Particles are displaying in all worlds

Hello, i trying to display a Helix with particles in one world and one location, but my code with your library is displaying the helix in all worlds in the same X , Y and Z. (Video https://www.youtube.com/watch?v=jr_dwEfkwiU)

Can you help me?

private int createNPCHelix(Entity npc) {
		if(npc == null) return 0;
		final int radius = 1;
		Location npcLocation = npc.getLocation();
		List<Object> packets = new ArrayList<>();
		ParticleBuilder particleBuilder = new ParticleBuilder(particle);
		for(int t = 0; t < 20; t++) {
			double x = radius * Math.cos(t);
			double z = radius * Math.sin(t);
			packets.add(particleBuilder.setLocation(npcLocation.clone().add(x, 0.5, z)).toPacket());
		}
		ParticleTask task = new GlobalTask(packets, 3);
		return TaskManager.getTaskManager().startTask(task);
	}

NullPointerException (Client) when using BlockTexture

Hello,

nice plugin! I'm using it for my own server on 1.16.3 and have now faced complications with Spigots internal legacy support. Plugins not using the api-version settings in plugin.yml (introduced in 1.13) may lead to load the old legacy support.
More information about this is provided by Spigot on https://www.spigotmc.org/wiki/plugin-yml/#optional-attributes under api-version section.
You mind adding the api-version to your plugin.yml in the next update?

api-version: 1.14

I used this code in a event listener method:

new ParticleBuilder(particle, location).setParticleData(new BlockTexture(Material.GLASS)).display();

It seems that getBlockData() in BlockTexture is causing this, because the call on material.name() goes to class CraftLegacy in the OBC. If edited the plugin.yml and it worked out of box. The call above is working and resolving to OBC Material.name() instead.

Thanks for this nice plugin and your work
~Kaonashi

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.