添加开启动画状态机,修改粒子

This commit is contained in:
17146 2024-11-28 20:37:43 +08:00
parent 858d6c3e88
commit 8539d74e42
3 changed files with 14 additions and 6 deletions

View file

@ -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

View file

@ -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,8 +30,11 @@ public class ContainerBlockEntity extends BlockEntity implements GeoBlockEntity
}
private PlayState predicate(AnimationState<ContainerBlockEntity> event) {
if (this.getBlockState().getValue(ContainerBlock.OPENED)) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.container.open"));
}
return PlayState.STOP;
}
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {

View file

@ -0,0 +1,6 @@
{
"parent": "superbwarfare:item/container",
"textures": {
"particle": "minecraft:block/orange_terracotta"
}
}