Copper golems cause massive lag spikes when checking chests and copper chests.
Steps to reproduce the issue
summon 45 copper golems the natural way (pumpkins and copper blocks, that way the copper chests generate). After a few minutes, remove the copper chests.
Expected result
The game’s performance would remain consistent.
Actual result
The game lags to unplayable levels until the copper chests are removed. This also applies to normal chests.
Linked issues
Attachments
Comments 5
Here is the requested video, this website refuses to let me upload it, so I had to use a google drive link.
https://drive.google.com/file/d/1LQjTUJCYCVx-fkt50uY-ZyNGb2SmCNV6/view?usp=sharing&t=5
As you can see, once the copper golems are all killed, the lag completely vanishes instantly.
As of 1.21.9 Pre-Release 2, the issue still happens when the copper golems are checking chests. Copper golems will no longer cause lag when queuing for a chest other copper golems are checking, so my previous example will not cause much lag, but they still cause just as much lag when they are checking chests themselves. I’ll attach a new video with an example
I wrote a patch that seems to help with the remaining issue while the chests are open
Index: net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java b/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java
--- a/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java (revision 9ceed0392b1bed23ac562ba56adc889d3d60315a)
+++ b/net/minecraft/world/entity/ai/behavior/TransportItemsBetweenContainers.java (date 1758315147845)
@@ -62,6 +62,7 @@
@Nullable
private TransportItemsBetweenContainers.ContainerInteractionState interactionState;
private int ticksSinceReachingTarget;
+ @Nullable private net.minecraft.world.level.pathfinder.Path interactionPath;
public TransportItemsBetweenContainers(
float speedModifier,
@@ -213,6 +214,7 @@
}
private void startOnReachedTargetInteraction(TransportItemsBetweenContainers.TransportItemTarget target, PathfinderMob mob) {
+ this.interactionPath = mob.getNavigation().getPath();
this.doReachedTargetInteraction(
mob,
target.container,
@@ -225,6 +227,7 @@
}
private void onStartTravelling(PathfinderMob mob) {
+ this.interactionPath = null;
this.onStartTravelling.accept(mob);
this.setTransportingState(TransportItemsBetweenContainers.TransportItemState.TRAVELLING);
this.interactionState = null;
@@ -333,7 +336,9 @@
return true;
}
- Path path = mob.getNavigation().getPath() == null ? mob.getNavigation().createPath(this.target.pos, 0) : mob.getNavigation().getPath();
+ Path path = mob.getNavigation().getPath();
+ if (path == null && this.state.equals(net.minecraft.world.entity.ai.behavior.TransportItemsBetweenContainers.TransportItemState.INTERACTING)) path = this.interactionPath;
+ if (path == null) path = mob.getNavigation().createPath(this.target.pos, 0);
Vec3 positionToReachTargetFrom = this.getPositionToReachTargetFrom(path, mob);
boolean isWithinTargetDistance = this.isWithinTargetDistance(getInteractionRange(mob), this.target, level, mob, positionToReachTargetFrom);
boolean flag1 = path == null && !isWithinTargetDistance;
Hey!
Could you please record a video of this issue?
Could you please also write do fps drop on specific place or specific action?
Quick Links:
📓 Issue Guidelines – 💬 Mojang Support – 📧 Suggestions – 📖 Minecraft Wiki