Don't save canTick of armor stands if it has not been set by API (#2608)

This commit is contained in:
Omer Uddin 2019-10-02 20:20:40 -04:00 committed by Zach
parent bfc807c27a
commit aa776c1b15

View file

@ -1,4 +1,4 @@
From 88841b295d4d86d407a9c4f9dd69b4841c7e58cb Mon Sep 17 00:00:00 2001 From 90e7aab7fb05f9d57e27ba10668f10d43c9d47ad Mon Sep 17 00:00:00 2001
From: kashike <kashike@vq.lc> From: kashike <kashike@vq.lc>
Date: Wed, 15 Aug 2018 01:26:09 -0700 Date: Wed, 15 Aug 2018 01:26:09 -0700
Subject: [PATCH] Allow disabling armour stand ticking Subject: [PATCH] Allow disabling armour stand ticking
@ -20,22 +20,23 @@ index 09607fb44..5832c3e86 100644
+ } + }
} }
diff --git a/src/main/java/net/minecraft/server/EntityArmorStand.java b/src/main/java/net/minecraft/server/EntityArmorStand.java diff --git a/src/main/java/net/minecraft/server/EntityArmorStand.java b/src/main/java/net/minecraft/server/EntityArmorStand.java
index c04dee058..aa9e69bce 100644 index c04dee058..529e4904e 100644
--- a/src/main/java/net/minecraft/server/EntityArmorStand.java --- a/src/main/java/net/minecraft/server/EntityArmorStand.java
+++ b/src/main/java/net/minecraft/server/EntityArmorStand.java +++ b/src/main/java/net/minecraft/server/EntityArmorStand.java
@@ -44,6 +44,11 @@ public class EntityArmorStand extends EntityLiving { @@ -44,6 +44,12 @@ public class EntityArmorStand extends EntityLiving {
public Vector3f leftLegPose; public Vector3f leftLegPose;
public Vector3f rightLegPose; public Vector3f rightLegPose;
public boolean canMove = true; // Paper public boolean canMove = true; // Paper
+ // Paper start - Allow ArmorStands not to tick + // Paper start - Allow ArmorStands not to tick
+ public boolean canTick = true; + public boolean canTick = true;
+ public boolean canTickSetByAPI = false;
+ private boolean noTickPoseDirty = false; + private boolean noTickPoseDirty = false;
+ private boolean noTickEquipmentDirty = false; + private boolean noTickEquipmentDirty = false;
+ // Paper end + // Paper end
public EntityArmorStand(EntityTypes<? extends EntityArmorStand> entitytypes, World world) { public EntityArmorStand(EntityTypes<? extends EntityArmorStand> entitytypes, World world) {
super(entitytypes, world); super(entitytypes, world);
@@ -55,6 +60,7 @@ public class EntityArmorStand extends EntityLiving { @@ -55,6 +61,7 @@ public class EntityArmorStand extends EntityLiving {
this.rightArmPose = EntityArmorStand.bx; this.rightArmPose = EntityArmorStand.bx;
this.leftLegPose = EntityArmorStand.by; this.leftLegPose = EntityArmorStand.by;
this.rightLegPose = EntityArmorStand.bz; this.rightLegPose = EntityArmorStand.bz;
@ -43,7 +44,7 @@ index c04dee058..aa9e69bce 100644
this.K = 0.0F; this.K = 0.0F;
} }
@@ -135,6 +141,7 @@ public class EntityArmorStand extends EntityLiving { @@ -135,6 +142,7 @@ public class EntityArmorStand extends EntityLiving {
this.armorItems.set(enumitemslot.b(), itemstack); this.armorItems.set(enumitemslot.b(), itemstack);
} }
@ -51,27 +52,28 @@ index c04dee058..aa9e69bce 100644
} }
@Override @Override
@@ -215,6 +222,7 @@ public class EntityArmorStand extends EntityLiving { @@ -215,6 +223,7 @@ public class EntityArmorStand extends EntityLiving {
} }
nbttagcompound.set("Pose", this.B()); nbttagcompound.set("Pose", this.B());
+ nbttagcompound.setBoolean("Paper.CanTick", this.canTick); // Paper - persist no tick setting + if (this.canTickSetByAPI) nbttagcompound.setBoolean("Paper.CanTickOverride", this.canTick); // Paper - persist no tick setting
} }
@Override @Override
@@ -246,6 +254,11 @@ public class EntityArmorStand extends EntityLiving { @@ -246,6 +255,12 @@ public class EntityArmorStand extends EntityLiving {
this.setBasePlate(nbttagcompound.getBoolean("NoBasePlate")); this.setBasePlate(nbttagcompound.getBoolean("NoBasePlate"));
this.setMarker(nbttagcompound.getBoolean("Marker")); this.setMarker(nbttagcompound.getBoolean("Marker"));
this.noclip = !this.A(); this.noclip = !this.A();
+ // Paper start - persist no tick + // Paper start - persist no tick
+ if (nbttagcompound.hasKey("Paper.CanTick")) { + if (nbttagcompound.hasKey("Paper.CanTickOverride")) {
+ this.canTick = nbttagcompound.getBoolean("Paper.CanTick"); + this.canTick = nbttagcompound.getBoolean("Paper.CanTickOverride");
+ this.canTickSetByAPI = true;
+ } + }
+ // Paper end + // Paper end
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Pose"); NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Pose");
this.g(nbttagcompound1); this.g(nbttagcompound1);
@@ -589,7 +602,29 @@ public class EntityArmorStand extends EntityLiving { @@ -589,7 +604,29 @@ public class EntityArmorStand extends EntityLiving {
@Override @Override
public void tick() { public void tick() {
@ -101,7 +103,7 @@ index c04dee058..aa9e69bce 100644
Vector3f vector3f = (Vector3f) this.datawatcher.get(EntityArmorStand.c); Vector3f vector3f = (Vector3f) this.datawatcher.get(EntityArmorStand.c);
if (!this.headPose.equals(vector3f)) { if (!this.headPose.equals(vector3f)) {
@@ -712,31 +747,37 @@ public class EntityArmorStand extends EntityLiving { @@ -712,31 +749,37 @@ public class EntityArmorStand extends EntityLiving {
public void setHeadPose(Vector3f vector3f) { public void setHeadPose(Vector3f vector3f) {
this.headPose = vector3f; this.headPose = vector3f;
this.datawatcher.set(EntityArmorStand.c, vector3f); this.datawatcher.set(EntityArmorStand.c, vector3f);
@ -256,10 +258,10 @@ index e1972f793..dbf42f882 100644
float f2 = MathHelper.g(f - this.aK); float f2 = MathHelper.g(f - this.aK);
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
index 9f5c3b92e..07ce93f17 100644 index 9f5c3b92e..73714d71a 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
@@ -297,5 +297,15 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand { @@ -297,5 +297,16 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand {
public boolean isSlotDisabled(org.bukkit.inventory.EquipmentSlot slot) { public boolean isSlotDisabled(org.bukkit.inventory.EquipmentSlot slot) {
return getHandle().isSlotDisabled(org.bukkit.craftbukkit.CraftEquipmentSlot.getNMS(slot)); return getHandle().isSlotDisabled(org.bukkit.craftbukkit.CraftEquipmentSlot.getNMS(slot));
} }
@ -272,9 +274,10 @@ index 9f5c3b92e..07ce93f17 100644
+ @Override + @Override
+ public void setCanTick(final boolean tick) { + public void setCanTick(final boolean tick) {
+ this.getHandle().canTick = tick; + this.getHandle().canTick = tick;
+ this.getHandle().canTickSetByAPI = true;
+ } + }
// Paper end // Paper end
} }
-- --
2.23.0 2.22.0