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!");
}
}
});
}
}
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();
}
}
}
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);
}
}
}
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;
}
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));
}
Aggregations