Merge remote-tracking branch 'origin/1.21.1' into 26.1

This commit is contained in:
embeddedt 2026-04-11 14:07:18 -04:00
commit 18734563d6
No known key found for this signature in database
GPG Key ID: A69433EC199B5613

View File

@ -5,6 +5,7 @@ import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import org.embeddedt.modernfix.entity.AttributeInstanceTemplates;
import org.embeddedt.modernfix.neoforge.init.ModernFixForge;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -26,6 +27,11 @@ public class AttributeSupplierBuilderMixin {
*/
@Inject(method = "build", at = @At(value = "NEW", target = "(Ljava/util/Map;)Lnet/minecraft/world/entity/ai/attributes/AttributeSupplier;"))
private void deduplicateInstances(CallbackInfoReturnable<AttributeSupplier> cir) {
// The interning has overhead, so we only apply it early during the launch, when mods are normally
// registering the custom attribute suppliers.
if (ModernFixForge.registryEventsFired) {
return;
}
this.builder.replaceAll((a, i) -> AttributeInstanceTemplates.intern(i));
}
}