2018-12-15 01:17:27 +00:00
|
|
|
From e48332db0f5bfbafa2fb3ad77e4cf28dac027a60 Mon Sep 17 00:00:00 2001
|
2018-08-15 08:26:51 +00: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
|
2018-12-13 00:40:29 +00:00
|
|
|
index 4059c7a72..10efe6b3d 100644
|
2018-08-15 08:26:51 +00:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
2018-12-13 00:40:29 +00:00
|
|
|
@@ -498,4 +498,10 @@ public class PaperWorldConfig {
|
2018-08-26 18:11:49 +00:00
|
|
|
break;
|
|
|
|
}
|
2018-08-15 08:26:51 +00: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
|
2018-12-08 10:09:55 +00:00
|
|
|
index 1dcc482c0..c5bddb1da 100644
|
2018-08-15 08:26:51 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityArmorStand.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityArmorStand.java
|
2018-11-08 01:48:22 +00:00
|
|
|
@@ -45,6 +45,11 @@ public class EntityArmorStand extends EntityLiving {
|
2018-08-15 08:26:51 +00:00
|
|
|
public Vector3f leftLegPose;
|
|
|
|
public Vector3f rightLegPose;
|
|
|
|
public boolean canMove = true; // Paper
|
2018-11-08 01:48:22 +00:00
|
|
|
+ // Paper start - Allow ArmorStands not to tick
|
|
|
|
+ public boolean canTick = true;
|
|
|
|
+ private boolean noTickPoseDirty = false;
|
|
|
|
+ private boolean noTickEquipmentDirty = false;
|
|
|
|
+ // Paper end
|
2018-08-15 08:26:51 +00:00
|
|
|
|
|
|
|
public EntityArmorStand(World world) {
|
2018-08-16 22:11:35 +00:00
|
|
|
super(EntityTypes.ARMOR_STAND, world);
|
2018-11-08 01:48:22 +00:00
|
|
|
@@ -57,6 +62,7 @@ public class EntityArmorStand extends EntityLiving {
|
2018-08-16 22:11:35 +00:00
|
|
|
this.leftLegPose = EntityArmorStand.bB;
|
|
|
|
this.rightLegPose = EntityArmorStand.bC;
|
2018-08-15 08:26:51 +00:00
|
|
|
this.noclip = this.isNoGravity();
|
|
|
|
+ if (world != null) this.canTick = world.paperConfig.armorStandTick; // Paper - armour stand ticking
|
2018-08-16 22:11:35 +00:00
|
|
|
this.setSize(0.5F, 1.975F);
|
|
|
|
this.Q = 0.0F;
|
2018-08-15 08:26:51 +00:00
|
|
|
}
|
2018-12-08 10:09:55 +00:00
|
|
|
@@ -128,6 +134,7 @@ public class EntityArmorStand extends EntityLiving {
|
2018-11-08 01:48:22 +00:00
|
|
|
this.bF.set(enumitemslot.b(), itemstack);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ this.noTickEquipmentDirty = true; // Paper - Allow equipment to be updated even when tick disabled
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean c(int i, ItemStack itemstack) {
|
2018-12-08 10:09:55 +00:00
|
|
|
@@ -199,6 +206,7 @@ public class EntityArmorStand extends EntityLiving {
|
2018-11-27 23:14:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nbttagcompound.set("Pose", this.z());
|
|
|
|
+ nbttagcompound.setBoolean("Paper.CanTick", this.canTick); // Paper - persist no tick setting
|
|
|
|
}
|
|
|
|
|
|
|
|
public void a(NBTTagCompound nbttagcompound) {
|
2018-12-08 10:09:55 +00:00
|
|
|
@@ -230,6 +238,11 @@ public class EntityArmorStand extends EntityLiving {
|
2018-11-27 23:14:57 +00:00
|
|
|
this.setMarker(nbttagcompound.getBoolean("Marker"));
|
|
|
|
this.bI = !this.isMarker();
|
|
|
|
this.noclip = this.isNoGravity();
|
|
|
|
+ // Paper start - persist no tick
|
|
|
|
+ if (nbttagcompound.hasKey("Paper.CanTick")) {
|
|
|
|
+ this.canTick = nbttagcompound.getBoolean("Paper.CanTick");
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("Pose");
|
|
|
|
|
|
|
|
this.g(nbttagcompound1);
|
2018-12-08 10:09:55 +00:00
|
|
|
@@ -553,7 +566,30 @@ public class EntityArmorStand extends EntityLiving {
|
2018-08-15 08:26:51 +00:00
|
|
|
}
|
|
|
|
|
2018-08-16 22:11:35 +00:00
|
|
|
public void tick() {
|
2018-11-08 01:48:22 +00:00
|
|
|
+ // Paper start
|
|
|
|
+ if (!this.canTick) {
|
|
|
|
+ if (this.noTickPoseDirty) {
|
2018-11-08 04:23:53 +00:00
|
|
|
+ this.noTickPoseDirty = false;
|
2018-11-08 01:48:22 +00:00
|
|
|
+ this.updatePose();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (this.noTickEquipmentDirty) {
|
|
|
|
+ this.noTickEquipmentDirty = false;
|
|
|
|
+ this.updateEntityEquipment();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
2018-08-16 22:11:35 +00:00
|
|
|
super.tick();
|
2018-11-08 01:48:22 +00:00
|
|
|
+
|
|
|
|
+ // Paper start - Split into separate method
|
|
|
|
+ updatePose();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void updatePose() {
|
|
|
|
+ // Paper end
|
2018-08-15 08:26:51 +00:00
|
|
|
Vector3f vector3f = (Vector3f) this.datawatcher.get(EntityArmorStand.b);
|
|
|
|
|
2018-11-08 01:48:22 +00:00
|
|
|
if (!this.headPose.equals(vector3f)) {
|
2018-12-08 10:09:55 +00:00
|
|
|
@@ -682,31 +718,37 @@ public class EntityArmorStand extends EntityLiving {
|
2018-11-08 01:48:22 +00:00
|
|
|
public void setHeadPose(Vector3f vector3f) {
|
|
|
|
this.headPose = vector3f;
|
|
|
|
this.datawatcher.set(EntityArmorStand.b, vector3f);
|
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setBodyPose(Vector3f vector3f) {
|
|
|
|
this.bodyPose = vector3f;
|
|
|
|
this.datawatcher.set(EntityArmorStand.c, vector3f);
|
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLeftArmPose(Vector3f vector3f) {
|
|
|
|
this.leftArmPose = vector3f;
|
|
|
|
this.datawatcher.set(EntityArmorStand.d, vector3f);
|
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setRightArmPose(Vector3f vector3f) {
|
|
|
|
this.rightArmPose = vector3f;
|
|
|
|
this.datawatcher.set(EntityArmorStand.e, vector3f);
|
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLeftLegPose(Vector3f vector3f) {
|
|
|
|
this.leftLegPose = vector3f;
|
|
|
|
this.datawatcher.set(EntityArmorStand.f, vector3f);
|
|
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setRightLegPose(Vector3f vector3f) {
|
|
|
|
this.rightLegPose = vector3f;
|
|
|
|
this.datawatcher.set(EntityArmorStand.g, vector3f);
|
|
|
|
+ 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
|
2018-12-08 10:09:55 +00:00
|
|
|
index 3e9af4481..1dcb9a7e9 100644
|
2018-11-08 01:48:22 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
2018-12-08 10:09:55 +00:00
|
|
|
@@ -2082,52 +2082,7 @@ public abstract class EntityLiving extends Entity {
|
2018-11-08 01:48:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- EnumItemSlot[] aenumitemslot = EnumItemSlot.values();
|
|
|
|
- int j = aenumitemslot.length;
|
|
|
|
-
|
|
|
|
- for (int k = 0; k < j; ++k) {
|
|
|
|
- EnumItemSlot enumitemslot = aenumitemslot[k];
|
|
|
|
- ItemStack itemstack;
|
|
|
|
-
|
|
|
|
- switch (enumitemslot.a()) {
|
|
|
|
- case HAND:
|
|
|
|
- itemstack = (ItemStack) this.bB.get(enumitemslot.b());
|
|
|
|
- break;
|
|
|
|
- case ARMOR:
|
|
|
|
- itemstack = (ItemStack) this.bC.get(enumitemslot.b());
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- ItemStack itemstack1 = this.getEquipment(enumitemslot);
|
|
|
|
-
|
|
|
|
- if (!ItemStack.matches(itemstack1, itemstack)) {
|
|
|
|
- // Paper start - PlayerArmorChangeEvent
|
|
|
|
- if (this instanceof EntityPlayer && enumitemslot.getType() == EnumItemSlot.Function.ARMOR && !itemstack.getItem().equals(itemstack1.getItem())) {
|
|
|
|
- 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
|
|
|
|
- ((WorldServer) this.world).getTracker().a((Entity) this, (Packet) (new PacketPlayOutEntityEquipment(this.getId(), enumitemslot, itemstack1)));
|
|
|
|
- if (!itemstack.isEmpty()) {
|
|
|
|
- this.getAttributeMap().a(itemstack.a(enumitemslot));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!itemstack1.isEmpty()) {
|
|
|
|
- this.getAttributeMap().b(itemstack1.a(enumitemslot));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- switch (enumitemslot.a()) {
|
|
|
|
- case HAND:
|
|
|
|
- this.bB.set(enumitemslot.b(), itemstack1.isEmpty() ? ItemStack.a : itemstack1.cloneItemStack());
|
|
|
|
- break;
|
|
|
|
- case ARMOR:
|
|
|
|
- this.bC.set(enumitemslot.b(), itemstack1.isEmpty() ? ItemStack.a : itemstack1.cloneItemStack());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
+ updateEntityEquipment(); // Paper - split into own method
|
|
|
|
|
|
|
|
if (this.ticksLived % 20 == 0) {
|
|
|
|
this.getCombatTracker().g();
|
2018-12-08 10:09:55 +00:00
|
|
|
@@ -2220,6 +2175,57 @@ public abstract class EntityLiving extends Entity {
|
2018-11-08 01:48:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start - split into own method from above
|
|
|
|
+ public void updateEntityEquipment() {
|
2018-12-08 10:09:55 +00:00
|
|
|
+ EnumItemSlot[] aenumitemslot = EnumItemSlot.values();
|
|
|
|
+ int j = aenumitemslot.length;
|
|
|
|
+
|
|
|
|
+ for (int k = 0; k < j; ++k) {
|
|
|
|
+ EnumItemSlot enumitemslot = aenumitemslot[k];
|
2018-11-08 01:48:22 +00:00
|
|
|
+ ItemStack itemstack;
|
|
|
|
+
|
|
|
|
+ switch (enumitemslot.a()) {
|
|
|
|
+ case HAND:
|
|
|
|
+ itemstack = (ItemStack) this.bB.get(enumitemslot.b());
|
|
|
|
+ break;
|
|
|
|
+ case ARMOR:
|
|
|
|
+ itemstack = (ItemStack) this.bC.get(enumitemslot.b());
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ItemStack itemstack1 = this.getEquipment(enumitemslot);
|
|
|
|
+
|
|
|
|
+ if (!ItemStack.matches(itemstack1, itemstack)) {
|
|
|
|
+ // Paper start - PlayerArmorChangeEvent
|
|
|
|
+ if (this instanceof EntityPlayer && enumitemslot.getType() == EnumItemSlot.Function.ARMOR && !itemstack.getItem().equals(itemstack1.getItem())) {
|
|
|
|
+ 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
|
|
|
|
+ ((WorldServer) this.world).getTracker().a((Entity) this, (Packet) (new PacketPlayOutEntityEquipment(this.getId(), enumitemslot, itemstack1)));
|
|
|
|
+ if (!itemstack.isEmpty()) {
|
|
|
|
+ this.getAttributeMap().a(itemstack.a(enumitemslot));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!itemstack1.isEmpty()) {
|
|
|
|
+ this.getAttributeMap().b(itemstack1.a(enumitemslot));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ switch (enumitemslot.a()) {
|
|
|
|
+ case HAND:
|
|
|
|
+ this.bB.set(enumitemslot.b(), itemstack1.isEmpty() ? ItemStack.a : itemstack1.cloneItemStack());
|
|
|
|
+ break;
|
|
|
|
+ case ARMOR:
|
|
|
|
+ this.bC.set(enumitemslot.b(), itemstack1.isEmpty() ? ItemStack.a : itemstack1.cloneItemStack());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
protected float e(float f, float f1) {
|
|
|
|
float f2 = MathHelper.g(f - this.aQ);
|
|
|
|
|
2018-08-15 08:26:51 +00:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
|
2018-11-08 01:48:22 +00:00
|
|
|
index 9f5c3b92e..07ce93f17 100644
|
2018-08-15 08:26:51 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
|
2018-08-16 22:11:35 +00:00
|
|
|
@@ -297,5 +297,15 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand {
|
|
|
|
public boolean isSlotDisabled(org.bukkit.inventory.EquipmentSlot slot) {
|
|
|
|
return getHandle().isSlotDisabled(org.bukkit.craftbukkit.CraftEquipmentSlot.getNMS(slot));
|
2018-08-15 08:26:51 +00:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean canTick() {
|
|
|
|
+ return this.getHandle().canTick;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void setCanTick(final boolean tick) {
|
|
|
|
+ this.getHandle().canTick = tick;
|
|
|
|
+ }
|
2018-08-16 22:11:35 +00:00
|
|
|
// Paper end
|
2018-08-15 08:26:51 +00:00
|
|
|
}
|
|
|
|
--
|
2018-12-13 00:40:29 +00:00
|
|
|
2.20.0
|
2018-08-15 08:26:51 +00:00
|
|
|
|