Solved NMS colored particles

Discussion in 'Plugin Development' started by OkayName, May 29, 2021.

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

    OkayName

    Hey all! So while making a plugin for my server, I've ran into a slight problem, and it is that I cannot use Particles.DUST as the first parameter of PacketPlayOutWorldParticles. I can use every other particle, but I specifically need the DUST effect. Any help would be appreciated.
     
  2. Offline

    davidclue

    Code:
    dust = new DustOptions(Color.fromRGB(255, 136, 77), 1);
    p.spawnParticle(Particle.REDSTONE, p.getLocation().getX(), p.getLocation().getY()+1, p.getLocation().getZ(), 20, 1.5, 1, 1.5, 1, dust);
    Just some code from one of my plugins its self explanatory really. Also for block dust use this
    Code:
    BlockData bd = Material.SAND.createBlockData();
    p.spawnParticle(Particle.FALLING_DUST, p.getLocation().getX(), p.getLocation().getY()+2, p.getLocation().getZ(), 10, 1.5, 0.5, 1.5, 1, bd);
     
  3. Offline

    OkayName

    @davidclue sorry for the late reply, was out traveling. Unfortunately, this is not what I meant. I want to use NMS PacketPlayOutWorldParticles to send colored particles to the client. I know that you can and you should always avoid using NMS, but in this case I have to.
     
  4. Offline

    Shqep

    I mean, you can just search it up. One google search can give a lot of results and one may host your answer.
    Code:
    PacketPlayOutWorldParticles p1 = new PacketPlayOutWorldParticles(EnumParticle.REDSTONE, true, (float) l1.getX(), (float) l1.getY(), (float) l1.getZ(), red/255, green/255, blue/255, (float) 1, 0);
    Wiki for the packet here.
     
    Xp10d3 likes this.
  5. Offline

    Xp10d3

    Not an expert on NMS, but might help to say what version as well as any code you can provide.
     
  6. Offline

    OkayName

    I am using the version 1.16, which does not have EnumParticle, but rather just Particles. However, you cannot use Particles.DUST in PacketPlayOutWorldParticles, and I could not find any up-to-date posts on this topic, so I thought I would make one myself.

    Edit: You cant use Particles.DUST because it is of type Particle<net.minecraft.server.v1_16_R3.ParticleParamRedstone> and not ParticleType
     
  7. Offline

    davidclue

    @OkayName You said you wanted colored particles. In my previous post that is literally code to spawn any color of particles without NMS.
     
  8. Offline

    OkayName

    @davidclue I mentioned me using PacketPlayOutWorldParticles in the original post, which is a part of NMS.
     
  9. Offline

    davidclue

    @OkayName Why would you wanna use NMS when there is a much easier solution for the exact same thing without it???
     
    Shqep likes this.
  10. Offline

    OkayName

    @davidclue I don't have to explain myself if I don't want to. If you don't know the answer then please don't post anything.

    Also, I literally said in my reply that I specifically need to use NMS.
     
    Last edited: Jun 4, 2021
  11. Offline

    KarimAKL

    He is simply trying to help you, so there is no need to get defensive.

    I do not see any reason for you to "need" to use NMS. If you only want it client-side, I am pretty sure Player#spawnParticle(...) only sends it to that player, and World#spawnParticle(...) sends it to everyone.

    But if you really do want to use NMS (for whatever reason), you can look at the decompiled source for your version of NMS.
     
    Xp10d3, davidclue and Shqep like this.
  12. Offline

    Shqep

    @OkayName
    NMS is advised against if you have a way to avoid it,... which you have. I suggested a solution assuming you are developing for earlier versions (especially 1.8) because there would be no way to spawn a particle using the bare Bukkit 1.8 API, this is when NMS comes into place.
    Just use the fricking provided method to do so as @davidclue has mentioned.

    But if you still want to use the Packet, they changed from EnumParticle to a generic Particle, you can search through the values with Particles now.
    PHP:
    PacketPlayOutWorldParticles(Particles.CRITtruelocation.getX(), location.getY(), location.getZ(), 0.5F0.5F0.5F0F1)
    // The params: Particle Type, longDistance, X coord, Y coord, Z coord, offset X, offset Y, offset Z, data, count
    EDIT: Forgot to read that the first parameter accepts only a generic of ParticleParam and as ParticleParamRedstone is a superclass of it, it can not be accepted. Likewise, bare ParticleParamBlock and ParticleParamItem can not be accepted without creating an instance first.
    I'm not sure about what the params are:
    [​IMG]
     
    Last edited: Jun 4, 2021
    Xp10d3, davidclue and KarimAKL like this.
Thread Status:
Not open for further replies.

Share This Page