mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
PWR controllability
This commit is contained in:
parent
a7b741fe48
commit
05f45e8a76
@ -1,21 +1,29 @@
|
|||||||
package com.hbm.inventory.gui;
|
package com.hbm.inventory.gui;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.math.NumberUtils;
|
||||||
|
import org.lwjgl.input.Keyboard;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import com.hbm.inventory.container.ContainerPWR;
|
import com.hbm.inventory.container.ContainerPWR;
|
||||||
import com.hbm.items.ModItems;
|
import com.hbm.items.ModItems;
|
||||||
import com.hbm.lib.RefStrings;
|
import com.hbm.lib.RefStrings;
|
||||||
|
import com.hbm.packet.NBTControlPacket;
|
||||||
|
import com.hbm.packet.PacketDispatcher;
|
||||||
import com.hbm.render.util.GaugeUtil;
|
import com.hbm.render.util.GaugeUtil;
|
||||||
import com.hbm.render.util.GaugeUtil.Gauge;
|
import com.hbm.render.util.GaugeUtil.Gauge;
|
||||||
import com.hbm.tileentity.machine.TileEntityPWRController;
|
import com.hbm.tileentity.machine.TileEntityPWRController;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||||
import net.minecraft.client.gui.FontRenderer;
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
|
import net.minecraft.client.gui.GuiTextField;
|
||||||
import net.minecraft.client.renderer.RenderHelper;
|
import net.minecraft.client.renderer.RenderHelper;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.EnumChatFormatting;
|
import net.minecraft.util.EnumChatFormatting;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
public class GUIPWR extends GuiInfoContainer {
|
public class GUIPWR extends GuiInfoContainer {
|
||||||
@ -23,6 +31,8 @@ public class GUIPWR extends GuiInfoContainer {
|
|||||||
protected TileEntityPWRController controller;
|
protected TileEntityPWRController controller;
|
||||||
private final ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/reactors/gui_pwr.png");
|
private final ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/reactors/gui_pwr.png");
|
||||||
|
|
||||||
|
private GuiTextField field;
|
||||||
|
|
||||||
public GUIPWR(InventoryPlayer inventory, TileEntityPWRController controller) {
|
public GUIPWR(InventoryPlayer inventory, TileEntityPWRController controller) {
|
||||||
super(new ContainerPWR(inventory, controller));
|
super(new ContainerPWR(inventory, controller));
|
||||||
this.controller = controller;
|
this.controller = controller;
|
||||||
@ -31,6 +41,21 @@ public class GUIPWR extends GuiInfoContainer {
|
|||||||
this.ySize = 188;
|
this.ySize = 188;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initGui() {
|
||||||
|
super.initGui();
|
||||||
|
|
||||||
|
Keyboard.enableRepeatEvents(true);
|
||||||
|
|
||||||
|
this.field = new GuiTextField(this.fontRendererObj, guiLeft + 57, guiTop + 63, 30, 8);
|
||||||
|
this.field.setTextColor(0x00ff00);
|
||||||
|
this.field.setDisabledTextColour(0x008000);
|
||||||
|
this.field.setEnableBackgroundDrawing(false);
|
||||||
|
this.field.setMaxStringLength(3);
|
||||||
|
|
||||||
|
this.field.setText((100 - controller.rodTarget) + "");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawScreen(int x, int y, float interp) {
|
public void drawScreen(int x, int y, float interp) {
|
||||||
super.drawScreen(x, y, interp);
|
super.drawScreen(x, y, interp);
|
||||||
@ -38,12 +63,8 @@ public class GUIPWR extends GuiInfoContainer {
|
|||||||
this.drawCustomInfoStat(x, y, guiLeft + 115, guiTop + 31, 18, 18, x, y, new String[] { "Core: " + String.format("%,d", controller.coreHeat) + " / " + String.format("%,d", controller.coreHeatCapacity) + " TU" });
|
this.drawCustomInfoStat(x, y, guiLeft + 115, guiTop + 31, 18, 18, x, y, new String[] { "Core: " + String.format("%,d", controller.coreHeat) + " / " + String.format("%,d", controller.coreHeatCapacity) + " TU" });
|
||||||
this.drawCustomInfoStat(x, y, guiLeft + 151, guiTop + 31, 18, 18, x, y, new String[] { "Hull: " + String.format("%,d", controller.hullHeat) + " / " + String.format("%,d", controller.hullHeatCapacity) + " TU" });
|
this.drawCustomInfoStat(x, y, guiLeft + 151, guiTop + 31, 18, 18, x, y, new String[] { "Hull: " + String.format("%,d", controller.hullHeat) + " / " + String.format("%,d", controller.hullHeatCapacity) + " TU" });
|
||||||
|
|
||||||
//TODO: calculate some prediction using extrapolation (or some math sector that ends with -ic)
|
|
||||||
//int timeLeft = (controller.processTime - controller.progress) / 20;
|
|
||||||
//this.drawCustomInfoStat(x, y, guiLeft + 52, guiTop + 31, 36, 18, x, y, new String[] { "Cycle: " + (timeLeft / 60) + ":" + String.format("%02d", timeLeft % 60)});
|
|
||||||
|
|
||||||
this.drawCustomInfoStat(x, y, guiLeft + 52, guiTop + 31, 36, 18, x, y, new String[] { ((int) (controller.progress * 100 / controller.processTime)) + "%" });
|
this.drawCustomInfoStat(x, y, guiLeft + 52, guiTop + 31, 36, 18, x, y, new String[] { ((int) (controller.progress * 100 / controller.processTime)) + "%" });
|
||||||
|
this.drawCustomInfoStat(x, y, guiLeft + 52, guiTop + 53, 54, 4, x, y, "Control rod level: " + (100 - controller.rodLevel) + "%");
|
||||||
|
|
||||||
if(controller.typeLoaded != -1 && controller.amountLoaded > 0) {
|
if(controller.typeLoaded != -1 && controller.amountLoaded > 0) {
|
||||||
ItemStack display = new ItemStack(ModItems.pwr_fuel, 1, controller.typeLoaded);
|
ItemStack display = new ItemStack(ModItems.pwr_fuel, 1, controller.typeLoaded);
|
||||||
@ -88,12 +109,15 @@ public class GUIPWR 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);
|
||||||
|
|
||||||
if(System.currentTimeMillis() % 1000 < 500)
|
if(controller.hullHeat > controller.hullHeatCapacity * 0.8 || controller.coreHeat > controller.coreHeatCapacity * 0.8)
|
||||||
drawTexturedModalRect(guiLeft + 147, guiTop, 176, 14, 26, 26);
|
drawTexturedModalRect(guiLeft + 147, guiTop, 176, 14, 26, 26);
|
||||||
|
|
||||||
int p = (int) (controller.progress * 33 / controller.processTime);
|
int p = (int) (controller.progress * 33 / controller.processTime);
|
||||||
drawTexturedModalRect(guiLeft + 54, guiTop + 33, 176, 0, p, 14);
|
drawTexturedModalRect(guiLeft + 54, guiTop + 33, 176, 0, p, 14);
|
||||||
|
|
||||||
|
int c = (int) (controller.rodLevel * 52 / 100);
|
||||||
|
drawTexturedModalRect(guiLeft + 53, guiTop + 54, 176, 40, c, 2);
|
||||||
|
|
||||||
GaugeUtil.renderGauge(Gauge.ROUND_SMALL, guiLeft + 115, guiTop + 31, this.zLevel, (double) controller.coreHeat / (double) controller.coreHeatCapacity);
|
GaugeUtil.renderGauge(Gauge.ROUND_SMALL, guiLeft + 115, guiTop + 31, this.zLevel, (double) controller.coreHeat / (double) controller.coreHeatCapacity);
|
||||||
GaugeUtil.renderGauge(Gauge.ROUND_SMALL, guiLeft + 151, guiTop + 31, this.zLevel, (double) controller.hullHeat / (double) controller.hullHeatCapacity);
|
GaugeUtil.renderGauge(Gauge.ROUND_SMALL, guiLeft + 151, guiTop + 31, this.zLevel, (double) controller.hullHeat / (double) controller.hullHeatCapacity);
|
||||||
|
|
||||||
@ -104,7 +128,37 @@ public class GUIPWR extends GuiInfoContainer {
|
|||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
|
|
||||||
controller.tanks[0].renderTank(guiLeft + 8, guiTop + 57, this.zLevel, 16, 52);
|
controller.tanks[0].renderTank(guiLeft + 8, guiTop + 57, this.zLevel, 16, 52);
|
||||||
controller.tanks[1].renderTank(guiLeft + 26, guiTop + 57, this.zLevel, 16, 52);
|
controller.tanks[1].renderTank(guiLeft + 26, guiTop + 57, this.zLevel, 16, 52);
|
||||||
|
|
||||||
|
this.field.drawTextBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void mouseClicked(int mouseX, int mouseY, int i) {
|
||||||
|
super.mouseClicked(mouseX, mouseY, i);
|
||||||
|
this.field.mouseClicked(mouseX, mouseY, i);
|
||||||
|
|
||||||
|
if(guiLeft + 88 <= mouseX && guiLeft + 88 + 18 > mouseX && guiTop + 58 < mouseY && guiTop + 58 + 18 >= mouseY) {
|
||||||
|
|
||||||
|
if(NumberUtils.isNumber(field.getText())) {
|
||||||
|
int level = (int)MathHelper.clamp_double(Double.parseDouble(field.getText()), 0, 100);
|
||||||
|
field.setText(level + "");
|
||||||
|
|
||||||
|
NBTTagCompound control = new NBTTagCompound();
|
||||||
|
control.setInteger("control", 100 - level);
|
||||||
|
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(control, controller.xCoord, controller.yCoord, controller.zCoord));
|
||||||
|
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1F));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void keyTyped(char c, int i) {
|
||||||
|
if(this.field.textboxKeyTyped(c, i)) return;
|
||||||
|
super.keyTyped(c, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -304,6 +304,8 @@ public class TileEntityMachineChemplant extends TileEntityMachineBase implements
|
|||||||
|
|
||||||
this.maxProgress = recipe.getDuration() * this.speed / 100;
|
this.maxProgress = recipe.getDuration() * this.speed / 100;
|
||||||
|
|
||||||
|
if(maxProgress <= 0) maxProgress = 1;
|
||||||
|
|
||||||
if(this.progress >= this.maxProgress) {
|
if(this.progress >= this.maxProgress) {
|
||||||
consumeFluids(recipe);
|
consumeFluids(recipe);
|
||||||
produceFluids(recipe);
|
produceFluids(recipe);
|
||||||
|
|||||||
@ -150,6 +150,8 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa
|
|||||||
|
|
||||||
this.maxProgress[index] = recipe.getDuration() * this.speed / 100;
|
this.maxProgress[index] = recipe.getDuration() * this.speed / 100;
|
||||||
|
|
||||||
|
if(maxProgress[index] <= 0) maxProgress[index] = 1;
|
||||||
|
|
||||||
if(this.progress[index] >= this.maxProgress[index]) {
|
if(this.progress[index] >= this.maxProgress[index]) {
|
||||||
consumeFluids(recipe, index);
|
consumeFluids(recipe, index);
|
||||||
produceFluids(recipe, index);
|
produceFluids(recipe, index);
|
||||||
|
|||||||
@ -16,6 +16,8 @@ import com.hbm.inventory.fluid.trait.FT_Heatable.HeatingType;
|
|||||||
import com.hbm.inventory.gui.GUIPWR;
|
import com.hbm.inventory.gui.GUIPWR;
|
||||||
import com.hbm.items.ModItems;
|
import com.hbm.items.ModItems;
|
||||||
import com.hbm.items.machine.ItemPWRFuel.EnumPWRFuel;
|
import com.hbm.items.machine.ItemPWRFuel.EnumPWRFuel;
|
||||||
|
import com.hbm.main.MainRegistry;
|
||||||
|
import com.hbm.sound.AudioWrapper;
|
||||||
import com.hbm.tileentity.IGUIProvider;
|
import com.hbm.tileentity.IGUIProvider;
|
||||||
import com.hbm.tileentity.TileEntityMachineBase;
|
import com.hbm.tileentity.TileEntityMachineBase;
|
||||||
import com.hbm.util.EnumUtil;
|
import com.hbm.util.EnumUtil;
|
||||||
@ -41,8 +43,8 @@ public class TileEntityPWRController extends TileEntityMachineBase implements IG
|
|||||||
public static final int hullHeatCapacity = 10_000_000;
|
public static final int hullHeatCapacity = 10_000_000;
|
||||||
public double flux;
|
public double flux;
|
||||||
|
|
||||||
public int rodLevel;
|
public int rodLevel = 100;
|
||||||
public int rodTarget;
|
public int rodTarget = 100;
|
||||||
|
|
||||||
public int typeLoaded;
|
public int typeLoaded;
|
||||||
public int amountLoaded;
|
public int amountLoaded;
|
||||||
@ -58,6 +60,8 @@ public class TileEntityPWRController extends TileEntityMachineBase implements IG
|
|||||||
|
|
||||||
public boolean assembled;
|
public boolean assembled;
|
||||||
|
|
||||||
|
private AudioWrapper audio;
|
||||||
|
|
||||||
protected List<BlockPos> ports = new ArrayList();
|
protected List<BlockPos> ports = new ArrayList();
|
||||||
|
|
||||||
public TileEntityPWRController() {
|
public TileEntityPWRController() {
|
||||||
@ -228,7 +232,54 @@ public class TileEntityPWRController extends TileEntityMachineBase implements IG
|
|||||||
data.setDouble("progress", progress);
|
data.setDouble("progress", progress);
|
||||||
data.setInteger("typeLoaded", typeLoaded);
|
data.setInteger("typeLoaded", typeLoaded);
|
||||||
data.setInteger("amountLoaded", amountLoaded);
|
data.setInteger("amountLoaded", amountLoaded);
|
||||||
|
data.setInteger("rodLevel", rodLevel);
|
||||||
|
data.setInteger("rodTarget", rodTarget);
|
||||||
this.networkPack(data, 150);
|
this.networkPack(data, 150);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if(amountLoaded > 0) {
|
||||||
|
|
||||||
|
if(audio == null) {
|
||||||
|
audio = createAudioLoop();
|
||||||
|
audio.startSound();
|
||||||
|
} else if(!audio.isPlaying()) {
|
||||||
|
audio = rebootAudio(audio);
|
||||||
|
}
|
||||||
|
|
||||||
|
audio.keepAlive();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if(audio != null) {
|
||||||
|
audio.stopSound();
|
||||||
|
audio = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AudioWrapper createAudioLoop() {
|
||||||
|
return MainRegistry.proxy.getLoopedSound("hbm:block.reactorLoop", xCoord, yCoord, zCoord, 1F, 10F, 1.0F, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onChunkUnload() {
|
||||||
|
|
||||||
|
if(audio != null) {
|
||||||
|
audio.stopSound();
|
||||||
|
audio = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invalidate() {
|
||||||
|
|
||||||
|
super.invalidate();
|
||||||
|
|
||||||
|
if(audio != null) {
|
||||||
|
audio.stopSound();
|
||||||
|
audio = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,6 +314,8 @@ public class TileEntityPWRController extends TileEntityMachineBase implements IG
|
|||||||
progress = nbt.getDouble("progress");
|
progress = nbt.getDouble("progress");
|
||||||
typeLoaded = nbt.getInteger("typeLoaded");
|
typeLoaded = nbt.getInteger("typeLoaded");
|
||||||
amountLoaded = nbt.getInteger("amountLoaded");
|
amountLoaded = nbt.getInteger("amountLoaded");
|
||||||
|
rodLevel = nbt.getInteger("rodLevel");
|
||||||
|
rodTarget = nbt.getInteger("rodTarget");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setupTanks() {
|
protected void setupTanks() {
|
||||||
@ -296,6 +349,9 @@ public class TileEntityPWRController extends TileEntityMachineBase implements IG
|
|||||||
public void readFromNBT(NBTTagCompound nbt) {
|
public void readFromNBT(NBTTagCompound nbt) {
|
||||||
super.readFromNBT(nbt);
|
super.readFromNBT(nbt);
|
||||||
|
|
||||||
|
tanks[0].readFromNBT(nbt, "t0");
|
||||||
|
tanks[1].readFromNBT(nbt, "t1");
|
||||||
|
|
||||||
this.assembled = nbt.getBoolean("assembled");
|
this.assembled = nbt.getBoolean("assembled");
|
||||||
this.coreHeat = nbt.getInteger("coreHeat");
|
this.coreHeat = nbt.getInteger("coreHeat");
|
||||||
this.hullHeat = nbt.getInteger("hullHeat");
|
this.hullHeat = nbt.getInteger("hullHeat");
|
||||||
@ -326,6 +382,9 @@ public class TileEntityPWRController extends TileEntityMachineBase implements IG
|
|||||||
public void writeToNBT(NBTTagCompound nbt) {
|
public void writeToNBT(NBTTagCompound nbt) {
|
||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
|
|
||||||
|
tanks[0].writeToNBT(nbt, "t0");
|
||||||
|
tanks[1].writeToNBT(nbt, "t1");
|
||||||
|
|
||||||
nbt.setBoolean("assembled", assembled);
|
nbt.setBoolean("assembled", assembled);
|
||||||
nbt.setInteger("coreHeat", coreHeat);
|
nbt.setInteger("coreHeat", coreHeat);
|
||||||
nbt.setInteger("hullHeat", hullHeat);
|
nbt.setInteger("hullHeat", hullHeat);
|
||||||
@ -361,6 +420,7 @@ public class TileEntityPWRController extends TileEntityMachineBase implements IG
|
|||||||
|
|
||||||
if(data.hasKey("control")) {
|
if(data.hasKey("control")) {
|
||||||
this.rodTarget = MathHelper.clamp_int(data.getInteger("control"), 0, 100);
|
this.rodTarget = MathHelper.clamp_int(data.getInteger("control"), 0, 100);
|
||||||
|
this.markChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -58,6 +58,7 @@
|
|||||||
"block.hornNearDual": {"category": "block", "sounds": [{"name": "block/hornNearDual", "stream": false}]},
|
"block.hornNearDual": {"category": "block", "sounds": [{"name": "block/hornNearDual", "stream": false}]},
|
||||||
"block.hornFarSingle": {"category": "block", "sounds": [{"name": "block/hornFarSingle", "stream": false}]},
|
"block.hornFarSingle": {"category": "block", "sounds": [{"name": "block/hornFarSingle", "stream": false}]},
|
||||||
"block.hornFarDual": {"category": "block", "sounds": [{"name": "block/hornFarDual", "stream": false}]},
|
"block.hornFarDual": {"category": "block", "sounds": [{"name": "block/hornFarDual", "stream": false}]},
|
||||||
|
"block.reactorLoop": {"category": "block", "sounds": [{"name": "block/reactorLoop", "stream": false}]},
|
||||||
|
|
||||||
"door.TransitionSealOpen": {"category": "block", "sounds": [{"name": "block/door/transition_seal_open", "stream": true}]},
|
"door.TransitionSealOpen": {"category": "block", "sounds": [{"name": "block/door/transition_seal_open", "stream": true}]},
|
||||||
"door.wghStart": {"category": "block", "sounds": [{"name": "block/door/wgh_start", "stream": true}]},
|
"door.wghStart": {"category": "block", "sounds": [{"name": "block/door/wgh_start", "stream": true}]},
|
||||||
|
|||||||
BIN
src/main/resources/assets/hbm/sounds/block/reactorLoop.ogg
Normal file
BIN
src/main/resources/assets/hbm/sounds/block/reactorLoop.ogg
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user