Create Temporally Blocks

Using the example, the Spectral Block (Cast by spells):

  1. You will need a Block that extends BlockWithEntity (Or anyone related)

public class SpectralBlock extends BlockWithEntity {
    public SpectralBlock() {
        super(
        //ITEM SETTINGS HERE
        );
    }

}
  1. Now just createBlockEntity create a BlockEntityTimer and set the max time

public class SpectralBlock extends BlockWithEntity {
    public SpectralBlock() {
        super(
        //ITEM SETTINGS HERE
        );
    }

    @Nullable
    @Override
    public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
        BlockEntityTimer blockEntityTimer = new BlockEntityTimer(pos, state);
        blockEntityTimer.setMaxTime(1200);

        return blockEntityTimer;
    }
}
  1. Now just put your own functions and features to your fantastic block ^^

Last updated