mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-20 01:47:42 +01:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user