aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0283-Add-more-Zombie-API.patch
blob: 552fe1f502e2142a3a9c211fbefb2e4ac416ad41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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

== AT ==
public net.minecraft.world.entity.monster.Zombie isSunSensitive()Z

diff --git a/src/main/java/net/minecraft/world/entity/monster/Zombie.java b/src/main/java/net/minecraft/world/entity/monster/Zombie.java
index 2aec8e2f45fe6ba56d84e5a51a6e30d36505df42..d4f72024c15d03f70a86f09714403ace6e26885a 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Zombie.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Zombie.java
@@ -96,6 +96,7 @@ public class Zombie extends Monster {
     private int inWaterTime;
     public int conversionTime;
     private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
+    private boolean shouldBurnInDay = true; // Paper
 
     public Zombie(EntityType<? extends Zombie> type, Level world) {
         super(type, world);
@@ -264,6 +265,12 @@ public class Zombie extends Monster {
         super.aiStep();
     }
 
+    // Paper start
+    public void stopDrowning() {
+        this.conversionTime = -1;
+        this.getEntityData().set(Zombie.DATA_DROWNED_CONVERSION_ID, false);
+    }
+    // Paper end
     public void startUnderWaterConversion(int ticksUntilWaterConversion) {
         this.lastTick = MinecraftServer.currentTick; // CraftBukkit
         this.conversionTime = ticksUntilWaterConversion;
@@ -293,9 +300,15 @@ public class Zombie extends Monster {
     }
 
     public boolean isSunSensitive() {
-        return true;
+        return this.shouldBurnInDay; // Paper - use api value instead
     }
 
+    // Paper start
+    public void setShouldBurnInDay(boolean shouldBurnInDay) {
+        this.shouldBurnInDay = shouldBurnInDay;
+    }
+    // Paper end
+
     @Override
     public boolean hurt(DamageSource source, float amount) {
         if (!super.hurt(source, amount)) {
@@ -415,6 +428,7 @@ public class Zombie extends Monster {
         nbt.putBoolean("CanBreakDoors", this.canBreakDoors());
         nbt.putInt("InWaterTime", this.isInWater() ? this.inWaterTime : -1);
         nbt.putInt("DrownedConversionTime", this.isUnderWaterConverting() ? this.conversionTime : -1);
+        nbt.putBoolean("Paper.ShouldBurnInDay", this.shouldBurnInDay); // Paper
     }
 
     @Override
@@ -426,6 +440,11 @@ public class Zombie extends Monster {
         if (nbt.contains("DrownedConversionTime", 99) && nbt.getInt("DrownedConversionTime") > -1) {
             this.startUnderWaterConversion(nbt.getInt("DrownedConversionTime"));
         }
+        // Paper start
+        if (nbt.contains("Paper.ShouldBurnInDay")) {
+            this.shouldBurnInDay = nbt.getBoolean("Paper.ShouldBurnInDay");
+        }
+        // Paper end
 
     }
 
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java
index 99dcaa827831a40ea46453f502d8b6ccb107f0ad..4412c913123f7521f449c98b60378e8d3b1671ce 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java
@@ -87,6 +87,42 @@ public class CraftZombie extends CraftMonster implements Zombie {
     @Override
     public void setAgeLock(boolean b) {
     }
+    // Paper start
+    @Override
+    public boolean isDrowning() {
+        return getHandle().isUnderWaterConverting();
+    }
+
+    @Override
+    public void startDrowning(int drownedConversionTime) {
+        getHandle().startUnderWaterConversion(drownedConversionTime);
+    }
+
+    @Override
+    public void stopDrowning() {
+        getHandle().stopDrowning();
+    }
+
+    @Override
+    public boolean shouldBurnInDay() {
+        return getHandle().isSunSensitive();
+    }
+
+    @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
 
     @Override
     public boolean getAgeLock() {