2021-06-11 12:02:28 +00: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
|
2022-06-06 00:17:27 +00:00
|
|
|
index 7372f826b346bf684eb5987dedb4b907076ef2c0..6e7eb2134186e530f31eef6f86e30e8dbf523c4d 100644
|
2021-06-11 12:02:28 +00:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2022-06-06 00:17:27 +00:00
|
|
|
@@ -440,4 +440,10 @@ public class PaperWorldConfig {
|
2021-06-11 12:02:28 +00: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/world/entity/decoration/ArmorStand.java b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
|
2021-11-23 15:04:41 +00:00
|
|
|
index b92c2d5f9ad3936f619b51c79379983e3231e700..91cf7728aee475cb36f2c02bbfb7e3d2e0d00576 100644
|
2021-06-11 12:02:28 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
|
2021-11-23 15:04:41 +00:00
|
|
|
@@ -92,9 +92,16 @@ public class ArmorStand extends LivingEntity {
|
2021-06-11 12:02:28 +00:00
|
|
|
public Rotations leftLegPose;
|
|
|
|
public Rotations 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 ArmorStand(EntityType<? extends ArmorStand> type, Level world) {
|
|
|
|
super(type, world);
|
|
|
|
+ if (world != null) this.canTick = world.paperConfig.armorStandTick; // Paper - armour stand ticking
|
2021-06-12 23:45:00 +00:00
|
|
|
this.handItems = NonNullList.withSize(2, ItemStack.EMPTY);
|
|
|
|
this.armorItems = NonNullList.withSize(4, ItemStack.EMPTY);
|
2021-06-11 12:02:28 +00:00
|
|
|
this.headPose = ArmorStand.DEFAULT_HEAD_POSE;
|
2021-11-23 15:04:41 +00:00
|
|
|
@@ -191,6 +198,7 @@ public class ArmorStand extends LivingEntity {
|
2021-06-11 12:02:28 +00:00
|
|
|
this.armorItems.set(enumitemslot.getIndex(), itemstack);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ this.noTickEquipmentDirty = true; // Paper - Allow equipment to be updated even when tick disabled
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-11-23 15:04:41 +00:00
|
|
|
@@ -241,6 +249,7 @@ public class ArmorStand extends LivingEntity {
|
2021-06-11 12:02:28 +00:00
|
|
|
}
|
|
|
|
|
2021-06-12 23:45:00 +00:00
|
|
|
nbt.put("Pose", this.writePose());
|
|
|
|
+ if (this.canTickSetByAPI) nbt.putBoolean("Paper.CanTickOverride", this.canTick); // Paper - persist no tick setting
|
2021-06-11 12:02:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-11-23 15:04:41 +00:00
|
|
|
@@ -272,6 +281,12 @@ public class ArmorStand extends LivingEntity {
|
2021-06-12 23:45:00 +00:00
|
|
|
this.setNoBasePlate(nbt.getBoolean("NoBasePlate"));
|
|
|
|
this.setMarker(nbt.getBoolean("Marker"));
|
2021-06-11 12:02:28 +00:00
|
|
|
this.noPhysics = !this.hasPhysics();
|
|
|
|
+ // Paper start - persist no tick
|
2021-06-12 23:45:00 +00:00
|
|
|
+ if (nbt.contains("Paper.CanTickOverride")) {
|
|
|
|
+ this.canTick = nbt.getBoolean("Paper.CanTickOverride");
|
2021-06-11 12:02:28 +00:00
|
|
|
+ this.canTickSetByAPI = true;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
2021-06-12 23:45:00 +00:00
|
|
|
CompoundTag nbttagcompound1 = nbt.getCompound("Pose");
|
2021-06-11 12:02:28 +00:00
|
|
|
|
|
|
|
this.readPose(nbttagcompound1);
|
2021-11-23 15:04:41 +00:00
|
|
|
@@ -653,7 +668,29 @@ public class ArmorStand extends LivingEntity {
|
2021-06-11 12:02:28 +00: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.detectEquipmentUpdates();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
super.tick();
|
|
|
|
+ // Paper start - Split into separate method
|
|
|
|
+ updatePose();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void updatePose() {
|
|
|
|
+ // Paper end
|
|
|
|
Rotations vector3f = (Rotations) this.entityData.get(ArmorStand.DATA_HEAD_POSE);
|
|
|
|
|
|
|
|
if (!this.headPose.equals(vector3f)) {
|
2021-11-23 15:04:41 +00:00
|
|
|
@@ -776,31 +813,37 @@ public class ArmorStand extends LivingEntity {
|
2021-06-12 23:45:00 +00:00
|
|
|
public void setHeadPose(Rotations angle) {
|
|
|
|
this.headPose = angle;
|
|
|
|
this.entityData.set(ArmorStand.DATA_HEAD_POSE, angle);
|
2021-06-11 12:02:28 +00:00
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
|
|
}
|
|
|
|
|
2021-06-12 23:45:00 +00:00
|
|
|
public void setBodyPose(Rotations angle) {
|
|
|
|
this.bodyPose = angle;
|
|
|
|
this.entityData.set(ArmorStand.DATA_BODY_POSE, angle);
|
2021-06-11 12:02:28 +00:00
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
|
|
}
|
|
|
|
|
2021-06-12 23:45:00 +00:00
|
|
|
public void setLeftArmPose(Rotations angle) {
|
|
|
|
this.leftArmPose = angle;
|
|
|
|
this.entityData.set(ArmorStand.DATA_LEFT_ARM_POSE, angle);
|
2021-06-11 12:02:28 +00:00
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
|
|
}
|
|
|
|
|
2021-06-12 23:45:00 +00:00
|
|
|
public void setRightArmPose(Rotations angle) {
|
|
|
|
this.rightArmPose = angle;
|
|
|
|
this.entityData.set(ArmorStand.DATA_RIGHT_ARM_POSE, angle);
|
2021-06-11 12:02:28 +00:00
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
|
|
}
|
|
|
|
|
2021-06-12 23:45:00 +00:00
|
|
|
public void setLeftLegPose(Rotations angle) {
|
|
|
|
this.leftLegPose = angle;
|
|
|
|
this.entityData.set(ArmorStand.DATA_LEFT_LEG_POSE, angle);
|
2021-06-11 12:02:28 +00:00
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
|
|
}
|
|
|
|
|
2021-06-12 23:45:00 +00:00
|
|
|
public void setRightLegPose(Rotations angle) {
|
|
|
|
this.rightLegPose = angle;
|
|
|
|
this.entityData.set(ArmorStand.DATA_RIGHT_LEG_POSE, angle);
|
2021-06-11 12:02:28 +00:00
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
|
|
}
|
2021-06-12 23:45:00 +00:00
|
|
|
|
|
|
|
public Rotations getHeadPose() {
|
2021-06-11 12:02:28 +00:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
|
2021-06-12 23:45:00 +00:00
|
|
|
index 06cedeea447f53d100e32a6eba6f83b4719cb231..82b9ee993b0d2e7e0685231f7bad2b85756ec959 100644
|
2021-06-11 12:02:28 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
|
2021-06-12 23:45:00 +00:00
|
|
|
@@ -238,5 +238,16 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand {
|
|
|
|
public void setCanMove(boolean move) {
|
|
|
|
getHandle().canMove = move;
|
2021-06-11 12:02:28 +00:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @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
|
|
|
|
}
|