Solved Problem with BlockFadeEvent

Discussion in 'Plugin Development' started by Orchface, Jul 8, 2018.

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

    Orchface

    Hello, I am trying to create a method that prevents frosted ice from melting (changing states).

    This is the code I use to set a frosted ice block without using the Frost Walker enchantment:
    Code:
    player.getWorld().getBlockAt(player.getLocation()).setType(Material.FROSTED_ICE);
    This is the method in my listener that is supposed to stop the frosted ice from melting.
    (and yes, I did call getPluginManager()#registerEvents on this listener)
    Code:
        @EventHandler(priority = EventPriority.NORMAL)
        public void onFrostedIceFade(BlockFadeEvent e){
    
            if(e.getBlock().getType()==Material.FROSTED_ICE){ 
    
                     e.setCancelled(true);
       
            }
        }
       
    

    I used the first code snippet to place a frosted ice block in a desert biome. I waited a few minutes, and the frosted ice block changed states anyway, despite the BlockFadeEvent#setCancelled call. I am unsure as to why this is. Perhaps it has to do with the event priority, method of block placement, or an error in the Bukkit API.

    Any help is appreciated.
     
  2. Offline

    CommonSenze

    @Orchface
    BlockFromToEvent. Check if the ToBlock is either water or stationary water
     
  3. Offline

    Orchface

    Thanks. Solved.
     
Thread Status:
Not open for further replies.

Share This Page