Skip to content

Commit

Permalink
One Punch Man 2: Electric Boogaloo (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
theomega24 committed Mar 9, 2021
1 parent c54e65f commit 63c370c
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions patches/server/0174-One-Punch-Man.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,45 @@ Subject: [PATCH] One Punch Man!


diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 50fa5f8395fea3ba6fa202a5a38519cd55ae00e0..44e4d52653f77fa5075840d873ad1a3a917041d0 100644
index 50fa5f8395fea3ba6fa202a5a38519cd55ae00e0..c8f23b21cbe8625f7344c118eb62bab7e55e42e2 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -1921,6 +1921,15 @@ public abstract class EntityLiving extends Entity {
@@ -1921,6 +1921,23 @@ public abstract class EntityLiving extends Entity {
((EntityPlayer) damagesource.getEntity()).a(StatisticList.DAMAGE_DEALT_ABSORBED, Math.round(f2 * 10.0F));
}

+ // Purpur start
+ if (damagesource.getEntity() instanceof EntityHuman && damagesource.getEntity().world.purpurConfig.creativeOnePunch) {
+ if (damagesource.getEntity().world.purpurConfig.creativeOnePunch && damagesource.getEntity() instanceof EntityHuman) {
+ EntityHuman entityHuman = (EntityHuman) damagesource.getEntity();
+ if (entityHuman.getItemInMainHand().getItem() == Items.AIR && entityHuman.isCreative()) {
+ this.setHealth(0);
+ if (entityHuman.isCreative()) {
+ double attackDamage = 0;
+
+ for (AttributeModifier modifier : entityHuman.getItemInMainHand().getAttributeModifiers(EnumItemSlot.MAINHAND).get(GenericAttributes.ATTACK_DAMAGE)) {
+ attackDamage += modifier.getAmount();
+ }
+
+ if (attackDamage == 0) {
+ this.setHealth(0);
+ }
+ }
+ }
+ // Purpur end
+
if (f > 0 || !human) {
if (human) {
// PAIL: Be sure to drag all this code from the EntityHuman subclass each update.
diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
index 3f9062d8eca3ce53c0fb9e9e40330aa4e3296c9a..47e3ac6bcebacd9c424ddcc49774e06e05f02fe2 100644
--- a/src/main/java/net/minecraft/server/ItemStack.java
+++ b/src/main/java/net/minecraft/server/ItemStack.java
@@ -842,6 +842,7 @@ public final class ItemStack {
this.getOrCreateTag().setInt("RepairCost", i);
}

+ public Multimap<AttributeBase, AttributeModifier> getAttributeModifiers(EnumItemSlot enumitemslot) { return this.a(enumitemslot); } // Purpur - OBFHELPER
public Multimap<AttributeBase, AttributeModifier> a(EnumItemSlot enumitemslot) {
Object object;

diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 5f14c6c0e62ce5bece342b850e201357314061b2..1e7c75c1f8830b5c2660c2cf8aab0167916ff501 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
Expand Down

0 comments on commit 63c370c

Please sign in to comment.