From 2bdae381a9ce0b885b94945f502bf2b7edbd4ce4 Mon Sep 17 00:00:00 2001 From: Fff Date: Thu, 12 Nov 2026 11:27:18 -0800 Subject: [PATCH] =?UTF-8?q?fix(blueprint):=20=E5=85=BC=E5=AE=B9=E8=B7=A8?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E9=92=A2=E7=AD=8B=E6=B7=B7=E5=87=9D=E5=9C=9F?= =?UTF-8?q?=E6=96=B9=E5=9D=97=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 导入时识别新版十六种颜色钢筋混凝土及台阶、楼梯、墙的名称 - 保留方块属性与原始蓝图数据,并继续拒绝未知方块 --- .../building/StructureSnapshotCodec.java | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/main/java/dev/dubhe/anvilcraft/building/StructureSnapshotCodec.java b/src/main/java/dev/dubhe/anvilcraft/building/StructureSnapshotCodec.java index 8c263c73fc..aa85d368eb 100644 --- a/src/main/java/dev/dubhe/anvilcraft/building/StructureSnapshotCodec.java +++ b/src/main/java/dev/dubhe/anvilcraft/building/StructureSnapshotCodec.java @@ -1,5 +1,7 @@ package dev.dubhe.anvilcraft.building; +import dev.dubhe.anvilcraft.AnvilCraft; +import dev.dubhe.anvilcraft.block.state.Color; import net.minecraft.SharedConstants; import net.minecraft.core.BlockPos; import net.minecraft.core.HolderGetter; @@ -133,6 +135,7 @@ private static List parsePaletteStates(ListTag paletteTag, HolderLoo throws ConstructionBlueprintException { HolderGetter lookup = registries.lookupOrThrow(Registries.BLOCK); Set unknownIds = new LinkedHashSet<>(); + List states = new ArrayList<>(paletteTag.size()); for (int index = 0; index < paletteTag.size(); index++) { CompoundTag stateTag = paletteTag.getCompound(index); String rawName = stateTag.getString("Name"); @@ -140,7 +143,13 @@ private static List parsePaletteStates(ListTag paletteTag, HolderLoo if (id == null) { throw new ConstructionBlueprintException("corrupt_palette", "invalid block id: " + rawName); } - if (lookup.get(ResourceKey.create(Registries.BLOCK, id)).isEmpty()) { + ResourceLocation normalizedId = normalizeConcreteId(id); + if (!normalizedId.equals(id)) { + stateTag = stateTag.copy(); + stateTag.putString("Name", normalizedId.toString()); + } + states.add(stateTag); + if (lookup.get(ResourceKey.create(Registries.BLOCK, normalizedId)).isEmpty()) { unknownIds.add(id.toString()); } } @@ -149,11 +158,28 @@ private static List parsePaletteStates(ListTag paletteTag, HolderLoo } List palette = new ArrayList<>(paletteTag.size()); for (int index = 0; index < paletteTag.size(); index++) { - palette.add(NbtUtils.readBlockState(lookup, paletteTag.getCompound(index))); + palette.add(NbtUtils.readBlockState(lookup, states.get(index))); } return palette; } + private static ResourceLocation normalizeConcreteId(ResourceLocation id) { + if (!id.getNamespace().equals(AnvilCraft.MOD_ID)) { + return id; + } + for (Color color : Color.values()) { + String prefix = color + "_reinforced_concrete"; + if (!id.getPath().startsWith(prefix)) { + continue; + } + String suffix = id.getPath().substring(prefix.length()); + if (List.of("", "_slab", "_stair", "_wall").contains(suffix)) { + return AnvilCraft.of("reinforced_concrete_" + color + suffix); + } + } + return id; + } + private static List parseBlocks( CompoundTag tag, Vec3i size,