Skip to content

Commit

Permalink
Fix collections.attributes incorrectly using reference equality on re…
Browse files Browse the repository at this point in the history
…cord keys

Relates to #587
  • Loading branch information
2No2Name committed Nov 26, 2024
1 parent 9418c8c commit 463a55d
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<Holder<Attribute>, AttributeInstance> attributes;
private Set<AttributeInstance> attributesToUpdate;

@Mutable
@Shadow
@Final
private Set<AttributeInstance> attributesToUpdate;
private Set<AttributeInstance> attributesToSync;

@Inject(
method = "<init>",
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);
}
}

0 comments on commit 463a55d

Please sign in to comment.