use of binnie.botany.api.genetics.IFlower in project Binnie by ForestryMC.
the class FlowerAlyzerPlugin method drawAnalyticsPage1.
@SideOnly(Side.CLIENT)
@Override
public void drawAnalyticsPage1(GuiScreen gui, ItemStack itemStack) {
lastTopOffset = 10;
guiLeft = (gui.width - 246) / 2;
guiTop = (gui.height - 238) / 2;
IFlower flower = BotanyAPI.flowerRoot.getMember(itemStack);
if (flower == null) {
return;
}
ItemStack renderP = getIconStacks().get(flower.getGenome().getPrimary().getUID());
ItemStack renderS = getIconStacks().get(flower.getGenome().getSecondary().getUID());
gui.mc.fontRenderer.drawString("Active", guiLeft + 10 + COLUMN_1, guiTop + 10, 0xffffff);
gui.mc.fontRenderer.drawString("Inactive", guiLeft + 10 + COLUMN_2, guiTop + 10, 0xffffff);
if (renderP != null && renderS != null) {
RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
itemRender.renderItemAndEffectIntoGUI(renderP, guiLeft + 10 + COLUMN_1, guiTop + 10 + 12);
itemRender.renderItemOverlayIntoGUI(gui.mc.fontRenderer, renderP, guiLeft + 10 + COLUMN_1, guiTop + 10 + 12, null);
itemRender.renderItemAndEffectIntoGUI(renderS, guiLeft + 10 + COLUMN_2, guiTop + 10 + 12);
itemRender.renderItemOverlayIntoGUI(gui.mc.fontRenderer, renderS, guiLeft + 10 + COLUMN_1, guiTop + 10 + 12, null);
}
guiTop += ROW_SIZE * 3;
for (EnumFlowerChromosome chromosom : firstPageChromosome) {
drawChromosome(gui, chromosom, flower);
}
}
use of binnie.botany.api.genetics.IFlower in project Binnie by ForestryMC.
the class FlowerRoot method tryGrowSection.
@Override
public void tryGrowSection(World world, BlockPos pos) {
if (world.isRemote) {
return;
}
TileEntity tileFlower = world.getTileEntity(pos);
if (tileFlower == null || !(tileFlower instanceof TileEntityFlower)) {
return;
}
IFlower flower = ((TileEntityFlower) tileFlower).getFlower();
int section = ((TileEntityFlower) tileFlower).getSection();
if (flower == null || section >= flower.getGenome().getPrimary().getType().getSections() - 1 || flower.getAge() <= 0) {
return;
}
BlockPos up = pos.up();
IBlockState blockAbove = world.getBlockState(up);
if (blockAbove.getBlock().isReplaceable(world, up)) {
world.setBlockState(up, ModuleFlowers.flower.getDefaultState());
TileEntity flowerAbove = world.getTileEntity(up);
if (flowerAbove != null && flowerAbove instanceof TileEntityFlower) {
((TileEntityFlower) flowerAbove).setSection(section + 1);
}
}
}
use of binnie.botany.api.genetics.IFlower in project Binnie by ForestryMC.
the class FlowerRoot method getMemberStack.
@Override
public ItemStack getMemberStack(IIndividual flower, ISpeciesType type) {
if (!isMember(flower)) {
return ItemStack.EMPTY;
}
Item flowerItem = ModuleFlowers.flowerItem;
if (type == EnumFlowerStage.SEED) {
flowerItem = ModuleFlowers.seed;
} else if (type == EnumFlowerStage.POLLEN) {
flowerItem = ModuleFlowers.pollen;
}
if (flowerItem != ModuleFlowers.flowerItem) {
((IFlower) flower).setAge(0);
}
NBTTagCompound nbttagcompound = new NBTTagCompound();
flower.writeToNBT(nbttagcompound);
ItemStack flowerStack = new ItemStack(flowerItem);
flowerStack.setTagCompound(nbttagcompound);
return flowerStack;
}
use of binnie.botany.api.genetics.IFlower in project Binnie by ForestryMC.
the class BlockFlower method onBlockActivated.
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack heldItem = player.getHeldItemMainhand();
if (heldItem.isEmpty() || heldItem.getItem() != BinnieCore.getFieldKit() || !player.isSneaking()) {
return false;
}
if (world.isRemote) {
return true;
}
TileEntity tile = world.getTileEntity(pos);
if (!(tile instanceof TileEntityFlower)) {
return true;
}
TileEntityFlower tileFlower = (TileEntityFlower) tile;
IFlower flower = tileFlower.getFlower();
if (flower == null) {
return true;
}
IFlowerGenome flowerGenome = flower.getGenome();
NBTTagCompound info = new NBTTagCompound();
info.setString("Species", flowerGenome.getPrimary().getUID());
info.setString("Species2", flowerGenome.getSecondary().getUID());
info.setFloat("Age", flower.getAge() / flowerGenome.getLifespan());
info.setShort("Colour", (short) flowerGenome.getPrimaryColor().getID());
info.setShort("Colour2", (short) flowerGenome.getSecondaryColor().getID());
info.setBoolean("Wilting", flower.isWilted());
info.setBoolean("Flowered", flower.hasFlowered());
Botany.proxy.sendToPlayer(new MessageNBT(PacketID.FIELDKIT.ordinal(), info), player);
heldItem.damageItem(1, player);
return true;
}
use of binnie.botany.api.genetics.IFlower in project Binnie by ForestryMC.
the class BlockFlower method onBlockPlacedBy.
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
super.onBlockPlacedBy(world, pos, state, placer, stack);
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
TileEntity flower = world.getTileEntity(pos);
if (world.isRemote) {
if (flower != null && flower instanceof TileEntityFlower) {
IFlower f = flowerRoot.getMember(stack);
if (f != null) {
((TileEntityFlower) flower).setRender(new FlowerRenderInfo(f, (TileEntityFlower) flower));
}
}
return;
}
TileEntity below = world.getTileEntity(pos.down());
if (flower != null && flower instanceof TileEntityFlower) {
if (below instanceof TileEntityFlower) {
((TileEntityFlower) flower).setSection(((TileEntityFlower) below).getSection());
} else {
GameProfile owner = (placer instanceof EntityPlayer) ? ((EntityPlayer) placer).getGameProfile() : null;
((TileEntityFlower) flower).create(stack, owner);
}
}
flowerRoot.tryGrowSection(world, pos);
}
Aggregations