@Override public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, net.minecraftforge.common.IPlantable plantable) { EnumPlantType plantType = plantable.getPlantType(world, pos.offset(direction)); switch (plantType) { case Plains: return true; case Beach: 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 hasWater; default: break; } return super.canSustainPlant(state, world, pos, direction, plantable); }
@Override public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z) { EnumPlantType Custom; EnumPlantType Jen; EnumPlantType Pat; //if (this == Blocks.wheat) return Crop; //if (this == Blocks.carrots) return Crop; //if (this == Blocks.potatoes) return Crop; //if (this == Blocks.melon_stem) return Crop; //if (this == Blocks.pumpkin_stem) return Crop; //if (this == Blocks.deadbush) return Desert; //if (this == Blocks.waterlily) return Water; //if (this == Blocks.red_mushroom) return Cave; //if (this == Blocks.brown_mushroom) return Cave; //if (this == Blocks.nether_wart) return Nether; //if (this == Blocks.sapling) return Plains; //if (this == Blocks.tallgrass) return Plains; if (this == BlockLoader.BlockJenGrass_Plant) return Plains; if (this == BlockLoader.BlockPatGrass_Plant) return Plains; if (this == BlockLoader.BlockJenGrassTall_Plant) return Plains; if (this == BlockLoader.BlockPatGrassTall_Plant) return Plains; return Plains; }
@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; }
@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; }
@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; }
@Override public boolean canSustainPlant(IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable) { Block plant = plantable.getPlant(world, x, y + 1, z); EnumPlantType plantType = plantable.getPlantType(world, x, y + 1, z); switch (plantType) { case Desert: return false; case Nether: return false; case Crop: return true; case Cave: return false; case Plains: return false; case Water: return false; case Beach: return false; } return false; }
public boolean canSustainPlant(IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable) { Block plant = plantable.getPlant(world, x, y + 1, z); EnumPlantType plantType = plantable.getPlantType(world, x, y + 1, z); switch (plantType) { case Beach: break; case Cave: break; case Crop: break; case Desert: break; case Nether: break; case Plains: break; case Water: break; default: break; } return false; }
@Override public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z) { /*if (this == Blocks.wheat) return Crop; if (this == Blocks.carrots) return Crop; if (this == Blocks.potatoes) return Crop; if (this == Blocks.melon_stem) return Crop; if (this == Blocks.pumpkin_stem) return Crop; if (this == Blocks.deadbush) return Desert; if (this == Blocks.waterlily) return Water; if (this == Blocks.red_mushroom) return Cave; if (this == Blocks.brown_mushroom) return Cave; if (this == Blocks.nether_wart) return Nether; if (this == Blocks.sapling) return Plains; if (this == Blocks.tallgrass) return Plains; if (this == Blocks.double_plant) return Plains; if (this == Blocks.red_flower) return Plains; if (this == Blocks.yellow_flower) return Plains;*/ return Plains; }
@Override public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z) { if (this == Blocks.wheat) return Crop; if (this == Blocks.carrots) return Crop; if (this == Blocks.potatoes) return Crop; if (this == Blocks.melon_stem) return Crop; if (this == Blocks.pumpkin_stem) return Crop; if (this == Blocks.deadbush) return Desert; if (this == Blocks.waterlily) return Water; if (this == Blocks.red_mushroom) return Cave; if (this == Blocks.brown_mushroom) return Cave; if (this == Blocks.nether_wart) return Nether; if (this == Blocks.sapling) return Plains; if (this == Blocks.tallgrass) return Plains; if (this == Blocks.double_plant) return Plains; if (this == Blocks.red_flower) return Plains; if (this == Blocks.yellow_flower) return Plains; return Plains; }
@Override public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, net.minecraftforge.common.IPlantable plantable) { EnumPlantType plantType = plantable.getPlantType(world, pos); if (plantType==EnumPlantType.Nether) return true; //Nether plants grow extremely well on meat if (plantType==EnumPlantType.Cave) return true; //Cave plants like mushrooms will grow on bare stone return false; }
public BlockCropsBase(String unlocalizedName, String modId, Item seed, Item crop, Collection<Block> canGrowOn, EnumPlantType plantType) { super(); setUnlocalizedName(unlocalizedName); setRegistryName(new ResourceLocation(modId, unlocalizedName)); this.seed = seed; this.crop = crop; this.canGrowOn = canGrowOn; this.plantType = plantType; }
@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); } }
@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); }
@Test public void test() throws Exception { Map<String, EnumPlantType> map = gson.fromJson("{ \"plant\": \"Crop\" }", new TypeToken<Map<String, EnumPlantType>>() {}.getType()); EnumPlantType plant = map.get("plant"); assertSame(EnumPlantType.Crop, plant); }
public boolean canSustainPlantType(IBlockAccess world, BlockPos pos, EnumPlantType plantType) { IBlockState state = world.getBlockState(pos); switch ((ExtraGrassType) state.getValue(VARIANT)) { case FARM: if (plantType == EnumPlantType.Crop) {return true;} break; case SAND: case REDSAND: if (plantType == EnumPlantType.Desert) {return true;} break; default: break; } switch (plantType) { // support plains and cave plants case Plains: case Cave: return true; // support beach plants if there's water alongside case Beach: return ( (!world.isAirBlock(pos.east()) && world.getBlockState(pos.east()).getMaterial() == Material.WATER) || (!world.isAirBlock(pos.west()) && world.getBlockState(pos.west()).getMaterial() == Material.WATER) || (!world.isAirBlock(pos.north()) && world.getBlockState(pos.north()).getMaterial() == Material.WATER) || (!world.isAirBlock(pos.south()) && world.getBlockState(pos.south()).getMaterial() == Material.WATER) ); // don't support nether plants, water plants, or crops (require farmland), or anything else by default default: return false; } }
@Override protected boolean acceptsInputStack(int slot, ItemStack stack) { if (ItemStackUtil.isEmpty(stack)) { return false; } if (stack.getItem() instanceof IPlantable) { IPlantable plant = (IPlantable) stack.getItem(); if (plant.getPlantType(this.getWorld(), this.getPos()) == EnumPlantType.Crop) { return true; } } return false; }
@Override public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable) { final BlockPos plantPos = new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()); final EnumPlantType plantType = plantable.getPlantType(world, plantPos); switch (plantType) { case Desert: { return true; } case Water: { return world.getBlockState(pos).getMaterial() == Material.WATER && world.getBlockState(pos) == getDefaultState(); } case Beach: { return ( (world.getBlockState(new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ())).getMaterial() == Material.WATER) || (world.getBlockState(new BlockPos(pos.getX() + 1, pos.getY(), pos.getZ())).getMaterial() == Material.WATER) || (world.getBlockState(new BlockPos(pos.getX(), pos.getY(), pos.getZ() - 1)).getMaterial() == Material.WATER) || (world.getBlockState(new BlockPos(pos.getX(), pos.getY(), pos.getZ() + 1)).getMaterial() == Material.WATER)); } } return false; }
@SafeVarargs public ItemEdibleSeedDecayable(String name, int hunger, float saturation, int stackSize, Supplier<Block> crop, EnumPlantType plantType, EFoodType foodType, int shelfLife, Class<? extends EntityAnimal>... animalEaters) { super(name, hunger, saturation, stackSize, foodType, shelfLife, animalEaters); this.crop = crop; this.plantType = plantType; }
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); }
@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; }
/******************************************************************************* * 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; }
@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; }
@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; }
public boolean canSustainPlant(final IBlockAccess world, final int x, final int y, final int z, final ForgeDirection direction, final IPlantable plantable) { final EnumPlantType plant = plantable.getPlantType(world, x, y + 1, z); // Crops or reeds return plant == EnumPlantType.Crop || plant == EnumPlantType.Beach; }
@Override public EnumPlantType getPlantType(World world, int x, int y, int z) { if (blockID == crops.blockID ) return Crop; if (blockID == deadBush.blockID ) return Desert; if (blockID == waterlily.blockID ) return Water; if (blockID == mushroomRed.blockID ) return Cave; if (blockID == mushroomBrown.blockID) return Cave; if (blockID == netherStalk.blockID ) return Nether; if (blockID == sapling.blockID ) return Plains; if (blockID == melonStem.blockID ) return Crop; if (blockID == pumpkinStem.blockID ) return Crop; if (blockID == tallGrass.blockID ) return Plains; return Plains; }
public static HashMap<Integer, Object> EnumSetToMap(EnumSet<EnumPlantType> iterable) { HashMap<Integer,Object> map = new HashMap<Integer,Object>(); Iterator<EnumPlantType> types = iterable.iterator(); for (int i = 0; i < iterable.size(); i++) { map.put(i+1, types.next()); } return map; }
@Override public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable) { 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 plantable.getPlantType(world, pos.offset(direction)) == EnumPlantType.Plains || plantable.getPlantType(world, pos.offset(direction)) == EnumPlantType.Beach && hasWater; }
@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; }
@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; }