one punch!! improvements

- go back to setting attack damage to a really high value
- move above event calls to allow plugin manipulation
- ignore damage from projectiles
This commit is contained in:
granny
2024-05-30 22:09:44 -07:00
parent ee56117c43
commit 847719c323
5 changed files with 29 additions and 26 deletions

View File

@@ -5,31 +5,34 @@ 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 450b289398cb3cccfcddcb4377004358a77d2c45..3a1236048a4cb3fd0efe7343dbc2649bed67dedd 100644
index 450b289398cb3cccfcddcb4377004358a77d2c45..d69efde99472087c98cdadfe76b154847718951b 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -2372,6 +2372,21 @@ public abstract class LivingEntity extends Entity implements Attackable {
}
@@ -1451,6 +1451,24 @@ public abstract class LivingEntity extends Entity implements Attackable {
this.stopSleeping();
}
+ // Purpur start
+ if (damagesource.getEntity() instanceof net.minecraft.world.entity.player.Player player && damagesource.getEntity().level().purpurConfig.creativeOnePunch) {
+ if (source.getEntity() instanceof net.minecraft.world.entity.player.Player player && source.getEntity().level().purpurConfig.creativeOnePunch && !source.is(DamageTypeTags.IS_PROJECTILE)) {
+ 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);
+ org.apache.commons.lang3.mutable.MutableDouble attackDamage = new org.apache.commons.lang3.mutable.MutableDouble();
+ player.getMainHandItem().forEachModifier(EquipmentSlot.MAINHAND, (attributeHolder, attributeModifier) -> {
+ if (attributeModifier.operation() == AttributeModifier.Operation.ADD_VALUE) {
+ attackDamage.addAndGet(attributeModifier.amount());
+ }
+ });
+
+ attackDamage = itemattributemodifiers.compute(player.getAttributeBaseValue(Attributes.ATTACK_DAMAGE), EquipmentSlot.MAINHAND);
+
+ if (attackDamage == 1.0D) {
+ this.setHealth(0);
+ if (attackDamage.doubleValue() == 0.0D) {
+ // One punch!
+ amount = 9999F;
+ }
+ }
+ }
+ // Purpur end
+
if (f > 0 || !human) {
if (human) {
// PAIL: Be sure to drag all this code from the EntityHuman subclass each update.
this.noActionTime = 0;
float f1 = amount;
boolean flag = amount > 0.0F && this.isDamageSourceBlocked(source); // Copied from below
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index 3a13246c0dccb82ef8168d35d59932911ef2a5ad..b830a673a8c7033147d15d0a63474aa33f5520e6 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java

View File

@@ -32,7 +32,7 @@ index 0eea9e29170a365e96659bcea2dea283d6f1ceda..ed2b8138d23e94b5471181396f290c53
return this.hardCollides;
}
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 15f89efd59c7f6334483c67d49e3de6dd03921c9..12f37b245901b84b4cee4e75d38446a554b2274b 100644
index 64642403d6821d149e2acc3a4cac43ef19b4dd3d..753b1220ecf63914920ef85292db47d006ecfa27 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -274,6 +274,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -63,7 +63,7 @@ index 15f89efd59c7f6334483c67d49e3de6dd03921c9..12f37b245901b84b4cee4e75d38446a5
}
// CraftBukkit start
@@ -3563,6 +3570,27 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -3566,6 +3573,27 @@ public abstract class LivingEntity extends Entity implements Attackable {
this.hurt(this.damageSources().drown(), 1.0F);
}

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Toggle for kinetic damage
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 12f37b245901b84b4cee4e75d38446a554b2274b..3e18ca92cdaee1b836d17cddb259ffb683f8ba97 100644
index 753b1220ecf63914920ef85292db47d006ecfa27..a4a0486a3cc7c638b8abf8ca0004ca6f7781b0de 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -2983,6 +2983,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -2986,6 +2986,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
if (f3 > 0.0F) {
this.playSound(this.getFallDamageSound((int) f3), 1.0F, 1.0F);

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Config for mob last hurt by player time
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 2257f14e5abf775cad3d5e0d2a8f6736c72f41cb..2fa0404f4f4a332248cdf7e84f2d9723dda7df8b 100644
index 7f717b3e8bb8a8eef98411216823f98ead912408..ceb420d3b9c5d3050b0d72ae612b8003d562202a 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -1561,13 +1561,13 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -1579,13 +1579,13 @@ public abstract class LivingEntity extends Entity implements Attackable {
if (entity1 instanceof net.minecraft.world.entity.player.Player) {
net.minecraft.world.entity.player.Player entityhuman = (net.minecraft.world.entity.player.Player) entity1;

View File

@@ -1211,7 +1211,7 @@ index d42cf771b9cf77304d5174f374c56eb793fc2991..45e06ec0e975973edb4434f64ddfc0f6
}
} else {
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 2fa0404f4f4a332248cdf7e84f2d9723dda7df8b..3c132007cc40a330693e33350e0cad087ac4c90b 100644
index ceb420d3b9c5d3050b0d72ae612b8003d562202a..05644dd1872d8b558ed64f74fc8699d651cc893e 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -423,7 +423,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -1232,7 +1232,7 @@ index 2fa0404f4f4a332248cdf7e84f2d9723dda7df8b..3c132007cc40a330693e33350e0cad08
}
public boolean canSpawnSoulSpeedParticle() {
@@ -3217,10 +3217,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -3220,10 +3220,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
}
this.run += (f3 - this.run) * 0.3F;
@@ -1246,7 +1246,7 @@ index 2fa0404f4f4a332248cdf7e84f2d9723dda7df8b..3c132007cc40a330693e33350e0cad08
// Paper start - stop large pitch and yaw changes from crashing the server
this.yRotO += Math.round((this.getYRot() - this.yRotO) / 360.0F) * 360.0F;
@@ -3232,7 +3232,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -3235,7 +3235,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
this.yHeadRotO += Math.round((this.yHeadRot - this.yHeadRotO) / 360.0F) * 360.0F;
// Paper end
@@ -1255,7 +1255,7 @@ index 2fa0404f4f4a332248cdf7e84f2d9723dda7df8b..3c132007cc40a330693e33350e0cad08
this.animStep += f2;
if (this.isFallFlying()) {
++this.fallFlyTicks;
@@ -3455,19 +3455,19 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -3458,19 +3458,19 @@ public abstract class LivingEntity extends Entity implements Attackable {
}
this.setDeltaMovement(d0, d1, d2);
@@ -1280,7 +1280,7 @@ index 2fa0404f4f4a332248cdf7e84f2d9723dda7df8b..3c132007cc40a330693e33350e0cad08
if (this.jumping && this.isAffectedByFluids()) {
double d3;
@@ -3494,8 +3494,8 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -3497,8 +3497,8 @@ public abstract class LivingEntity extends Entity implements Attackable {
this.noJumpDelay = 0;
}
@@ -1291,7 +1291,7 @@ index 2fa0404f4f4a332248cdf7e84f2d9723dda7df8b..3c132007cc40a330693e33350e0cad08
this.xxa *= 0.98F;
this.zza *= 0.98F;
this.updateFallFlying();
@@ -3520,8 +3520,8 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -3523,8 +3523,8 @@ public abstract class LivingEntity extends Entity implements Attackable {
this.travel(vec3d1);
}
@@ -1302,7 +1302,7 @@ index 2fa0404f4f4a332248cdf7e84f2d9723dda7df8b..3c132007cc40a330693e33350e0cad08
if (!this.level().isClientSide && !this.isDeadOrDying() && !this.freezeLocked) { // Paper - Freeze Tick Lock API
int i = this.getTicksFrozen();
@@ -3538,15 +3538,15 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -3541,15 +3541,15 @@ public abstract class LivingEntity extends Entity implements Attackable {
this.hurt(this.damageSources().freeze(), 1.0F);
}