Block Break Particle Effect With Different Particles Than Block Type?

Discussion in 'Plugin Development' started by SnowGears, Nov 28, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    SnowGears

    I want to make a piece of red wool play a particle effect (block break effect) of white wool. Is this possible?

    I know it is possible to play a white wool particle effect on white wool but I was just curious if I could change this. Thanks in advance!
     
  2. Offline

    skipperguy12

    Ok, sorry if theres a MUCH better way to do this, but:

    You could always try to use packets. I suck with packets, but you could probably send a packet for Particles at a location (whitewool).
     
  3. Offline

    SnowGears

    Hmm okay. Not really sure how to go about this with packets either. Especially changing the block type of the particle effect.
     
  4. Offline

    fireblast709

    Code:java
    1. public void sendBlockBreakParticles(Player p, ItemStack i)
    2. {
    3. Packet60WorldEvent packet = new Packet60WorldEvent(2001, x, y, z, i.getTypeId(), false);
    4. ((CraftPlayer)p).getHandle().netServerHandler.sendPacket(packet);
    5. }
     
  5. Offline

    Malikk

    Alternatively, if you wanted everyone within range to see it, rather than just the one player, you could use
    Code:
    Location loc;
    ((CraftServer)Bukkit.getServer()).getServer().getServerConfigurationManager().sendPacketNearby(loc.getX(), loc.getY(), loc.getZ(), 64, ((CraftWorld) loc.getWorld()).getHandle().dimension, packet);
    
    fireblast709 has the packet correct, so see his post for that.
     
  6. Offline

    SnowGears

    Thanks but is this supposed to be packet61 ? It cannot find a packet60... (from fireblast709 code)

    This code throws errors

    Code:
    public void playBlockBreakEffect(Location loc, int blockTypeID){
        Packet61WorldEvent packet = new Packet61WorldEvent(2001, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), blockTypeID);
        for(Player p : loc.getWorld().getPlayers()){
                ((CraftPlayer)p).getHandle().netServerHandler.sendPacket(packet);
          }
    }
    
    Malikk

    I keep getting an error at 2nd line. (although it compiles fine)
    Code:
    public void playBlockBreakEffect(Location loc, ItemStack blockTypeID){
    Packet61WorldEvent packet = new Packet61WorldEvent(2001, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), blockTypeID.getTypeId());
    ((CraftServer)Bukkit.getServer()).getServer().getServerConfigurationManager().sendPacketNearby(loc.getX(), loc.getY(), loc.getZ(), 300, ((CraftWorld) loc.getWorld()).getHandle().dimension, packet);
    }
    
    Can anyone tell me what I am doing wrong? It compiles fine but when I try to execute it I get an internal error exception.

    Here is the error.
    Code:
    16:30:40 [SEVERE] null
    org.bukkit.command.CommandException: Unhandled exception executing command 'bg' in plugin Battleground v1.0
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46)
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:185)
    at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:502)
    at net.minecraft.server.NetServerHandler.handleCommand(NetServerHandler.java:917)
    at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:835)
    at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:812)
    at net.minecraft.server.Packet3Chat.handle(Packet3Chat.java:44)
    at net.minecraft.server.NetworkManager.b(NetworkManager.java:290)
    at net.minecraft.server.NetServerHandler.d(NetServerHandler.java:112)
    at net.minecraft.server.ServerConnection.b(SourceFile:39)
    at net.minecraft.server.DedicatedServerConnection.b(SourceFile:30)
    at net.minecraft.server.MinecraftServer.r(MinecraftServer.java:595)
    at net.minecraft.server.DedicatedServer.r(DedicatedServer.java:222)
    at net.minecraft.server.MinecraftServer.q(MinecraftServer.java:493)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:426)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:856)
    Caused by: java.lang.NoSuchMethodError: net.minecraft.server.Packet61WorldEvent.<init>(IIIII)V
    at com.pluggertech.battleground.BattleListener.playBlockBreakEffect(BattleListener.java:60)
    at com.pluggertech.battleground.Battleground.onCommand(Battleground.java:81)
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
    ... 15 more
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  7. You're sure the bukkit version you compile against matches the craftbukkit version running at the server you are testing this? If so eclipse (or whatever IDE you use) should give you errors.
     
  8. Offline

    Malikk

    Yeah, it should be 61. And add a boolean false as the last param creating your packet, that was added in a recent update, although your ide should be telling you that, as violator said.

    You realize that the step sound effect doesn't do this at all, right? He wants the block break particles, which is completely separate. It's easily sent through packets.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  9. Offline

    CeramicTitan

    Works alright for me. I'll send you a sceenshot if you don't believe me?

    I don't think this is possible with redwool?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  10. Offline

    SnowGears

    The packet thing kept throwing an error even though it compiled fine in Eclipse with no errors but the Effect.step_sound does in fact do what I want. Although I dont know how to incorporate blocks with extra data (such as red wool) with this. If anyone can figure that out that would be awesome. But other than that I think I am all set on this. Thanks a lot all of you.
     
  11. If STEP_SOUND does this go fill a bug report as it should make (as the name states) a sound, not a particle effect.

    //EDIT: Indeed it's a bukkit bug. Bukkit uses effect ID 2001 for step sound, which is the block break particle effect. You really should report this telling them to change the name (seems like you can't send a step sound with this method at all anymore).
     
  12. Offline

    CeramicTitan

    I was speaking with Amaranth and this is most definitely not possible, nor is any item with metadata. So my suggestions would be this:

    player.getWorld().playEffect(player.getLocation(), Effect.STEP_SOUND, Material.REDSTONE.getId());
    //Very similar with the red particles from red wool.
     
    Tooner101 likes this.
  13. Offline

    Gawdzahh

    You do know that using redstone with playEffect() now causes all players to crash? Or if your playing the effect from player.playEffect() it crashes that player?

    in 1.4.5 anyway.
     
  14. Offline

    fireblast709

    Gawdzahh and how would it crash you? any errors?
     
  15. Offline

    Gawdzahh

    No console errors at all, Just crashes the player with the client error code.

    Looks like null at a Render class.
    Code:
    --- BEGIN ERROR REPORT c6d03c93 --------
    Full report at:
    C:\Users\Administrator\AppData\Roaming\.minecraft\crash-reports\crash-2012-12-17_10.41.38-client.txt
    Please show that file to Mojang, NOT just this screen!
     
    Generated 12/17/12 10:41 AM
     
    -- Head --
    Stacktrace:
        at bak.a(RenderGlobal.java:2443)
        at xv.a(SourceFile:2481)
        at xv.f(SourceFile:2476)
        at axz.a(SourceFile:915)
        at dv.a(SourceFile:45)
        at cg.b(SourceFile:349)
        at axz.d(SourceFile:80)
     
    -- Affected level --
    Details:
        Level name: MpServer
        All players: 2 total; [ayk['Gawdzahh'/1669939, l='MpServer', x=-38.54, y=90.12, z=174.74], azw['Player'/1671979, l='MpServer', x=-39.94, y=88.00, z=173.59]]
        Chunk stats: MultiplayerChunkCache: 441
        Level seed: 0
        Level generator: ID 00 - default, ver 1. Features enabled: false
        Level generator options:
        Level spawn location: World: (41,88,30), Chunk: (at 9,5,14 in 2,1; contains blocks 32,0,16 to 47,255,31), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
        Level time: 699045 game time, 898770 day time
        Level dimension: 0
        Level storage version: 0x00000 - Unknown?
        Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
        Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false
        Forced entities: 5 total; [px['item.item.egg'/1671757, l='MpServer', x=-27.24, y=76.39, z=108.44], oy['Chicken'/93, l='MpServer', x=-27.47, y=85.00, z=112.25], azw['Player'/1671979, l='MpServer', x=-39.94, y=88.00, z=173.59], azw['Player'/1671979, l='MpServer', x=-39.94, y=88.00, z=173.59], ayk['Gawdzahh'/1669939, l='MpServer', x=-38.54, y=90.12, z=174.74]]
        Retry entities: 0 total; []
    Stacktrace:
        at ayh.a(SourceFile:290)
        at net.minecraft.client.Minecraft.l(SourceFile:1338)
        at net.minecraft.client.Minecraft.J(SourceFile:582)
        at net.minecraft.client.Minecraft.run(SourceFile:534)
        at java.lang.Thread.run(Unknown Source)
     
    -- Affected level --
    Details:
        Level name: MpServer
        All players: 2 total; [ayk['Gawdzahh'/1669939, l='MpServer', x=-38.54, y=90.12, z=174.74], azw['Player'/1671979, l='MpServer', x=-39.94, y=88.00, z=173.59]]
        Chunk stats: MultiplayerChunkCache: 441
        Level seed: 0
        Level generator: ID 00 - default, ver 1. Features enabled: false
        Level generator options:
        Level spawn location: World: (41,88,30), Chunk: (at 9,5,14 in 2,1; contains blocks 32,0,16 to 47,255,31), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
        Level time: 699045 game time, 898770 day time
        Level dimension: 0
        Level storage version: 0x00000 - Unknown?
        Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
        Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false
        Forced entities: 5 total; [px['item.item.egg'/1671757, l='MpServer', x=-27.24, y=76.39, z=108.44], oy['Chicken'/93, l='MpServer', x=-27.47, y=85.00, z=112.25], azw['Player'/1671979, l='MpServer', x=-39.94, y=88.00, z=173.59], azw['Player'/1671979, l='MpServer', x=-39.94, y=88.00, z=173.59], ayk['Gawdzahh'/1669939, l='MpServer', x=-38.54, y=90.12, z=174.74]]
        Retry entities: 0 total; []
     
    -- System Details --
    Details:
        Minecraft Version: 1.4.5
        Operating System: Windows 7 (amd64) version 6.1
        Java Version: 1.7.0_05, Oracle Corporation
        Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
        Memory: 454401456 bytes (433 MB) / 514523136 bytes (490 MB) up to 954466304 bytes (910 MB)
        JVM Flags: 2 total; -Xms512m -Xmx1024m
        AABB Pool Size: 120 (6720 bytes; 0 MB) allocated, 31 (1736 bytes; 0 MB) used
        Suspicious classes: IWrUpdater, Config, WrUpdates, ...]
        IntCache: cache: 0, tcache: 0, allocated: 3, tallocated: 63
        LWJGL: 2.4.2
        OpenGL: GeForce GTX 560 Ti/PCIe/SSE2 GL version 4.2.0, NVIDIA Corporation
        Is Modded: Very likely; Jar signature invalidated
        Type: Client (map_client.txt)
        Texture Pack: Default
        Profiler Position: N/A (disabled)
        Vec3 Pool Size: 51 (2856 bytes; 0 MB) allocated, 18 (1008 bytes; 0 MB) used
     
    java.lang.NullPointerException
        at bak.a(RenderGlobal.java:2443)
        at xv.a(SourceFile:2481)
        at xv.f(SourceFile:2476)
        at axz.a(SourceFile:915)
        at dv.a(SourceFile:45)
        at cg.b(SourceFile:349)
        at axz.d(SourceFile:80)
        at ayh.b(SourceFile:62)
        at net.minecraft.client.Minecraft.l(SourceFile:1331)
        at net.minecraft.client.Minecraft.J(SourceFile:582)
        at net.minecraft.client.Minecraft.run(SourceFile:534)
        at java.lang.Thread.run(Unknown Source)
    --- END ERROR REPORT bba13368 ----------
     
  16. Offline

    fireblast709

    yep NPE. And what is the code you are trying?
     
  17. Offline

    CeramicTitan

    your not meant to contact it directly from the player. you need to get the world. player.getWorld().playEffect(etc)
     
  18. Offline

    fireblast709

    then why can you do it ;3
     
  19. Offline

    CeramicTitan

    you need to get the world first
     
  20. Offline

    Gawdzahh

    Wasn't the problem, It was simply because i was using Material.REDSTONE instead of Material.REDSTON_WIRE
    Haha
     
  21. Offline

    CeramicTitan

    Your meant to use red stone not redstone wire
     
  22. Offline

    Cybermaxke

    With the packages is the sound still not gone. :/
     
  23. Offline

    Jensjojo123

    how can i make a trail of that?
     
  24. I updated the code to the recent build:
    Code:java
    1. public static final void playBlockBreakParticles(final Location loc, final Material m) {
    2. playBlockBreakParticles(loc, m, Bukkit.getOnlinePlayers());
    3. }
    4.  
    5. public static final void playBlockBreakParticles(final Location loc, final Material m, final Player... players) {
    6. @SuppressWarnings("deprecation")
    7. Packet61WorldEvent packet = new Packet61WorldEvent(2001, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), m.getId(), false);
    8. for(final Player p : players) {
    9. ((CraftPlayer)p).getHandle().playerConnection.sendPacket(packet);
    10. }
    11. }
     
  25. Offline

    ClassifiedLife

    I am trying to make it so when I hit a player it will show the redstone dust breaking particles. I am on 1.7.9 and I have tried world.playEffect(entity.getLocation(), Effect.STEP_SOUND, Material.REDSTONE.getId()); but it doesn't work. I do not really understand the Packets stuff so if someone could help me on that or give me a simpler code to use I would appreciate it.
     
  26. Offline

    97WaterPolo

    ClassifiedLife
    Talk about necro..., anyways the packets have changed since 1.6. All the code here that is based on packets won't work.

    As for your code, that only displays the particles of a block, so you would need to do Material.REDSTONE_BLOCK.
     
  27. Offline

    ClassifiedLife

  28. Offline

    97WaterPolo

    ClassifiedLife
    Nice! If this thread is closed, mark it as solved please.
     
Thread Status:
Not open for further replies.

Share This Page