Disabling Blaze Water Damage?

Discussion in 'Spigot Plugin Help' started by connor3253, Apr 17, 2017.

  1. Just cancel the entitydeath event when blazes are drowning.
     
  2. How do i do that exactly ?
     
  3. 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
     
  4. 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.
     
  5. 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);
            }
          }
        }
     
  6. 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 :D
     
  7. What am i putting all this code into tho.
     
  8. 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. :)
     
  9. Make a class called something, i'll call it BlazeSaver

    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);
     
  10. I think Ramidzk's solution is better, go for that one! :)
     
  11. Whats a class and how do i make one please.
     
  12. Do you just want me to make you the plugin? You're clearly a beginner.
     
    • Agree Agree x 1
  13. I think someone making that plugin would make it easier on you :)
     
    • Like Like x 1
    • Agree Agree x 1
  14. Yes please, but i would like to learn if anyone could teach me the basics.
     
  15. 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.
     

    Attached Files:

    • Like Like x 2
    • Agree Agree x 1