From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Martijn Muijsers Date: Wed, 30 Nov 2022 20:54:31 +0100 Subject: [PATCH] Replace AI attributes with optimized collections License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) Gale - https://galemc.org This patch is based on the following mixin: "me/jellysquid/mods/lithium/mixin/collections/attributes/AttributeContainerMixin.java" By: 2No2Name <2No2Name@web.de> As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric) Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java index d1602af2d6e5d4dd8d8b44ab66bca39c60195093..c6f4e9e465e24a37b773b348feb24feb0ac3adf7 100644 --- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java +++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java @@ -1,8 +1,6 @@ package net.minecraft.world.entity.ai.attributes; -import com.google.common.collect.Maps; import com.google.common.collect.Multimap; -import com.google.common.collect.Sets; import com.mojang.logging.LogUtils; import java.util.Collection; import java.util.Map; @@ -10,6 +8,9 @@ import java.util.Set; import java.util.UUID; import java.util.stream.Collectors; import javax.annotation.Nullable; + +import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap; +import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; import net.minecraft.Util; import net.minecraft.core.Holder; import net.minecraft.core.registries.BuiltInRegistries; @@ -20,8 +21,10 @@ import org.slf4j.Logger; public class AttributeMap { private static final Logger LOGGER = LogUtils.getLogger(); - private final Map attributes = Maps.newHashMap(); - private final Set dirtyAttributes = Sets.newHashSet(); + // Gale start - Lithium - replace AI attributes with optimized collections + private final Map attributes = new Reference2ReferenceOpenHashMap<>(0); + private final Set dirtyAttributes = new ReferenceOpenHashSet<>(0); + // Gale end - Lithium - replace AI attributes with optimized collections private final AttributeSupplier supplier; private final java.util.function.Function createInstance; // Gale - Airplane - reduce entity allocations