Jump to content

w1ll0311

Members
  • Posts

    2
  • Joined

  • Last visited

w1ll0311's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Ohhhh, okay ! I thought by cancelling the event, it would stop the whole thing, damage effect and all. Thank you for your reply ^^
  2. Hello ! I'm trying to add a Water Resistance effect to the game. But, I must be missing something. I'm using an event handler (LivingHurtEntity) to check if the damage source is DROWN and that the entity's air supply is higher than 0 (I just want to protect against water damage, but can still drown if they run out of oxygen). Then, checks if the entity has the water resistance effect. If the entity does have it, I cancel the event. I've tested this by summoning an enderman, giving it the enchantment, then pushing/dropping him into water. I've checked, the event does get cancelled, but the enderman still takes damage on screen (turns red and teleports away). I was just hoping somebody might have an idea of where I'm going wrong, if I should be using a different event or doing something else entirely. Thank you for your time and help, it is very much appreciated. And here is my code. First is the event handler, then it's the water_resistance effect. @Mod.EventBusSubscriber(modid = Extras.MOD_ID) public class ModEvents { @SubscribeEvent public static void waterResistanceEffect(LivingHurtEvent event){ Extras.LOGGER.debug("Check water dmg"); Extras.LOGGER.debug("Entity: " + event.getEntity()); Extras.LOGGER.debug("DamageSource: " + event.getSource()); Extras.LOGGER.debug("AirSupply: " + event.getEntity().getAirSupply()); if(event.getSource() == DamageSource.DROWN && event.getEntity().getAirSupply() > 0){ Extras.LOGGER.debug("Entity is getting water damage"); if(event.getEntity().hasEffect(ModMobEffects.WATER_RESISTANCE.get())){ Extras.LOGGER.debug("Cancel event"); event.setCanceled(true); } } } } public class ModEffect extends MobEffect { public ModEffect(MobEffectCategory category, int color) { super(category, color); } @Override public void applyEffectTick(LivingEntity p_19467_, int p_19468_) { super.applyEffectTick(p_19467_, p_19468_); } @Override public boolean isDurationEffectTick(int p_19455_, int p_19456_) { return true; } }
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.