Make things better
This commit is contained in:
parent
32c86b535b
commit
a785d2a514
9 changed files with 156 additions and 165 deletions
|
@ -1,12 +1,9 @@
|
||||||
package techreborn.client.container.builder;
|
package techreborn.client.container.builder;
|
||||||
|
|
||||||
import org.apache.commons.lang3.Range;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||||
|
import org.apache.commons.lang3.Range;
|
||||||
import reborncore.client.gui.slots.BaseSlot;
|
import reborncore.client.gui.slots.BaseSlot;
|
||||||
|
|
||||||
import techreborn.client.container.builder.slot.FilteredSlot;
|
import techreborn.client.container.builder.slot.FilteredSlot;
|
||||||
|
|
||||||
public final class ContainerPlayerInventoryBuilder {
|
public final class ContainerPlayerInventoryBuilder {
|
||||||
|
@ -72,10 +69,10 @@ public final class ContainerPlayerInventoryBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ContainerPlayerArmorInventoryBuilder armor(final int index, final int xStart, final int yStart,
|
private ContainerPlayerArmorInventoryBuilder armor(final int index, final int xStart, final int yStart,
|
||||||
final EntityEquipmentSlot slotType) {
|
final EntityEquipmentSlot slotType) {
|
||||||
|
|
||||||
this.parent.parent.slots.add(new FilteredSlot(this.parent.player, index, xStart, yStart)
|
this.parent.parent.slots.add(new FilteredSlot(this.parent.player, index, xStart, yStart)
|
||||||
.setFilter(stack -> stack.getItem().isValidArmor(stack, slotType, this.parent.player.player)));
|
.setFilter(stack -> stack.getItem().isValidArmor(stack, slotType, this.parent.player.player)));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,8 +93,8 @@ public final class ContainerPlayerInventoryBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContainerPlayerArmorInventoryBuilder complete(final int xStart, final int yStart) {
|
public ContainerPlayerArmorInventoryBuilder complete(final int xStart, final int yStart) {
|
||||||
return this.helmet(xStart, yStart).chestplate(xStart, yStart + 19).leggings(xStart, yStart + 38)
|
return this.helmet(xStart, yStart).chestplate(xStart, yStart + 18).leggings(xStart, yStart + 18 + 18)
|
||||||
.boots(xStart, yStart + 57);
|
.boots(xStart, yStart + 18 + 18 + 18);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContainerPlayerInventoryBuilder addArmor() {
|
public ContainerPlayerInventoryBuilder addArmor() {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.text.translation.I18n;
|
import net.minecraft.util.text.translation.I18n;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
import techreborn.client.gui.widget.GuiButtonPowerBar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Prospector
|
* Created by Prospector
|
||||||
|
@ -26,30 +27,41 @@ public class GuiBase extends GuiContainer {
|
||||||
this.container = container;
|
this.container = container;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawSlotForeground(int x, int y) {
|
protected void drawSlot(int x, int y, Layer layer) {
|
||||||
|
if (layer == Layer.BACKGROUND) {
|
||||||
|
x += guiLeft;
|
||||||
|
y += guiTop;
|
||||||
|
}
|
||||||
builder.drawSlot(this, x - 1, y - 1);
|
builder.drawSlot(this, x - 1, y - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawSlotBackground(int x, int y) {
|
protected void drawArmourSlots(int x, int y, Layer layer) {
|
||||||
drawSlotForeground(guiLeft + x, guiTop + y);
|
if (layer == Layer.BACKGROUND) {
|
||||||
|
x += guiLeft;
|
||||||
|
y += guiTop;
|
||||||
|
}
|
||||||
|
builder.drawSlot(this, x - 1, y - 1);
|
||||||
|
builder.drawSlot(this, x - 1, y - 1 + 18);
|
||||||
|
builder.drawSlot(this, x - 1, y - 1 + 18 + 18);
|
||||||
|
builder.drawSlot(this, x - 1, y - 1 + 18 + 18 + 18);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawOutputSlotForeground(int x, int y) {
|
protected void drawOutputSlot(int x, int y, Layer layer) {
|
||||||
|
if (layer == Layer.BACKGROUND) {
|
||||||
|
x += guiLeft;
|
||||||
|
y += guiTop;
|
||||||
|
}
|
||||||
builder.drawOutputSlot(this, x - 1, y - 1);
|
builder.drawOutputSlot(this, x - 1, y - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawOutputSlotBackground(int x, int y) {
|
protected void drawSelectedStack(int x, int y, Layer layer) {
|
||||||
drawOutputSlotForeground(guiLeft + x, guiTop + y);
|
if (layer == Layer.BACKGROUND) {
|
||||||
}
|
x += guiLeft;
|
||||||
|
y += guiTop;
|
||||||
protected void drawSelectedStackForeground(int x, int y) {
|
}
|
||||||
builder.drawSelectedStack(this, x, y);
|
builder.drawSelectedStack(this, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawSelectedStackBackground(int x, int y) {
|
|
||||||
drawSelectedStackForeground(guiLeft + x, guiTop + y);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initGui() {
|
public void initGui() {
|
||||||
super.initGui();
|
super.initGui();
|
||||||
|
@ -69,25 +81,46 @@ public class GuiBase extends GuiContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawTitle() {
|
protected void drawTitle() {
|
||||||
drawCentredString(I18n.translateToLocal(tile.getBlockType().getUnlocalizedName() + ".name"), 6, 4210752);
|
drawCentredString(I18n.translateToLocal(tile.getBlockType().getUnlocalizedName() + ".name"), 6, 4210752, Layer.FOREGROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawCentredString(String string, int y, int colour) {
|
protected void drawCentredString(String string, int y, int colour, Layer layer) {
|
||||||
drawString(string, (xSize / 2 - mc.fontRendererObj.getStringWidth(string) / 2), y, colour);
|
drawString(string, (xSize / 2 - mc.fontRendererObj.getStringWidth(string) / 2), y, colour, layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawCentredString(String string, int y, int colour, int modifier) {
|
protected void drawCentredString(String string, int y, int colour, int modifier, Layer layer) {
|
||||||
drawString(string, (xSize / 2 - (mc.fontRendererObj.getStringWidth(string)) / 2) + modifier, y, colour);
|
drawString(string, (xSize / 2 - (mc.fontRendererObj.getStringWidth(string)) / 2) + modifier, y, colour, layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawString(String string, int x, int y, int colour) {
|
protected void drawString(String string, int x, int y, int colour, Layer layer) {
|
||||||
mc.fontRendererObj.drawString(string, x, y, colour);
|
int factorX = 0;
|
||||||
|
int factorY = 0;
|
||||||
|
if (layer == Layer.BACKGROUND) {
|
||||||
|
factorX = guiLeft;
|
||||||
|
factorY = guiTop;
|
||||||
|
}
|
||||||
|
mc.fontRendererObj.drawString(string, x + factorX, y + factorY, colour);
|
||||||
GlStateManager.color(1, 1, 1, 1);
|
GlStateManager.color(1, 1, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addPowerButton(int x, int y, int id, Layer layer) {
|
||||||
|
buttonList.clear();
|
||||||
|
int factorX = 0;
|
||||||
|
int factorY = 0;
|
||||||
|
if (layer == Layer.BACKGROUND) {
|
||||||
|
factorX = guiLeft;
|
||||||
|
factorY = guiTop;
|
||||||
|
}
|
||||||
|
buttonList.add(new GuiButtonPowerBar(0, x + factorX, y + factorY, this, layer));
|
||||||
|
}
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
public enum SlotRender {
|
public enum SlotRender {
|
||||||
STANDARD, OUTPUT, NONE, SPRITE;
|
STANDARD, OUTPUT, NONE, SPRITE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum Layer {
|
||||||
|
BACKGROUND, FOREGROUND
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
import techreborn.client.container.builder.ContainerBuilder;
|
import techreborn.client.container.builder.ContainerBuilder;
|
||||||
import techreborn.client.gui.widget.GuiButtonPowerBar;
|
|
||||||
import techreborn.tiles.storage.TileBatBox;
|
import techreborn.tiles.storage.TileBatBox;
|
||||||
|
|
||||||
public class GuiBatbox extends GuiBase {
|
public class GuiBatbox extends GuiBase {
|
||||||
|
@ -19,19 +18,20 @@ public class GuiBatbox extends GuiBase {
|
||||||
@Override
|
@Override
|
||||||
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
|
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
|
||||||
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
||||||
|
Layer layer = Layer.BACKGROUND;
|
||||||
|
|
||||||
this.buttonList.clear();
|
drawSlot(62, 45, layer);
|
||||||
drawSlotBackground(62, 45);
|
drawSlot(98, 45, layer);
|
||||||
drawSlotBackground(98, 45);
|
|
||||||
this.buttonList.add(new GuiButtonPowerBar(0, guiLeft + 82, guiTop + 29));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||||
builder.drawMultiEnergyBar(this, 81, 28, (int) tile.getEnergy(), (int) tile.getMaxPower(), mouseX - guiLeft, mouseY - guiTop);
|
Layer layer = Layer.FOREGROUND;
|
||||||
|
|
||||||
|
builder.drawMultiEnergyBar(this, 81, 28, (int) tile.getEnergy(), (int) tile.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||||
GlStateManager.scale(0.6, 0.6, 5);
|
GlStateManager.scale(0.6, 0.6, 5);
|
||||||
drawCentredString(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) (tile.getEnergy())) + "/" + PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) (tile.getMaxPower())) + " " + PowerSystem.getDisplayPower().abbreviation, 35, 0, 58);
|
drawCentredString(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) (tile.getEnergy())) + "/" + PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) (tile.getMaxPower())) + " " + PowerSystem.getDisplayPower().abbreviation, 35, 0, 58, layer);
|
||||||
GlStateManager.scale(1, 1, 1);
|
GlStateManager.scale(1, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,19 +17,22 @@ public class GuiDigitalChest extends GuiBase {
|
||||||
@Override
|
@Override
|
||||||
protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) {
|
protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) {
|
||||||
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
||||||
|
Layer layer = Layer.BACKGROUND;
|
||||||
|
|
||||||
this.drawSlotBackground(80, 24);
|
this.drawSlot(80, 24, layer);
|
||||||
this.drawSlotBackground(80, 64);
|
this.drawSlot(80, 64, layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) {
|
protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) {
|
||||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||||
|
Layer layer = Layer.FOREGROUND;
|
||||||
|
|
||||||
if (this.tile.storedItem != ItemStack.EMPTY && this.tile.getStackInSlot(1) != null) {
|
if (this.tile.storedItem != ItemStack.EMPTY && this.tile.getStackInSlot(1) != null) {
|
||||||
this.builder.drawBigBlueBar(this, 31, 43, this.tile.storedItem.getCount() + this.tile.getStackInSlot(1).getCount(), this.tile.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored");
|
this.builder.drawBigBlueBar(this, 31, 43, this.tile.storedItem.getCount() + this.tile.getStackInSlot(1).getCount(), this.tile.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored", layer);
|
||||||
}
|
}
|
||||||
if (this.tile.storedItem == ItemStack.EMPTY && this.tile.getStackInSlot(1) != null) {
|
if (this.tile.storedItem == ItemStack.EMPTY && this.tile.getStackInSlot(1) != null) {
|
||||||
this.builder.drawBigBlueBar(this, 31, 43, this.tile.getStackInSlot(1).getCount(), this.tile.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored");
|
this.builder.drawBigBlueBar(this, 31, 43, this.tile.getStackInSlot(1).getCount(), this.tile.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored", layer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,75 +1,38 @@
|
||||||
package techreborn.client.gui;
|
package techreborn.client.gui;
|
||||||
|
|
||||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraft.util.text.translation.I18n;
|
|
||||||
|
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
|
|
||||||
import techreborn.client.container.builder.ContainerBuilder;
|
import techreborn.client.container.builder.ContainerBuilder;
|
||||||
import techreborn.tiles.storage.TileMFE;
|
import techreborn.tiles.storage.TileMFE;
|
||||||
|
|
||||||
/**
|
public class GuiMFE extends GuiBase {
|
||||||
* Created by Rushmead
|
|
||||||
*/
|
|
||||||
public class GuiMFE extends GuiContainer {
|
|
||||||
|
|
||||||
public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/mfe.png");
|
TileMFE tile;
|
||||||
|
|
||||||
TileMFE generator;
|
public GuiMFE(final EntityPlayer player, final TileMFE tile) {
|
||||||
|
super(player, tile, new ContainerBuilder("mfe").player(player.inventory).inventory().hotbar().armor().complete(8, 18).addArmor().addInventory().tile(tile).energySlot(0, 62, 45).energySlot(1, 98, 45).syncEnergyValue().addInventory().create());
|
||||||
|
this.tile = tile;
|
||||||
public GuiMFE(final EntityPlayer player, final TileMFE generator) {
|
|
||||||
super(new ContainerBuilder("mfe").player(player.inventory).inventory(8, 84).hotbar(8, 142).armor()
|
|
||||||
.complete(44, 6).addArmor().addInventory().tile(generator).energySlot(0, 80, 17).energySlot(1, 80, 53)
|
|
||||||
.syncEnergyValue().addInventory().create());
|
|
||||||
this.xSize = 176;
|
|
||||||
this.ySize = 167;
|
|
||||||
this.generator = generator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initGui() {
|
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
|
||||||
final int k = (this.width - this.xSize) / 2;
|
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
||||||
final int l = (this.height - this.ySize) / 2;
|
Layer layer = Layer.BACKGROUND;
|
||||||
super.initGui();
|
|
||||||
|
drawSlot(62, 45, layer);
|
||||||
|
drawSlot(98, 45, layer);
|
||||||
|
drawArmourSlots(8, 18, layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawGuiContainerBackgroundLayer(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) {
|
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||||
this.mc.getTextureManager().bindTexture(GuiMFE.texture);
|
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||||
final int k = (this.width - this.xSize) / 2;
|
Layer layer = Layer.FOREGROUND;
|
||||||
final int l = (this.height - this.ySize) / 2;
|
|
||||||
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
|
||||||
|
|
||||||
int j = 0;
|
builder.drawMultiEnergyBar(this, 81, 28, (int) tile.getEnergy(), (int) tile.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||||
|
GlStateManager.scale(0.6, 0.6, 5);
|
||||||
j = this.generator.getEnergyScaled(24);
|
drawCentredString(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) (tile.getEnergy())) + "/" + PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) (tile.getMaxPower())) + " " + PowerSystem.getDisplayPower().abbreviation, 35, 0, 58, layer);
|
||||||
if (j > 0) {
|
GlStateManager.scale(1, 1, 1);
|
||||||
this.drawTexturedModalRect(k + 109, l + 21 + 12, 176, 0, j + 1, 16);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// if (containerGenerator.burnTime != 0)
|
|
||||||
// {
|
|
||||||
// j = containerGenerator.getScaledBurnTime(13);
|
|
||||||
// this.drawTexturedModalRect(k + 80, l + 38 + 12 - j, 176, 30 - j, 14,
|
|
||||||
// j + 1);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
|
|
||||||
final String name = I18n.translateToLocal("tile.techreborn.mfe.name");
|
|
||||||
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
|
|
||||||
4210752);
|
|
||||||
|
|
||||||
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), this.xSize - 60,
|
|
||||||
this.ySize - 96 + 2, 4210752);
|
|
||||||
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(this.generator.getMaxPower()), 110, this.ySize - 150,
|
|
||||||
4210752);
|
|
||||||
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(this.generator.getEnergy()), 110,
|
|
||||||
this.ySize - 160,
|
|
||||||
4210752);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,73 +1,38 @@
|
||||||
package techreborn.client.gui;
|
package techreborn.client.gui;
|
||||||
|
|
||||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraft.util.text.translation.I18n;
|
|
||||||
|
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
|
|
||||||
import techreborn.client.container.builder.ContainerBuilder;
|
import techreborn.client.container.builder.ContainerBuilder;
|
||||||
import techreborn.tiles.storage.TileMFSU;
|
import techreborn.tiles.storage.TileMFSU;
|
||||||
|
|
||||||
/**
|
public class GuiMFSU extends GuiBase {
|
||||||
* Created by Rushmead
|
|
||||||
*/
|
|
||||||
public class GuiMFSU extends GuiContainer {
|
|
||||||
|
|
||||||
public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/mfsu.png");
|
TileMFSU tile;
|
||||||
|
|
||||||
TileMFSU generator;
|
public GuiMFSU(final EntityPlayer player, final TileMFSU tile) {
|
||||||
|
super(player, tile, new ContainerBuilder("mfsu").player(player.inventory).inventory().hotbar().armor().complete(8, 18).addArmor().addInventory().tile(tile).energySlot(0, 62, 45).energySlot(1, 98, 45).syncEnergyValue().addInventory().create());
|
||||||
public GuiMFSU(final EntityPlayer player, final TileMFSU generator) {
|
this.tile = tile;
|
||||||
super(new ContainerBuilder("mfsu").player(player.inventory).inventory(8, 84).hotbar(8, 142).armor()
|
|
||||||
.complete(44, 6).addArmor().addInventory().tile(generator).energySlot(0, 80, 17).energySlot(1, 80, 53)
|
|
||||||
.syncEnergyValue().addInventory().create());
|
|
||||||
this.xSize = 176;
|
|
||||||
this.ySize = 167;
|
|
||||||
this.generator = generator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initGui() {
|
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
|
||||||
final int k = (this.width - this.xSize) / 2;
|
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
||||||
final int l = (this.height - this.ySize) / 2;
|
Layer layer = Layer.BACKGROUND;
|
||||||
super.initGui();
|
|
||||||
|
drawSlot(62, 45, layer);
|
||||||
|
drawSlot(98, 45, layer);
|
||||||
|
drawArmourSlots(8, 18, layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawGuiContainerBackgroundLayer(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) {
|
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||||
this.mc.getTextureManager().bindTexture(GuiMFSU.texture);
|
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||||
final int k = (this.width - this.xSize) / 2;
|
Layer layer = Layer.FOREGROUND;
|
||||||
final int l = (this.height - this.ySize) / 2;
|
|
||||||
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
|
||||||
|
|
||||||
int j = 0;
|
builder.drawMultiEnergyBar(this, 81, 28, (int) tile.getEnergy(), (int) tile.getMaxPower(), mouseX, mouseY, 0, layer);
|
||||||
|
GlStateManager.scale(0.6, 0.6, 5);
|
||||||
j = this.generator.getEnergyScaled(24);
|
drawCentredString(PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) (tile.getEnergy())) + "/" + PowerSystem.getLocaliszedPowerFormattedNoSuffix((int) (tile.getMaxPower())) + " " + PowerSystem.getDisplayPower().abbreviation, 35, 0, 58, layer);
|
||||||
if (j > 0) {
|
GlStateManager.scale(1, 1, 1);
|
||||||
this.drawTexturedModalRect(k + 109, l + 21 + 12, 176, 0, j + 1, 16);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// if (containerGenerator.burnTime != 0)
|
|
||||||
// {
|
|
||||||
// j = containerGenerator.getScaledBurnTime(13);
|
|
||||||
// this.drawTexturedModalRect(k + 80, l + 38 + 12 - j, 176, 30 - j, 14,
|
|
||||||
// j + 1);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void drawGuiContainerForegroundLayer(final int p_146979_1_, final int p_146979_2_) {
|
|
||||||
final String name = I18n.translateToLocal("tile.techreborn.mfsu.name");
|
|
||||||
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
|
|
||||||
4210752);
|
|
||||||
|
|
||||||
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), this.xSize - 60,
|
|
||||||
this.ySize - 96 + 2, 4210752);
|
|
||||||
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(this.generator.getMaxPower()), 110, this.ySize - 150,
|
|
||||||
4210752);
|
|
||||||
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(this.generator.getEnergy()), 110,
|
|
||||||
this.ySize - 160, 4210752);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,20 +15,24 @@ public class GuiQuantumChest extends GuiBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
|
protected void drawGuiContainerBackgroundLayer(final float f, final int mouseX, final int mouseY) {
|
||||||
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
||||||
|
Layer layer = Layer.BACKGROUND;
|
||||||
|
|
||||||
drawSlotBackground(80, 24);
|
this.drawSlot(80, 24, layer);
|
||||||
drawSlotBackground(80, 64);
|
this.drawSlot(80, 64, layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
@Override
|
||||||
|
protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) {
|
||||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||||
if (tile.storedItem != ItemStack.EMPTY && tile.getStackInSlot(1) != null) {
|
Layer layer = Layer.FOREGROUND;
|
||||||
builder.drawBigBlueBar(this, 31, 43, tile.storedItem.getCount() + tile.getStackInSlot(1).getCount(), tile.maxCapacity, mouseX - guiLeft, mouseY - guiTop, "Stored");
|
|
||||||
|
if (this.tile.storedItem != ItemStack.EMPTY && this.tile.getStackInSlot(1) != null) {
|
||||||
|
this.builder.drawBigBlueBar(this, 31, 43, this.tile.storedItem.getCount() + this.tile.getStackInSlot(1).getCount(), this.tile.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored", layer);
|
||||||
}
|
}
|
||||||
if (tile.storedItem == ItemStack.EMPTY && tile.getStackInSlot(1) != null) {
|
if (this.tile.storedItem == ItemStack.EMPTY && this.tile.getStackInSlot(1) != null) {
|
||||||
builder.drawBigBlueBar(this, 31, 43, tile.getStackInSlot(1).getCount(), tile.maxCapacity, mouseX - guiLeft, mouseY - guiTop, "Stored");
|
this.builder.drawBigBlueBar(this, 31, 43, this.tile.getStackInSlot(1).getCount(), this.tile.maxCapacity, mouseX - this.guiLeft, mouseY - this.guiTop, "Stored", layer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,15 @@ public class TRBuilder extends GuiBuilder {
|
||||||
super(GUI_SHEET);
|
super(GUI_SHEET);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawMultiEnergyBar(GuiBase gui, int x, int y, int energyStored, int maxEnergyStored, int mouseX, int mouseY) {
|
public void drawMultiEnergyBar(GuiBase gui, int x, int y, int energyStored, int maxEnergyStored, int mouseX, int mouseY, int buttonID, GuiBase.Layer layer) {
|
||||||
|
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||||
|
x += gui.getGuiLeft();
|
||||||
|
y += gui.getGuiTop();
|
||||||
|
}
|
||||||
|
if (layer == GuiBase.Layer.FOREGROUND) {
|
||||||
|
mouseX -= gui.getGuiLeft();
|
||||||
|
mouseY -= gui.getGuiTop();
|
||||||
|
}
|
||||||
Minecraft.getMinecraft().getTextureManager().bindTexture(GUI_SHEET);
|
Minecraft.getMinecraft().getTextureManager().bindTexture(GUI_SHEET);
|
||||||
|
|
||||||
gui.drawTexturedModalRect(x, y, PowerSystem.getDisplayPower().xBar - 15, PowerSystem.getDisplayPower().yBar - 1, 14, 50);
|
gui.drawTexturedModalRect(x, y, PowerSystem.getDisplayPower().xBar - 15, PowerSystem.getDisplayPower().yBar - 1, 14, 50);
|
||||||
|
@ -49,9 +57,14 @@ public class TRBuilder extends GuiBuilder {
|
||||||
GlStateManager.disableLighting();
|
GlStateManager.disableLighting();
|
||||||
GlStateManager.color(1, 1, 1, 1);
|
GlStateManager.color(1, 1, 1, 1);
|
||||||
}
|
}
|
||||||
|
gui.addPowerButton(x, y, buttonID, layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawBigBlueBar(GuiBase gui, int x, int y, int value, int max, int mouseX, int mouseY, String suffix) {
|
public void drawBigBlueBar(GuiBase gui, int x, int y, int value, int max, int mouseX, int mouseY, String suffix, GuiBase.Layer layer) {
|
||||||
|
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||||
|
x += gui.getGuiLeft();
|
||||||
|
y += gui.getGuiTop();
|
||||||
|
}
|
||||||
gui.mc.getTextureManager().bindTexture(GUI_SHEET);
|
gui.mc.getTextureManager().bindTexture(GUI_SHEET);
|
||||||
if (!suffix.equals("")) {
|
if (!suffix.equals("")) {
|
||||||
suffix = " " + suffix;
|
suffix = " " + suffix;
|
||||||
|
@ -61,7 +74,7 @@ public class TRBuilder extends GuiBuilder {
|
||||||
if (j < 0)
|
if (j < 0)
|
||||||
j = 0;
|
j = 0;
|
||||||
gui.drawTexturedModalRect(x + 4, y + 4, 0, 236, j, 10);
|
gui.drawTexturedModalRect(x + 4, y + 4, 0, 236, j, 10);
|
||||||
gui.drawCentredString(value + suffix, y + 5, 0xFFFFFF);
|
gui.drawCentredString(value + suffix, y + 5, 0xFFFFFF, layer);
|
||||||
if (isInRect(x, y, 114, 18, mouseX, mouseY)) {
|
if (isInRect(x, y, 114, 18, mouseX, mouseY)) {
|
||||||
int percentage = percentage(max, value);
|
int percentage = percentage(max, value);
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
|
@ -79,8 +92,8 @@ public class TRBuilder extends GuiBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawBigBlueBar(GuiBase gui, int x, int y, int value, int max, int mouseX, int mouseY) {
|
public void drawBigBlueBar(GuiBase gui, int x, int y, int value, int max, int mouseX, int mouseY, GuiBase.Layer layer) {
|
||||||
drawBigBlueBar(gui, x, y, value, max, mouseX, mouseY, "");
|
drawBigBlueBar(gui, x, y, value, max, mouseX, mouseY, "", layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawSelectedStack(GuiBase gui, int x, int y) {
|
public void drawSelectedStack(GuiBase gui, int x, int y) {
|
||||||
|
|
|
@ -3,17 +3,30 @@ package techreborn.client.gui.widget;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
|
import techreborn.client.gui.GuiBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Prospector
|
* Created by Prospector
|
||||||
*/
|
*/
|
||||||
public class GuiButtonPowerBar extends GuiButton {
|
public class GuiButtonPowerBar extends GuiButton {
|
||||||
public GuiButtonPowerBar(int buttonId, int x, int y) {
|
|
||||||
|
GuiBase.Layer layer;
|
||||||
|
GuiBase gui;
|
||||||
|
|
||||||
|
public GuiButtonPowerBar(int buttonId, int x, int y, GuiBase gui, GuiBase.Layer layer) {
|
||||||
super(buttonId, x, y, 12, 48, "");
|
super(buttonId, x, y, 12, 48, "");
|
||||||
|
this.layer = layer;
|
||||||
|
this.gui = gui;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) {
|
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) {
|
||||||
|
|
||||||
|
if (layer == GuiBase.Layer.FOREGROUND) {
|
||||||
|
mouseX -= gui.getGuiLeft();
|
||||||
|
mouseY -= gui.getGuiTop();
|
||||||
|
}
|
||||||
|
|
||||||
if (this.enabled && this.visible && mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height) {
|
if (this.enabled && this.visible && mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height) {
|
||||||
PowerSystem.bumpPowerConfig();
|
PowerSystem.bumpPowerConfig();
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue