Java Code Examples for net.minecraft.block.Blocks#FARMLAND
The following examples show how to use
net.minecraft.block.Blocks#FARMLAND .
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: FarmerVillagerTask_wartFarmMixin.java From carpet-extra with GNU Lesser General Public License v3.0 | 5 votes |
@Redirect(method = "keepRunning", at = @At( value = "INVOKE", target = "Lnet/minecraft/block/BlockState;getBlock()Lnet/minecraft/block/Block;", ordinal = 1 )) private Block getFarmlangBLock(BlockState blockState) { Block block = blockState.getBlock(); if (isFarmingCleric && block == Blocks.SOUL_SAND) { return Blocks.FARMLAND; } return block; }
Example 2
Source File: IForgeBlock.java From patchwork-api with GNU Lesser General Public License v2.1 | 5 votes |
/** * Determines if this block can support the passed in plant, allowing it to be planted and grow. * Some examples: * Reeds check if its a reed, or if its sand/dirt/grass and adjacent to water * Cacti checks if its a cacti, or if its sand * Nether types check for soul sand * Crops check for tilled soil * Caves check if it's a solid surface * Plains check if its grass or dirt * Water check if its still water * * @param state The Current state * @param world The current world * @param facing The direction relative to the given position the plant wants to be, typically its UP * @param plantable The plant that wants to check * @return True to allow the plant to be planted/stay. */ default boolean canSustainPlant(BlockState state, BlockView world, BlockPos pos, Direction facing, IPlantable plantable) { BlockState plant = plantable.getPlant(world, pos.offset(facing)); if (plant.getBlock() == Blocks.CACTUS) { return this.getBlock() == Blocks.CACTUS || this.getBlock() == Blocks.SAND || this.getBlock() == Blocks.RED_SAND; } if (plant.getBlock() == Blocks.SUGAR_CANE && this.getBlock() == Blocks.SUGAR_CANE) { return true; } if (plantable instanceof PlantBlock && ((PlantBlockAccessor) plantable).invokeCanPlantOnTop(state, world, pos)) { return true; } switch (plantable.getPlantType(world, pos)) { case Desert: return this.getBlock() == Blocks.SAND || this.getBlock() == Blocks.TERRACOTTA || this.getBlock() instanceof GlazedTerracottaBlock; case Nether: return this.getBlock() == Blocks.SOUL_SAND; case Crop: return this.getBlock() == Blocks.FARMLAND; case Cave: return Block.isSideSolidFullSquare(state, world, pos, Direction.UP); case Plains: return this.getBlock() == Blocks.GRASS_BLOCK || Block.isNaturalDirt(this.getBlock()) || this.getBlock() == Blocks.FARMLAND; case Water: return state.getMaterial() == Material.WATER; case Beach: boolean isBeach = this.getBlock() == Blocks.GRASS_BLOCK || Block.isNaturalDirt(this.getBlock()) || this.getBlock() == Blocks.SAND; boolean hasWater = (world.getBlockState(pos.east()).getMaterial() == Material.WATER || world.getBlockState(pos.west()).getMaterial() == Material.WATER || world.getBlockState(pos.north()).getMaterial() == Material.WATER || world.getBlockState(pos.south()).getMaterial() == Material.WATER); return isBeach && hasWater; } return false; }
Example 3
Source File: CarpetDispenserBehaviours.java From carpet-extra with GNU Lesser General Public License v3.0 | 4 votes |
private boolean isFarmland(BlockState state) { return state.getBlock() == Blocks.FARMLAND; }
Example 4
Source File: MixinCropBlock.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
@Redirect(method = "getAvailableMoisture", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;getBlock()Lnet/minecraft/block/Block;", ordinal = 0)) private static Block redirectFarmlandCheck(BlockState blockState) { final IForgeBlockState forgeBlockState = (IForgeBlockState) blockState; return forgeBlockState.canSustainPlant(currentWorld.get(), currentBlockPos.get(), Direction.UP, (IPlantable) currentBlock.get()) ? Blocks.FARMLAND : Blocks.STONE; }
Example 5
Source File: IForgeBlock.java From patchwork-api with GNU Lesser General Public License v2.1 | 3 votes |
/** * Checks if this soil is fertile, typically this means that growth rates * of plants on this soil will be slightly sped up. * Only vanilla case is tilledField when it is within range of water. * * @param state The current state * @param world The current world * @param pos Block position in world * @return True if the soil should be considered fertile. */ default boolean isFertile(BlockState state, BlockView world, BlockPos pos) { if (this.getBlock() == Blocks.FARMLAND) { return state.get(FarmlandBlock.MOISTURE) > 0; } return false; }