Fix weird issues with Creeper ignite state (#1534)

This commit is contained in:
BillyGalbreath 2018-10-07 11:58:09 -05:00
parent 2af722672a
commit 92e277e36b

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Add More Creeper API
diff --git a/src/main/java/net/minecraft/server/EntityCreeper.java b/src/main/java/net/minecraft/server/EntityCreeper.java
index 19022b6e24..e070e7b2d2 100644
index 19022b6e2..72b4735d4 100644
--- a/src/main/java/net/minecraft/server/EntityCreeper.java
+++ b/src/main/java/net/minecraft/server/EntityCreeper.java
@@ -0,0 +0,0 @@ public class EntityCreeper extends EntityMonster {
@ -17,54 +17,6 @@ index 19022b6e24..e070e7b2d2 100644
public int maxFuseTicks = 30;
public int explosionRadius = 3;
private int bG;
@@ -0,0 +0,0 @@ public class EntityCreeper extends EntityMonster {
public void tick() {
if (this.isAlive()) {
this.bC = this.fuseTicks;
- if (this.isIgnited()) {
- this.a(1);
- }
+ // Paper start - This is no longer needed as the state is being set in setIgnited() now.
+ // Ensures the CreeperIgniteEvent is not spammed every tick
+ //if (this.isIgnited()) {
+ // this.a(1);
+ //}
+ // Paper end
int i = this.dz();
@@ -0,0 +0,0 @@ public class EntityCreeper extends EntityMonster {
this.a(SoundEffects.ENTITY_CREEPER_PRIMED, 1.0F, 0.5F);
}
- this.fuseTicks += i;
+ this.fuseTicks += this.isIgnited() ? 1 : i; // Paper - workaround now that we aren't letting it get re-set every tick - GH-1389
if (this.fuseTicks < 0) {
this.fuseTicks = 0;
}
@@ -0,0 +0,0 @@ public class EntityCreeper extends EntityMonster {
return LootTables.x;
}
+ public int getState() { return dz(); } // Paper - OBFHELPER
public int dz() {
return ((Integer) this.datawatcher.get(EntityCreeper.a)).intValue();
}
+ public void setState(int state) { a(state); } // Paper - OBFHELPER
public void a(int i) {
- this.datawatcher.set(EntityCreeper.a, Integer.valueOf(i));
+ // Paper start
+ if (getState() != i) {
+ com.destroystokyo.paper.event.entity.CreeperIgniteEvent event = new com.destroystokyo.paper.event.entity.CreeperIgniteEvent((org.bukkit.entity.Creeper) getBukkitEntity(), i == 1);
+ if (event.callEvent()) {
+ this.datawatcher.set(EntityCreeper.a, event.isIgnited() ? 1 : -1);
+ }
+ }
+ // Paper end
}
public void onLightningStrike(EntityLightning entitylightning) {
@@ -0,0 +0,0 @@ public class EntityCreeper extends EntityMonster {
return super.a(entityhuman, enumhand);
}
@ -79,8 +31,12 @@ index 19022b6e24..e070e7b2d2 100644
+ // Paper start
+ public void setIgnited(boolean ignited) {
+ this.datawatcher.set(EntityCreeper.c, ignited);
+ setState(ignited ? 1 : -1);
+ if (isIgnited() != ignited) {
+ com.destroystokyo.paper.event.entity.CreeperIgniteEvent event = new com.destroystokyo.paper.event.entity.CreeperIgniteEvent((org.bukkit.entity.Creeper) getBukkitEntity(), ignited);
+ if (event.callEvent()) {
+ this.datawatcher.set(EntityCreeper.c, event.isIgnited());
+ }
+ }
+ }
+
public void dB() {
@ -91,7 +47,7 @@ index 19022b6e24..e070e7b2d2 100644
public boolean canCauseHeadDrop() {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java
index ffebb54caa..ab2b20a0d4 100644
index ffebb54ca..ab2b20a0d 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreeper.java
@@ -0,0 +0,0 @@ public class CraftCreeper extends CraftMonster implements Creeper {