Advertisement
Scouter456

Untitled

Aug 2nd, 2023
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.54 KB | None | 0 0
  1. public class BounceShroomBlock extends BaseEntityBlock {
  2.  
  3.     protected static final VoxelShape SHAPE = Shapes.join(Block.box(5, 0, 5, 11, 3, 11), Block.box(1, 2.5, 1, 15, 9.5, 15), BooleanOp.OR);
  4.     protected BounceShroomBlock(Properties pProperties) {
  5.         super(pProperties);
  6.     }
  7.  
  8.  
  9.     @Nullable
  10.     @Override
  11.     public BlockEntity newBlockEntity(BlockPos pPos, BlockState pState) {
  12.         return EQBlockEntities.BOUNCE_SHROOM.get().create(pPos, pState);
  13.     }
  14.  
  15.     @Override
  16.     public RenderShape getRenderShape(BlockState pState) {
  17.         return RenderShape.ENTITYBLOCK_ANIMATED;
  18.     }
  19.  
  20.     @Override
  21.     public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) {
  22.         return SHAPE;
  23.     }
  24.  
  25.     @Override
  26.     public void stepOn(Level pLevel, BlockPos pPos, BlockState pState, Entity pEntity) {
  27.         BounceShroomBlockEntity blockEntity = (BounceShroomBlockEntity) pLevel.getBlockEntity(pPos);
  28.         pEntity.resetFallDistance();
  29.         if(!pEntity.isShiftKeyDown()) {
  30.             blockEntity.setBounce(true);
  31.             TaskScheduler.schedule(() -> pEntity.setDeltaMovement(new Vec3(0, 1, 0)),4);
  32.         }
  33.         super.stepOn(pLevel, pPos, pState, pEntity);
  34.     }
  35.  
  36.     @Nullable
  37.     @Override
  38.     public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level pLevel, BlockState pState, BlockEntityType<T> pBlockEntityType) {
  39.         return createTickerHelper(pBlockEntityType, EQBlockEntities.BOUNCE_SHROOM.get(), BounceShroomBlockEntity::tick);
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement