2021-06-11 14:02:28 +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
|
2024-01-21 17:39:05 +01:00
|
|
|
Subject: [PATCH] Allow disabling armor stand ticking
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
index 1a3727bbd9d67c32846e7ad4bd4bc9001a4aa313..0634b88a5bbfb549d5ec5931e19f674fb9ca4cbe 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
@@ -94,9 +94,16 @@ public class ArmorStand extends LivingEntity {
|
2021-06-11 14:02:28 +02: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;
|
2024-01-21 17:39:05 +01:00
|
|
|
+ // Paper end - Allow ArmorStands not to tick
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
public ArmorStand(EntityType<? extends ArmorStand> type, Level world) {
|
|
|
|
super(type, world);
|
2024-01-21 17:39:05 +01:00
|
|
|
+ if (world != null) this.canTick = world.paperConfig().entities.armorStands.tick; // Paper - Allow ArmorStands not to tick
|
2021-06-13 01:45:00 +02:00
|
|
|
this.handItems = NonNullList.withSize(2, ItemStack.EMPTY);
|
|
|
|
this.armorItems = NonNullList.withSize(4, ItemStack.EMPTY);
|
2021-06-11 14:02:28 +02:00
|
|
|
this.headPose = ArmorStand.DEFAULT_HEAD_POSE;
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
@@ -191,6 +198,7 @@ public class ArmorStand extends LivingEntity {
|
2022-06-07 23:45:11 +02:00
|
|
|
this.onEquipItem(enumitemslot, (ItemStack) this.armorItems.set(enumitemslot.getIndex(), itemstack), itemstack, silent); // CraftBukkit
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
2024-01-21 17:39:05 +01:00
|
|
|
+ this.noTickEquipmentDirty = true; // Paper - Allow ArmorStands not to tick; Still update equipment
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
@@ -241,6 +249,7 @@ public class ArmorStand extends LivingEntity {
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
2021-06-13 01:45:00 +02:00
|
|
|
nbt.put("Pose", this.writePose());
|
2024-01-21 17:39:05 +01:00
|
|
|
+ if (this.canTickSetByAPI) nbt.putBoolean("Paper.CanTickOverride", this.canTick); // Paper - Allow ArmorStands not to tick
|
2021-06-11 14:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
@@ -272,6 +281,12 @@ public class ArmorStand extends LivingEntity {
|
2021-06-13 01:45:00 +02:00
|
|
|
this.setNoBasePlate(nbt.getBoolean("NoBasePlate"));
|
|
|
|
this.setMarker(nbt.getBoolean("Marker"));
|
2021-06-11 14:02:28 +02:00
|
|
|
this.noPhysics = !this.hasPhysics();
|
2024-01-21 17:39:05 +01:00
|
|
|
+ // Paper start - Allow ArmorStands not to tick
|
2021-06-13 01:45:00 +02:00
|
|
|
+ if (nbt.contains("Paper.CanTickOverride")) {
|
|
|
|
+ this.canTick = nbt.getBoolean("Paper.CanTickOverride");
|
2021-06-11 14:02:28 +02:00
|
|
|
+ this.canTickSetByAPI = true;
|
|
|
|
+ }
|
2024-01-21 17:39:05 +01:00
|
|
|
+ // Paper end - Allow ArmorStands not to tick
|
2021-06-13 01:45:00 +02:00
|
|
|
CompoundTag nbttagcompound1 = nbt.getCompound("Pose");
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
this.readPose(nbttagcompound1);
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
@@ -659,7 +674,29 @@ public class ArmorStand extends LivingEntity {
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void tick() {
|
2024-01-21 17:39:05 +01:00
|
|
|
+ // Paper start - Allow ArmorStands not to tick
|
2021-06-11 14:02:28 +02:00
|
|
|
+ if (!this.canTick) {
|
|
|
|
+ if (this.noTickPoseDirty) {
|
|
|
|
+ this.noTickPoseDirty = false;
|
|
|
|
+ this.updatePose();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (this.noTickEquipmentDirty) {
|
|
|
|
+ this.noTickEquipmentDirty = false;
|
2023-09-29 02:28:26 +02:00
|
|
|
+ this.detectEquipmentUpdatesPublic();
|
2021-06-11 14:02:28 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return;
|
|
|
|
+ }
|
2024-01-21 17:39:05 +01:00
|
|
|
+ // Paper end - Allow ArmorStands not to tick
|
2021-06-11 14:02:28 +02:00
|
|
|
+
|
|
|
|
super.tick();
|
2024-01-21 17:39:05 +01:00
|
|
|
+ // Paper start - Allow ArmorStands not to tick
|
2021-06-11 14:02:28 +02:00
|
|
|
+ updatePose();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void updatePose() {
|
2024-01-21 17:39:05 +01:00
|
|
|
+ // Paper end - Allow ArmorStands not to tick
|
2021-06-11 14:02:28 +02:00
|
|
|
Rotations vector3f = (Rotations) this.entityData.get(ArmorStand.DATA_HEAD_POSE);
|
|
|
|
|
|
|
|
if (!this.headPose.equals(vector3f)) {
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
@@ -788,31 +825,37 @@ public class ArmorStand extends LivingEntity {
|
2021-06-13 01:45:00 +02:00
|
|
|
public void setHeadPose(Rotations angle) {
|
|
|
|
this.headPose = angle;
|
|
|
|
this.entityData.set(ArmorStand.DATA_HEAD_POSE, angle);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
|
|
}
|
|
|
|
|
2021-06-13 01:45:00 +02:00
|
|
|
public void setBodyPose(Rotations angle) {
|
|
|
|
this.bodyPose = angle;
|
|
|
|
this.entityData.set(ArmorStand.DATA_BODY_POSE, angle);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
|
|
}
|
|
|
|
|
2021-06-13 01:45:00 +02:00
|
|
|
public void setLeftArmPose(Rotations angle) {
|
|
|
|
this.leftArmPose = angle;
|
|
|
|
this.entityData.set(ArmorStand.DATA_LEFT_ARM_POSE, angle);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
|
|
}
|
|
|
|
|
2021-06-13 01:45:00 +02:00
|
|
|
public void setRightArmPose(Rotations angle) {
|
|
|
|
this.rightArmPose = angle;
|
|
|
|
this.entityData.set(ArmorStand.DATA_RIGHT_ARM_POSE, angle);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
|
|
}
|
|
|
|
|
2021-06-13 01:45:00 +02:00
|
|
|
public void setLeftLegPose(Rotations angle) {
|
|
|
|
this.leftLegPose = angle;
|
|
|
|
this.entityData.set(ArmorStand.DATA_LEFT_LEG_POSE, angle);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
|
|
}
|
|
|
|
|
2021-06-13 01:45:00 +02:00
|
|
|
public void setRightLegPose(Rotations angle) {
|
|
|
|
this.rightLegPose = angle;
|
|
|
|
this.entityData.set(ArmorStand.DATA_RIGHT_LEG_POSE, angle);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
|
|
}
|
2021-06-13 01:45:00 +02:00
|
|
|
|
|
|
|
public Rotations getHeadPose() {
|
2021-06-11 14:02:28 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
|
2023-12-05 18:20:55 +01:00
|
|
|
index 52ffc401bbb9fa768534a4b871f9cc7dbebb8b20..9923cea74ba39a774d6b16a225bc3e455e54c418 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
|
2023-08-14 01:32:51 +02:00
|
|
|
@@ -232,5 +232,16 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand {
|
2021-06-13 01:45:00 +02:00
|
|
|
public void setCanMove(boolean move) {
|
|
|
|
getHandle().canMove = move;
|
2021-06-11 14:02:28 +02: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
|
|
|
|
}
|