net.minecraftforge.common.EnumPlantType Java Examples

The following examples show how to use net.minecraftforge.common.EnumPlantType. 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 vote down vote up
@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 vote down vote up
@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 vote down vote up
@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: BlockMixin.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable)
{
    EnumPlantType type = plantable.getPlantType(world, pos.offset(direction));

    EnumPlantType[] sustainedPlants = getContent().sustainedPlants.get(getSubtype(state)).orElse(null);
    if (sustainedPlants != null)
    {
        return ArrayUtils.contains(sustainedPlants, type);
    } else
    {
        return super.canSustainPlant(state, world, pos, direction, plantable);
    }
}
 
Example #5
Source File: EnumPlantTypeDeserializer.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public EnumPlantType deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
{
    if (json.isJsonPrimitive())
    {
        JsonPrimitive primitive = json.getAsJsonPrimitive();
        if (primitive.isString())
        {
            return EnumPlantType.getPlantType(json.getAsString());
        }
    }

    throw new JsonParseException("Invalid plant type: " + json);
}
 
Example #6
Source File: EnumPlantTypeDeserializerTest.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void test()
{
    Map<String, EnumPlantType> map = gson.fromJson("{ \"plant\": \"Crop\" }", new TypeToken<Map<String, EnumPlantType>>() {}.getType());

    EnumPlantType plant = map.get("plant");

    assertSame(EnumPlantType.Crop, plant);
}
 
Example #7
Source File: ItemSeedBase.java    From ExNihiloAdscensio with MIT License 5 votes vote down vote up
public ItemSeedBase(String name, IBlockState plant) {
	super();
	this.setRegistryName("itemSeed" + StringUtils.capitalize(name));
	this.setUnlocalizedName("itemSeed" + StringUtils.capitalize(name));
	this.plant = plant;
	this.name = name;
	type = EnumPlantType.Plains;
	
	GameRegistry.<Item>register(this);
}
 
Example #8
Source File: BlockStone.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@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 #9
Source File: BlockDirt.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
/*******************************************************************************
 * 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 #10
Source File: BlockCactus.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@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 #11
Source File: BlockVegDesert.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@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 #12
Source File: BlockLargePot.java    From GardenCollection with MIT License 5 votes vote down vote up
@Override
public boolean canSustainPlant (IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable) {
    TileEntityGarden gardenTile = getTileEntity(world, x, y, z);
    EnumPlantType plantType = plantable.getPlantType(world, x, y, z);

    if (plantType == EnumPlantType.Crop)
        return substrateSupportsCrops(gardenTile.getSubstrate());

    return false;
}
 
Example #13
Source File: BlockGardenFarmland.java    From GardenCollection with MIT License 5 votes vote down vote up
@Override
public boolean canSustainPlant (IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable) {
    EnumPlantType plantType = plantable.getPlantType(world, x, y, z);
    if (plantType == EnumPlantType.Crop)
        return true;

    return false;
}
 
Example #14
Source File: BlockSapling.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos) {
	return EnumPlantType.Plains;
}
 
Example #15
Source File: BlockCactus.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos) 
{
	return EnumPlantType.Desert;
}
 
Example #16
Source File: BlockVegDesert.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos) 
{
	return EnumPlantType.Desert;
}
 
Example #17
Source File: BlockVegetation.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos) 
{
	return EnumPlantType.Plains;
}
 
Example #18
Source File: ItemSeeds.java    From GardenCollection with MIT License 4 votes vote down vote up
@Override
public EnumPlantType getPlantType (IBlockAccess world, int x, int y, int z) {
    return EnumPlantType.Crop;
}
 
Example #19
Source File: BlockCandelilla.java    From GardenCollection with MIT License 4 votes vote down vote up
@Override
public EnumPlantType getPlantType (IBlockAccess world, int x, int y, int z) {
    return EnumPlantType.Crop;
}
 
Example #20
Source File: ENItems.java    From ExNihiloAdscensio with MIT License 4 votes vote down vote up
@SuppressWarnings("deprecation")
   public static void init()
{
	hammerWood = new HammerBase("hammerWood", 64, ToolMaterial.WOOD);
	hammerWood.setCreativeTab(ExNihiloAdscensio.tabExNihilo);
	
	hammerStone = new HammerBase("hammerStone", 128, ToolMaterial.STONE);
	hammerStone.setCreativeTab(ExNihiloAdscensio.tabExNihilo);
	
	hammerIron = new HammerBase("hammerIron", 512, ToolMaterial.IRON);
	hammerIron.setCreativeTab(ExNihiloAdscensio.tabExNihilo);
	
	hammerDiamond = new HammerBase("hammerDiamond", 4096, ToolMaterial.DIAMOND);
	hammerDiamond.setCreativeTab(ExNihiloAdscensio.tabExNihilo);
	
	hammerGold = new HammerBase("hammerGold", 64, ToolMaterial.GOLD);
	hammerGold.setCreativeTab(ExNihiloAdscensio.tabExNihilo);
	
	crookWood = new CrookBase("crookWood", 64);
	crookWood.setCreativeTab(ExNihiloAdscensio.tabExNihilo);
	
	crookBone = new CrookBase("crookBone", 256);
	crookBone.setCreativeTab(ExNihiloAdscensio.tabExNihilo);
	
	mesh = new ItemMesh();
	mesh.setCreativeTab(ExNihiloAdscensio.tabExNihilo);
	
	resources = new ItemResource();
	OreDictionary.registerOre("clayPorcelain", ItemResource.getResourceStack("porcelain_clay"));
	
	cookedSilkworm = new ItemCookedSilkworm();

       pebbles = new ItemPebble();
	
	itemSeeds.add(new ItemSeedBase("oak", Blocks.SAPLING.getStateFromMeta(0)));
	itemSeeds.add(new ItemSeedBase("spruce", Blocks.SAPLING.getStateFromMeta(1)));
	itemSeeds.add(new ItemSeedBase("birch", Blocks.SAPLING.getStateFromMeta(2)));
	itemSeeds.add(new ItemSeedBase("jungle", Blocks.SAPLING.getStateFromMeta(3)));
       itemSeeds.add(new ItemSeedBase("acacia", Blocks.SAPLING.getStateFromMeta(4)));
       itemSeeds.add(new ItemSeedBase("darkOak", Blocks.SAPLING.getStateFromMeta(5)));
	itemSeeds.add(new ItemSeedBase("cactus", Blocks.CACTUS.getDefaultState()).setPlantType(EnumPlantType.Desert));
	itemSeeds.add(new ItemSeedBase("sugarcane", Blocks.REEDS.getDefaultState()).setPlantType(EnumPlantType.Beach));
	itemSeeds.add(new ItemSeedBase("carrot", Blocks.CARROTS.getDefaultState()).setPlantType(EnumPlantType.Crop));
	itemSeeds.add(new ItemSeedBase("potato", Blocks.POTATOES.getDefaultState()).setPlantType(EnumPlantType.Crop));
	
	dolls = new ItemDoll();
	
}
 
Example #21
Source File: ItemSeedBase.java    From ExNihiloAdscensio with MIT License 4 votes vote down vote up
@Override
public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos) {
	return type;
}
 
Example #22
Source File: ItemSeedBase.java    From ExNihiloAdscensio with MIT License 4 votes vote down vote up
public ItemSeedBase setPlantType(EnumPlantType type) {
	this.type = type;
	return this;
}
 
Example #23
Source File: MoCBlock.java    From mocreaturesdev with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean canSustainPlant(World world, int x, int y, int z, ForgeDirection direction, IPlantable plant)
{
    int plantID = plant.getPlantID(world, x, y + 1, z);
    EnumPlantType plantType = plant.getPlantType(world, x, y + 1, z);

    if (plantID == cactus.blockID && blockID == cactus.blockID)
    {
        return true;
    }

    if (plantID == reed.blockID && blockID == reed.blockID)
    {
        return true;
    }
    
    
    if (plant instanceof BlockFlower)
    {
        return true;
    }

    switch (plantType)
    {
        case Desert: return blockID == sand.blockID;
        case Nether: return blockID == slowSand.blockID;
        case Crop:   return blockID == tilledField.blockID;
        case Cave:   return isBlockSolidOnSide(world, x, y, z, UP);
        case Plains: return blockID == grass.blockID || blockID == dirt.blockID;
        case Water:  return world.getBlockMaterial(x, y, z) == Material.water && world.getBlockMetadata(x, y, z) == 0;
        case Beach:
            boolean isBeach = (blockID == Block.grass.blockID || blockID == Block.dirt.blockID || blockID == Block.sand.blockID);
            boolean hasWater = (world.getBlockMaterial(x - 1, y, z    ) == Material.water ||
                                world.getBlockMaterial(x + 1, y, z    ) == Material.water ||
                                world.getBlockMaterial(x,     y, z - 1) == Material.water ||
                                world.getBlockMaterial(x,     y, z + 1) == Material.water);
            return isBeach && hasWater;
    }

    return false;
}
 
Example #24
Source File: ItemRiceSeed.java    From TofuCraftReload with MIT License 4 votes vote down vote up
@Override
public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos)
{
    return EnumPlantType.Crop;
}
 
Example #25
Source File: ItemSeeds.java    From customstuff4 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos)
{
    return EnumPlantType.Crop;
}
 
Example #26
Source File: ItemSoybeans.java    From TofuCraftReload with MIT License 4 votes vote down vote up
@Override
public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos)
{
    return EnumPlantType.Crop;
}
 
Example #27
Source File: ItemSoybeansNether.java    From TofuCraftReload with MIT License 4 votes vote down vote up
@Override
public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos)
{
    return EnumPlantType.Crop;
}
 
Example #28
Source File: BlockLeek.java    From TofuCraftReload with MIT License 4 votes vote down vote up
@Override
public net.minecraftforge.common.EnumPlantType getPlantType(net.minecraft.world.IBlockAccess world, BlockPos pos) {
    return EnumPlantType.Plains;
}
 
Example #29
Source File: BlockApricotSapling.java    From TofuCraftReload with MIT License 4 votes vote down vote up
@Override
public net.minecraftforge.common.EnumPlantType getPlantType(net.minecraft.world.IBlockAccess world, BlockPos pos) {
    return EnumPlantType.Plains;
}
 
Example #30
Source File: BlockTofuSapling.java    From TofuCraftReload with MIT License 4 votes vote down vote up
@Override
public net.minecraftforge.common.EnumPlantType getPlantType(net.minecraft.world.IBlockAccess world, BlockPos pos) {
    return EnumPlantType.Plains;
}