From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> Date: Sun, 14 Jan 2024 22:58:43 +0300 Subject: [PATCH] Suppress errors from dirty attributes diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java index 04b98e23eed926d8473cc2464e04a5b9f18f1140..68463f809aea61d818fc428f1c8b80682b05538b 100644 --- a/src/main/java/net/minecraft/server/level/ServerEntity.java +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java @@ -386,7 +386,10 @@ public class ServerEntity { } if (this.entity instanceof LivingEntity) { - Set set = ((LivingEntity) this.entity).getAttributes().getDirtyAttributes(); + // DivineMC start - Suppress errors from dirty attributes + Set attributes = ((LivingEntity) this.entity).getAttributes().getDirtyAttributes(); + final Set set = this.level.divinemcConfig.suppressErrorsFromDirtyAttributes ? Collections.synchronizedSet(attributes) : attributes; + // DivineMC end if (!set.isEmpty()) { // CraftBukkit start - Send scaled max health @@ -397,7 +400,7 @@ public class ServerEntity { this.broadcastAndSend(new ClientboundUpdateAttributesPacket(this.entity.getId(), set)); } - set.clear(); + attributes.clear(); // DivineMC } } diff --git a/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java b/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java index 02dfe1750f9955a4b1b945e90491bdee13fe2ef5..c4b41a6a3fd2c3d7ff942fe8754a7333afb2c8ed 100644 --- a/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java +++ b/src/main/java/space/bxteam/divinemc/configuration/DivineWorldConfig.java @@ -115,4 +115,9 @@ public class DivineWorldConfig { } linearCrashOnBrokenSymlink = getBoolean("region-format.linear.crash-on-broken-symlink", linearCrashOnBrokenSymlink); } + + public boolean suppressErrorsFromDirtyAttributes = true; + private void suppressErrorsFromDirtyAttributes() { + suppressErrorsFromDirtyAttributes = getBoolean("suppress-errors-from-dirty-attributes", suppressErrorsFromDirtyAttributes); + } }