MinecraftScripterAI
Discord ↗
Link Copied to Clipboard
×
"Create a sword that makes you immune to lightning damage"
/* This mod creates a sword that makes the player immune to lightning damage when held. */ public class LightningProofSword extends SwordItem { public LightningProofSword(IItemTier tier, int attackDamageIn, float attackSpeedIn, Item.Properties builder) { super(tier, attackDamageIn, attackSpeedIn, builder); } @Override public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { if (isSelected && entityIn instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity) entityIn; player.addEffect(new MobEffectInstance(MobEffects.LIGHTNING_RESISTANCE, 20, 0, false, false, true)); } } } /* You will need to register this item and add the LIGHTNING_RESISTANCE effect to the game. The effect can be implemented by cancelling the lightning damage event when the player has the effect. */