From 8539d74e420d834ac0bbbd8271c9328eeebbb502 Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Thu, 28 Nov 2024 20:37:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BC=80=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E7=94=BB=E7=8A=B6=E6=80=81=E6=9C=BA=EF=BC=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=B2=92=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/atsuishio/superbwarfare/block/ContainerBlock.java | 8 +++----- .../superbwarfare/block/entity/ContainerBlockEntity.java | 6 +++++- .../assets/superbwarfare/models/block/container.json | 6 ++++++ 3 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 src/main/resources/assets/superbwarfare/models/block/container.json diff --git a/src/main/java/com/atsuishio/superbwarfare/block/ContainerBlock.java b/src/main/java/com/atsuishio/superbwarfare/block/ContainerBlock.java index 79b0d3449..290af542f 100644 --- a/src/main/java/com/atsuishio/superbwarfare/block/ContainerBlock.java +++ b/src/main/java/com/atsuishio/superbwarfare/block/ContainerBlock.java @@ -41,17 +41,15 @@ public class ContainerBlock extends BaseEntityBlock { @Override public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHit) { - if (pLevel.isClientSide) { - return InteractionResult.PASS; - } else { + if (!pLevel.isClientSide) { if (canOpen(pLevel, pPos)) { pLevel.setBlockAndUpdate(pPos, pState.setValue(OPENED, true)); return InteractionResult.SUCCESS; } pPlayer.displayClientMessage(Component.literal("打不开哼哼啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊"), true); - return InteractionResult.PASS; } + return InteractionResult.PASS; } public boolean canOpen(Level pLevel, BlockPos pPos) { @@ -89,7 +87,7 @@ public class ContainerBlock extends BaseEntityBlock { @Override public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { - return state.getValue(OPENED) ? box(1, 0, 1, 15, 14, 15) : box(0, 0, 0, 16, 16, 16); + return state.getValue(OPENED) ? box(1, 0, 1, 15, 14, 15) : box(0, 0, 0, 16, 15, 16); } @Override 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 48ef19a67..fe430accb 100644 --- a/src/main/java/com/atsuishio/superbwarfare/block/entity/ContainerBlockEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/block/entity/ContainerBlockEntity.java @@ -1,5 +1,6 @@ package com.atsuishio.superbwarfare.block.entity; +import com.atsuishio.superbwarfare.block.ContainerBlock; import com.atsuishio.superbwarfare.init.ModBlockEntities; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; @@ -29,7 +30,10 @@ public class ContainerBlockEntity extends BlockEntity implements GeoBlockEntity } private PlayState predicate(AnimationState event) { - return event.setAndContinue(RawAnimation.begin().thenPlay("animation.container.open")); + if (this.getBlockState().getValue(ContainerBlock.OPENED)) { + return event.setAndContinue(RawAnimation.begin().thenPlay("animation.container.open")); + } + return PlayState.STOP; } @Override diff --git a/src/main/resources/assets/superbwarfare/models/block/container.json b/src/main/resources/assets/superbwarfare/models/block/container.json new file mode 100644 index 000000000..152700c97 --- /dev/null +++ b/src/main/resources/assets/superbwarfare/models/block/container.json @@ -0,0 +1,6 @@ +{ + "parent": "superbwarfare:item/container", + "textures": { + "particle": "minecraft:block/orange_terracotta" + } +} \ No newline at end of file