Paper/Spigot-Server-Patches/0323-Add-more-Zombie-API.patch
Aikar 9788250b10
Clean up a lot of obfuscation helpers and impls
This fixes a bug with obfuscation helpers for attack cooldown
But every other change should stay the same.

Cleaning up a lot of helpers that pointed to already unobfuscated items.
Also adds final to many of the obfhelpers to assist with inlining.

This is pretty much a patch maintenance
2020-08-02 01:39:36 -04:00

119 lines
4.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Sun, 7 Oct 2018 04:29:59 -0500
Subject: [PATCH] Add more Zombie API
diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java
index bb7f62fa52b758ed83db7def9053b79da3d97dcd..641d0b462d326dc9b5f6ce2d7f620e428dc25539 100644
--- a/src/main/java/net/minecraft/server/EntityZombie.java
+++ b/src/main/java/net/minecraft/server/EntityZombie.java
@@ -33,6 +33,7 @@ public class EntityZombie extends EntityMonster {
private int bA;
public int drownedConversionTime;
private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
+ private boolean shouldBurnInDay = true; // Paper
public EntityZombie(EntityTypes<? extends EntityZombie> entitytypes, World world) {
super(entitytypes, world);
@@ -206,6 +207,13 @@ public class EntityZombie extends EntityMonster {
this.getDataWatcher().set(EntityZombie.DROWN_CONVERTING, true);
}
+ // Paper start
+ public void stopDrowning() {
+ this.drownedConversionTime = -1;
+ this.getDataWatcher().set(EntityZombie.DROWN_CONVERTING, false);
+ }
+ // Paper end
+
protected void eQ() {
this.c(EntityTypes.DROWNED);
if (!this.isSilent()) {
@@ -225,10 +233,17 @@ public class EntityZombie extends EntityMonster {
}
+ public boolean shouldBurnInDay() { return U_(); } // Paper - OBFHELPER
protected boolean U_() {
- return true;
+ return shouldBurnInDay;
}
+ // Paper start
+ public void setShouldBurnInDay(boolean shouldBurnInDay) {
+ this.shouldBurnInDay = shouldBurnInDay;
+ }
+ // Paper end
+
@Override
public boolean damageEntity(DamageSource damagesource, float f) {
if (super.damageEntity(damagesource, f)) {
@@ -348,6 +363,7 @@ public class EntityZombie extends EntityMonster {
nbttagcompound.setBoolean("CanBreakDoors", this.eV());
nbttagcompound.setInt("InWaterTime", this.isInWater() ? this.bA : -1);
nbttagcompound.setInt("DrownedConversionTime", this.isDrownConverting() ? this.drownedConversionTime : -1);
+ nbttagcompound.setBoolean("Paper.ShouldBurnInDay", shouldBurnInDay); // Paper
}
@Override
@@ -362,7 +378,11 @@ public class EntityZombie extends EntityMonster {
if (nbttagcompound.hasKeyOfType("DrownedConversionTime", 99) && nbttagcompound.getInt("DrownedConversionTime") > -1) {
this.startDrownedConversion(nbttagcompound.getInt("DrownedConversionTime"));
}
-
+ // Paper start
+ if (nbttagcompound.hasKey("Paper.ShouldBurnInDay")) {
+ shouldBurnInDay = nbttagcompound.getBoolean("Paper.ShouldBurnInDay");
+ }
+ // Paper end
}
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java
index 0429cf020e462d3655bf1159ec857cad33544b71..30004ea3a36029827e90e587017a1dad2ede4435 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java
@@ -80,4 +80,41 @@ public class CraftZombie extends CraftMonster implements Zombie {
getHandle().startDrownedConversion(time);
}
}
+
+ // Paper start
+ @Override
+ public boolean isDrowning() {
+ return getHandle().isDrownConverting();
+ }
+
+ @Override
+ public void startDrowning(int drownedConversionTime) {
+ getHandle().startDrownedConversion(drownedConversionTime);
+ }
+
+ @Override
+ public void stopDrowning() {
+ getHandle().stopDrowning();
+ }
+
+ @Override
+ public boolean shouldBurnInDay() {
+ return getHandle().shouldBurnInDay();
+ }
+
+ @Override
+ public boolean isArmsRaised() {
+ return getHandle().isAggressive();
+ }
+
+ @Override
+ public void setArmsRaised(final boolean raised) {
+ getHandle().setAggressive(raised);
+ }
+
+ @Override
+ public void setShouldBurnInDay(boolean shouldBurnInDay) {
+ getHandle().setShouldBurnInDay(shouldBurnInDay);
+ }
+ // Paper end
}