mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
Resistive heater is just about done!
This commit is contained in:
1 parent
9d55f6cc8a
commit
63335a57c8
6 files changed
+84
-7
No files matched your search
@@ -1,9 +1,17 @@
|
||||
package mekanism.client.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.util.UnitDisplayUtils.TemperatureUnit;
|
||||
import mekanism.client.gui.element.GuiPowerBar;
|
||||
import mekanism.client.gui.element.GuiSlot;
|
||||
import mekanism.client.gui.element.GuiSlot.SlotOverlay;
|
||||
import mekanism.client.gui.element.GuiSlot.SlotType;
|
||||
import mekanism.client.sound.SoundHandler;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.inventory.container.ContainerResistiveHeater;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.tile.TileEntityResistiveHeater;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
@@ -29,7 +37,8 @@ public class GuiResistiveHeater extends GuiMekanism
|
||||
super(tentity, new ContainerResistiveHeater(inventory, tentity));
|
||||
tileEntity = tentity;
|
||||
|
||||
guiElements.add(new GuiSlot(SlotType.POWER, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 27, 34).with(SlotOverlay.POWER));
|
||||
guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiResistiveHeater.png"), 164, 15));
|
||||
guiElements.add(new GuiSlot(SlotType.POWER, this, MekanismUtils.getResource(ResourceType.GUI, "GuiResistiveHeater.png"), 14, 34).with(SlotOverlay.POWER));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -42,7 +51,7 @@ public class GuiResistiveHeater extends GuiMekanism
|
||||
|
||||
String prevEnergyUsage = energyUsageField != null ? energyUsageField.getText() : "";
|
||||
|
||||
energyUsageField = new GuiTextField(fontRendererObj, guiWidth + 50, guiHeight + 104, 86, 11);
|
||||
energyUsageField = new GuiTextField(fontRendererObj, guiWidth + 49, guiHeight + 52, 66, 11);
|
||||
energyUsageField.setMaxStringLength(7);
|
||||
energyUsageField.setEnableBackgroundDrawing(false);
|
||||
energyUsageField.setText(prevEnergyUsage);
|
||||
@@ -53,6 +62,9 @@ public class GuiResistiveHeater extends GuiMekanism
|
||||
{
|
||||
fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize / 2) - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), 6, 0x404040);
|
||||
fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040);
|
||||
|
||||
renderScaledText(LangUtils.localize("gui.temp") + ": " + MekanismUtils.getTemperatureDisplay(tileEntity.temperature, TemperatureUnit.AMBIENT), 50, 25, 0x00CD00, 76);
|
||||
renderScaledText(LangUtils.localize("gui.usage") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.energyUsage), 50, 41, 0x00CD00, 76);
|
||||
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
}
|
||||
@@ -60,18 +72,69 @@ public class GuiResistiveHeater extends GuiMekanism
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
|
||||
{
|
||||
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"));
|
||||
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiResistiveHeater.png"));
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
int guiWidth = (width - xSize) / 2;
|
||||
int guiHeight = (height - ySize) / 2;
|
||||
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
|
||||
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
if(xAxis >= 116 && xAxis <= 126 && yAxis >= 51 && yAxis <= 61)
|
||||
{
|
||||
drawTexturedModalRect(guiWidth + 116, guiHeight + 51, xSize, 0, 11, 11);
|
||||
}
|
||||
else {
|
||||
drawTexturedModalRect(guiWidth + 116, guiHeight + 51, xSize, 11, 11, 11);
|
||||
}
|
||||
|
||||
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
||||
|
||||
energyUsageField.drawTextBox();
|
||||
}
|
||||
|
||||
private void setEnergyUsage()
|
||||
{
|
||||
if(!energyUsageField.getText().isEmpty())
|
||||
{
|
||||
int toUse = Integer.parseInt(energyUsageField.getText());
|
||||
|
||||
ArrayList data = new ArrayList();
|
||||
data.add(toUse);
|
||||
|
||||
Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data));
|
||||
|
||||
energyUsageField.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen()
|
||||
{
|
||||
super.updateScreen();
|
||||
|
||||
energyUsageField.updateCursorCounter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int button)
|
||||
{
|
||||
super.mouseClicked(mouseX, mouseY, button);
|
||||
|
||||
energyUsageField.mouseClicked(mouseX, mouseY, button);
|
||||
|
||||
if(button == 0)
|
||||
{
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
if(xAxis >= 116 && xAxis <= 126 && yAxis >= 51 && yAxis <= 61)
|
||||
{
|
||||
setEnergyUsage();
|
||||
SoundHandler.playSound("gui.button.press");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -225,6 +225,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo
|
||||
case MACHINE_BLOCK_3:
|
||||
icons[0][0] = register.registerIcon("mekanism:AmbientAccumulator");
|
||||
icons[2][0] = BASE_ICON;
|
||||
icons[4][0] = BASE_ICON;
|
||||
MekanismRenderer.loadDynamicTextures(register, MachineType.OREDICTIONIFICATOR.name, icons[3], DefIcon.getAll(register.registerIcon("mekanism:OredictionificatorSide")));
|
||||
break;
|
||||
}
|
||||
@@ -1147,7 +1148,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo
|
||||
SOLAR_NEUTRON_ACTIVATOR(MachineBlock.MACHINE_BLOCK_3, 1, "SolarNeutronActivator", 47, TileEntitySolarNeutronActivator.class, false, true, false),
|
||||
AMBIENT_ACCUMULATOR(MachineBlock.MACHINE_BLOCK_3, 2, "AmbientAccumulator", 48, TileEntityAmbientAccumulator.class, true, false, false),
|
||||
OREDICTIONIFICATOR(MachineBlock.MACHINE_BLOCK_3, 3, "Oredictionificator", 52, TileEntityOredictionificator.class, false, false, false),
|
||||
RESISTIVE_HEATER(MachineBlock.MACHINE_BLOCK_3, 4, "ResistiveHeater", 53, TileEntityResistiveHeater.class, true, true, false);
|
||||
RESISTIVE_HEATER(MachineBlock.MACHINE_BLOCK_3, 4, "ResistiveHeater", 53, TileEntityResistiveHeater.class, true, false, false);
|
||||
|
||||
public MachineBlock typeBlock;
|
||||
public int meta;
|
||||
@@ -1198,7 +1199,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo
|
||||
|
||||
for(MachineType type : MachineType.values())
|
||||
{
|
||||
if(type != ENTANGLED_BLOCK && type != AMBIENT_ACCUMULATOR && type != RESISTIVE_HEATER)
|
||||
if(type != ENTANGLED_BLOCK && type != AMBIENT_ACCUMULATOR)
|
||||
{
|
||||
ret.add(type);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public class ContainerResistiveHeater extends Container
|
||||
public ContainerResistiveHeater(InventoryPlayer inventory, TileEntityResistiveHeater tentity)
|
||||
{
|
||||
tileEntity = tentity;
|
||||
addSlotToContainer(new SlotDischarge(tentity, 0, 28, 35));
|
||||
addSlotToContainer(new SlotDischarge(tentity, 0, 15, 35));
|
||||
|
||||
int slotY;
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import mekanism.common.util.HeatUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock implements IHeatTransfer
|
||||
@@ -73,6 +74,7 @@ public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock impl
|
||||
double toUse = Math.min(getEnergy(), energyUsage);
|
||||
heatToAbsorb += toUse/general.energyPerHeat;
|
||||
setEnergy(getEnergy() - toUse);
|
||||
setActive(toUse > 0);
|
||||
|
||||
simulateHeat();
|
||||
applyTemperatureChange();
|
||||
@@ -87,6 +89,8 @@ public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock impl
|
||||
energyUsage = nbtTags.getDouble("energyUsage");
|
||||
temperature = nbtTags.getDouble("temperature");
|
||||
clientActive = isActive = nbtTags.getBoolean("isActive");
|
||||
|
||||
maxEnergy = energyUsage * 400;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -104,7 +108,8 @@ public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock impl
|
||||
{
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
energyUsage = dataStream.readDouble();
|
||||
energyUsage = dataStream.readInt();
|
||||
maxEnergy = energyUsage * 400;
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -185,6 +190,13 @@ public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock impl
|
||||
@Override
|
||||
public IHeatTransfer getAdjacent(ForgeDirection side)
|
||||
{
|
||||
TileEntity adj = Coord4D.get(this).getFromSide(side).getTileEntity(worldObj);
|
||||
|
||||
if(adj instanceof IHeatTransfer)
|
||||
{
|
||||
return (IHeatTransfer)adj;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user