添加开启动画状态机,修改粒子
This commit is contained in:
parent
858d6c3e88
commit
8539d74e42
3 changed files with 14 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "superbwarfare:item/container",
|
||||
"textures": {
|
||||
"particle": "minecraft:block/orange_terracotta"
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue