From b52f8f6745775f25a42ef8706ab70f2d9b9fb6a9 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Tue, 15 Oct 2024 13:45:41 +0800 Subject: [PATCH] feat(BlockStateSafeGetter): use block type's default state --- .../org/allaymc/api/block/type/BlockStateSafeGetter.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/org/allaymc/api/block/type/BlockStateSafeGetter.java b/api/src/main/java/org/allaymc/api/block/type/BlockStateSafeGetter.java index 876f67899..23de1a073 100644 --- a/api/src/main/java/org/allaymc/api/block/type/BlockStateSafeGetter.java +++ b/api/src/main/java/org/allaymc/api/block/type/BlockStateSafeGetter.java @@ -93,9 +93,11 @@ public BlockState blockState() { // Add missing properties var updatedStates = updatedNbt.getCompound("states"); var updatedStatesBuilder = updatedStates.toBuilder(); - for (var entry : blockType.getProperties().entrySet()) { - if (updatedStatesBuilder.containsKey(entry.getKey())) continue; - updatedStatesBuilder.put(entry.getKey(), entry.getValue().createDefaultValue().getSerializedValue()); + for (var entry : blockType.getDefaultState().getPropertyValues().entrySet()) { + if (updatedStatesBuilder.containsKey(entry.getKey().getName())) { + continue; + } + updatedStatesBuilder.put(entry.getKey().getName(), entry.getValue().getSerializedValue()); } updatedStates = updatedStatesBuilder.build();