Custom Particle Effects

Discussion in 'Plugin Development' started by Live2Pwn, Mar 1, 2013.

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

    Live2Pwn

    Hey, I am trying to make a particle effect, making a single flame spawn at an exact location, not the whole Effect.MOBSPAWNER_FLAMES thing, but a single flame at the given location. Please do not redirect me to different forum posts, I have spent the past hour and a half searching for how to do this, and haven't really found anything I understand or that works the way I need it to. Thanks!
     
  2. Offline

    chasechocolate

  3. Offline

    Live2Pwn

    Changing the data doesnt seem to do much other then slightly change the color of the potion effect. In the link you sent me I noticed there was a second playEffect method that was:
    Code:
    playEffect(Location location, Effect effect, int data, int radius)
    The radius seems like it would do what I am looking for, though it throws errors when I add a second int variable. Forgive me, I am still pretty new to java :3
     
  4. Offline

    chasechocolate

    Live2Pwn what errors does it give? In your IDE or console?
     
  5. Offline

    Infamous Jeezy

    Live2Pwn
    What errors is it throwing when you try to add the second int variable?

    Edit:
    Oops chasechocolate beat me to it lol :p
     
  6. Offline

    Live2Pwn

    chasechocolate
    Infamous Jeezy
    In Eclipse, it says 'The method playEffect(Location, Effect, int) in the Player type is not applicable for the arguments (Location, Effect, int, int)'
     
  7. Offline

    Infamous Jeezy

    Well that's strange..
    I typed in..
    selPlayer.getWorld().playEffect(selPlayer.getLocation(), Effect.BLAZE_SHOOT, 1, 1);
    and checked for error and it resulted in no errors.
     
  8. Offline

    Live2Pwn

    Well, turns out I forgot to put .getWorld() at the beginning. But that still does not do what I am trying to do. It still generates a large number of particles spread out over a block. I am trying to make a single flame at a single point, and the radius does not seem to do anything.
     
  9. Offline

    Infamous Jeezy

    I don't think it's possible then to make the flame smaller/single if changing the radius and the data didn't work.
    I could be wrong though.
     
  10. Offline

    stirante

    I tried to follow bukkit's playEffect method:
    Code:
    Method World.playEffect(Location, Effect, Integer, Integer):
        public void playEffect(Location location, Effect effect, int data, int radius) {
            Validate.notNull(location, "Location cannot be null");
            Validate.notNull(effect, "Effect cannot be null");
            Validate.notNull(location.getWorld(), "World cannot be null");
            int packetData = effect.getId();
            Packet61WorldEvent packet = new Packet61WorldEvent(packetData, location.getBlockX(), location.getBlockY(), location.getBlockZ(), data, false);
            int distance;
            radius *= radius;
     
            for (Player player : getPlayers()) {
                if (((CraftPlayer) player).getHandle().playerConnection == null) continue;
                if (!location.getWorld().equals(player.getWorld())) continue;
     
                distance = (int) player.getLocation().distanceSquared(location);
                if (distance <= radius) {
                    ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
                }
            }
        }
     
    Method which receives this packet in client. NetClientHandler.handleDoorChange(Packet61DoorChange):
        public void handleDoorChange(Packet61DoorChange par1Packet61DoorChange)
        {
            if (par1Packet61DoorChange.func_82560_d())
            {
                this.mc.theWorld.func_82739_e(par1Packet61DoorChange.sfxID, par1Packet61DoorChange.posX, par1Packet61DoorChange.posY, par1Packet61DoorChange.posZ, par1Packet61DoorChange.auxData);
            }
            else
            {
                this.mc.theWorld.playAuxSFX(par1Packet61DoorChange.sfxID, par1Packet61DoorChange.posX, par1Packet61DoorChange.posY, par1Packet61DoorChange.posZ, par1Packet61DoorChange.auxData);
            }
        }
     
    Methods which method above triggers. World class:
     
        public void func_82739_e(int par1, int par2, int par3, int par4, int par5)
        {
            for (int var6 = 0; var6 < this.worldAccesses.size(); ++var6)
            {
                ((IWorldAccess)this.worldAccesses.get(var6)).func_82746_a(par1, par2, par3, par4, par5);
            }
        }
     
        /**
        * See description for playAuxSFX.
        */
        public void playAuxSFX(int par1, int par2, int par3, int par4, int par5)
        {
            this.playAuxSFXAtEntity((EntityPlayer)null, par1, par2, par3, par4, par5);
        }
     
        /**
        * See description for playAuxSFX.
        */
        public void playAuxSFXAtEntity(EntityPlayer par1EntityPlayer, int par2, int par3, int par4, int par5, int par6)
        {
            try
            {
                for (int var7 = 0; var7 < this.worldAccesses.size(); ++var7)
                {
                    ((IWorldAccess)this.worldAccesses.get(var7)).playAuxSFX(par1EntityPlayer, par2, par3, par4, par5, par6);
                }
            }
            catch (Throwable var10)
            {
                CrashReport var8 = CrashReport.makeCrashReport(var10, "Playing level event");
                CrashReportCategory var9 = var8.makeCategory("Level event being played");
                var9.addCrashSection("Block coordinates", CrashReportCategory.func_85071_a(par3, par4, par5));
                var9.addCrashSection("Event source", par1EntityPlayer);
                var9.addCrashSection("Event type", Integer.valueOf(par2));
                var9.addCrashSection("Event data", Integer.valueOf(par6));
                throw new ReportedException(var8);
            }
        }
     
    And more methods triggerd by methods above. WorldManager class:
        /**
        * Plays a pre-canned sound effect along with potentially auxiliary data-driven one-shot behaviour (particles, etc).
        */
        public void playAuxSFX(EntityPlayer par1EntityPlayer, int par2, int par3, int par4, int par5, int par6)
        {
            this.mcServer.getConfigurationManager().sendToAllNearExcept(par1EntityPlayer, (double)par3, (double)par4, (double)par5, 64.0D, this.theWorldServer.provider.dimensionId, new Packet61DoorChange(par2, par3, par4, par5, par6, false));
        }
     
        public void func_82746_a(int par1, int par2, int par3, int par4, int par5)
        {
            this.mcServer.getConfigurationManager().sendPacketToAllPlayers(new Packet61DoorChange(par1, par2, par3, par4, par5, true));
        }
     
    And these methods just sents almost the same packet to other players.
    Honestly, I don't get it.
     
  11. Offline

    Live2Pwn

    Would it be possible to do this using packets?
     
  12. Offline

    stirante

    I don't think so :(
     
  13. Offline

    firecombat4

  14. Offline

    stirante

    firecombat4 You know that this thread is about 7-8 months old?
     
    BajanAmerican likes this.
  15. Offline

    firecombat4

    Yea that's true, it still may be useful for people in the future who are googling this topic. That's the only reason I came upon this thread haha :)
     
  16. You know of a method that i can do enchantment table effects, but ithout adding 2 classes of 600 lines for a simple 40 line plugin(single class)?
     
  17. Live2Pwn
    You should use the single flame of a torch... I have seen that effect on a server too .. the effect you mean.. its not from mobspawner, its from a torch but you need the effectlibrary for that ; )
     
  18. Offline

    firecombat4

    The most simple way to do this would be to look through the class and pull out the methods you need, namely the "sendTo" method. Mainly it has so many lines because the author puts a lot of documentation into each method to make it more simple and clear to understand.
     
Thread Status:
Not open for further replies.

Share This Page