From 4ae8167c462408fb2fcf3279a83b931a58c97435 Mon Sep 17 00:00:00 2001 From: Integer Limit <103940576+IntegerLimit@users.noreply.github.com> Date: Tue, 9 Jul 2024 15:49:35 +1000 Subject: [PATCH] Fix Corruption of remapping of CT Blocks --- .../remap/datafixer/storage/BlockStateLike.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/nomiceu/nomilabs/remap/datafixer/storage/BlockStateLike.java b/src/main/java/com/nomiceu/nomilabs/remap/datafixer/storage/BlockStateLike.java index 462f1df7..7a86eecf 100644 --- a/src/main/java/com/nomiceu/nomilabs/remap/datafixer/storage/BlockStateLike.java +++ b/src/main/java/com/nomiceu/nomilabs/remap/datafixer/storage/BlockStateLike.java @@ -3,6 +3,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; +import com.nomiceu.nomilabs.NomiLabs; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; @@ -65,7 +66,14 @@ public int getOldId() { } public int getId() { - return rl == null ? -1 : DataFixerHandler.getBlockToIdMap().getOrDefault(rl, 0); + // Return oldId as a fallback, so that if the rl is not registered, we can still let remappers remap it + if (rl == null || !DataFixerHandler.getBlockToIdMap().containsKey(rl)) { + NomiLabs.LOGGER.debug("[Data Fixer] Block at Pos {} has Resource Location {}, which is not registered.", rl, pos); + NomiLabs.LOGGER.debug("[Data Fixer] Most likely, this indicates removed blocks. If the Resource Location is null, report this to Nomi-CEu/Nomi-Labs Devs."); + return oldId; + } + // Still use getOrDefault, just in case + return DataFixerHandler.getBlockToIdMap().getOrDefault(rl, oldId); } public BlockStateLike copy() {