Solved Where the BlockFadeEvent is called in NMS for Ice Melting

Discussion in 'Spigot Plugin Development' started by Dramatically, Jan 28, 2020.

Thread Status:
Not open for further replies.
  1. I am trying to re-create the Ice melting in the nether so I am trying to look at how the event is called in a normal world and re-create it in a nether world.
     
  2. What do you mean in the nether world? Are you trying to make ice melt in the nether?

    For 1.8.8 it's this method in BlockIce, but for you to implement this you would have to manually tick all the ice blocks I would assume.

    Code (Java):
    public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
            if (world.b(EnumSkyBlock.BLOCK, blockposition) > 11 - this.p()) {
                // CraftBukkit start
                if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), world.worldProvider.n() ? Blocks.AIR : Blocks.WATER).isCancelled()) {
                    return;
                }
                // CraftBukkit end
               
                if (world.worldProvider.n()) {
                    world.setAir(blockposition);
                } else {
                    this.b(world, blockposition, world.getType(blockposition), 0);
                    world.setTypeUpdate(blockposition, Blocks.WATER.getBlockData());
                }
            }
        }
     
  3. I solved this by
    Code (Text):

    for (int x = -2; x < 2; x++) {
        for (int y = -2; y < 2; y++) {
            for (int z = -2; z < 2; z++) {
                Location loc = event.getBlock().getLocation().clone().add(x, y, z);
                if (loc.getBlock().getType() == Material.ICE) {
                    if (loc.getBlock().getLightLevel() > 4) {
                        final BlockState blockState = loc.getWorld().getBlockAt(loc.getBlock().getX(),
                                loc.getBlock().getY(), loc.getBlock().getZ()).getState();
                        blockState.setType(Material.WATER);
                        final BlockFadeEvent e = new BlockFadeEvent(blockState.getBlock(), blockState);
                        core.getServer().getPluginManager().callEvent(e);
                        blockState.update(true);
                    }
                }
            }
        }
    }
     
    It works essentially the same way, I found a similar use of BlockFadeEvent in BlockGrass not BlockIce but thanks!
     
Thread Status:
Not open for further replies.