use of binnie.botany.api.genetics.IFlowerRoot in project Binnie by ForestryMC.
the class FarmableVanillaFlower method plantSaplingAt.
@Override
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
IFlower flower = flowerRoot.getConversion(germling);
return flowerRoot.plant(world, pos, flower, player.getGameProfile());
}
use of binnie.botany.api.genetics.IFlowerRoot in project Binnie by ForestryMC.
the class FarmableFlower method plantSaplingAt.
@Override
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
IFlower flower = flowerRoot.getMember(germling);
flowerRoot.plant(world, pos, flower, player.getGameProfile());
return true;
}
use of binnie.botany.api.genetics.IFlowerRoot in project Binnie by ForestryMC.
the class FarmableFlower method getCropAt.
@Nullable
@Override
public ICrop getCropAt(World world, BlockPos pos, IBlockState blockState) {
IFlower flower = null;
if (world.getTileEntity(pos) instanceof TileEntityFlower) {
flower = ((TileEntityFlower) world.getTileEntity(pos)).getFlower();
}
// TODO Look at TileEntityFlower::onShear logic
if (flower != null && flower.getAge() > 1) {
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
ItemStack mature = flowerRoot.getMemberStack(flower, EnumFlowerStage.FLOWER);
ItemStack seed = flowerRoot.getMemberStack(flower, EnumFlowerStage.SEED);
if (!mature.isEmpty() && !seed.isEmpty()) {
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
return new FlowerCrop(pos, mature, seed);
}
}
return null;
}
use of binnie.botany.api.genetics.IFlowerRoot in project Binnie by ForestryMC.
the class ModuleFlowers method onPlantVanilla.
@Deprecated
public void onPlantVanilla(PlayerInteractEvent.RightClickBlock event) {
BlockPos pos = event.getPos();
World world = event.getWorld();
EntityPlayer player = event.getEntityPlayer();
ItemStack heldItem = player.getHeldItemMainhand();
if (event.getWorld().isRemote) {
return;
}
if (heldItem.isEmpty()) {
return;
}
Block block = world.getBlockState(pos).getBlock();
int py = -1;
if (block instanceof IBlockSoil && (world.isAirBlock(pos.up()) || block.isReplaceable(world, pos))) {
py = 1;
}
if (py < 0) {
return;
}
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
IFlower flower = flowerRoot.getConversion(heldItem);
if (flower != null && flowerRoot.plant(world, pos.add(0, py, 0), flower, player.getGameProfile()) && !player.capabilities.isCreativeMode) {
heldItem.shrink(1);
}
}
use of binnie.botany.api.genetics.IFlowerRoot in project Binnie by ForestryMC.
the class ModuleFlowers method plantVanilla.
@SubscribeEvent
public void plantVanilla(BlockEvent.PlaceEvent event) {
World world = event.getWorld();
BlockPos pos = event.getPos();
Block block = world.getBlockState(pos.down()).getBlock();
if (!BotanyCore.getGardening().isSoil(block)) {
return;
}
EntityPlayer player = event.getPlayer();
ItemStack heldItem = player.getHeldItem(event.getHand());
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
IFlower flower = flowerRoot.getConversion(heldItem);
if (flower != null) {
flowerRoot.plant(world, pos, flower, player.getGameProfile());
}
}
Aggregations