Search in sources :

Example 1 with WindowInventory

use of binnie.core.gui.minecraft.WindowInventory in project Binnie by ForestryMC.

the class WindowFieldKit method onWindowInventoryChanged.

@Override
public void onWindowInventoryChanged() {
    super.onWindowInventoryChanged();
    WindowInventory inventory = getWindowInventory();
    if (this.isServer()) {
        final ItemStack kit = this.getPlayer().getHeldItemMainhand();
        if (kit.isEmpty() || !kit.getItem().equals(BinnieCore.getFieldKit())) {
            return;
        }
        ItemStack paper = inventory.getStackInSlot(PAPER_SLOT);
        final int sheets = 64 - kit.getItemDamage();
        final int size = (paper.isEmpty()) ? 0 : paper.getCount();
        if (sheets != size) {
            kit.setItemDamage(64 - size);
        }
        ((EntityPlayerMP) this.getPlayer()).updateHeldItem();
    }
    if (this.isClient()) {
        final ItemStack item = inventory.getStackInSlot(INDIVIDUAL_SLOT);
        this.text.setValue("");
        if (!item.isEmpty() && !ManagerGenetics.isAnalysed(item)) {
            if (inventory.getStackInSlot(PAPER_SLOT).isEmpty()) {
                this.text.setValue(I18N.localise("binniecore.gui.fieldkit.paper.no"));
                this.isAnalysing = false;
                this.analyseProgress = 1;
            } else {
                this.startAnalysing();
                this.chromo.setSystem(null);
            }
        } else if (!item.isEmpty()) {
            this.isAnalysing = false;
            this.analyseProgress = 1;
            this.refreshSpecies();
        } else {
            this.isAnalysing = false;
            this.analyseProgress = 1;
            this.chromo.setSystem(null);
        }
    }
}
Also used : WindowInventory(binnie.core.gui.minecraft.WindowInventory) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack) Point(binnie.core.gui.geometry.Point)

Example 2 with WindowInventory

use of binnie.core.gui.minecraft.WindowInventory in project Binnie by ForestryMC.

the class WindowFieldKit method initialiseServer.

@Override
public void initialiseServer() {
    // create slots
    WindowInventory inventory = this.getWindowInventory();
    final ItemStack kit = this.getPlayer().getHeldItemMainhand();
    final int sheets = 64 - kit.getItemDamage();
    inventory.createSlot(INDIVIDUAL_SLOT);
    inventory.createSlot(PAPER_SLOT);
    if (sheets != 0) {
        inventory.setInventorySlotContents(PAPER_SLOT, new ItemStack(Items.PAPER, sheets));
    }
    this.setupValidators();
}
Also used : WindowInventory(binnie.core.gui.minecraft.WindowInventory) ItemStack(net.minecraft.item.ItemStack) Point(binnie.core.gui.geometry.Point)

Example 3 with WindowInventory

use of binnie.core.gui.minecraft.WindowInventory in project Binnie by ForestryMC.

the class ControlSlot method getHelpTooltip.

@Override
public void getHelpTooltip(final Tooltip tooltip, ITooltipFlag tooltipFlag) {
    final InventorySlot slot = this.getInventorySlot();
    if (slot != null) {
        tooltip.add(slot.getName());
        if (tooltipFlag.isAdvanced()) {
            Collection<EnumFacing> inputSides = slot.getInputSides();
            if (inputSides.size() > 0) {
                tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.side.insert", MachineSide.asString(inputSides)));
            }
            Collection<EnumFacing> outputSides = slot.getOutputSides();
            if (outputSides.size() > 0) {
                tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.side.extract", MachineSide.asString(outputSides)));
            }
            if (slot.isReadOnly()) {
                tooltip.add(TextFormatting.GRAY + I18N.localise(ModId.CORE, "gui.slot.pickup.only"));
            }
        }
    } else if (this.slot.inventory instanceof WindowInventory) {
        if (tooltipFlag.isAdvanced()) {
            final SlotValidator s = ((WindowInventory) this.slot.inventory).getValidator(this.slot.getSlotIndex());
            tooltip.add("Accepts: " + ((s == null) ? "Any Item" : s.getTooltip()));
        }
    } else if (this.slot.inventory instanceof InventoryPlayer) {
        if (tooltipFlag.isAdvanced()) {
            tooltip.add(I18N.localise(ModId.CORE, "gui.slot.player.inventory"));
        }
    }
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) WindowInventory(binnie.core.gui.minecraft.WindowInventory) EnumFacing(net.minecraft.util.EnumFacing) InventorySlot(binnie.core.machines.inventory.InventorySlot) SlotValidator(binnie.core.machines.inventory.SlotValidator)

Example 4 with WindowInventory

use of binnie.core.gui.minecraft.WindowInventory in project Binnie by ForestryMC.

the class WindowFieldKit method setupValidators.

private void setupValidators() {
    WindowInventory inventory = this.getWindowInventory();
    inventory.setValidator(INDIVIDUAL_SLOT, new SlotValidatorIndividual(null));
    inventory.setValidator(PAPER_SLOT, new SlotValidatorPaper(null));
    inventory.disableAutoDispense(PAPER_SLOT);
}
Also used : WindowInventory(binnie.core.gui.minecraft.WindowInventory)

Example 5 with WindowInventory

use of binnie.core.gui.minecraft.WindowInventory in project Binnie by ForestryMC.

the class WindowFieldKit method initialiseClient.

@Override
@SideOnly(Side.CLIENT)
public void initialiseClient() {
    this.setTitle(I18N.localise("binniecore.gui.fieldkit.title"));
    CraftGUI.RENDER.setStyleSheet(StyleSheetManager.getSheet(StyleSheetManager.PUNNETT_SHEET));
    WindowInventory inventory = this.getWindowInventory();
    inventory.createSlot(INDIVIDUAL_SLOT);
    inventory.createSlot(PAPER_SLOT);
    this.setupValidators();
    new ControlPlayerInventory(this);
    final Point handGlass = new Point(16, 32);
    this.GlassControl = new ControlImage(this, handGlass.xPos(), handGlass.yPos(), new StandardTexture(0, 160, 96, 96, BinnieCoreTexture.GUI_PUNNETT));
    new ControlSlot.Builder(this, handGlass.xPos() + 54, handGlass.yPos() + 26).assign(InventoryType.WINDOW, 0);
    new ControlSlot.Builder(this, 208, 8).assign(InventoryType.WINDOW, 1);
    (this.text = new ControlText(this, new Point(232, 13), I18N.localise("binniecore.gui.fieldkit.paper"))).setColor(2236962);
    (this.text = new ControlText(this, new Area(0, 120, this.getWidth(), 24), "", TextJustification.MIDDLE_CENTER)).setColor(2236962);
    this.chromo = new ControlChromosome(this, 150, 24);
    this.addEventHandler(EventValueChanged.class, EventHandlerOrigin.DIRECT_CHILD, this.chromo, event -> {
        final IChromosomeType type = (IChromosomeType) event.getValue();
        if (type != null && WindowFieldKit.this.info.containsKey(type)) {
            final String t = WindowFieldKit.this.info.get(type);
            WindowFieldKit.this.text.setValue(t);
        } else {
            WindowFieldKit.this.text.setValue("");
        }
    });
}
Also used : StandardTexture(binnie.core.gui.resource.textures.StandardTexture) Area(binnie.core.gui.geometry.Area) WindowInventory(binnie.core.gui.minecraft.WindowInventory) ControlPlayerInventory(binnie.core.gui.minecraft.control.ControlPlayerInventory) ControlText(binnie.core.gui.controls.ControlText) ControlSlot(binnie.core.gui.minecraft.control.ControlSlot) Point(binnie.core.gui.geometry.Point) ControlImage(binnie.core.gui.minecraft.control.ControlImage) IChromosomeType(forestry.api.genetics.IChromosomeType) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

WindowInventory (binnie.core.gui.minecraft.WindowInventory)7 ItemStack (net.minecraft.item.ItemStack)4 Point (binnie.core.gui.geometry.Point)3 ControlText (binnie.core.gui.controls.ControlText)1 Area (binnie.core.gui.geometry.Area)1 ControlImage (binnie.core.gui.minecraft.control.ControlImage)1 ControlPlayerInventory (binnie.core.gui.minecraft.control.ControlPlayerInventory)1 ControlSlot (binnie.core.gui.minecraft.control.ControlSlot)1 StandardTexture (binnie.core.gui.resource.textures.StandardTexture)1 InventorySlot (binnie.core.machines.inventory.InventorySlot)1 SlotValidator (binnie.core.machines.inventory.SlotValidator)1 IChromosomeType (forestry.api.genetics.IChromosomeType)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 InventoryPlayer (net.minecraft.entity.player.InventoryPlayer)1 EnumFacing (net.minecraft.util.EnumFacing)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1