Improve IDSU
This commit is contained in:
parent
c4868a3264
commit
14e30481e5
5 changed files with 29 additions and 287 deletions
|
@ -50,7 +50,7 @@ public enum EGui {
|
|||
DIGITAL_CHEST(true),
|
||||
DESTRUCTOPACK(false),
|
||||
LESU(false),
|
||||
IDSU(false),
|
||||
IDSU(true),
|
||||
CHARGEBENCH(true),
|
||||
FUSION_CONTROLLER(true),
|
||||
VACUUM_FREEZER(true),
|
||||
|
|
|
@ -62,8 +62,6 @@ public class GuiHandler implements IGuiHandler {
|
|||
return new ContainerDestructoPack(player);
|
||||
case LESU:
|
||||
return new ContainerLESU((TileLesu) tile, player);
|
||||
case IDSU:
|
||||
return new ContainerIDSU((TileIDSU) tile, player);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,105 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2017 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IContainerListener;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import reborncore.client.gui.slots.BaseSlot;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.tiles.idsu.TileIDSU;
|
||||
|
||||
public class ContainerIDSU extends RebornContainer {
|
||||
|
||||
public int euOut;
|
||||
public int storedEu;
|
||||
public int euChange;
|
||||
public int channel;
|
||||
EntityPlayer player;
|
||||
TileIDSU tile;
|
||||
|
||||
public ContainerIDSU(TileIDSU tileIDSU, EntityPlayer player) {
|
||||
tile = tileIDSU;
|
||||
this.player = player;
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
this.addSlotToContainer(new BaseSlot(player.inventory, j + i * 9 + 9, 8 + j * 18, 115 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i) {
|
||||
this.addSlotToContainer(new BaseSlot(player.inventory, i, 8 + i * 18, 173));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
for (int i = 0; i < this.listeners.size(); i++) {
|
||||
IContainerListener IContainerListener = this.listeners.get(i);
|
||||
if (this.euOut != tile.maxEnergy) {
|
||||
IContainerListener.sendProgressBarUpdate(this, 0, tile.maxEnergy);
|
||||
}
|
||||
if (this.storedEu != (int) tile.getEnergy()) {
|
||||
IContainerListener.sendProgressBarUpdate(this, 1, (int) tile.getEnergy());
|
||||
}
|
||||
if (this.euChange != tile.getEuChange() && tile.getEuChange() != -1) {
|
||||
IContainerListener.sendProgressBarUpdate(this, 2, (int) tile.getEuChange());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(IContainerListener crafting) {
|
||||
super.addListener(crafting);
|
||||
crafting.sendProgressBarUpdate(this, 0, tile.maxEnergy);
|
||||
crafting.sendProgressBarUpdate(this, 1, (int) tile.getEnergy());
|
||||
crafting.sendProgressBarUpdate(this, 2, (int) tile.getEuChange());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void updateProgressBar(int id, int value) {
|
||||
if (id == 0) {
|
||||
this.euOut = value;
|
||||
} else if (id == 1) {
|
||||
this.storedEu = value;
|
||||
} else if (id == 2) {
|
||||
this.euChange = value;
|
||||
} else if (id == 3) {
|
||||
this.channel = value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -24,95 +24,43 @@
|
|||
|
||||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import reborncore.common.network.NetworkManager;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import techreborn.client.container.ContainerIDSU;
|
||||
import techreborn.packets.PacketIdsu;
|
||||
import techreborn.tiles.idsu.TileIDSU;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
|
||||
public class GuiIDSU extends GuiContainer {
|
||||
|
||||
private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/aesu.png");
|
||||
public class GuiIDSU extends GuiBase {
|
||||
|
||||
TileIDSU idsu;
|
||||
|
||||
ContainerIDSU containerIDSU;
|
||||
|
||||
public GuiIDSU(EntityPlayer player, TileIDSU tileIDSU) {
|
||||
super(new ContainerIDSU(tileIDSU, player));
|
||||
super(player, tileIDSU, tileIDSU.createContainer(player));
|
||||
this.xSize = 176;
|
||||
this.ySize = 197;
|
||||
idsu = tileIDSU;
|
||||
this.containerIDSU = (ContainerIDSU) this.inventorySlots;
|
||||
}
|
||||
|
||||
public static boolean isInteger(String s) {
|
||||
return isInteger(s, 10);
|
||||
}
|
||||
|
||||
public static boolean isInteger(String s, int radix) {
|
||||
if (s.isEmpty())
|
||||
return false;
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
if (i == 0 && s.charAt(i) == '-') {
|
||||
if (s.length() == 1)
|
||||
return false;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
if (Character.digit(s.charAt(i), radix) < 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
this.buttonList.clear();
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
this.buttonList.add(new GuiButton(0, k + 115, l + 5, 15, 20, "++"));
|
||||
this.buttonList.add(new GuiButton(1, k + 115, l + 5 + 20, 15, 20, "+"));
|
||||
this.buttonList.add(new GuiButton(2, k + 115, l + 5 + (20 * 2), 15, 20, "-"));
|
||||
this.buttonList.add(new GuiButton(3, k + 115, l + 5 + (20 * 3), 15, 20, "--"));
|
||||
this.buttonList.add(new GuiButton(4, k + 40, l + 10, 10, 10, "+"));
|
||||
protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
||||
final Layer layer = Layer.BACKGROUND;
|
||||
|
||||
this.drawSlot(62, 45, layer);
|
||||
this.drawSlot(98, 45, layer);
|
||||
this.drawArmourSlots(8, 18, layer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(texture);
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
||||
}
|
||||
protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
final Layer layer = Layer.FOREGROUND;
|
||||
|
||||
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
|
||||
this.fontRendererObj.drawString(I18n.translateToLocal("tile.techreborn.idsu.name"), 75, 10,
|
||||
Color.WHITE.getRGB());
|
||||
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerIDSU.euOut) + "/tick", 10, 22,
|
||||
Color.WHITE.getRGB());
|
||||
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerIDSU.storedEu), 10, 32,
|
||||
Color.WHITE.getRGB());
|
||||
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerIDSU.euChange) + " change", 10, 42,
|
||||
Color.WHITE.getRGB());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button) throws IOException {
|
||||
super.actionPerformed(button);
|
||||
NetworkManager.sendToServer(new PacketIdsu(button.id, idsu));
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scale(0.6, 0.6, 1);
|
||||
this.drawCentredString(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) this.idsu.getEnergy()) + "/" + PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) this.idsu.getMaxPower()) + " " + PowerSystem.getDisplayPower().abbreviation, 35, 0, 58, layer);
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
this.builder.drawMultiEnergyBar(this, 81, 28, (int) this.idsu.getEnergy(), (int) this.idsu.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue