From c9bfc98e961460c67ab04c503aa433542933414e Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 25 Aug 2019 10:15:46 +0200 Subject: [PATCH] Added re-entry armor protection --- .../cr0s/warpdrive/event/LivingHandler.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/java/cr0s/warpdrive/event/LivingHandler.java b/src/main/java/cr0s/warpdrive/event/LivingHandler.java index 68262b4f..01a9fdd3 100644 --- a/src/main/java/cr0s/warpdrive/event/LivingHandler.java +++ b/src/main/java/cr0s/warpdrive/event/LivingHandler.java @@ -9,9 +9,11 @@ import cr0s.warpdrive.data.CelestialObjectManager; import cr0s.warpdrive.config.Dictionary; import cr0s.warpdrive.config.WarpDriveConfig; import cr0s.warpdrive.data.CelestialObject; +import cr0s.warpdrive.data.EnumTier; import cr0s.warpdrive.data.StateAir; import cr0s.warpdrive.data.Vector3; import cr0s.warpdrive.data.VectorI; +import cr0s.warpdrive.item.ItemWarpArmor; import javax.annotation.Nonnull; import java.util.HashMap; @@ -219,7 +221,7 @@ public class LivingHandler { // add fire if we're entering an atmosphere if (!celestialObject.hasAtmosphere() && celestialObjectChild.hasAtmosphere()) { - entityLivingBase.setFire(30); + applyAtmosphericEntryEffect(entityLivingBase); } } @@ -230,6 +232,24 @@ public class LivingHandler { } } + private void applyAtmosphericEntryEffect(@Nonnull final EntityLivingBase entityLivingBase) { + final Iterable inventoryArmor = entityLivingBase.getArmorInventoryList(); + int countReentryArmor = 0; + for (final ItemStack itemStack : inventoryArmor) { + if ( itemStack.getItem() instanceof ItemWarpArmor + && ((ItemWarpArmor) itemStack.getItem()).getTier(itemStack).getIndex() > EnumTier.BASIC.getIndex() ) { + countReentryArmor++; + } + } + // no damage for player in full armor or entity with at least 1 element + if ( countReentryArmor == 4 + || ( !(entityLivingBase instanceof EntityPlayer) + && countReentryArmor>= 1 ) ) { + return; + } + entityLivingBase.setFire(30); + } + private void updatePlayerCloakState(final EntityLivingBase entity) { try { final EntityPlayerMP player = (EntityPlayerMP) entity;