Java Code Examples for net.minecraftforge.common.IPlantable#getPlant()
The following examples show how to use
net.minecraftforge.common.IPlantable#getPlant() .
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: BlockFarmland.java From TFC2 with GNU General Public License v3.0 | 6 votes |
@Override public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable) { IBlockState plant = plantable.getPlant(world, pos.offset(direction)); net.minecraftforge.common.EnumPlantType plantType = plantable.getPlantType(world, pos.offset(direction)); if(plantType == EnumPlantType.Crop) return true; if(plantType == EnumPlantType.Plains) return true; if(plantable == TFCBlocks.Sapling) return true; return false; }
Example 2
Source File: BlockVegetation.java From TFC2 with GNU General Public License v3.0 | 6 votes |
@Override public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable) { IBlockState plant = plantable.getPlant(world, pos.offset(direction)); EnumPlantType plantType = plantable.getPlantType(world, pos.offset(direction)); VegType veg = (VegType)state.getValue(META_PROPERTY); if(plant.getBlock() == this) { if(veg == VegType.DoubleGrassBottom && plant.getValue(META_PROPERTY) == VegType.DoubleGrassTop) return true; if(veg == VegType.DoubleGrassBottomLush && plant.getValue(META_PROPERTY) == VegType.DoubleGrassTopLush) return true; } return false; }
Example 3
Source File: BlockGrass.java From TFC2 with GNU General Public License v3.0 | 6 votes |
@Override public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable) { IBlockState plant = plantable.getPlant(world, pos.offset(direction)); net.minecraftforge.common.EnumPlantType plantType = plantable.getPlantType(world, pos.offset(direction)); if(plant.getBlock() == Blocks.SAPLING) return false;//This may break some cross mod compatability but for now its needed to prevent vanilla and some pam trees from generating if(plantType == EnumPlantType.Plains) return true; if(plant.getBlock() == TFCBlocks.VegDesert) return true; return false; }
Example 4
Source File: PlantItem.java From GardenCollection with MIT License | 6 votes |
public static PlantItem getForItem (IBlockAccess blockAccess, ItemStack itemStack) { if (itemStack == null || itemStack.getItem() == null) return null; IPlantable plantable = PlantRegistry.getPlantable(itemStack); if (plantable == null) return getForItem(itemStack); Block block = plantable.getPlant(blockAccess, 0, -1, 0); if (block == null) return getForItem(itemStack); int meta = plantable.getPlantMetadata(blockAccess, 0, -1, 0); if (meta == 0) meta = itemStack.getItemDamage(); return new PlantItem(itemStack, block, meta); }
Example 5
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 6
Source File: BlockStone.java From TFC2 with GNU General Public License v3.0 | 5 votes |
@Override public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable) { IBlockState plant = plantable.getPlant(world, pos.offset(direction)); EnumPlantType plantType = plantable.getPlantType(world, pos.offset(direction)); if(plantable == TFCBlocks.Vegetation && (VegType)plant.getValue(BlockVegetation.META_PROPERTY) == VegType.Grass) return true; return false; }
Example 7
Source File: BlockDirt.java From TFC2 with GNU General Public License v3.0 | 5 votes |
/******************************************************************************* * 1. Content *******************************************************************************/ @Override public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable) { IBlockState plant = plantable.getPlant(world, pos.offset(direction)); net.minecraftforge.common.EnumPlantType plantType = plantable.getPlantType(world, pos.offset(direction)); if(plantType == EnumPlantType.Plains) return true; return false; }
Example 8
Source File: BlockCactus.java From TFC2 with GNU General Public License v3.0 | 5 votes |
@Override public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable) { IBlockState plant = plantable.getPlant(world, pos.offset(direction)); EnumPlantType plantType = plantable.getPlantType(world, pos.offset(direction)); DesertCactusType veg = (DesertCactusType)state.getValue(META_PROPERTY); if(plant.getBlock() == this) { } return false; }
Example 9
Source File: BlockVegDesert.java From TFC2 with GNU General Public License v3.0 | 5 votes |
@Override public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable) { IBlockState plant = plantable.getPlant(world, pos.offset(direction)); EnumPlantType plantType = plantable.getPlantType(world, pos.offset(direction)); DesertVegType veg = (DesertVegType)state.getValue(META_PROPERTY); if(plant.getBlock() == this) { if(veg == DesertVegType.DoubleGrassBottomSparse && plant.getValue(META_PROPERTY) == DesertVegType.DoubleGrassTopSparse) return true; } return false; }
Example 10
Source File: PlantUtil.java From GardenCollection with MIT License | 5 votes |
private static int getPlantMetadata (IBlockAccess world, int x, int y, int z, IPlantable plant, int defaultMeta) { if (plant == null) return 0; Block itemBlock = plant.getPlant(world, x, y, z); int itemMeta = defaultMeta; if (itemBlock != null) { int plantMeta = plant.getPlantMetadata(world, x, y, z); if (plantMeta > 0) itemMeta = plantMeta; } return itemMeta; }
Example 11
Source File: PlantRegistry.java From GardenCollection with MIT License | 4 votes |
public IPlantInfo getPlantInfo (IBlockAccess world, IPlantable plant) { Block block = plant.getPlant(world, 0, 0, 0); int meta = plant.getPlantMetadata(world, 0, 0, 0); return getPlantInfo(block, meta); }