how to create a smoke effect

Discussion in 'Spigot Plugin Development' started by ritolika, Apr 14, 2017.

  1. So I have this block, and a function that removes it, after it gets removed I'd like some sort of smoke effect around the block. But I don't know how to do it.


    Code (Text):
    @EventHandler
        public void closeInv(InventoryCloseEvent e) {
            if(e.getInventory().getHolder() instanceof ShulkerBox){
                if(Container.get(ShulkerHandler.class).shulkBoxes.containsKey((ShulkerBox) e.getInventory().getHolder())){
                   
                    ShulkerBox sb = (ShulkerBox) e.getInventory().getHolder();
                    if(Container.get(ShulkerHandler.class).shulkBoxes.get(sb) != (Player)e.getPlayer())
                        return;
                int which = Container.get(ShulkerHandler.class).whichBox.get(sb);
                    ShulkerInventory inv = Container.get(ShulkerHandler.class).shulkers.get(e.getPlayer().getUniqueId()).getInv(which);
                ShulkerInventoryHolder sih = Container.get(ShulkerHandler.class).shulkers.get(e.getPlayer().getUniqueId());
                    inv.update(sb.getInventory());
                    sih.hasOpened = false;
                    Location staticLoc = sb.getLocation();
                    Container.get(ShulkerHandler.class).remove(sb);
                    staticLoc.getBlock().setType(Material.AIR);
                    //this is where I'd like the smoke effect to happen
                   
                }
            }

        }
     
  2. Choco

    Moderator

    Well, a "smoke effect around the block" is really vague. Circular? Rectangular? Cubic? Just a puff of smoke? There's a lot of different possibilities. Regardless, unless you're just displaying a smoke particle in the center of the block, there is going to be a bit of trigonometry involved
     
  3. A sphere around the block
     
  4. Choco

    Moderator

    Oh a sphere? Well, I could explain that to you but to be honest I'm rather lazy. Imma just send you over to finnbon's mathematics tutorial which covers circles. A sphere is just a bunch of layered circles with a curve similar to that of an inverted cosine wave (0 -> 1 -> 0 radius)
     
    • Like Like x 1
  5. Check out EffectLib it has a lot of pre made effects and a manager for adding and removing them. It definitely has a sphere effect and smoke.

    You depend on it in your plugin, hook into it and add/remove effects as you need it's super handy


    Sent from my iPhone using Tapatalk
     
  6. Choco

    Moderator

    When it's something as simple as a sphere, I don't think an entire library of effects is required. Spheres are rather easy to accomplish if you've got a basic understanding of trigonometry and radians (not even radians. You can do it in degrees). Though if the OP isn't fond of mathematics, then sure, EffectLib would be useful
     
    • Agree Agree x 1
  7. True enough, if it's just a sphere and that's it EffectLib's github has the source code would make it pretty easy to get the math he needs for it


    Sent from my iPhone using Tapatalk
     
  8. I'll have you know I have a tutorial for a sphere itself too ;)
     
  9. Choco

    Moderator

    Oh... I knew that. Heh... Toooootally knew that.
    :oops: -whistles-

    @OP You should use that instead
     
    • Like Like x 1