Skip to content

Commit

Permalink
fixed resonarium armor damage check
Browse files Browse the repository at this point in the history
fixes #340
  • Loading branch information
NewJumper committed Aug 24, 2024
1 parent 10b2466 commit cf8391f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/java/com/kyanite/deeperdarker/DeeperDarkerEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import net.minecraft.util.StringUtil;
import net.minecraft.world.Difficulty;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.inventory.AnvilMenu;
import net.minecraft.world.item.ArmorItem;
Expand Down Expand Up @@ -153,19 +154,18 @@ public static void breakEvent(final BlockEvent.BreakEvent event) {
public static void livingDamageEvent(final LivingDamageEvent.Pre event) {
if(event.getSource().is(DamageTypeTags.BYPASSES_ARMOR)) return;

float incoming = event.getOriginalDamage();
LivingEntity entity = event.getEntity();
float incoming = event.getNewDamage();
float reduction = incoming / 4;
boolean resonarium = false;

for(ItemStack stack : event.getEntity().getArmorSlots()) {
for(ItemStack stack : entity.getArmorSlots()) {
if(stack.getItem() instanceof ArmorItem armor && armor.getMaterial().is(DDArmorMaterials.RESONARIUM.getId())) {
resonarium = true;
incoming -= reduction;
stack.hurtAndBreak((int) (event.getOriginalDamage() / 1.5f), event.getEntity(), stack.getEquipmentSlot());
stack.hurtAndBreak((int) (event.getOriginalDamage() / 1.5f), entity, armor.getEquipmentSlot());
}
}

if(resonarium) event.setNewDamage(incoming);
event.setNewDamage(incoming);
}

@SubscribeEvent
Expand Down

0 comments on commit cf8391f

Please sign in to comment.