Advertisement
SirPuli

Untitled

Jun 1st, 2020
1,299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.60 KB | None | 0 0
  1. @Override
  2.     public void randomTick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random){
  3.  
  4.  
  5.         if (TreeUtils.doDecay(worldIn, pos, this, 7)){
  6.             spawnDrops(state, worldIn, pos);
  7.             worldIn.removeBlock(pos, false);
  8.         }
  9.     }
  10.  
  11. public static boolean doDecay(ServerWorld worldIn, BlockPos pos, Block block, int distance){
  12.         BlockState[] blockStates = new BlockState[] {
  13.                 worldIn.getBlockState(pos.down().north()),
  14.                 worldIn.getBlockState(pos.down().east()),
  15.                 worldIn.getBlockState(pos.down().south()),
  16.                 worldIn.getBlockState(pos.down().west()),
  17.                 worldIn.getBlockState(pos.up().north()),
  18.                 worldIn.getBlockState(pos.up().east()),
  19.                 worldIn.getBlockState(pos.up().south()),
  20.                 worldIn.getBlockState(pos.up().west()),
  21.  
  22.                 worldIn.getBlockState(pos.down().north().east()),
  23.                 worldIn.getBlockState(pos.down().north().west()),
  24.                 worldIn.getBlockState(pos.down().south().east()),
  25.                 worldIn.getBlockState(pos.down().south().west()),
  26.                 worldIn.getBlockState(pos.up().north().east()),
  27.                 worldIn.getBlockState(pos.up().north().west()),
  28.                 worldIn.getBlockState(pos.up().south().east()),
  29.                 worldIn.getBlockState(pos.up().south().west()),
  30.  
  31.                 worldIn.getBlockState(pos.north().east()),
  32.                 worldIn.getBlockState(pos.north().west()),
  33.                 worldIn.getBlockState(pos.south().east()),
  34.                 worldIn.getBlockState(pos.south().west())
  35.         };
  36.         for (BlockState blockState : blockStates){
  37.             if (blockState.getBlock() == block && !blockState.get(BlockStateProperties.PERSISTENT) && blockState.get(BlockStateProperties.DISTANCE_1_7) == distance - 1)
  38.                 return true;
  39.         }
  40.         return false;
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement