net.minecraft.block.Fertilizable Java Examples
The following examples show how to use
net.minecraft.block.Fertilizable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BonemealAuraHack.java From Wurst7 with GNU General Public License v3.0 | 6 votes |
private boolean isCorrectBlock(BlockPos pos) { Block block = BlockUtils.getBlock(pos); if(!(block instanceof Fertilizable) || block instanceof GrassBlock || !((Fertilizable)block).canGrow(MC.world, MC.world.random, pos, BlockUtils.getState(pos))) return false; if(block instanceof SaplingBlock) return saplings.isChecked(); else if(block instanceof CropBlock) return crops.isChecked(); else if(block instanceof StemBlock) return stems.isChecked(); else if(block instanceof CocoaBlock) return cocoa.isChecked(); else return other.isChecked(); }
Example #2
Source File: DeceasedGrassBlock.java From the-hallow with MIT License | 5 votes |
@Override public void grow(ServerWorld world, Random random, BlockPos blockPos, BlockState blockState) { BlockPos upPos = blockPos.up(); BlockState grassBlock = HallowedBlocks.DECEASED_GRASS_BLOCK.getDefaultState(); label48: for (int i = 0; i < 128; ++i) { BlockPos randomPos = upPos; for (int j = 0; j < i / 16; ++j) { randomPos = randomPos.add(random.nextInt(3) - 1, (random.nextInt(3) - 1) * random.nextInt(3) / 2, random.nextInt(3) - 1); if (world.getBlockState(randomPos.down()).getBlock() != this || world.getBlockState(randomPos).isFullCube(world, randomPos)) { continue label48; } } BlockState randomBlockState = world.getBlockState(randomPos); if (randomBlockState.getBlock() == grassBlock.getBlock() && random.nextInt(10) == 0) { ((Fertilizable) grassBlock.getBlock()).grow(world, random, randomPos, randomBlockState); } if (randomBlockState.isAir()) { BlockState stateToPlace; if (random.nextInt(8) == 0) { List<ConfiguredFeature<?, ?>> list = world.getBiomeAccess().getBiome(randomPos).getFlowerFeatures(); if (list.isEmpty()) { continue; } stateToPlace = ((FlowerFeature) ((DecoratedFeatureConfig) (list.get(0)).config).feature.feature).getFlowerToPlace(random, randomPos, list.get(0).config); } else { stateToPlace = grassBlock; } if (stateToPlace.canPlaceAt(world, randomPos)) { world.setBlockState(randomPos, stateToPlace, 3); } } } }