Hello, So today alkarin and I were playing around with this new Packet and we found out how to create effects that I thought was client side so here you go! Code: import java.lang.reflect.Field; import net.minecraft.server.v1_5_R2.Packet63WorldParticles; import org.bukkit.craftbukkit.v1_5_R2.entity.CraftPlayer; public class CustomEffect { public CustomEffect() { } public void createEffect(CraftPlayer player, String nameOfEffect, float playersX, float playersY, float playersZ, float xOffset, float yOffset, float zOffset, float effectSpeed, int amountOfParticles) { // Make an instance of the packet! Packet63WorldParticles sPacket = new Packet63WorldParticles(); for (Field field : sPacket.getClass().getDeclaredFields()) { try { // Get those fields we need to be accessible! field.setAccessible(true); String fieldName = field.getName(); // Set them to what we want! switch (fieldName) { case "a": field.set(sPacket, name); break; case "b": field.setFloat(sPacket, playersX); break; case "c": field.setFloat(sPacket, playersY); break; case "d": field.setFloat(sPacket, playersZ); break; case "e": field.setFloat(sPacket, xOffset); break; case "f": field.setFloat(sPacket, yOffset); break; case "g": field.setFloat(sPacket, zOffset); break; case "h": field.setFloat(sPacket, effectSpeed); break; case "i": field.setInt(sPacket, amountOfParticles); break; } } catch (Exception e) { player.sendMessage("Something went wrong...."); System.out.println(e.getMessage()); } } player.getHandle().playerConnection.sendPacket(sPacket); } } The name of effects can be found here! My personal favorite effect is the "happyVillager". I like the emerald stars above a villager's head a lot!
+1 from me EDIT: Question. How would you set the data value of some of these effects? For example, "tilecrack_" or "iconcrack_". Would it be like "iconcrack_id"?
_DSH105_ Have not played around with that a lot but I believe so. EDIT: Just tested it and yes that is how it works.
Some particles can also have diffrent colors. I haven't tested it yet but I think that speed in note particle is color. EDIT: I can confirm it in particles mob spell and mob spell ambient EDIT2: Class looks good but I think using Location instead of seperate x, y and z would be much better. I also would use vector instead of offset x, y and z but with seperate parameters it's ok. Remembering all particle names is kinda hard so I would use enum: Code: package com.stirante.ParticlesAPI; public enum ParticleType { LARGE_EXPLOSION("largeexplode"), FIREWORK_SPARK("fireworksSpark"), BUBBLE("bubble"), SUSPENDED("suspended"), DEPTH_SUSPEND("depthsuspend"), TOWN_AURA("townaura"), CRITICAL_HIT("crit"), MAGICAL_CRITICAL_HIT("magicCrit"), SMOKE("smoke"), MOB_SPELL("mobSpell"), MOB_SPELL_AMBIENT("mobSpellAmbient"), SPELL("spell"), INSTANT_SPELL("instantSpell"), WITCH_MAGIC("witchMagic"), NOTE("note"), PORTAL("portal"), ENCHANTMENT_TABLE("enchantmenttable"), EXPLODE("explode"), FLAME("flame"), LAVA("lava"), FOOTSTEP("footstep"), SPLASH("splash"), LARGE_SMOKE("largesmoke"), CLOUD("cloud"), REDSTONE("reddust"), SNOWBALL_POOF("snowballpoof"), DROP_WATER("dripWater"), DROP_LAVA("dripLava"), SNOW_SHOVEL("snowshovel"), SLIME("slime"), HEART("heart"), ANGRY_VILLAGER("angryVillager"), HAPPY_VILLAGER("happyVillager"), HUGE_EXPLOSION("hugeexplosion"); private Stringid; private ParticleType(String name) { id = name; } public String getParticleName() { return id; } } I think method which sends this packet to all players in world or near players would be better than to 1 player becouse if you make loop wich will execute method for 1 player it will create soo many same packets. These are only my thougts. Feel free to ignore them xD EDIT3:I think i do too many edits. In tilecrack and itemcrack it's tilecrack_blockId_metadata and itemcrack_itemId
mncat77 Honestly I don't see a difference =P stirante I actually made some of these changes before you posted and forgot to update it =P. We are making an effect library for BattleArena and such.
Crit is normal particles when you do critical hit and magicCrit is when you do critical hit with enchanted sword. Particles are more blue. EDIT:I know it's annoying, but isn't it better when you'll use static methods? Otherwise many inexperienced devs will create a lot of instances.
stirante I would not think an inexperienced dev would jump right into packets and reflection but of course I am most likely wrong =P. I hate using static methods so I make all my instances in my main class then get them through the main class like plugin.getCustomEffects() just a preference I have. Also this just shows an example of how to implement it in your own plugin and doesn't mean it has to have its own class.
import net.minecraft.server.v1_5_R2.Packet63WorldParticles; where is the v1_5_R2 craftbukkit download? all i can find is v1_5_R1
danielmiles If your not experienced with packets do not try this and this build i was using was a beta build not a recommended.
stirante I'm in disney world happiest place on earth and will ignore that lol. Good thing I did not make a bet with you
i am experienced enough to use packets but can i just get a link? all i was asking for. not to be judged... i just wanted a link -.- EDIT by Moderator: merged posts, please use the edit button instead of double posting.
danielmiles No offense but I think we came to that conclusion because we thought an experienced developer would know were to get non approved builds. Link: http://dl.bukkit.org/downloads/craftbukkit/get/02046_1.5.1-R0.1/craftbukkit-dev.jar
Well thats kinda my bad... the download reads craftbukkit-1.5.1-R0.1 so i assumed that would show "org.bukkit.craftbukkit.v1_5_R1.entity.CraftPlayer" but in reality when you go and look it has "org.bukkit.craftbukkit.v1_5_R2.entity.CraftPlayer" which confused me, i thought u had a craftbukkit-1.5.1-R0.2
microgeek Can always change them to if statements as this was meant not to be a library rather a this is how you can do it.
There's actually a pull request that adds the ability to spawn these particles, however it hasn't been accepted yet. For now, this solution may provide the same effect as the pull request and is probably our best bet for spawning particles for now.
Hey there I need some help with this Packet :S I'm really new to bukkit but I hope you still help me Code:java Player p = (Player) cs; Location loc = (Location) p.getLocation(); String effekt = "happyVillager"; Float speed = (float) 100; int amount = 100; float x = (float) p.getLocation().getX(); float y = (float) p.getLocation().getY(); float z = (float) p.getLocation().getZ(); createEffect((CraftPlayer) p, effekt, x, y, z, x, y, z, speed, amount); I know that there's something wrong with the coordinates. Thank you for your help :3
I haven't looked to much into this, but looking at the variable names in the first post, the second x, y and z are an offset, this should be where you want the effect to be played relative to the player? I think that if you wanted to play the effect on the player you would do something like this: Code:java createEffect((CraftPlayer) p, effekt, x, y, z, 0, 0, 0, speed, amount);
I still get an error: Code: 22:59:55 [SEVERE] null org.bukkit.command.CommandException: Unhandled exception executing command 'effe kt' in plugin Effect v0.0.1 at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:18 9) at org.bukkit.craftbukkit.v1_6_R2.CraftServer.dispatchCommand(CraftServe r.java:523) at net.minecraft.server.v1_6_R2.PlayerConnection.handleCommand(PlayerCon nection.java:964) at net.minecraft.server.v1_6_R2.PlayerConnection.chat(PlayerConnection.j ava:882) at net.minecraft.server.v1_6_R2.PlayerConnection.a(PlayerConnection.java :839) at net.minecraft.server.v1_6_R2.Packet3Chat.handle(SourceFile:49) at net.minecraft.server.v1_6_R2.NetworkManager.b(NetworkManager.java:296 ) at net.minecraft.server.v1_6_R2.PlayerConnection.e(PlayerConnection.java :118) at net.minecraft.server.v1_6_R2.ServerConnection.b(SourceFile:37) at net.minecraft.server.v1_6_R2.DedicatedServerConnection.b(SourceFile:3 0) at net.minecraft.server.v1_6_R2.MinecraftServer.t(MinecraftServer.java:5 90) at net.minecraft.server.v1_6_R2.DedicatedServer.t(DedicatedServer.java:2 26) at net.minecraft.server.v1_6_R2.MinecraftServer.s(MinecraftServer.java:4 86) at net.minecraft.server.v1_6_R2.MinecraftServer.run(MinecraftServer.java :419) at net.minecraft.server.v1_6_R2.ThreadServerApplication.run(SourceFile:5 82) Caused by: java.lang.ClassCastException: org.bukkit.Location cannot be cast to j avax.tools.JavaFileManager$Location at de.Ice3ider4.Effect.Effect.onCommand(Effect.java:32) at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ... 15 more I think the X/Y/Z coordinates can't be casted to the float type but I'm not sure ): Thank you for your help
you are right, you cannot use floats, instead you need to cast them to ints and times them by 32, not positive on 32 though may have to mess around with that, maybe 20