diff --git a/src/main/java/com/atsuishio/superbwarfare/block/ContainerBlock.java b/src/main/java/com/atsuishio/superbwarfare/block/ContainerBlock.java index 7d7c19de6..5fc2e8096 100644 --- a/src/main/java/com/atsuishio/superbwarfare/block/ContainerBlock.java +++ b/src/main/java/com/atsuishio/superbwarfare/block/ContainerBlock.java @@ -142,7 +142,8 @@ public class ContainerBlock extends BaseEntityBlock { var entityType = EntityType.byString(tag.getString("EntityType")).orElse(null); if (entityType != null) { - int w = 0, h = 0; + float w = 0; + int h = 0; Level level = null; try { @@ -150,21 +151,21 @@ public class ContainerBlock extends BaseEntityBlock { } catch (Exception ignored) { } - if (level != null && tag.contains("Entity")) { + if (level instanceof Level && tag.contains("Entity")) { var entity = entityType.create(level); if (entity != null) { entity.load(tag.getCompound("Entity")); - w = (int) (entity.getType().getDimensions().width() + 1); - if (w % 2 == 0) w++; + w = (float) Math.ceil(entity.getType().getDimensions().width() / 2); h = (int) (entity.getType().getDimensions().height() + 1); } } else { - w = (int) (entityType.getDimensions().width() + 1); - if (w % 2 == 0) w++; + w = (float) Math.ceil(entityType.getDimensions().width() / 2); h = (int) (entityType.getDimensions().height() + 1); } if (w != 0 && h != 0) { - tooltipComponents.add(Component.literal(w + " x " + w + " x " + h).withStyle(ChatFormatting.YELLOW)); + w *= 2; + if ((int) w % 2 == 0) w++; + tooltipComponents.add(Component.literal((int) w + " x " + (int) w + " x " + h).withStyle(ChatFormatting.YELLOW)); } } } diff --git a/src/main/java/com/atsuishio/superbwarfare/compat/jade/providers/ContainerEntityProvider.java b/src/main/java/com/atsuishio/superbwarfare/compat/jade/providers/ContainerEntityProvider.java index ff460c695..2a57c63d9 100644 --- a/src/main/java/com/atsuishio/superbwarfare/compat/jade/providers/ContainerEntityProvider.java +++ b/src/main/java/com/atsuishio/superbwarfare/compat/jade/providers/ContainerEntityProvider.java @@ -28,11 +28,11 @@ public enum ContainerEntityProvider implements IBlockComponentProvider { // 所需尺寸显示 var entityType = EntityType.byString(registerName).orElse(null); if (entityType != null) { - int w = (int) (entityType.getDimensions().width() + 1); - if (w % 2 == 0) w++; + float w = (float) Math.ceil(entityType.getDimensions().width() / 2) * 2; + if ((int) w % 2 == 0) w++; int h = (int) (entityType.getDimensions().height() + 1); if (h != 0) { - iTooltip.add(Component.literal(w + " x " + w + " x " + h).withStyle(ChatFormatting.YELLOW)); + iTooltip.add(Component.literal((int) w + " x " + (int) w + " x " + h).withStyle(ChatFormatting.YELLOW)); } } @@ -46,6 +46,5 @@ public enum ContainerEntityProvider implements IBlockComponentProvider { public ResourceLocation getUid() { return ID; } - }