geforkt von Mirrors/Paper
ce2eae5ce3
Upstream has released updates that appears 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:
b56e8160 #519: Add ArrowBodyCountChangeEvent
CraftBukkit Changes:
39806409e
#697: Add ArrowBodyCountChangeEvent
172 Zeilen
7.1 KiB
Diff
172 Zeilen
7.1 KiB
Diff
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
|
|
index 92ddf96f7db08a2b390ef3f49b0643f9d90bbea4..414b9077317022e4efc0b1e547d7f387610146dc 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
|
@@ -377,4 +377,10 @@ public class PaperWorldConfig {
|
|
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
|
|
index 944c34a7011a0cfc447014e2931c8742f324fe59..4a4c2a7b117428137bed65ed66f207d693b90c4b 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityArmorStand.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityArmorStand.java
|
|
@@ -46,9 +46,16 @@ public class EntityArmorStand extends EntityLiving {
|
|
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
|
|
this.handItems = NonNullList.a(2, ItemStack.b);
|
|
this.armorItems = NonNullList.a(4, ItemStack.b);
|
|
this.headPose = EntityArmorStand.bj;
|
|
@@ -137,6 +144,7 @@ public class EntityArmorStand extends EntityLiving {
|
|
this.armorItems.set(enumitemslot.b(), itemstack);
|
|
}
|
|
|
|
+ this.noTickEquipmentDirty = true; // Paper - Allow equipment to be updated even when tick disabled
|
|
}
|
|
|
|
@Override
|
|
@@ -217,6 +225,7 @@ public class EntityArmorStand extends EntityLiving {
|
|
}
|
|
|
|
nbttagcompound.set("Pose", this.B());
|
|
+ if (this.canTickSetByAPI) nbttagcompound.setBoolean("Paper.CanTickOverride", this.canTick); // Paper - persist no tick setting
|
|
}
|
|
|
|
@Override
|
|
@@ -248,6 +257,12 @@ public class EntityArmorStand extends EntityLiving {
|
|
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);
|
|
@@ -602,7 +617,29 @@ public class EntityArmorStand extends EntityLiving {
|
|
|
|
@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)) {
|
|
@@ -725,29 +762,36 @@ public class EntityArmorStand extends EntityLiving {
|
|
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) {
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
this.leftLegPose = vector3f;
|
|
this.datawatcher.set(EntityArmorStand.g, vector3f);
|
|
+
|
|
}
|
|
|
|
public void setRightLegPose(Vector3f vector3f) {
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
this.rightLegPose = vector3f;
|
|
this.datawatcher.set(EntityArmorStand.bh, vector3f);
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
index 4c48ff8fad90686da65097e4be6bcedca9761c3d..14fb5f34c683ec93c57b5383aef339dcbbf9e19a 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
@@ -2513,6 +2513,7 @@ public abstract class EntityLiving extends Entity {
|
|
}
|
|
}
|
|
|
|
+ public final void updateEntityEquipment() { p(); }; // Paper - OBFHELPER
|
|
private void p() {
|
|
Map<EnumItemSlot, ItemStack> map = this.q();
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
|
|
index 83838500017025005b89361c0926b15eed003761..4936266b1be1c0acd49fb8eabd7bc909b2f6de9e 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
|
|
@@ -313,5 +313,16 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand {
|
|
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
|
|
}
|