Techman88 | Pillager/Raid Lag Explanation and a Fix (Minecraft 1.14.4) @techman8817 | Uploaded 5 years ago | Updated 13 hours ago
The main lag seems to be caused by pillagers having a PatrolTarget set (an XYZ value), which they cannot reach, but continually try to pathfind through for example a mountain gap which causes laggy pathfinding all the time. This PatrolTarget is set on randomly spawned raids, the ones that rarely, and randomly occur anywhere.
This is the bug tracker issue bugs.mojang.com/browse/MC-157697
It's "fixed" but they won't release the fix until 1.15 if history says anything. They should make 1.14.5 with minor fixes like this.
My fix to the lag, just tells them not to patrol. You could just run this every few seconds in a command block, but I'll try to make a datapack.
/execute as @e[type=#minecraft:raiders] run data merge entity @s {Patrolling:0b}
May have some effect on raids on villages, in which the patrol leaders have Patrolling set to 1b. I did not test this with village-based raid farms, which may be affected.
I tried to simply remove PatrolTarget (which I believe is a good fix), but failed to find a working solution. Here's an attempt:
/execute as @e[type=#minecraft:raiders] run data remove entity @s PatrolTarget
It always resetted the PatrolTarget to 0,0,0 after running that, in all the variations I tried.
Also tried commands like this
/execute as @e[type=#minecraft:raiders] run data remove entity @s PatrolTarget.X
/execute as @e[type=#minecraft:raiders] run data remove entity @s PatrolTarget.Y
/execute as @e[type=#minecraft:raiders] run data remove entity @s PatrolTarget.Z
but it had the same effect, PatrolTarget would still be set to 0,0,0. I couldn't manage to simply remove the array. There might be a way to do this.
To summon a pillager that will cause lag:
/summon minecraft:pillager ~ ~ ~ {PatrolTarget:{X:5000,Y:0,Z:0},Patrolling:1}
A patrol leader copied from an actual random spawn (after hours of tick warp @ an ocean monument):
/summon minecraft:pillager ~ ~1 ~ {Brain: {memories: {}}, HurtByTimestamp: 0, CanJoinRaid: 1b, Attributes: [{Base: 24.0d, Name: "generic.maxHealth"}, {Base: 0.0d, Name: "generic.knockbackResistance"}, {Base: 0.3499999940395355d, Name: "generic.movementSpeed"}, {Base: 0.0d, Name: "generic.armor"}, {Base: 0.0d, Name: "generic.armorToughness"}, {Base: 32.0d, Modifiers: [{UUIDMost: 8155537058742812996L, UUIDLeast: -8989477423505343755L, Amount: 0.0798937026941346d, Operation: 1, Name: "Random spawn bonus"}], Name: "generic.followRange"}, {Base: 0.0d, Name: "generic.attackKnockback"}, {Base: 5.0d, Name: "generic.attackDamage"}], PatrolLeader: 1b, Invulnerable: 0b, FallFlying: 0b, PortalCooldown: 0, AbsorptionAmount: 0.0f, PatrolTarget: {X: 5000, Y: 70, Z: 0}, FallDistance: 0.0f, DeathTime: 0s, HandDropChances: [0.085f, 0.085f], PersistenceRequired: 0b, Patrolling: 1b, Motion: [0.006517125234045166d, -0.0784000015258789d, -0.01838171977574866d], Health: 24.0f, LeftHanded: 0b, Air: 300s, OnGround: 1b, Rotation: [190.26996f, -29.157398f], HandItems: [{id: "minecraft:crossbow", Count: 1b, tag: {Damage: 0}}, {}], Wave: 0, ArmorDropChances: [0.085f, 0.085f, 0.085f, 2.0f], Fire: -1s, ArmorItems: [{}, {}, {}, {id: "minecraft:white_banner", Count: 1b, tag: {BlockEntityTag: {Patterns: [{Pattern: "mr", Color: 9}, {Pattern: "bs", Color: 8}, {Pattern: "cs", Color: 7}, {Pattern: "bo", Color: 8}, {Pattern: "ms", Color: 15}, {Pattern: "hh", Color: 8}, {Pattern: "mc", Color: 8}, {Pattern: "bo", Color: 15}]}, display: {Name: '{"color":"gold","translate":"block.minecraft.ominous_banner"}'}}}], CanPickUpLoot: 1b, HurtTime: 0s, Inventory: []}
And a nonleader
/summon minecraft:pillager ~ ~1 ~ {Brain: {memories: {}}, HurtByTimestamp: 0, CanJoinRaid: 1b, Attributes: [{Base: 24.0d, Name: "generic.maxHealth"}, {Base: 0.0d, Name: "generic.knockbackResistance"}, {Base: 0.3499999940395355d, Name: "generic.movementSpeed"}, {Base: 0.0d, Name: "generic.armor"}, {Base: 0.0d, Name: "generic.armorToughness"}, {Base: 32.0d, Modifiers: [{UUIDMost: 1091068557595069214L, UUIDLeast: -5600343144297854598L, Amount: 0.032188637513724826d, Operation: 1, Name: "Random spawn bonus"}], Name: "generic.followRange"}, {Base: 0.0d, Name: "generic.attackKnockback"}, {Base: 5.0d, Name: "generic.attackDamage"}], PatrolLeader: 0b, Invulnerable: 0b, FallFlying: 0b, PortalCooldown: 0, AbsorptionAmount: 0.0f, PatrolTarget: {X: 5000, Y: 70, Z: 0}, FallDistance: 0.0f, DeathTime: 0s, HandDropChances: [0.085f, 0.085f], PersistenceRequired: 0b, Patrolling: 1b, Motion: [0.09824108023061612d, -0.0784000015258789d, 0.1033702431011876d], Health: 24.0f, LeftHanded: 0b, Air: 300s, OnGround: 1b, Rotation: [156.74881f, -15.138995f], HandItems: [{id: "minecraft:crossbow", Count: 1b, tag: {ChargedProjectiles: [{id: "minecraft:arrow", Count: 1b}], Charged: 1b, Damage: 0}}, {}], Wave: 0, ArmorDropChances: [0.085f, 0.085f, 0.085f, 0.085f], Fire: -1s, ArmorItems: [{}, {}, {}, {}], CanPickUpLoot: 1b, HurtTime: 0s, Inventory: []}
The main lag seems to be caused by pillagers having a PatrolTarget set (an XYZ value), which they cannot reach, but continually try to pathfind through for example a mountain gap which causes laggy pathfinding all the time. This PatrolTarget is set on randomly spawned raids, the ones that rarely, and randomly occur anywhere.
This is the bug tracker issue bugs.mojang.com/browse/MC-157697
It's "fixed" but they won't release the fix until 1.15 if history says anything. They should make 1.14.5 with minor fixes like this.
My fix to the lag, just tells them not to patrol. You could just run this every few seconds in a command block, but I'll try to make a datapack.
/execute as @e[type=#minecraft:raiders] run data merge entity @s {Patrolling:0b}
May have some effect on raids on villages, in which the patrol leaders have Patrolling set to 1b. I did not test this with village-based raid farms, which may be affected.
I tried to simply remove PatrolTarget (which I believe is a good fix), but failed to find a working solution. Here's an attempt:
/execute as @e[type=#minecraft:raiders] run data remove entity @s PatrolTarget
It always resetted the PatrolTarget to 0,0,0 after running that, in all the variations I tried.
Also tried commands like this
/execute as @e[type=#minecraft:raiders] run data remove entity @s PatrolTarget.X
/execute as @e[type=#minecraft:raiders] run data remove entity @s PatrolTarget.Y
/execute as @e[type=#minecraft:raiders] run data remove entity @s PatrolTarget.Z
but it had the same effect, PatrolTarget would still be set to 0,0,0. I couldn't manage to simply remove the array. There might be a way to do this.
To summon a pillager that will cause lag:
/summon minecraft:pillager ~ ~ ~ {PatrolTarget:{X:5000,Y:0,Z:0},Patrolling:1}
A patrol leader copied from an actual random spawn (after hours of tick warp @ an ocean monument):
/summon minecraft:pillager ~ ~1 ~ {Brain: {memories: {}}, HurtByTimestamp: 0, CanJoinRaid: 1b, Attributes: [{Base: 24.0d, Name: "generic.maxHealth"}, {Base: 0.0d, Name: "generic.knockbackResistance"}, {Base: 0.3499999940395355d, Name: "generic.movementSpeed"}, {Base: 0.0d, Name: "generic.armor"}, {Base: 0.0d, Name: "generic.armorToughness"}, {Base: 32.0d, Modifiers: [{UUIDMost: 8155537058742812996L, UUIDLeast: -8989477423505343755L, Amount: 0.0798937026941346d, Operation: 1, Name: "Random spawn bonus"}], Name: "generic.followRange"}, {Base: 0.0d, Name: "generic.attackKnockback"}, {Base: 5.0d, Name: "generic.attackDamage"}], PatrolLeader: 1b, Invulnerable: 0b, FallFlying: 0b, PortalCooldown: 0, AbsorptionAmount: 0.0f, PatrolTarget: {X: 5000, Y: 70, Z: 0}, FallDistance: 0.0f, DeathTime: 0s, HandDropChances: [0.085f, 0.085f], PersistenceRequired: 0b, Patrolling: 1b, Motion: [0.006517125234045166d, -0.0784000015258789d, -0.01838171977574866d], Health: 24.0f, LeftHanded: 0b, Air: 300s, OnGround: 1b, Rotation: [190.26996f, -29.157398f], HandItems: [{id: "minecraft:crossbow", Count: 1b, tag: {Damage: 0}}, {}], Wave: 0, ArmorDropChances: [0.085f, 0.085f, 0.085f, 2.0f], Fire: -1s, ArmorItems: [{}, {}, {}, {id: "minecraft:white_banner", Count: 1b, tag: {BlockEntityTag: {Patterns: [{Pattern: "mr", Color: 9}, {Pattern: "bs", Color: 8}, {Pattern: "cs", Color: 7}, {Pattern: "bo", Color: 8}, {Pattern: "ms", Color: 15}, {Pattern: "hh", Color: 8}, {Pattern: "mc", Color: 8}, {Pattern: "bo", Color: 15}]}, display: {Name: '{"color":"gold","translate":"block.minecraft.ominous_banner"}'}}}], CanPickUpLoot: 1b, HurtTime: 0s, Inventory: []}
And a nonleader
/summon minecraft:pillager ~ ~1 ~ {Brain: {memories: {}}, HurtByTimestamp: 0, CanJoinRaid: 1b, Attributes: [{Base: 24.0d, Name: "generic.maxHealth"}, {Base: 0.0d, Name: "generic.knockbackResistance"}, {Base: 0.3499999940395355d, Name: "generic.movementSpeed"}, {Base: 0.0d, Name: "generic.armor"}, {Base: 0.0d, Name: "generic.armorToughness"}, {Base: 32.0d, Modifiers: [{UUIDMost: 1091068557595069214L, UUIDLeast: -5600343144297854598L, Amount: 0.032188637513724826d, Operation: 1, Name: "Random spawn bonus"}], Name: "generic.followRange"}, {Base: 0.0d, Name: "generic.attackKnockback"}, {Base: 5.0d, Name: "generic.attackDamage"}], PatrolLeader: 0b, Invulnerable: 0b, FallFlying: 0b, PortalCooldown: 0, AbsorptionAmount: 0.0f, PatrolTarget: {X: 5000, Y: 70, Z: 0}, FallDistance: 0.0f, DeathTime: 0s, HandDropChances: [0.085f, 0.085f], PersistenceRequired: 0b, Patrolling: 1b, Motion: [0.09824108023061612d, -0.0784000015258789d, 0.1033702431011876d], Health: 24.0f, LeftHanded: 0b, Air: 300s, OnGround: 1b, Rotation: [156.74881f, -15.138995f], HandItems: [{id: "minecraft:crossbow", Count: 1b, tag: {ChargedProjectiles: [{id: "minecraft:arrow", Count: 1b}], Charged: 1b, Damage: 0}}, {}], Wave: 0, ArmorDropChances: [0.085f, 0.085f, 0.085f, 0.085f], Fire: -1s, ArmorItems: [{}, {}, {}, {}], CanPickUpLoot: 1b, HurtTime: 0s, Inventory: []}