So, i want to make i mod that inclues armor which is invulnerable against the Weapons and Tools of Draconic Evolution. My code for this event works perfectly fine against all of the weapons and tools of DE, except for the Bows/Arrows. I don't understand why, because both of the Bows extend "ToolBase". Anyone can help me? Here's the code:
package com.Panferno18.againstthedragons.event;
import com.Panferno18.againstthedragons.items.armor.HunterArmor;
import com.Panferno18.againstthedragons.util.Reference;
import com.brandon3055.draconicevolution.items.tools.ToolBase;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@EventBusSubscriber(modid = Reference.MOD_ID)
public class ArmorEvents{
@SubscribeEvent(priority = EventPriority.HIGH)
public static void onDragonAttack(LivingAttackEvent event)
{
EntityLivingBase entity = event.getEntityLiving();
if (event.getSource().getImmediateSource() instanceof EntityPlayer) {
EntityPlayer attacker = (EntityPlayer) event.getSource().getImmediateSource();
ItemStack weapon = attacker.getHeldItem(EnumHand.MAIN_HAND);
if (!(weapon.getItem() instanceof ToolBase))
return;
}
else
return;
boolean draconicAlert = true;
for (ItemStack stack : entity.getArmorInventoryList()) {
if (!(stack.getItem() instanceof HunterArmor))
draconicAlert = false;
}
if (draconicAlert)
{
event.setCanceled(true);
}
}
}