2020-06-26 14:04:38 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: kashike <kashike@vq.lc>
|
|
|
|
Date: Wed, 15 Aug 2018 01:26:09 -0700
|
|
|
|
Subject: [PATCH] Allow disabling armour stand ticking
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2020-11-12 02:48:12 +01:00
|
|
|
index 5059b808804ee50ffa6c0cce175f737a7e4e2a50..e6894d2659ad400d333c72a0b736f02ab103264c 100644
|
2020-06-26 14:04:38 +02:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2020-11-12 02:48:12 +01:00
|
|
|
@@ -382,4 +382,10 @@ public class PaperWorldConfig {
|
2020-06-26 14:04:38 +02:00
|
|
|
private void armorStandEntityLookups() {
|
|
|
|
armorStandEntityLookups = getBoolean("armor-stands-do-collision-entity-lookups", true);
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ public boolean armorStandTick = true;
|
|
|
|
+ private void armorStandTick() {
|
|
|
|
+ this.armorStandTick = this.getBoolean("armor-stands-tick", this.armorStandTick);
|
|
|
|
+ log("ArmorStand ticking is " + (this.armorStandTick ? "enabled" : "disabled") + " by default");
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityArmorStand.java b/src/main/java/net/minecraft/server/EntityArmorStand.java
|
2020-12-21 08:56:22 +01:00
|
|
|
index 8922c656617bd8aed5b68f671d5191a537695bdf..8021d06b7765ad00abdbd8b77c37f7a80cb15803 100644
|
2020-06-26 14:04:38 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityArmorStand.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityArmorStand.java
|
2020-08-25 04:22:08 +02:00
|
|
|
@@ -46,9 +46,16 @@ public class EntityArmorStand extends EntityLiving {
|
2020-06-26 14:04:38 +02:00
|
|
|
public Vector3f leftLegPose;
|
|
|
|
public Vector3f rightLegPose;
|
|
|
|
public boolean canMove = true; // Paper
|
|
|
|
+ // Paper start - Allow ArmorStands not to tick
|
|
|
|
+ public boolean canTick = true;
|
|
|
|
+ public boolean canTickSetByAPI = false;
|
|
|
|
+ private boolean noTickPoseDirty = false;
|
|
|
|
+ private boolean noTickEquipmentDirty = false;
|
|
|
|
+ // Paper end
|
|
|
|
|
|
|
|
public EntityArmorStand(EntityTypes<? extends EntityArmorStand> entitytypes, World world) {
|
|
|
|
super(entitytypes, world);
|
|
|
|
+ if (world != null) this.canTick = world.paperConfig.armorStandTick; // Paper - armour stand ticking
|
2020-08-25 04:22:08 +02:00
|
|
|
this.handItems = NonNullList.a(2, ItemStack.b);
|
|
|
|
this.armorItems = NonNullList.a(4, ItemStack.b);
|
|
|
|
this.headPose = EntityArmorStand.bj;
|
2020-12-21 08:56:22 +01:00
|
|
|
@@ -144,6 +151,7 @@ public class EntityArmorStand extends EntityLiving {
|
2020-06-26 14:04:38 +02:00
|
|
|
this.armorItems.set(enumitemslot.b(), itemstack);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ this.noTickEquipmentDirty = true; // Paper - Allow equipment to be updated even when tick disabled
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-12-21 08:56:22 +01:00
|
|
|
@@ -224,6 +232,7 @@ public class EntityArmorStand extends EntityLiving {
|
2020-06-26 14:04:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
nbttagcompound.set("Pose", this.B());
|
|
|
|
+ if (this.canTickSetByAPI) nbttagcompound.setBoolean("Paper.CanTickOverride", this.canTick); // Paper - persist no tick setting
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-12-21 08:56:22 +01:00
|
|
|
@@ -255,6 +264,12 @@ public class EntityArmorStand extends EntityLiving {
|
2020-06-26 14:04:38 +02:00
|
|
|
this.setBasePlate(nbttagcompound.getBoolean("NoBasePlate"));
|
|
|
|
this.setMarker(nbttagcompound.getBoolean("Marker"));
|
|
|
|
this.noclip = !this.A();
|
|
|
|
+ // Paper start - persist no tick
|
|
|
|
+ if (nbttagcompound.hasKey("Paper.CanTickOverride")) {
|
|
|
|
+ this.canTick = nbttagcompound.getBoolean("Paper.CanTickOverride");
|
|
|
|
+ this.canTickSetByAPI = true;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Pose");
|
|
|
|
|
|
|
|
this.g(nbttagcompound1);
|
2020-12-21 08:56:22 +01:00
|
|
|
@@ -610,7 +625,29 @@ public class EntityArmorStand extends EntityLiving {
|
2020-06-26 14:04:38 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void tick() {
|
|
|
|
+ // Paper start
|
|
|
|
+ if (!this.canTick) {
|
|
|
|
+ if (this.noTickPoseDirty) {
|
|
|
|
+ this.noTickPoseDirty = false;
|
|
|
|
+ this.updatePose();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (this.noTickEquipmentDirty) {
|
|
|
|
+ this.noTickEquipmentDirty = false;
|
|
|
|
+ this.updateEntityEquipment();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
super.tick();
|
|
|
|
+ // Paper start - Split into separate method
|
|
|
|
+ updatePose();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void updatePose() {
|
|
|
|
+ // Paper end
|
|
|
|
Vector3f vector3f = (Vector3f) this.datawatcher.get(EntityArmorStand.c);
|
|
|
|
|
|
|
|
if (!this.headPose.equals(vector3f)) {
|
2020-12-21 08:56:22 +01:00
|
|
|
@@ -733,29 +770,36 @@ public class EntityArmorStand extends EntityLiving {
|
2020-06-26 14:04:38 +02:00
|
|
|
public void setHeadPose(Vector3f vector3f) {
|
|
|
|
this.headPose = vector3f;
|
|
|
|
this.datawatcher.set(EntityArmorStand.c, vector3f);
|
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setBodyPose(Vector3f vector3f) {
|
|
|
|
this.bodyPose = vector3f;
|
|
|
|
this.datawatcher.set(EntityArmorStand.d, vector3f);
|
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLeftArmPose(Vector3f vector3f) {
|
|
|
|
this.leftArmPose = vector3f;
|
|
|
|
this.datawatcher.set(EntityArmorStand.e, vector3f);
|
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setRightArmPose(Vector3f vector3f) {
|
|
|
|
this.rightArmPose = vector3f;
|
|
|
|
this.datawatcher.set(EntityArmorStand.f, vector3f);
|
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLeftLegPose(Vector3f vector3f) {
|
2020-08-25 04:22:08 +02:00
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
2020-06-26 14:04:38 +02:00
|
|
|
this.leftLegPose = vector3f;
|
|
|
|
this.datawatcher.set(EntityArmorStand.g, vector3f);
|
2020-08-25 04:22:08 +02:00
|
|
|
+
|
2020-06-26 14:04:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setRightLegPose(Vector3f vector3f) {
|
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
2020-08-25 04:22:08 +02:00
|
|
|
this.rightLegPose = vector3f;
|
|
|
|
this.datawatcher.set(EntityArmorStand.bh, vector3f);
|
2020-06-26 14:04:38 +02:00
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
2020-11-12 02:48:12 +01:00
|
|
|
index 0040f91477af23b7021a3c5506bb0f16121a9a1f..190161266fb26ac2bfee72ad24fa4101e09a2877 100644
|
2020-06-26 14:04:38 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
2020-12-22 22:02:19 +01:00
|
|
|
@@ -2526,6 +2526,7 @@ public abstract class EntityLiving extends Entity {
|
2020-06-26 14:04:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-25 04:22:08 +02:00
|
|
|
+ public final void updateEntityEquipment() { p(); }; // Paper - OBFHELPER
|
|
|
|
private void p() {
|
|
|
|
Map<EnumItemSlot, ItemStack> map = this.q();
|
2020-06-26 14:04:38 +02:00
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
|
2020-09-11 01:56:58 +02:00
|
|
|
index c19f0b0dd3fe988a30049297355445fd73cae630..cb22cbd68a4d310fecad3a87a97bf101216a5f64 100644
|
2020-06-26 14:04:38 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
|
2020-09-11 01:56:58 +02:00
|
|
|
@@ -311,5 +311,16 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand {
|
2020-06-26 14:04:38 +02:00
|
|
|
public boolean isSlotDisabled(org.bukkit.inventory.EquipmentSlot slot) {
|
|
|
|
return getHandle().isSlotDisabled(org.bukkit.craftbukkit.CraftEquipmentSlot.getNMS(slot));
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean canTick() {
|
|
|
|
+ return this.getHandle().canTick;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void setCanTick(final boolean tick) {
|
|
|
|
+ this.getHandle().canTick = tick;
|
|
|
|
+ this.getHandle().canTickSetByAPI = true;
|
|
|
|
+ }
|
|
|
|
// Paper end
|
|
|
|
}
|