use of binnie.botany.tile.TileEntityFlower in project Binnie by ForestryMC.
the class BlockFlower method getActualState.
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("deprecation")
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
TileEntityFlower flower = TileUtil.getTile(world, pos, TileEntityFlower.class);
if (flower != null && flower.getType() != null) {
state = state.withProperty(FLOWER, flower.getType());
state = state.withProperty(FLOWERED, flower.isFlowered());
state = state.withProperty(SECTION, flower.getRenderSection());
state = state.withProperty(SEED, flower.getAge() == 0);
} else {
state = state.withProperty(FLOWER, FlowerDefinition.Dandelion.getSpecies().getType());
state = state.withProperty(FLOWERED, false);
state = state.withProperty(SEED, false);
}
return state;
}
use of binnie.botany.tile.TileEntityFlower in project Binnie by ForestryMC.
the class BlockFlower method updateTick.
@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityFlower) {
((TileEntityFlower) tile).randomUpdate(rand);
checkAndDropBlock(world, pos);
return;
}
world.setBlockToAir(pos);
}
use of binnie.botany.tile.TileEntityFlower in project Binnie by ForestryMC.
the class GardenLogic method trySetCrop.
private boolean trySetCrop(World world, BlockPos position, FarmDirection direction, IFarmHousing housing) {
for (IFarmable farmable : farmables) {
if (!housing.plantGermling(farmable, world, position, direction)) {
continue;
}
if (housing instanceof IOwnedTile) {
TileEntity tile = world.getTileEntity(position);
if (tile instanceof TileEntityFlower) {
TileEntityFlower flower = (TileEntityFlower) tile;
IOwnedTile owned = (IOwnedTile) housing;
flower.setOwner(owned.getOwnerHandler().getOwner());
}
}
return true;
}
return false;
}
use of binnie.botany.tile.TileEntityFlower 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.tile.TileEntityFlower in project Binnie by ForestryMC.
the class FlowerRoot method plant.
public boolean plant(World world, BlockPos pos, IFlower flower, GameProfile owner) {
boolean set = world.setBlockState(pos, ModuleFlowers.flower.getDefaultState());
if (!set) {
return false;
}
TileEntity tile = world.getTileEntity(pos);
TileEntity below = world.getTileEntity(pos.down());
if (tile != null && tile instanceof TileEntityFlower) {
TileEntityFlower tileFlower = (TileEntityFlower) tile;
if (below instanceof TileEntityFlower) {
tileFlower.setSection(((TileEntityFlower) below).getSection());
} else {
tileFlower.create(flower, owner);
}
}
tryGrowSection(world, pos);
return true;
}
Aggregations