fix one punch man patch

This commit is contained in:
granny
2024-04-28 14:32:43 -07:00
parent 9e63d11b9c
commit c9115d3655
4 changed files with 27 additions and 26 deletions

View File

@@ -5,26 +5,27 @@ 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
index dc1c7c55fd13cc1a8ade803bfb1b7c385cf29132..e8a92e4941ab7d638d3e3ac5ad8d6314bede17c0 100644
index dc1c7c55fd13cc1a8ade803bfb1b7c385cf29132..0b4384b6898ad591b8b9256b2427359474dd9c57 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -2382,6 +2382,20 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -2382,6 +2382,21 @@ public abstract class LivingEntity extends Entity implements Attackable {
}
}
+ // Purpur start
+ if (damagesource.getEntity() instanceof net.minecraft.world.entity.player.Player player && damagesource.getEntity().level().purpurConfig.creativeOnePunch) {
+ if (player.isCreative()) {
+ double attackDamage = 0;
+ for (AttributeModifier modifier : player.getMainHandItem().getAttributeModifiers(EquipmentSlot.MAINHAND).get(Attributes.ATTACK_DAMAGE)) {
+ attackDamage += modifier.getAmount();
+ }
+ if (attackDamage == 0) {
+ this.setHealth(0);
+ }
+ }
+ }
+ // Purpur end
+ // Purpur start
+ if (damagesource.getEntity() instanceof net.minecraft.world.entity.player.Player player && damagesource.getEntity().level().purpurConfig.creativeOnePunch) {
+ if (player.isCreative()) {
+ double attackDamage;
+ 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);
+
+ if (attackDamage == 0) {
+ this.setHealth(0);
+ }
+ }
+ }
+ // Purpur end
+
if (f > 0 || !human) {
if (human) {