fix one punch not working correctly on hostile & passive mobs

This commit is contained in:
granny
2024-04-30 19:04:10 -07:00
parent b02dc7ac07
commit 333dc0c9d2

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] One Punch Man!
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index dc1c7c55fd13cc1a8ade803bfb1b7c385cf29132..0b4384b6898ad591b8b9256b2427359474dd9c57 100644 index dc1c7c55fd13cc1a8ade803bfb1b7c385cf29132..523052af43aa86982d2ded0cc0882d34bac24da7 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -2382,6 +2382,21 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -2382,6 +2382,21 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -18,9 +18,9 @@ index dc1c7c55fd13cc1a8ade803bfb1b7c385cf29132..0b4384b6898ad591b8b9256b24273594
+ double attackDamage; + double attackDamage;
+ net.minecraft.world.item.component.ItemAttributeModifiers itemattributemodifiers = player.getMainHandItem().getOrDefault(DataComponents.ATTRIBUTE_MODIFIERS, net.minecraft.world.item.component.ItemAttributeModifiers.EMPTY); + net.minecraft.world.item.component.ItemAttributeModifiers itemattributemodifiers = player.getMainHandItem().getOrDefault(DataComponents.ATTRIBUTE_MODIFIERS, net.minecraft.world.item.component.ItemAttributeModifiers.EMPTY);
+ +
+ attackDamage = itemattributemodifiers.compute(this.getAttributeBaseValue(Attributes.ATTACK_DAMAGE), EquipmentSlot.MAINHAND); + attackDamage = itemattributemodifiers.compute(player.getAttributeBaseValue(Attributes.ATTACK_DAMAGE), EquipmentSlot.MAINHAND);
+ +
+ if (attackDamage == 0) { + if (attackDamage == 1.0D) {
+ this.setHealth(0); + this.setHealth(0);
+ } + }
+ } + }