2020-01-22 03:02:07 +01:00
|
|
|
From 0994b1f1e7de07d1654d56b9626f69cc15fb2959 Mon Sep 17 00:00:00 2001
|
2018-08-15 10:26:51 +02:00
|
|
|
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-01-18 18:28:32 +01:00
|
|
|
index eaaa51e4b..bc3df01aa 100644
|
2018-08-15 10:26:51 +02:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2020-01-18 18:28:32 +01:00
|
|
|
@@ -393,4 +393,10 @@ public class PaperWorldConfig {
|
2019-12-12 01:03:31 +01:00
|
|
|
private void armorStandEntityLookups() {
|
|
|
|
armorStandEntityLookups = getBoolean("armor-stands-do-collision-entity-lookups", true);
|
2018-08-15 10:26:51 +02:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ 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-01-22 03:02:07 +01:00
|
|
|
index 61d7d507a..42b9a339e 100644
|
2018-08-15 10:26:51 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityArmorStand.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityArmorStand.java
|
2019-10-03 02:20:40 +02:00
|
|
|
@@ -44,6 +44,12 @@ public class EntityArmorStand extends EntityLiving {
|
2018-08-15 10:26:51 +02:00
|
|
|
public Vector3f leftLegPose;
|
|
|
|
public Vector3f rightLegPose;
|
|
|
|
public boolean canMove = true; // Paper
|
2018-11-08 02:48:22 +01:00
|
|
|
+ // Paper start - Allow ArmorStands not to tick
|
|
|
|
+ public boolean canTick = true;
|
2019-10-03 02:20:40 +02:00
|
|
|
+ public boolean canTickSetByAPI = false;
|
2018-11-08 02:48:22 +01:00
|
|
|
+ private boolean noTickPoseDirty = false;
|
|
|
|
+ private boolean noTickEquipmentDirty = false;
|
|
|
|
+ // Paper end
|
2018-08-15 10:26:51 +02:00
|
|
|
|
2019-05-05 04:23:25 +02:00
|
|
|
public EntityArmorStand(EntityTypes<? extends EntityArmorStand> entitytypes, World world) {
|
|
|
|
super(entitytypes, world);
|
2019-10-03 02:20:40 +02:00
|
|
|
@@ -55,6 +61,7 @@ public class EntityArmorStand extends EntityLiving {
|
2019-12-12 01:03:31 +01:00
|
|
|
this.rightArmPose = EntityArmorStand.bu;
|
|
|
|
this.leftLegPose = EntityArmorStand.bv;
|
|
|
|
this.rightLegPose = EntityArmorStand.bw;
|
2018-08-15 10:26:51 +02:00
|
|
|
+ if (world != null) this.canTick = world.paperConfig.armorStandTick; // Paper - armour stand ticking
|
2019-12-12 01:03:31 +01:00
|
|
|
this.H = 0.0F;
|
2018-08-15 10:26:51 +02:00
|
|
|
}
|
2019-05-05 04:23:25 +02:00
|
|
|
|
2020-01-22 03:02:07 +01:00
|
|
|
@@ -135,6 +142,7 @@ public class EntityArmorStand extends EntityLiving {
|
2019-05-28 01:01:45 +02:00
|
|
|
this.armorItems.set(enumitemslot.b(), itemstack);
|
2018-11-08 02:48:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
+ this.noTickEquipmentDirty = true; // Paper - Allow equipment to be updated even when tick disabled
|
|
|
|
}
|
|
|
|
|
2019-05-05 04:23:25 +02:00
|
|
|
@Override
|
2020-01-22 03:02:07 +01:00
|
|
|
@@ -215,6 +223,7 @@ public class EntityArmorStand extends EntityLiving {
|
2018-11-28 00:14:57 +01:00
|
|
|
}
|
|
|
|
|
2019-05-05 04:23:25 +02:00
|
|
|
nbttagcompound.set("Pose", this.B());
|
2019-10-03 02:20:40 +02:00
|
|
|
+ if (this.canTickSetByAPI) nbttagcompound.setBoolean("Paper.CanTickOverride", this.canTick); // Paper - persist no tick setting
|
2018-11-28 00:14:57 +01:00
|
|
|
}
|
|
|
|
|
2019-05-05 04:23:25 +02:00
|
|
|
@Override
|
2020-01-22 03:02:07 +01:00
|
|
|
@@ -246,6 +255,12 @@ public class EntityArmorStand extends EntityLiving {
|
2019-05-05 04:23:25 +02:00
|
|
|
this.setBasePlate(nbttagcompound.getBoolean("NoBasePlate"));
|
2018-11-28 00:14:57 +01:00
|
|
|
this.setMarker(nbttagcompound.getBoolean("Marker"));
|
2019-05-05 04:23:25 +02:00
|
|
|
this.noclip = !this.A();
|
2018-11-28 00:14:57 +01:00
|
|
|
+ // Paper start - persist no tick
|
2019-10-03 02:20:40 +02:00
|
|
|
+ if (nbttagcompound.hasKey("Paper.CanTickOverride")) {
|
|
|
|
+ this.canTick = nbttagcompound.getBoolean("Paper.CanTickOverride");
|
|
|
|
+ this.canTickSetByAPI = true;
|
2018-11-28 00:14:57 +01:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Pose");
|
|
|
|
|
|
|
|
this.g(nbttagcompound1);
|
2020-01-22 03:02:07 +01:00
|
|
|
@@ -600,7 +615,29 @@ public class EntityArmorStand extends EntityLiving {
|
2018-08-15 10:26:51 +02:00
|
|
|
|
2019-05-05 04:23:25 +02:00
|
|
|
@Override
|
2018-08-17 00:11:35 +02:00
|
|
|
public void tick() {
|
2018-11-08 02:48:22 +01:00
|
|
|
+ // Paper start
|
|
|
|
+ if (!this.canTick) {
|
|
|
|
+ if (this.noTickPoseDirty) {
|
2018-11-08 05:23:53 +01:00
|
|
|
+ this.noTickPoseDirty = false;
|
2018-11-08 02:48:22 +01:00
|
|
|
+ this.updatePose();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (this.noTickEquipmentDirty) {
|
|
|
|
+ this.noTickEquipmentDirty = false;
|
|
|
|
+ this.updateEntityEquipment();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
2018-08-17 00:11:35 +02:00
|
|
|
super.tick();
|
2018-11-08 02:48:22 +01:00
|
|
|
+ // Paper start - Split into separate method
|
|
|
|
+ updatePose();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void updatePose() {
|
|
|
|
+ // Paper end
|
2019-05-05 04:23:25 +02:00
|
|
|
Vector3f vector3f = (Vector3f) this.datawatcher.get(EntityArmorStand.c);
|
2018-08-15 10:26:51 +02:00
|
|
|
|
2018-11-08 02:48:22 +01:00
|
|
|
if (!this.headPose.equals(vector3f)) {
|
2020-01-22 03:02:07 +01:00
|
|
|
@@ -723,31 +760,37 @@ public class EntityArmorStand extends EntityLiving {
|
2018-11-08 02:48:22 +01:00
|
|
|
public void setHeadPose(Vector3f vector3f) {
|
|
|
|
this.headPose = vector3f;
|
2019-05-05 04:23:25 +02:00
|
|
|
this.datawatcher.set(EntityArmorStand.c, vector3f);
|
2018-11-08 02:48:22 +01:00
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setBodyPose(Vector3f vector3f) {
|
|
|
|
this.bodyPose = vector3f;
|
2019-05-05 04:23:25 +02:00
|
|
|
this.datawatcher.set(EntityArmorStand.d, vector3f);
|
2018-11-08 02:48:22 +01:00
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLeftArmPose(Vector3f vector3f) {
|
|
|
|
this.leftArmPose = vector3f;
|
2019-05-05 04:23:25 +02:00
|
|
|
this.datawatcher.set(EntityArmorStand.e, vector3f);
|
2018-11-08 02:48:22 +01:00
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setRightArmPose(Vector3f vector3f) {
|
|
|
|
this.rightArmPose = vector3f;
|
2019-05-05 04:23:25 +02:00
|
|
|
this.datawatcher.set(EntityArmorStand.f, vector3f);
|
2018-11-08 02:48:22 +01:00
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLeftLegPose(Vector3f vector3f) {
|
|
|
|
this.leftLegPose = vector3f;
|
2019-05-05 04:23:25 +02:00
|
|
|
this.datawatcher.set(EntityArmorStand.g, vector3f);
|
2018-11-08 02:48:22 +01:00
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setRightLegPose(Vector3f vector3f) {
|
|
|
|
this.rightLegPose = vector3f;
|
2019-12-12 01:03:31 +01:00
|
|
|
this.datawatcher.set(EntityArmorStand.bp, vector3f);
|
2018-11-08 02:48:22 +01:00
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
|
|
}
|
|
|
|
|
|
|
|
public Vector3f r() {
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
2020-01-22 03:02:07 +01:00
|
|
|
index fea821be1..0b84ead5f 100644
|
2018-11-08 02:48:22 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
2020-01-22 03:02:07 +01:00
|
|
|
@@ -2326,52 +2326,7 @@ public abstract class EntityLiving extends Entity {
|
2018-11-08 02:48:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- EnumItemSlot[] aenumitemslot = EnumItemSlot.values();
|
2019-12-12 01:03:31 +01:00
|
|
|
- int k = aenumitemslot.length;
|
2018-11-08 02:48:22 +01:00
|
|
|
-
|
2019-12-12 01:03:31 +01:00
|
|
|
- for (int l = 0; l < k; ++l) {
|
|
|
|
- EnumItemSlot enumitemslot = aenumitemslot[l];
|
2018-11-08 02:48:22 +01:00
|
|
|
- ItemStack itemstack;
|
|
|
|
-
|
|
|
|
- switch (enumitemslot.a()) {
|
2019-05-28 01:01:45 +02:00
|
|
|
- case HAND:
|
2019-12-12 01:03:31 +01:00
|
|
|
- itemstack = (ItemStack) this.bu.get(enumitemslot.b());
|
2019-05-28 01:01:45 +02:00
|
|
|
- break;
|
|
|
|
- case ARMOR:
|
2019-12-12 01:03:31 +01:00
|
|
|
- itemstack = (ItemStack) this.bv.get(enumitemslot.b());
|
2019-05-28 01:01:45 +02:00
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- continue;
|
2018-11-08 02:48:22 +01:00
|
|
|
- }
|
|
|
|
-
|
|
|
|
- ItemStack itemstack1 = this.getEquipment(enumitemslot);
|
|
|
|
-
|
|
|
|
- if (!ItemStack.matches(itemstack1, itemstack)) {
|
|
|
|
- // Paper start - PlayerArmorChangeEvent
|
2019-03-03 21:21:51 +01:00
|
|
|
- if (this instanceof EntityPlayer && enumitemslot.getType() == EnumItemSlot.Function.ARMOR) {
|
2018-11-08 02:48:22 +01:00
|
|
|
- final org.bukkit.inventory.ItemStack oldItem = CraftItemStack.asBukkitCopy(itemstack);
|
|
|
|
- final org.bukkit.inventory.ItemStack newItem = CraftItemStack.asBukkitCopy(itemstack1);
|
|
|
|
- new PlayerArmorChangeEvent((Player) this.getBukkitEntity(), PlayerArmorChangeEvent.SlotType.valueOf(enumitemslot.name()), oldItem, newItem).callEvent();
|
|
|
|
- }
|
|
|
|
- // Paper end
|
2019-05-05 04:23:25 +02:00
|
|
|
- ((WorldServer) this.world).getChunkProvider().broadcast(this, new PacketPlayOutEntityEquipment(this.getId(), enumitemslot, itemstack1));
|
2018-11-08 02:48:22 +01:00
|
|
|
- if (!itemstack.isEmpty()) {
|
|
|
|
- this.getAttributeMap().a(itemstack.a(enumitemslot));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!itemstack1.isEmpty()) {
|
|
|
|
- this.getAttributeMap().b(itemstack1.a(enumitemslot));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- switch (enumitemslot.a()) {
|
2019-05-28 01:01:45 +02:00
|
|
|
- case HAND:
|
2019-12-12 01:03:31 +01:00
|
|
|
- this.bu.set(enumitemslot.b(), itemstack1.cloneItemStack());
|
2019-05-28 01:01:45 +02:00
|
|
|
- break;
|
|
|
|
- case ARMOR:
|
2019-12-12 01:03:31 +01:00
|
|
|
- this.bv.set(enumitemslot.b(), itemstack1.cloneItemStack());
|
2018-11-08 02:48:22 +01:00
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
+ updateEntityEquipment(); // Paper - split into own method
|
|
|
|
|
|
|
|
if (this.ticksLived % 20 == 0) {
|
|
|
|
this.getCombatTracker().g();
|
2020-01-22 03:02:07 +01:00
|
|
|
@@ -2472,6 +2427,55 @@ public abstract class EntityLiving extends Entity {
|
2018-11-08 02:48:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start - split into own method from above
|
|
|
|
+ public void updateEntityEquipment() {
|
2018-12-08 11:09:55 +01:00
|
|
|
+ EnumItemSlot[] aenumitemslot = EnumItemSlot.values();
|
2019-12-12 01:03:31 +01:00
|
|
|
+ int k = aenumitemslot.length;
|
|
|
|
+ for (int l = 0; l < k; ++l) {
|
|
|
|
+ EnumItemSlot enumitemslot = aenumitemslot[l];
|
2018-11-08 02:48:22 +01:00
|
|
|
+ ItemStack itemstack;
|
|
|
|
+
|
|
|
|
+ switch (enumitemslot.a()) {
|
|
|
|
+ case HAND:
|
2019-12-12 01:03:31 +01:00
|
|
|
+ itemstack = (ItemStack) this.bu.get(enumitemslot.b());
|
2018-11-08 02:48:22 +01:00
|
|
|
+ break;
|
|
|
|
+ case ARMOR:
|
2019-12-12 01:03:31 +01:00
|
|
|
+ itemstack = (ItemStack) this.bv.get(enumitemslot.b());
|
2018-11-08 02:48:22 +01:00
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ItemStack itemstack1 = this.getEquipment(enumitemslot);
|
|
|
|
+
|
|
|
|
+ if (!ItemStack.matches(itemstack1, itemstack)) {
|
|
|
|
+ // Paper start - PlayerArmorChangeEvent
|
2019-03-03 21:21:51 +01:00
|
|
|
+ if (this instanceof EntityPlayer && enumitemslot.getType() == EnumItemSlot.Function.ARMOR) {
|
2018-11-08 02:48:22 +01:00
|
|
|
+ final org.bukkit.inventory.ItemStack oldItem = CraftItemStack.asBukkitCopy(itemstack);
|
|
|
|
+ final org.bukkit.inventory.ItemStack newItem = CraftItemStack.asBukkitCopy(itemstack1);
|
|
|
|
+ new PlayerArmorChangeEvent((Player) this.getBukkitEntity(), PlayerArmorChangeEvent.SlotType.valueOf(enumitemslot.name()), oldItem, newItem).callEvent();
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
2019-05-05 04:23:25 +02:00
|
|
|
+ ((WorldServer) this.world).getChunkProvider().broadcast(this, new PacketPlayOutEntityEquipment(this.getId(), enumitemslot, itemstack1));
|
2018-11-08 02:48:22 +01:00
|
|
|
+ if (!itemstack.isEmpty()) {
|
|
|
|
+ this.getAttributeMap().a(itemstack.a(enumitemslot));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!itemstack1.isEmpty()) {
|
|
|
|
+ this.getAttributeMap().b(itemstack1.a(enumitemslot));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ switch (enumitemslot.a()) {
|
|
|
|
+ case HAND:
|
2019-12-12 01:03:31 +01:00
|
|
|
+ this.bu.set(enumitemslot.b(), itemstack1.cloneItemStack());
|
2018-11-08 02:48:22 +01:00
|
|
|
+ break;
|
|
|
|
+ case ARMOR:
|
2019-12-12 01:03:31 +01:00
|
|
|
+ this.bv.set(enumitemslot.b(), itemstack1.cloneItemStack());
|
2018-11-08 02:48:22 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2019-12-12 01:03:31 +01:00
|
|
|
protected float f(float f, float f1) {
|
|
|
|
float f2 = MathHelper.g(f - this.aI);
|
2018-11-08 02:48:22 +01:00
|
|
|
|
2018-08-15 10:26:51 +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-01-18 18:28:32 +01:00
|
|
|
index d1d689e5d..ac105270d 100644
|
2018-08-15 10:26:51 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
|
2019-10-03 02:20:40 +02:00
|
|
|
@@ -297,5 +297,16 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand {
|
2018-08-17 00:11:35 +02:00
|
|
|
public boolean isSlotDisabled(org.bukkit.inventory.EquipmentSlot slot) {
|
|
|
|
return getHandle().isSlotDisabled(org.bukkit.craftbukkit.CraftEquipmentSlot.getNMS(slot));
|
2018-08-15 10:26:51 +02:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean canTick() {
|
|
|
|
+ return this.getHandle().canTick;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void setCanTick(final boolean tick) {
|
|
|
|
+ this.getHandle().canTick = tick;
|
2019-10-03 02:20:40 +02:00
|
|
|
+ this.getHandle().canTickSetByAPI = true;
|
2018-08-15 10:26:51 +02:00
|
|
|
+ }
|
2018-08-17 00:11:35 +02:00
|
|
|
// Paper end
|
2018-08-15 10:26:51 +02:00
|
|
|
}
|
|
|
|
--
|
2020-01-18 18:28:32 +01:00
|
|
|
2.25.0.windows.1
|
2018-08-15 10:26:51 +02:00
|
|
|
|