Search in sources :

Example 16 with IFlower

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);
    }
}
Also used : RenderItem(net.minecraft.client.renderer.RenderItem) IFlower(binnie.botany.api.genetics.IFlower) ItemStack(net.minecraft.item.ItemStack) EnumFlowerChromosome(binnie.botany.api.genetics.EnumFlowerChromosome) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 17 with IFlower

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);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) IFlower(binnie.botany.api.genetics.IFlower) BlockPos(net.minecraft.util.math.BlockPos) TileEntityFlower(binnie.botany.tile.TileEntityFlower)

Example 18 with IFlower

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;
}
Also used : Item(net.minecraft.item.Item) IFlower(binnie.botany.api.genetics.IFlower) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 19 with IFlower

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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IFlowerGenome(binnie.botany.api.genetics.IFlowerGenome) MessageNBT(binnie.core.network.packet.MessageNBT) IFlower(binnie.botany.api.genetics.IFlower) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) TileEntityFlower(binnie.botany.tile.TileEntityFlower)

Example 20 with IFlower

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);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FlowerRenderInfo(binnie.botany.tile.FlowerRenderInfo) IFlower(binnie.botany.api.genetics.IFlower) GameProfile(com.mojang.authlib.GameProfile) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TileEntityFlower(binnie.botany.tile.TileEntityFlower) IFlowerRoot(binnie.botany.api.genetics.IFlowerRoot)

Aggregations

IFlower (binnie.botany.api.genetics.IFlower)24 ItemStack (net.minecraft.item.ItemStack)10 IFlowerRoot (binnie.botany.api.genetics.IFlowerRoot)6 TileEntity (net.minecraft.tileentity.TileEntity)6 IFlowerGenome (binnie.botany.api.genetics.IFlowerGenome)5 TileEntityFlower (binnie.botany.tile.TileEntityFlower)5 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 Block (net.minecraft.block.Block)3 BlockPos (net.minecraft.util.math.BlockPos)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 EnumFlowerChromosome (binnie.botany.api.genetics.EnumFlowerChromosome)2 IAlleleFlowerSpecies (binnie.botany.api.genetics.IAlleleFlowerSpecies)2 Area (binnie.core.gui.geometry.Area)2 World (net.minecraft.world.World)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 EnumSoilType (binnie.botany.api.gardening.EnumSoilType)1 IBlockSoil (binnie.botany.api.gardening.IBlockSoil)1 FlowerRenderInfo (binnie.botany.tile.FlowerRenderInfo)1 ControlText (binnie.core.gui.controls.ControlText)1