Search in sources :

Example 6 with IHeatExchanger

use of pneumaticCraft.api.tileentity.IHeatExchanger in project PneumaticCraft by MineMaarten.

the class TileEntityBase method addLuaMethods.

/*
     * COMPUTERCRAFT API 
     */
protected void addLuaMethods() {
    if (this instanceof IHeatExchanger) {
        final IHeatExchanger exchanger = (IHeatExchanger) this;
        luaMethods.add(new LuaMethod("getTemperature") {

            @Override
            public Object[] call(Object[] args) throws Exception {
                if (args.length == 0) {
                    return new Object[] { exchanger.getHeatExchangerLogic(ForgeDirection.UNKNOWN).getTemperature() };
                } else if (args.length == 1) {
                    IHeatExchangerLogic logic = exchanger.getHeatExchangerLogic(getDirForString((String) args[0]));
                    return new Object[] { logic != null ? logic.getTemperature() : 0 };
                } else {
                    throw new IllegalArgumentException("getTemperature method requires 0 or 1 argument (direction: up, down, east, west, north, south!");
                }
            }
        });
    }
}
Also used : IHeatExchanger(pneumaticCraft.api.tileentity.IHeatExchanger) ILuaMethod(pneumaticCraft.common.thirdparty.computercraft.ILuaMethod) LuaMethod(pneumaticCraft.common.thirdparty.computercraft.LuaMethod) LuaException(dan200.computercraft.api.lua.LuaException) IHeatExchangerLogic(pneumaticCraft.api.IHeatExchangerLogic)

Example 7 with IHeatExchanger

use of pneumaticCraft.api.tileentity.IHeatExchanger in project PneumaticCraft by MineMaarten.

the class TileEntityBase method updateEntity.

@Override
public void updateEntity() {
    if (firstRun && !worldObj.isRemote) {
        //firstRun = false;
        onFirstServerUpdate();
        onNeighborTileUpdate();
        onNeighborBlockUpdate();
    }
    firstRun = false;
    if (!worldObj.isRemote) {
        if (this instanceof IHeatExchanger) {
            ((IHeatExchanger) this).getHeatExchangerLogic(ForgeDirection.UNKNOWN).update();
        }
        if (descriptionFields == null)
            descriptionPacketScheduled = true;
        for (SyncedField field : getDescriptionFields()) {
            if (field.update()) {
                descriptionPacketScheduled = true;
            }
        }
        if (descriptionPacketScheduled) {
            descriptionPacketScheduled = false;
            sendDescriptionPacket();
        }
    }
}
Also used : IHeatExchanger(pneumaticCraft.api.tileentity.IHeatExchanger) SyncedField(pneumaticCraft.common.inventory.SyncedField)

Example 8 with IHeatExchanger

use of pneumaticCraft.api.tileentity.IHeatExchanger in project PneumaticCraft by MineMaarten.

the class GuiPneumaticContainerBase method initGui.

@Override
public void initGui() {
    super.initGui();
    lastLeftStat = lastRightStat = null;
    if (shouldAddPressureTab() && te instanceof TileEntityPneumaticBase) {
        pressureStat = this.addAnimatedStat("gui.tab.pressure", new ItemStack(Blockss.pressureTube), 0xFF00AA00, false);
    }
    if (shouldAddProblemTab()) {
        problemTab = addAnimatedStat("gui.tab.problems", Textures.GUI_PROBLEMS_TEXTURE, 0xFFFF0000, false);
    }
    if (shouldAddRedstoneTab() && te instanceof IRedstoneControl) {
        redstoneTab = addAnimatedStat("gui.tab.redstoneBehaviour", new ItemStack(Items.redstone), 0xFFCC0000, true);
        List<String> curInfo = new ArrayList<String>();
        curInfo.add(I18n.format(getRedstoneString()));
        for (int i = 0; i < 3; i++) // create some space for the button
        curInfo.add("                                      ");
        redstoneTab.setTextWithoutCuttingString(curInfo);
        Rectangle buttonRect = redstoneTab.getButtonScaledRectangle(-170, 24, 170, 20);
        //getButtonFromRectangle(0, buttonRect, "-");
        redstoneButton = new GuiButtonSpecial(0, buttonRect.x, buttonRect.y, buttonRect.width, buttonRect.height, "-");
        redstoneTab.addWidget(redstoneButton);
    }
    if (te instanceof IInventory) {
        if (shouldAddInfoTab()) {
            String info = "gui.tab.info." + ((IInventory) te).getInventoryName();
            String translatedInfo = I18n.format(info);
            if (!translatedInfo.equals(info)) {
                addInfoTab(translatedInfo);
            }
        }
        if (te instanceof IHeatExchanger) {
            addAnimatedStat("gui.tab.info.heat.title", new ItemStack(Blocks.fire), 0xFFFF5500, false).setText("gui.tab.info.heat");
        }
        if (shouldAddUpgradeTab()) {
            String upgrades = "gui.tab.upgrades." + ((IInventory) te).getInventoryName();
            String translatedUpgrades = I18n.format(upgrades);
            List<String> upgradeText = new ArrayList<String>();
            if (te instanceof TileEntityPneumaticBase) {
                upgradeText.add("gui.tab.upgrades.volume");
                upgradeText.add("gui.tab.upgrades.security");
            }
            if (te instanceof IHeatExchanger) {
                upgradeText.add("gui.tab.upgrades.volumeCapacity");
            }
            if (!translatedUpgrades.equals(upgrades))
                upgradeText.add(upgrades);
            if (upgradeText.size() > 0)
                addAnimatedStat("gui.tab.upgrades", Textures.GUI_UPGRADES_LOCATION, 0xFF0000FF, true).setText(upgradeText);
        }
    }
}
Also used : IInventory(net.minecraft.inventory.IInventory) IHeatExchanger(pneumaticCraft.api.tileentity.IHeatExchanger) IRedstoneControl(pneumaticCraft.common.tileentity.IRedstoneControl) ArrayList(java.util.ArrayList) Rectangle(java.awt.Rectangle) ItemStack(net.minecraft.item.ItemStack) Point(java.awt.Point) TileEntityPneumaticBase(pneumaticCraft.common.tileentity.TileEntityPneumaticBase)

Example 9 with IHeatExchanger

use of pneumaticCraft.api.tileentity.IHeatExchanger in project PneumaticCraft by MineMaarten.

the class ItemManometer method onItemUseFirst.

/**
     * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
     * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
     */
@Override
public boolean onItemUseFirst(ItemStack iStack, EntityPlayer player, World world, int x, int y, int z, int side, float par8, float par9, float par10) {
    if (world.isRemote)
        return false;
    if (((IPressurizable) iStack.getItem()).getPressure(iStack) > 0F) {
        TileEntity te = world.getTileEntity(x, y, z);
        IPneumaticMachine machine = ModInteractionUtils.getInstance().getMachine(te);
        List<IChatComponent> curInfo = new ArrayList<IChatComponent>();
        List<String> info = new ArrayList<String>();
        if (te instanceof IManoMeasurable) {
            ((IManoMeasurable) te).printManometerMessage(player, info);
        } else if (machine != null) {
            machine.getAirHandler().printManometerMessage(player, info);
        }
        for (String s : info) curInfo.add(new ChatComponentTranslation(s));
        if (te instanceof IHeatExchanger) {
            IHeatExchangerLogic exchanger = ((IHeatExchanger) te).getHeatExchangerLogic(ForgeDirection.getOrientation(side));
            if (exchanger != null) {
                curInfo.add(new ChatComponentTranslation("waila.temperature", (int) exchanger.getTemperature() - 273));
            } else {
                for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
                    exchanger = ((IHeatExchanger) te).getHeatExchangerLogic(d);
                    if (exchanger != null) {
                        curInfo.add(new ChatComponentTranslation("waila.temperature." + d.toString().toLowerCase(), (int) exchanger.getTemperature() - 273));
                    }
                }
            }
        }
        if (curInfo.size() > 0) {
            ((IPressurizable) iStack.getItem()).addAir(iStack, -30);
            for (IChatComponent s : curInfo) {
                player.addChatComponentMessage(s);
            }
            return true;
        }
    } else {
        player.addChatComponentMessage(new ChatComponentTranslation(EnumChatFormatting.RED + "The Manometer doesn't have any charge!"));
        return false;
    }
    return false;
}
Also used : IPressurizable(pneumaticCraft.api.item.IPressurizable) IManoMeasurable(pneumaticCraft.api.tileentity.IManoMeasurable) ArrayList(java.util.ArrayList) TileEntity(net.minecraft.tileentity.TileEntity) IHeatExchanger(pneumaticCraft.api.tileentity.IHeatExchanger) IPneumaticMachine(pneumaticCraft.api.tileentity.IPneumaticMachine) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) IChatComponent(net.minecraft.util.IChatComponent) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) IHeatExchangerLogic(pneumaticCraft.api.IHeatExchangerLogic)

Example 10 with IHeatExchanger

use of pneumaticCraft.api.tileentity.IHeatExchanger in project PneumaticCraft by MineMaarten.

the class GuiPneumaticDynamo method initGui.

@Override
public void initGui() {
    super.initGui();
    inputStat = addAnimatedStat("Output", (ItemStack) null, 0xFF555555, false);
    addWidget(new WidgetEnergy(guiLeft + 20, guiTop + 20, te));
    addWidget(new WidgetTemperature(0, guiLeft + 87, guiTop + 20, 273, 675, ((IHeatExchanger) te).getHeatExchangerLogic(ForgeDirection.UNKNOWN), 325, 625));
}
Also used : IHeatExchanger(pneumaticCraft.api.tileentity.IHeatExchanger) WidgetTemperature(pneumaticCraft.client.gui.widget.WidgetTemperature) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IHeatExchanger (pneumaticCraft.api.tileentity.IHeatExchanger)11 WidgetTemperature (pneumaticCraft.client.gui.widget.WidgetTemperature)6 ItemStack (net.minecraft.item.ItemStack)3 IHeatExchangerLogic (pneumaticCraft.api.IHeatExchangerLogic)3 ArrayList (java.util.ArrayList)2 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)2 LuaException (dan200.computercraft.api.lua.LuaException)1 Point (java.awt.Point)1 Rectangle (java.awt.Rectangle)1 HashSet (java.util.HashSet)1 IInventory (net.minecraft.inventory.IInventory)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 NBTTagList (net.minecraft.nbt.NBTTagList)1 TileEntity (net.minecraft.tileentity.TileEntity)1 ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)1 IChatComponent (net.minecraft.util.IChatComponent)1 IPressurizable (pneumaticCraft.api.item.IPressurizable)1 IManoMeasurable (pneumaticCraft.api.tileentity.IManoMeasurable)1 IPneumaticMachine (pneumaticCraft.api.tileentity.IPneumaticMachine)1 SyncedField (pneumaticCraft.common.inventory.SyncedField)1