From c59c50752471fbf5a8a7470b59ad7979f2747374 Mon Sep 17 00:00:00 2001 From: IzzelAliz Date: Wed, 1 Dec 2021 17:24:53 +0800 Subject: [PATCH] Fix duplicate entry for loot tables (#389) --- .../storage/loot/LootTableManagerMixin.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/storage/loot/LootTableManagerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/storage/loot/LootTableManagerMixin.java index a86bb4d2..525d6191 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/storage/loot/LootTableManagerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/level/storage/loot/LootTableManagerMixin.java @@ -2,18 +2,19 @@ package io.izzel.arclight.common.mixin.core.world.level.storage.loot; import com.google.common.collect.ImmutableMap; import com.google.gson.JsonObject; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.util.profiling.ProfilerFiller; +import net.minecraft.world.level.storage.loot.LootTable; +import net.minecraft.world.level.storage.loot.LootTables; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import java.util.HashMap; import java.util.Map; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.packs.resources.ResourceManager; -import net.minecraft.util.profiling.ProfilerFiller; -import net.minecraft.world.level.storage.loot.LootTable; -import net.minecraft.world.level.storage.loot.LootTables; @Mixin(LootTables.class) public class LootTableManagerMixin { @@ -24,10 +25,10 @@ public class LootTableManagerMixin { public Map lootTableToKey = ImmutableMap.of(); - @Inject(method = "apply", at = @At("RETURN")) + @Inject(method = "apply(Ljava/util/Map;Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/util/profiling/ProfilerFiller;)V", at = @At("RETURN")) private void arclight$buildRev(Map objectIn, ResourceManager resourceManagerIn, ProfilerFiller profilerIn, CallbackInfo ci) { - ImmutableMap.Builder lootTableToKeyBuilder = ImmutableMap.builder(); + Map lootTableToKeyBuilder = new HashMap<>(); this.tables.forEach((lootTable, key) -> lootTableToKeyBuilder.put(key, lootTable)); - this.lootTableToKey = lootTableToKeyBuilder.build(); + this.lootTableToKey = ImmutableMap.copyOf(lootTableToKeyBuilder); } }