mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
aa
This commit is contained in:
parent
58502b4b23
commit
5829d5e4cf
@ -1,5 +1,10 @@
|
|||||||
package com.hbm.inventory.gui;
|
package com.hbm.inventory.gui;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.apache.commons.lang3.math.NumberUtils;
|
import org.apache.commons.lang3.math.NumberUtils;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
import org.lwjgl.input.Mouse;
|
import org.lwjgl.input.Mouse;
|
||||||
@ -69,8 +74,8 @@ public class GUIReactorControl extends GuiInfoContainer {
|
|||||||
|
|
||||||
this.fields[0].setText(String.valueOf((int)control.levelUpper));
|
this.fields[0].setText(String.valueOf((int)control.levelUpper));
|
||||||
this.fields[1].setText(String.valueOf((int)control.levelLower));
|
this.fields[1].setText(String.valueOf((int)control.levelLower));
|
||||||
this.fields[2].setText(String.valueOf((int)control.heatUpper));
|
this.fields[2].setText(String.valueOf((int)control.heatUpper / 50));
|
||||||
this.fields[3].setText(String.valueOf((int)control.heatLower));
|
this.fields[3].setText(String.valueOf((int)control.heatLower / 50));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -98,11 +103,12 @@ public class GUIReactorControl extends GuiInfoContainer {
|
|||||||
for(int k = 0; k < 4; k++) {
|
for(int k = 0; k < 4; k++) {
|
||||||
|
|
||||||
double clamp = k < 2 ? 100 : 1000;
|
double clamp = k < 2 ? 100 : 1000;
|
||||||
|
int mod = k < 2 ? 1 : 50;
|
||||||
|
|
||||||
if(NumberUtils.isDigits(fields[k].getText())) {
|
if(NumberUtils.isDigits(fields[k].getText())) {
|
||||||
int j = (int)MathHelper.clamp_double(Double.parseDouble(fields[k].getText()), 0, clamp);
|
int j = (int)MathHelper.clamp_double(Double.parseDouble(fields[k].getText()), 0, clamp);
|
||||||
fields[k].setText(j + "");
|
fields[k].setText(j + "");
|
||||||
vals[k] = j;
|
vals[k] = j * mod;
|
||||||
} else {
|
} else {
|
||||||
fields[k].setText("0");
|
fields[k].setText("0");
|
||||||
}
|
}
|
||||||
@ -128,13 +134,11 @@ public class GUIReactorControl extends GuiInfoContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawGuiContainerForegroundLayer( int i, int j) {
|
protected void drawGuiContainerForegroundLayer(int i, int j) {
|
||||||
String name = this.control.hasCustomInventoryName() ? this.control.getInventoryName() : I18n.format(this.control.getInventoryName());
|
String name = this.control.hasCustomInventoryName() ? this.control.getInventoryName() : I18n.format(this.control.getInventoryName());
|
||||||
|
|
||||||
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
|
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
|
||||||
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
|
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -143,11 +147,37 @@ public class GUIReactorControl extends GuiInfoContainer {
|
|||||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||||
|
|
||||||
for(int i = 0; i < 4; i++)
|
GL11.glPopMatrix();
|
||||||
this.fields[i].drawTextBox();
|
Tessellator tess = Tessellator.instance;
|
||||||
|
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||||
|
GL11.glLineWidth(3F);
|
||||||
|
tess.startDrawing(3);
|
||||||
|
tess.setColorOpaque_I(0x08FF00);
|
||||||
|
|
||||||
|
double render[] = new double[39];
|
||||||
|
|
||||||
|
for(int i = 0; i < render.length; i++) {
|
||||||
|
render[i] = control.getTargetLevel(control.function, 0 + i * 50000 / 28);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < render.length; i++) {
|
||||||
|
tess.addVertex(guiLeft + 128 + i, guiTop + 39 + render[i], this.zLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
//fuck i will figure this out later
|
||||||
|
/*for(int i = 0; i < render.length; i++) {
|
||||||
|
tess.addVertex(guiLeft + 128 + i, guiTop + 39 + control.getGraphPoint(control.function, 0 + i * 50, 28), this.zLevel);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
tess.draw();
|
||||||
|
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
|
||||||
for(byte i = 0; i < 3; i++)
|
for(byte i = 0; i < 3; i++)
|
||||||
displays[i].drawNumber(control.getDisplayData()[i]);
|
displays[i].drawNumber(control.getDisplayData()[i]);
|
||||||
|
|
||||||
|
for(int i = 0; i < 4; i++)
|
||||||
|
this.fields[i].drawTextBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -89,6 +89,9 @@ public class TileEntityReactorControl extends TileEntityMachineBase implements I
|
|||||||
public TileEntityReactorResearch reactor;
|
public TileEntityReactorResearch reactor;
|
||||||
|
|
||||||
public boolean isLinked;
|
public boolean isLinked;
|
||||||
|
|
||||||
|
public int flux;
|
||||||
|
public double level;
|
||||||
public int heat;
|
public int heat;
|
||||||
|
|
||||||
public double levelLower;
|
public double levelLower;
|
||||||
@ -106,7 +109,6 @@ public class TileEntityReactorControl extends TileEntityMachineBase implements I
|
|||||||
isLinked = establishLink();
|
isLinked = establishLink();
|
||||||
|
|
||||||
if(isLinked) {
|
if(isLinked) {
|
||||||
this.heat = reactor.heat;
|
|
||||||
|
|
||||||
double fauxLevel = 0;
|
double fauxLevel = 0;
|
||||||
|
|
||||||
@ -120,32 +122,22 @@ public class TileEntityReactorControl extends TileEntityMachineBase implements I
|
|||||||
fauxLevel = this.levelUpper;
|
fauxLevel = this.levelUpper;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
fauxLevel = getTargetLevel(this.function, this.heat);
|
||||||
switch(this.function) {
|
|
||||||
case LINEAR:
|
|
||||||
fauxLevel = (this.heat - this.heatLower) * ((this.levelUpper - this.levelLower) / (this.heatUpper - this.heatLower)) + this.levelLower;
|
|
||||||
break;
|
|
||||||
case QUAD:
|
|
||||||
fauxLevel = Math.pow((this.heat - this.heatLower) / (this.heatUpper - this.heatLower), 2) * (this.levelUpper - this.levelLower) + this.levelLower;
|
|
||||||
break;
|
|
||||||
case LOG:
|
|
||||||
fauxLevel = Math.pow((this.heat - this.heatUpper) / (this.heatLower - this.heatUpper), 2) * (this.levelLower - this.levelUpper) + this.levelUpper;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double level = MathHelper.clamp_double((fauxLevel * 0.01D), 0D, 1D);
|
double level = MathHelper.clamp_double((fauxLevel * 0.01D), 0D, 1D);
|
||||||
|
|
||||||
NBTTagCompound control = new NBTTagCompound();
|
if(level != this.level) {
|
||||||
control.setDouble("level", level);
|
NBTTagCompound control = new NBTTagCompound();
|
||||||
|
control.setDouble("level", level);
|
||||||
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(control, reactor.xCoord, reactor.yCoord, reactor.zCoord));
|
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(control, reactor.xCoord, reactor.yCoord, reactor.zCoord));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NBTTagCompound data = new NBTTagCompound();
|
NBTTagCompound data = new NBTTagCompound();
|
||||||
data.setInteger("heat", heat);
|
data.setInteger("heat", heat);
|
||||||
|
data.setDouble("level", level);
|
||||||
|
data.setInteger("flux", flux);
|
||||||
data.setBoolean("isLinked", isLinked);
|
data.setBoolean("isLinked", isLinked);
|
||||||
data.setDouble("levelLower", levelLower);
|
data.setDouble("levelLower", levelLower);
|
||||||
data.setDouble("levelUpper", levelUpper);
|
data.setDouble("levelUpper", levelUpper);
|
||||||
@ -158,6 +150,8 @@ public class TileEntityReactorControl extends TileEntityMachineBase implements I
|
|||||||
|
|
||||||
public void networkUnpack(NBTTagCompound data) {
|
public void networkUnpack(NBTTagCompound data) {
|
||||||
this.heat = data.getInteger("heat");
|
this.heat = data.getInteger("heat");
|
||||||
|
this.level = data.getDouble("level");
|
||||||
|
this.flux = data.getInteger("flux");
|
||||||
isLinked = data.getBoolean("isLinked");
|
isLinked = data.getBoolean("isLinked");
|
||||||
levelLower = data.getDouble("levelLower");
|
levelLower = data.getDouble("levelLower");
|
||||||
levelUpper = data.getDouble("levelUpper");
|
levelUpper = data.getDouble("levelUpper");
|
||||||
@ -185,6 +179,10 @@ public class TileEntityReactorControl extends TileEntityMachineBase implements I
|
|||||||
if(tile instanceof TileEntityReactorResearch) {
|
if(tile instanceof TileEntityReactorResearch) {
|
||||||
reactor = (TileEntityReactorResearch) tile;
|
reactor = (TileEntityReactorResearch) tile;
|
||||||
|
|
||||||
|
this.flux = reactor.totalFlux;
|
||||||
|
this.level = reactor.level;
|
||||||
|
this.heat = reactor.heat;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,11 +192,29 @@ public class TileEntityReactorControl extends TileEntityMachineBase implements I
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getTargetLevel(RodFunction function, int heat) {
|
||||||
|
double fauxLevel = 0;
|
||||||
|
|
||||||
|
switch(function) {
|
||||||
|
case LINEAR:
|
||||||
|
fauxLevel = (heat - this.heatLower) * ((this.levelUpper - this.levelLower) / (this.heatUpper - this.heatLower)) + this.levelLower;
|
||||||
|
return fauxLevel;
|
||||||
|
case LOG:
|
||||||
|
fauxLevel = Math.pow((heat - this.heatUpper) / (this.heatLower - this.heatUpper), 2) * (this.levelLower - this.levelUpper) + this.levelUpper;
|
||||||
|
return fauxLevel;
|
||||||
|
case QUAD:
|
||||||
|
fauxLevel = Math.pow((heat - this.heatLower) / (this.heatUpper - this.heatLower), 2) * (this.levelUpper - this.levelLower) + this.levelLower;
|
||||||
|
return fauxLevel;
|
||||||
|
default:
|
||||||
|
return 0.0D;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int[] getDisplayData() {
|
public int[] getDisplayData() {
|
||||||
if(reactor != null) {
|
if(this.isLinked) {
|
||||||
int[] data = new int[3];
|
int[] data = new int[3];
|
||||||
data[0] = (int) reactor.level * 100;
|
data[0] = (int) (this.level * 100);
|
||||||
data[1] = reactor.totalFlux;
|
data[1] = this.flux;
|
||||||
data[2] = (int) Math.round((this.heat) * 0.00002 * 980 + 20);
|
data[2] = (int) Math.round((this.heat) * 0.00002 * 980 + 20);
|
||||||
return data;
|
return data;
|
||||||
} else {
|
} else {
|
||||||
@ -231,174 +247,4 @@ public class TileEntityReactorControl extends TileEntityMachineBase implements I
|
|||||||
QUAD,
|
QUAD,
|
||||||
LOG
|
LOG
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public int hullHeat;
|
|
||||||
public int coreHeat;
|
|
||||||
public int fuel;
|
|
||||||
public int water;
|
|
||||||
public int cool;
|
|
||||||
public int steam;
|
|
||||||
public int maxWater;
|
|
||||||
public int maxCool;
|
|
||||||
public int maxSteam;
|
|
||||||
public int compression;
|
|
||||||
public int rods;
|
|
||||||
public int maxRods;
|
|
||||||
public boolean isOn;
|
|
||||||
public boolean auto;
|
|
||||||
public boolean isLinkd;
|
|
||||||
public boolean redstoned;
|
|
||||||
private int lastRods = 100;*/
|
|
||||||
|
|
||||||
/*@Override
|
|
||||||
public void updateEntity() {
|
|
||||||
|
|
||||||
if(!worldObj.isRemote)
|
|
||||||
{
|
|
||||||
if(slots[0] != null && slots[0].getItem() == ModItems.reactor_sensor &&
|
|
||||||
slots[0].stackTagCompound != null)
|
|
||||||
{
|
|
||||||
int xCoord = slots[0].stackTagCompound.getInteger("x");
|
|
||||||
int yCoord = slots[0].stackTagCompound.getInteger("y");
|
|
||||||
int zCoord = slots[0].stackTagCompound.getInteger("z");
|
|
||||||
|
|
||||||
Block b = worldObj.getBlock(xCoord, yCoord, zCoord);
|
|
||||||
|
|
||||||
if(b == ModBlocks.machine_reactor_small || b == ModBlocks.reactor_computer) {
|
|
||||||
linkX = xCoord;
|
|
||||||
linkY = yCoord;
|
|
||||||
linkZ = zCoord;
|
|
||||||
} else if(b == ModBlocks.dummy_block_reactor_small || b == ModBlocks.dummy_port_reactor_small) {
|
|
||||||
linkX = ((TileEntityDummy)worldObj.getTileEntity(xCoord, yCoord, zCoord)).targetX;
|
|
||||||
linkY = ((TileEntityDummy)worldObj.getTileEntity(xCoord, yCoord, zCoord)).targetY;
|
|
||||||
linkZ = ((TileEntityDummy)worldObj.getTileEntity(xCoord, yCoord, zCoord)).targetZ;
|
|
||||||
} else {
|
|
||||||
linkY = -1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
linkY = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(linkY >= 0 && worldObj.getTileEntity(linkX, linkY, linkZ) instanceof TileEntityMachineReactorSmall) {
|
|
||||||
TileEntityMachineReactorSmall reactor = (TileEntityMachineReactorSmall)worldObj.getTileEntity(linkX, linkY, linkZ);
|
|
||||||
|
|
||||||
hullHeat = reactor.hullHeat;
|
|
||||||
coreHeat = reactor.coreHeat;
|
|
||||||
fuel = reactor.getFuelPercent();
|
|
||||||
water = reactor.tanks[0].getFill();
|
|
||||||
cool = reactor.tanks[1].getFill();
|
|
||||||
steam = reactor.tanks[2].getFill();
|
|
||||||
maxWater = reactor.tanks[0].getMaxFill();
|
|
||||||
maxCool = reactor.tanks[1].getMaxFill();
|
|
||||||
maxSteam = reactor.tanks[2].getMaxFill();
|
|
||||||
rods = reactor.rods;
|
|
||||||
maxRods = reactor.rodsMax;
|
|
||||||
isOn = !reactor.retracting;
|
|
||||||
isLinked = true;
|
|
||||||
|
|
||||||
switch(reactor.tanks[2].getTankType()) {
|
|
||||||
case HOTSTEAM:
|
|
||||||
compression = 1; break;
|
|
||||||
case SUPERHOTSTEAM:
|
|
||||||
compression = 2; break;
|
|
||||||
default:
|
|
||||||
compression = 0; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!redstoned) {
|
|
||||||
if(worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) {
|
|
||||||
redstoned = true;
|
|
||||||
reactor.retracting = !reactor.retracting;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) {
|
|
||||||
redstoned = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(auto && (water < 100 || cool < 100 || coreHeat > (50000 * 0.95)) && fuel > 0) {
|
|
||||||
reactor.retracting = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if(linkY >= 0 && worldObj.getTileEntity(linkX, linkY, linkZ) instanceof TileEntityMachineReactorLarge && ((TileEntityMachineReactorLarge)worldObj.getTileEntity(linkX, linkY, linkZ)).checkBody()) {
|
|
||||||
TileEntityMachineReactorLarge reactor = (TileEntityMachineReactorLarge)worldObj.getTileEntity(linkX, linkY, linkZ);
|
|
||||||
|
|
||||||
hullHeat = reactor.hullHeat;
|
|
||||||
coreHeat = reactor.coreHeat;
|
|
||||||
fuel = reactor.fuel * 100 / Math.max(1, reactor.maxFuel);
|
|
||||||
water = reactor.tanks[0].getFill();
|
|
||||||
cool = reactor.tanks[1].getFill();
|
|
||||||
steam = reactor.tanks[2].getFill();
|
|
||||||
maxWater = reactor.tanks[0].getMaxFill();
|
|
||||||
maxCool = reactor.tanks[1].getMaxFill();
|
|
||||||
maxSteam = reactor.tanks[2].getMaxFill();
|
|
||||||
rods = reactor.rods;
|
|
||||||
maxRods = reactor.rodsMax;
|
|
||||||
isOn = reactor.rods > 0;
|
|
||||||
isLinked = true;
|
|
||||||
|
|
||||||
switch(reactor.tanks[2].getTankType()) {
|
|
||||||
case HOTSTEAM:
|
|
||||||
compression = 1; break;
|
|
||||||
case SUPERHOTSTEAM:
|
|
||||||
compression = 2; break;
|
|
||||||
default:
|
|
||||||
compression = 0; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(rods != 0)
|
|
||||||
lastRods = rods;
|
|
||||||
|
|
||||||
if(!redstoned) {
|
|
||||||
if(worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) {
|
|
||||||
redstoned = true;
|
|
||||||
|
|
||||||
if(rods == 0)
|
|
||||||
rods = lastRods;
|
|
||||||
else
|
|
||||||
rods = 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) {
|
|
||||||
redstoned = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(auto && (water < 100 || cool < 100 || coreHeat > (50000 * 0.95)) && fuel > 0) {
|
|
||||||
reactor.rods = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
hullHeat = 0;
|
|
||||||
coreHeat = 0;
|
|
||||||
fuel = 0;
|
|
||||||
water = 0;
|
|
||||||
cool = 0;
|
|
||||||
steam = 0;
|
|
||||||
maxWater = 0;
|
|
||||||
maxCool = 0;
|
|
||||||
maxSteam = 0;
|
|
||||||
rods = 0;
|
|
||||||
maxRods = 0;
|
|
||||||
isOn = false;
|
|
||||||
compression = 0;
|
|
||||||
isLinked = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(worldObj.getBlock(xCoord, yCoord, zCoord + 1) instanceof BlockRedstoneComparator) {
|
|
||||||
worldObj.scheduleBlockUpdate(xCoord, yCoord, zCoord + 1, worldObj.getBlock(xCoord, yCoord, zCoord + 1), 1);
|
|
||||||
}
|
|
||||||
if(worldObj.getBlock(xCoord, yCoord, zCoord - 1) instanceof BlockRedstoneComparator) {
|
|
||||||
worldObj.scheduleBlockUpdate(xCoord, yCoord, zCoord - 1, worldObj.getBlock(xCoord, yCoord, zCoord - 1), 1);
|
|
||||||
}
|
|
||||||
if(worldObj.getBlock(xCoord + 1, yCoord, zCoord) instanceof BlockRedstoneComparator) {
|
|
||||||
worldObj.scheduleBlockUpdate(xCoord + 1, yCoord, zCoord, worldObj.getBlock(xCoord + 1, yCoord, zCoord), 1);
|
|
||||||
}
|
|
||||||
if(worldObj.getBlock(xCoord - 1, yCoord, zCoord) instanceof BlockRedstoneComparator) {
|
|
||||||
worldObj.scheduleBlockUpdate(xCoord - 1, yCoord, zCoord, worldObj.getBlock(xCoord - 1, yCoord, zCoord), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
PacketDispatcher.wrapper.sendToAllAround(new TEControlPacket(xCoord, yCoord, zCoord, hullHeat, coreHeat, fuel, water, cool, steam, maxWater, maxCool, maxSteam, compression, rods, maxRods, isOn, auto, isLinked), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 30));
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user