From c8f8402ae616f666647deee39fcfa11c85ad61b4 Mon Sep 17 00:00:00 2001 From: 2No2Name <2no2name@web.de> Date: Tue, 26 Nov 2024 01:32:17 +0100 Subject: [PATCH] Fix collections.attributes incorrectly using reference equality on record keys Relates to https://github.com/CaffeineMC/lithium-fabric/issues/587 --- .../collections/attributes/AttributeMapMixin.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/common/src/main/java/net/caffeinemc/mods/lithium/mixin/collections/attributes/AttributeMapMixin.java b/common/src/main/java/net/caffeinemc/mods/lithium/mixin/collections/attributes/AttributeMapMixin.java index 427149df3..be39dd168 100644 --- a/common/src/main/java/net/caffeinemc/mods/lithium/mixin/collections/attributes/AttributeMapMixin.java +++ b/common/src/main/java/net/caffeinemc/mods/lithium/mixin/collections/attributes/AttributeMapMixin.java @@ -1,9 +1,6 @@ package net.caffeinemc.mods.lithium.mixin.collections.attributes; -import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap; import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; -import net.minecraft.core.Holder; -import net.minecraft.world.entity.ai.attributes.Attribute; import net.minecraft.world.entity.ai.attributes.AttributeInstance; import net.minecraft.world.entity.ai.attributes.AttributeMap; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; @@ -15,27 +12,27 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.Map; import java.util.Set; @Mixin(AttributeMap.class) public class AttributeMapMixin { + @Mutable @Shadow @Final - private Map, AttributeInstance> attributes; + private Set attributesToUpdate; @Mutable @Shadow @Final - private Set attributesToUpdate; + private Set attributesToSync; @Inject( method = "", at = @At("RETURN") ) private void initCollections(AttributeSupplier defaultAttributes, CallbackInfo ci) { - this.attributes = new Reference2ReferenceOpenHashMap<>(0); this.attributesToUpdate = new ReferenceOpenHashSet<>(0); + this.attributesToSync = new ReferenceOpenHashSet<>(0); } }