From 4ccb3112ed233f7f821038b566b92eb66767a8af Mon Sep 17 00:00:00 2001 From: Light_Quanta Date: Fri, 16 May 2025 03:14:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=9B=86=E8=A3=85=E7=AE=B1?= =?UTF-8?q?=E9=83=A8=E7=BD=B2=E5=B7=B2=E6=9C=89=E5=AE=9E=E4=BD=93=E6=97=B6?= =?UTF-8?q?=E4=B8=A2=E5=A4=B1=E6=95=B0=E6=8D=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../block/entity/ContainerBlockEntity.java | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/block/entity/ContainerBlockEntity.java b/src/main/java/com/atsuishio/superbwarfare/block/entity/ContainerBlockEntity.java index 4a5e0c07c..621c81294 100644 --- a/src/main/java/com/atsuishio/superbwarfare/block/entity/ContainerBlockEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/block/entity/ContainerBlockEntity.java @@ -56,22 +56,17 @@ public class ContainerBlockEntity extends BlockEntity implements GeoBlockEntity } else { var direction = pState.getValue(ContainerBlock.FACING); + var entity = blockEntity.entityType.create(pLevel); + if (entity == null) return; + if (blockEntity.entityTag != null) { - var entity = blockEntity.entityType.create(pLevel); - if (entity != null) { - entity.setPos(pPos.getX() + 0.5 + (2 * Math.random() - 1) * 0.1f, pPos.getY() + 0.5 + (2 * Math.random() - 1) * 0.1f, pPos.getZ() + 0.5 + (2 * Math.random() - 1) * 0.1f); - entity.setYRot(direction.toYRot()); - pLevel.addFreshEntity(entity); - } - } else if (blockEntity.entityType != null) { - var entity = blockEntity.entityType.create(pLevel); - if (entity != null) { - entity.setPos(pPos.getX() + 0.5 + (2 * Math.random() - 1) * 0.1f, pPos.getY() + 0.5 + (2 * Math.random() - 1) * 0.1f, pPos.getZ() + 0.5 + (2 * Math.random() - 1) * 0.1f); - entity.setYRot(direction.toYRot()); - pLevel.addFreshEntity(entity); - } + entity.load(blockEntity.entityTag); } + entity.setPos(pPos.getX() + 0.5 + (2 * Math.random() - 1) * 0.1f, pPos.getY() + 0.5 + (2 * Math.random() - 1) * 0.1f, pPos.getZ() + 0.5 + (2 * Math.random() - 1) * 0.1f); + entity.setYRot(direction.toYRot()); + pLevel.addFreshEntity(entity); + pLevel.setBlockAndUpdate(pPos, Blocks.AIR.defaultBlockState()); } }