Not make ice melt?

Discussion in 'Plugin Development' started by thok13, Mar 4, 2013.

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

    thok13

    I'm trying to make ice not melt or make water when broken:
    Code:
    public class AntiMelt extends JavaPlugin implements Listener {
        @Override
        public void onEnable(){
            this.getServer().getPluginManager().registerEvents(this, this);
            getLogger().info("AntiMelt plugin is now on!");
        }
        @Override
        public void onDisable() {
            this.saveConfig();
            getLogger().info("AntiMelt plugin is now off!");
        }
        @EventHandler
        public void onBlockPhysics(BlockPhysicsEvent event){
            if(event.getBlock().getType() == Material.ICE){
                event.setCancelled(true);
            }
        }
       
    }
    
    I tried that but the ice still melts....
     
  2. Offline

    chasechocolate

  3. Offline

    eamon12

    You have multiple errors, might wanna fix those
     
  4. Offline

    thok13

    What errors? Eclipse doesn't say there's any...

    Code:
    public class AntiMelt extends JavaPlugin implements Listener {
        @Override
        public void onEnable(){
            this.getServer().getPluginManager().registerEvents(this, this);
            getLogger().info("AntiMelt plugin is now on!");
        }
        @Override
        public void onDisable() {
            this.saveConfig();
            getLogger().info("AntiMelt plugin is now off!");
        }
        @EventHandler
        public void onBlockFromTo(BlockFromToEvent event) {
            if(event.getBlock().getType() == Material.SNOW_BLOCK && event.getToBlock().getType() == Material.WATER){
                event.setCancelled(true);
            }
        }
       
    }
    tried that but it doesn't seem to have worked...

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  5. Offline

    ZeusAllMighty11

    Because a block can't be 2 blocks at the same time
     
  6. Offline

    thok13

    event.getBlock().getType() == Material.SNOW_BLOCK && event.getToBlock().getType() == Material.WATER
    notice the "getToBlock"
     
  7. Offline

    ZeusAllMighty11

    Well despite that - snow doesn't turn into water AFAIK
     
  8. Offline

    thok13

    oh durp I was thinking ice xD. I changed it to this but it still doesn't work:
    Code:
        @EventHandler(priority = EventPriority.HIGHEST)
        public void onBlockFromTo(BlockFromToEvent event) {
            if(event.getToBlock().getType() == Material.WATER){
                event.setCancelled(true);
            }
        }
     
  9. Offline

    chasechocolate

    thok13 maybe also check for stationary water?
     
  10. Instead of blindly checking, do a debug.... meaning print a message in console with the type of getToBlock and getFromBlock.
     
  11. Offline

    eamon12

    Oh eclipse, look at the bar on the left of your screen on eclipse, there should be a light bulb with a X, did you show the full code?
     
  12. eamon12
    That code you quoted has no syntax errors, you might have import errors which you should be able to fix yourself...
    his code with imports (open)
    Code:
    import org.bukkit.Material;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.BlockPhysicsEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class AntiMelt extends JavaPlugin implements Listener
    {
        @Override
        public void onEnable()
        {
            this.getServer().getPluginManager().registerEvents(this, this);
            getLogger().info("AntiMelt plugin is now on!");
        }
        
        @Override
        public void onDisable()
        {
            this.saveConfig();
            getLogger().info("AntiMelt plugin is now off!");
        }
        
        @EventHandler
        public void onBlockPhysics(BlockPhysicsEvent event)
        {
            if(event.getBlock().getType() == Material.ICE)
            {
                event.setCancelled(true);
            }
        }    
    }

    Also, thok13 you should really remove those disable/enable messages, Bukkit already sends them and yours are extra and it's just spam.
     
  13. Offline

    eamon12

    Digi
    Oh okay, thanks was asking for the full code :p
     
  14. Offline

    fireblast709

    thok13 for the melting by a light source, you might want to try the BlockFadeEvent ;3
    For the melting by breaking, you probably have to cancel the event if getBlock().getType() == Material.ICE
     
  15. Offline

    thok13

    I didn't show all the import statements, but other than that it's the full code. There are no errors

    Tried that. Also I tried canceling the event no matter what. I found the the ice still turns to water, but the water doesn't spread. When I broadcast the event, it doesn't say anything about ice:
    Bukkit.getServer().broadcastMessage("From " + event.getBlock().getType().toString() + "To " + event.getToBlock().getType().toString());

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  16. thok13
    Then it doesn't trigger for ICE, that was the point of that message, to gather information :p
    And as fireblast709 said, use BlockFadeEvent since it says it works with ICE in its description.
     
Thread Status:
Not open for further replies.

Share This Page