mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 04:55:47 +01:00
01a13871de
Patch documentation to come Issues with the old system that are fixed now: - World generation does not scale with cpu cores effectively. - Relies on the main thread for scheduling and maintaining chunk state, dropping chunk load/generate rates at lower tps. - Unreliable prioritisation of chunk gen/load calls that block the main thread. - Shutdown logic is utterly unreliable, as it has to wait for all chunks to unload - is it guaranteed that the chunk system is in a state on shutdown that it can reliably do this? Watchdog shutdown also typically failed due to thread checks, which is now resolved. - Saving of data is not unified (i.e can save chunk data without saving entity data, poses problems for desync if shutdown is really abnormal. - Entities are not loaded with chunks. This caused quite a bit of headache for Chunk#getEntities API, but now the new chunk system loads entities with chunks so that they are ready whenever the chunk loads in. Effectively brings the behavior back to 1.16 era, but still storing entities in their own separate regionfiles. The above list is not complete. The patch documentation will complete it. New chunk system hard relies on starlight and dataconverter, and most importantly the new concurrent utilities in ConcurrentUtil. Some of the old async chunk i/o interface (i.e the old file io thread reroutes _some_ calls to the new file io thread) is kept for plugin compat reasons. It will be removed in the next major version of minecraft. The old legacy chunk system patches have been moved to the removed folder in case we need them again.
146 lines
5.7 KiB
Diff
146 lines
5.7 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/net/minecraft/world/entity/decoration/ArmorStand.java b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
|
|
index 9897dbb03c343e1e1842f7ca6bc9b99b95d0b8be..f94a74728bd7c02a7f8245c92e7916f0b669ee0d 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
|
|
@@ -92,9 +92,16 @@ public class ArmorStand extends LivingEntity {
|
|
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().entities.armorStands.tick; // Paper - armour stand ticking
|
|
this.handItems = NonNullList.withSize(2, ItemStack.EMPTY);
|
|
this.armorItems = NonNullList.withSize(4, ItemStack.EMPTY);
|
|
this.headPose = ArmorStand.DEFAULT_HEAD_POSE;
|
|
@@ -189,6 +196,7 @@ public class ArmorStand extends LivingEntity {
|
|
this.onEquipItem(enumitemslot, (ItemStack) this.armorItems.set(enumitemslot.getIndex(), itemstack), itemstack, silent); // CraftBukkit
|
|
}
|
|
|
|
+ this.noTickEquipmentDirty = true; // Paper - Allow equipment to be updated even when tick disabled
|
|
}
|
|
|
|
@Override
|
|
@@ -239,6 +247,7 @@ public class ArmorStand extends LivingEntity {
|
|
}
|
|
|
|
nbt.put("Pose", this.writePose());
|
|
+ if (this.canTickSetByAPI) nbt.putBoolean("Paper.CanTickOverride", this.canTick); // Paper - persist no tick setting
|
|
}
|
|
|
|
@Override
|
|
@@ -270,6 +279,12 @@ public class ArmorStand extends LivingEntity {
|
|
this.setNoBasePlate(nbt.getBoolean("NoBasePlate"));
|
|
this.setMarker(nbt.getBoolean("Marker"));
|
|
this.noPhysics = !this.hasPhysics();
|
|
+ // Paper start - persist no tick
|
|
+ if (nbt.contains("Paper.CanTickOverride")) {
|
|
+ this.canTick = nbt.getBoolean("Paper.CanTickOverride");
|
|
+ this.canTickSetByAPI = true;
|
|
+ }
|
|
+ // Paper end
|
|
CompoundTag nbttagcompound1 = nbt.getCompound("Pose");
|
|
|
|
this.readPose(nbttagcompound1);
|
|
@@ -651,7 +666,29 @@ public class ArmorStand extends LivingEntity {
|
|
|
|
@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)) {
|
|
@@ -775,31 +812,37 @@ public class ArmorStand extends LivingEntity {
|
|
public void setHeadPose(Rotations angle) {
|
|
this.headPose = angle;
|
|
this.entityData.set(ArmorStand.DATA_HEAD_POSE, angle);
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
}
|
|
|
|
public void setBodyPose(Rotations angle) {
|
|
this.bodyPose = angle;
|
|
this.entityData.set(ArmorStand.DATA_BODY_POSE, angle);
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
}
|
|
|
|
public void setLeftArmPose(Rotations angle) {
|
|
this.leftArmPose = angle;
|
|
this.entityData.set(ArmorStand.DATA_LEFT_ARM_POSE, angle);
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
}
|
|
|
|
public void setRightArmPose(Rotations angle) {
|
|
this.rightArmPose = angle;
|
|
this.entityData.set(ArmorStand.DATA_RIGHT_ARM_POSE, angle);
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
}
|
|
|
|
public void setLeftLegPose(Rotations angle) {
|
|
this.leftLegPose = angle;
|
|
this.entityData.set(ArmorStand.DATA_LEFT_LEG_POSE, angle);
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
}
|
|
|
|
public void setRightLegPose(Rotations angle) {
|
|
this.rightLegPose = angle;
|
|
this.entityData.set(ArmorStand.DATA_RIGHT_LEG_POSE, angle);
|
|
+ this.noTickPoseDirty = true; // Paper - Allow updates when not ticking
|
|
}
|
|
|
|
public Rotations getHeadPose() {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
|
|
index 06cedeea447f53d100e32a6eba6f83b4719cb231..82b9ee993b0d2e7e0685231f7bad2b85756ec959 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
|
|
@@ -238,5 +238,16 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand {
|
|
public void setCanMove(boolean move) {
|
|
getHandle().canMove = move;
|
|
}
|
|
+
|
|
+ @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
|
|
}
|