Hey does anyone know how i could stop blazes from taking damage in water, i have the plugin MobStacker to make them stack just in case that helps. This is what i mean: https://i.gyazo.com/419bb5ba4b94ad5d5cca8b0d95dc28f8.mp4
Write a EntityDeathEvent listener and if the entity is a blaze, check the cause of the death and if it is drowning, you cancel the event
I have never heard of half them things before so could you tell me how to do all of that please, as i would like to learn for future.
Example: Code (Text): @EventHandler public void onDmg(EntityDamageEvent e) { Entity ent = e.getEntity(); if(ent instanceof Blaze) { if(e.getCause() == DamageCause.DROWNING) { e.setCancelled(true); } } }
You should the EntityDamageEvent, because you can check the cause. Ill let you try it yourself, but if you need any help let me know
That's the event to disabling blaze water damage, Just either put this in your main class or create a new class and don't forget to register the event.
Make a class called something, i'll call it BlazeSaver Spoiler: Event Class Code (Text): import org.bukkit.Material; import org.bukkit.entity.Blaze; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageByBlockEvent; import org.bukkit.plugin.java.JavaPlugin; public class BlazeSaver<T extends JavaPlugin> implements Listener { public BlazeSaver(T javaPlugin) { } @EventHandler public void onHit(EntityDamageByBlockEvent e) { if (e.getEntity() instanceof Blaze) { if(e.getDamager().isLiquid() && e.getDamager().getType() == Material.WATER) { e.setCancelled(true); } } } } And in the main class in onEnable() you add getServer().getPluginManager().registerEvents(new BlazeSaver<JavaPlugin>(this), this);
Hello! I know this thread is kind of dated, but for those who stumble across this post I have made a plugin which is available for download. I thought this would come in handy for those who have no programming knowledge.