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....
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.
event.getBlock().getType() == Material.SNOW_BLOCK && event.getToBlock().getType() == Material.WATER notice the "getToBlock"
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); } }
Instead of blindly checking, do a debug.... meaning print a message in console with the type of getToBlock and getFromBlock.
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?
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 (Move your mouse to reveal the content) his code with imports (open) his code with imports (close) 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.
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
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.
thok13 Then it doesn't trigger for ICE, that was the point of that message, to gather information And as fireblast709 said, use BlockFadeEvent since it says it works with ICE in its description.