AMS base gui overhaul, limiter functionality (sorta)

This commit is contained in:
HbmMods 2017-11-25 20:40:47 +01:00
parent 5e793f3e50
commit cca25b1594
10 changed files with 134 additions and 2 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

View File

@ -34,6 +34,8 @@ public class GUIAMSLimiter extends GuiInfoContainer {
limiter.tank.renderTankInfo(this, mouseX, mouseY, guiLeft + 26, guiTop + 69 - 52, 16, 52);
this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 134, guiTop + 69 - 52, 16, 52, limiter.power, limiter.maxPower);
this.drawCustomInfo(this, mouseX, mouseY, guiLeft + 152, guiTop + 69 - 52, 16, 52, new String[] { "Efficiency:", limiter.efficiency + "%" });
this.drawCustomInfo(this, mouseX, mouseY, guiLeft + 8, guiTop + 69 - 52, 16, 52, new String[] { "Heat:", limiter.heat + "/" + limiter.maxHeat });
}
@Override
@ -53,6 +55,12 @@ public class GUIAMSLimiter extends GuiInfoContainer {
int i = (int) limiter.getPowerScaled(52);
drawTexturedModalRect(guiLeft + 134, guiTop + 69 - i, 192, 52 - i, 16, i);
int j = limiter.getEfficiencyScaled(52);
drawTexturedModalRect(guiLeft + 152, guiTop + 69 - j, 208, 52 - j, 16, j);
int k = limiter.getHeatScaled(52);
drawTexturedModalRect(guiLeft + 8, guiTop + 69 - k, 176, 52 - k, 16, k);
Minecraft.getMinecraft().getTextureManager().bindTexture(limiter.tank.getSheet());
limiter.tank.renderTank(this, guiLeft + 26, guiTop + 69, limiter.tank.getTankType().textureX() * FluidTank.x, limiter.tank.getTankType().textureY() * FluidTank.y, 16, 52);

View File

@ -20,5 +20,10 @@ public abstract class GuiInfoContainer extends GuiContainer {
if(x <= mouseX && x + width > mouseX && y < mouseY && y + height >= mouseY)
gui.drawFluidInfo(new String[] { power + "/" + maxPower + "HE" }, mouseX, mouseY);
}
public void drawCustomInfo(GuiInfoContainer gui, int mouseX, int mouseY, int x, int y, int width, int height, String[] text) {
if(x <= mouseX && x + width > mouseX && y < mouseY && y + height >= mouseY)
this.func_146283_a(Arrays.asList(text), mouseX, mouseY);
}
}

View File

@ -0,0 +1,71 @@
package com.hbm.packet;
import com.hbm.interfaces.IConsumer;
import com.hbm.interfaces.ISource;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.tileentity.TileEntity;
public class AuxGaugePacket implements IMessage {
int x;
int y;
int z;
int value;
int id;
public AuxGaugePacket()
{
}
public AuxGaugePacket(int x, int y, int z, int value, int id)
{
this.x = x;
this.y = y;
this.z = z;
this.value = value;
this.id = id;
}
@Override
public void fromBytes(ByteBuf buf) {
x = buf.readInt();
y = buf.readInt();
z = buf.readInt();
value = buf.readInt();
id = buf.readInt();
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(x);
buf.writeInt(y);
buf.writeInt(z);
buf.writeInt(value);
buf.writeInt(id);
}
public static class Handler implements IMessageHandler<AuxGaugePacket, IMessage> {
@Override
@SideOnly(Side.CLIENT)
public IMessage onMessage(AuxGaugePacket m, MessageContext ctx) {
try {
TileEntity te = Minecraft.getMinecraft().theWorld.getTileEntity(m.x, m.y, m.z);
if (true) {
}
} catch (Exception x) { }
return null;
}
}
}

View File

@ -51,6 +51,8 @@ public class PacketDispatcher {
wrapper.registerMessage(TEPressPacket.Handler.class, TEPressPacket.class, i++, Side.CLIENT);
//Electricity gauge for GUI rendering
wrapper.registerMessage(AuxElectricityPacket.Handler.class, AuxElectricityPacket.class, i++, Side.CLIENT);
//Electricity gauge for GUI rendering
wrapper.registerMessage(AuxGaugePacket.Handler.class, AuxGaugePacket.class, i++, Side.CLIENT);
}
}

View File

@ -32,9 +32,9 @@ public class TileEntityAMSLimiter extends TileEntity implements ISidedInventory,
public long power = 0;
public static final long maxPower = 1000000;
public int efficiency = 0;
public static final long maxEfficiency = 100;
public static final int maxEfficiency = 100;
public int heat = 0;
public static final long maxHeat = 2500;
public static final int maxHeat = 2500;
public int age = 0;
public int warning = 0;
public int mode = 0;
@ -211,6 +211,32 @@ public class TileEntityAMSLimiter extends TileEntity implements ISidedInventory,
tank.setType(0, 1, slots);
tank.updateTank(xCoord, yCoord, zCoord);
heat = 0;
if(slots[0] != null)
heat += maxHeat/2;
if(slots[1] != null)
heat += maxHeat/2;
if(power > 0) {
//" - (maxHeat / 2)" offsets center to 50% instead of 0%
efficiency = Math.round(calcEffect(power, heat - (maxHeat / 2)) * 100);
power -= Math.ceil(power * 0.025);
heat += efficiency;
} else {
efficiency = 0;
}
//TODO
/*if(tank.getTankType().name().equals(FluidType.CRYOGEL.name())) {
int i = (int) (1/Math.sqrt(heat + 1));
if() {
}
}*/
power = Library.chargeTEFromItems(slots, 3, power, maxPower);
@ -218,9 +244,29 @@ public class TileEntityAMSLimiter extends TileEntity implements ISidedInventory,
}
}
private float gauss(float a, float x) {
//Greater values -> less difference of temperate impact
double amplifier = 0.10;
return (float) ( (1/Math.sqrt(a * Math.PI)) * Math.pow(Math.E, -1 * Math.pow(x, 2)/amplifier) );
}
private float calcEffect(float a, float x) {
return (float) (gauss( 1 / a, x / maxHeat) * Math.sqrt(Math.PI * 2) / (Math.sqrt(2) * Math.sqrt(maxPower)));
}
public long getPowerScaled(long i) {
return (power * i) / maxPower;
}
public int getEfficiencyScaled(int i) {
return (efficiency * i) / maxEfficiency;
}
public int getHeatScaled(int i) {
return (heat * i) / maxHeat;
}
@Override
public void setPower(long i) {