Finished the new energy and fluid displays~

This commit is contained in:
Ellpeck 2016-07-21 13:22:55 +02:00
parent 5dc1951fa1
commit 3390a41a83
38 changed files with 195 additions and 214 deletions

View file

@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.event;
import de.ellpeck.actuallyadditions.mod.blocks.IHudDisplay; import de.ellpeck.actuallyadditions.mod.blocks.IHudDisplay;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.inventory.gui.EnergyDisplay;
import de.ellpeck.actuallyadditions.mod.tile.IEnergyDisplay; import de.ellpeck.actuallyadditions.mod.tile.IEnergyDisplay;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
@ -45,6 +46,8 @@ public class ClientEvents{
private static final String ADVANCED_INFO_TEXT_PRE = TextFormatting.DARK_GRAY+" "; private static final String ADVANCED_INFO_TEXT_PRE = TextFormatting.DARK_GRAY+" ";
private static final String ADVANCED_INFO_HEADER_PRE = TextFormatting.GRAY+" -"; private static final String ADVANCED_INFO_HEADER_PRE = TextFormatting.GRAY+" -";
private static final EnergyDisplay ENERGY_DISPLAY = new EnergyDisplay(0, 0, null);
public ClientEvents(){ public ClientEvents(){
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
} }
@ -172,8 +175,8 @@ public class ClientEvents{
IEnergyDisplay display = (IEnergyDisplay)tileHit; IEnergyDisplay display = (IEnergyDisplay)tileHit;
if(!display.needsHoldShift() || player.isSneaking()){ if(!display.needsHoldShift() || player.isSneaking()){
profiler.startSection("EnergyDisplay"); profiler.startSection("EnergyDisplay");
String strg = display.getEnergy()+"/"+display.getMaxEnergy()+" RF"; ENERGY_DISPLAY.setData(2, event.getResolution().getScaledHeight()-96, display.getEnergyStorage(), true, true);
font.drawStringWithShadow(TextFormatting.GOLD+strg, event.getResolution().getScaledWidth()/2+5, event.getResolution().getScaledHeight()/2-10, StringUtil.DECIMAL_COLOR_WHITE); ENERGY_DISPLAY.draw();
profiler.endSection(); profiler.endSection();
} }
} }

View file

@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui;
import cofh.api.energy.EnergyStorage; import cofh.api.energy.EnergyStorage;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.Gui;
import net.minecraftforge.fml.client.config.GuiUtils; import net.minecraftforge.fml.client.config.GuiUtils;
@ -20,20 +21,26 @@ import java.util.Collections;
public class EnergyDisplay extends Gui{ public class EnergyDisplay extends Gui{
private final EnergyStorage rfReference; private EnergyStorage rfReference;
private final int x; private int x;
private final int y; private int y;
private final boolean outline; private boolean outline;
private boolean drawTextNextTo;
public EnergyDisplay(int x, int y, EnergyStorage rfReference, boolean outline){ public EnergyDisplay(int x, int y, EnergyStorage rfReference, boolean outline, boolean drawTextNextTo){
this.setData(x, y, rfReference, outline, drawTextNextTo);
}
public EnergyDisplay(int x, int y, EnergyStorage rfReference){
this(x, y, rfReference, false, false);
}
public void setData(int x, int y, EnergyStorage rfReference, boolean outline, boolean drawTextNextTo){
this.x = x; this.x = x;
this.y = y; this.y = y;
this.rfReference = rfReference; this.rfReference = rfReference;
this.outline = outline; this.outline = outline;
} this.drawTextNextTo = drawTextNextTo;
public EnergyDisplay(int x, int y, EnergyStorage rfReference){
this(x, y, rfReference, false);
} }
public void draw(){ public void draw(){
@ -55,13 +62,20 @@ public class EnergyDisplay extends Gui{
int i = this.rfReference.getEnergyStored()*83/this.rfReference.getMaxEnergyStored(); int i = this.rfReference.getEnergyStored()*83/this.rfReference.getMaxEnergyStored();
this.drawTexturedModalRect(barX+1, barY+84-i, 36, 172, 16, i); this.drawTexturedModalRect(barX+1, barY+84-i, 36, 172, 16, i);
} }
if(this.drawTextNextTo){
this.drawString(mc.fontRendererObj, this.getOverlayText(), barX+25, barY+78, StringUtil.DECIMAL_COLOR_WHITE);
}
} }
public void drawOverlay(int mouseX, int mouseY){ public void drawOverlay(int mouseX, int mouseY){
if(mouseX >= this.x && mouseY >= this.y && mouseX < this.x+(this.outline ? 26 : 18) && mouseY < this.y+(this.outline ? 93 : 85)){ if(mouseX >= this.x && mouseY >= this.y && mouseX < this.x+(this.outline ? 26 : 18) && mouseY < this.y+(this.outline ? 93 : 85)){
Minecraft mc = Minecraft.getMinecraft(); Minecraft mc = Minecraft.getMinecraft();
String text = this.rfReference.getEnergyStored()+"/"+this.rfReference.getMaxEnergyStored()+" RF"; GuiUtils.drawHoveringText(Collections.singletonList(this.getOverlayText()), mouseX, mouseY, mc.displayWidth, mc.displayHeight, -1, mc.fontRendererObj);
GuiUtils.drawHoveringText(Collections.singletonList(text), mouseX, mouseY, mc.displayWidth, mc.displayHeight, -1, mc.fontRendererObj);
} }
} }
private String getOverlayText(){
return this.rfReference.getEnergyStored()+"/"+this.rfReference.getMaxEnergyStored()+" RF";
}
} }

View file

@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.inventory.gui;
import cofh.api.energy.EnergyStorage; import cofh.api.energy.EnergyStorage;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
@ -25,24 +26,31 @@ import java.util.Collections;
public class FluidDisplay extends Gui{ public class FluidDisplay extends Gui{
private final FluidTank fluidReference; private FluidTank fluidReference;
private Fluid oldFluid; private Fluid oldFluid;
private final int x; private int x;
private final int y; private int y;
private final boolean outline; private boolean outline;
private ResourceLocation resLoc; private ResourceLocation resLoc;
public FluidDisplay(int x, int y, FluidTank fluidReference, boolean outline){ private boolean drawTextNextTo;
public FluidDisplay(int x, int y, FluidTank fluidReference, boolean outline, boolean drawTextNextTo){
this.setData(x, y, fluidReference, outline, drawTextNextTo);
}
public FluidDisplay(int x, int y, FluidTank fluidReference){
this(x, y, fluidReference, false, false);
}
public void setData(int x, int y, FluidTank fluidReference, boolean outline, boolean drawTextNextTo){
this.x = x; this.x = x;
this.y = y; this.y = y;
this.fluidReference = fluidReference; this.fluidReference = fluidReference;
this.outline = outline; this.outline = outline;
} this.drawTextNextTo = drawTextNextTo;
public FluidDisplay(int x, int y, FluidTank fluidReference){
this(x, y, fluidReference, false);
} }
public void draw(){ public void draw(){
@ -82,15 +90,21 @@ public class FluidDisplay extends Gui{
GlStateManager.disableBlend(); GlStateManager.disableBlend();
GlStateManager.enableAlpha(); GlStateManager.enableAlpha();
} }
if(this.drawTextNextTo){
this.drawString(mc.fontRendererObj, this.getOverlayText(), barX+25, barY+78, StringUtil.DECIMAL_COLOR_WHITE);
}
} }
public void drawOverlay(int mouseX, int mouseY){ public void drawOverlay(int mouseX, int mouseY){
if(mouseX >= this.x && mouseY >= this.y && mouseX < this.x+(this.outline ? 26 : 18) && mouseY < this.y+(this.outline ? 93 : 85)){ if(mouseX >= this.x && mouseY >= this.y && mouseX < this.x+(this.outline ? 26 : 18) && mouseY < this.y+(this.outline ? 93 : 85)){
FluidStack stack = this.fluidReference.getFluid();
Minecraft mc = Minecraft.getMinecraft(); Minecraft mc = Minecraft.getMinecraft();
GuiUtils.drawHoveringText(Collections.singletonList(this.getOverlayText()), mouseX, mouseY, mc.displayWidth, mc.displayHeight, -1, mc.fontRendererObj);
}
}
String text = stack == null || stack.getFluid() == null ? "0/"+this.fluidReference.getCapacity()+" mB" : this.fluidReference.getFluidAmount()+"/"+this.fluidReference.getCapacity()+" mB "+stack.getLocalizedName(); private String getOverlayText(){
GuiUtils.drawHoveringText(Collections.singletonList(text), mouseX, mouseY, mc.displayWidth, mc.displayHeight, -1, mc.fontRendererObj); FluidStack stack = this.fluidReference.getFluid();
} return stack == null || stack.getFluid() == null ? "0/"+this.fluidReference.getCapacity()+" mB" : this.fluidReference.getFluidAmount()+"/"+this.fluidReference.getCapacity()+" mB "+stack.getLocalizedName();
} }
} }

View file

@ -28,6 +28,7 @@ public class GuiCoalGenerator extends GuiContainer{
private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("guiCoalGenerator"); private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("guiCoalGenerator");
private final TileEntityCoalGenerator generator; private final TileEntityCoalGenerator generator;
private EnergyDisplay energy;
public GuiCoalGenerator(InventoryPlayer inventory, TileEntityBase tile){ public GuiCoalGenerator(InventoryPlayer inventory, TileEntityBase tile){
super(new ContainerCoalGenerator(inventory, tile)); super(new ContainerCoalGenerator(inventory, tile));
@ -36,13 +37,16 @@ public class GuiCoalGenerator extends GuiContainer{
this.ySize = 93+86; this.ySize = 93+86;
} }
@Override
public void initGui(){
super.initGui();
this.energy = new EnergyDisplay(this.guiLeft+42, this.guiTop+5, this.generator.storage);
}
@Override @Override
public void drawScreen(int x, int y, float f){ public void drawScreen(int x, int y, float f){
super.drawScreen(x, y, f); super.drawScreen(x, y, f);
String text1 = this.generator.storage.getEnergyStored()+"/"+this.generator.storage.getMaxEnergyStored()+" RF"; this.energy.drawOverlay(x, y);
if(x >= this.guiLeft+43 && y >= this.guiTop+6 && x <= this.guiLeft+58 && y <= this.guiTop+88){
this.drawHoveringText(Collections.singletonList(text1), x, y);
}
} }
@Override @Override
@ -60,14 +64,11 @@ public class GuiCoalGenerator extends GuiContainer{
this.mc.getTextureManager().bindTexture(RES_LOC); this.mc.getTextureManager().bindTexture(RES_LOC);
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93);
if(this.generator.storage.getEnergyStored() > 0){
int i = this.generator.getEnergyScaled(83);
this.drawTexturedModalRect(this.guiLeft+43, this.guiTop+89-i, 176, 0, 16, i);
}
if(this.generator.currentBurnTime > 0){ if(this.generator.currentBurnTime > 0){
int i = this.generator.getBurningScaled(13); int i = this.generator.getBurningScaled(13);
this.drawTexturedModalRect(this.guiLeft+87, this.guiTop+27+12-i, 176, 96-i, 14, i); this.drawTexturedModalRect(this.guiLeft+87, this.guiTop+27+12-i, 176, 96-i, 14, i);
} }
this.energy.draw();
} }
} }

View file

@ -41,6 +41,9 @@ public class GuiCoffeeMachine extends GuiContainer{
private final int z; private final int z;
private final World world; private final World world;
private EnergyDisplay energy;
private FluidDisplay fluid;
public GuiCoffeeMachine(InventoryPlayer inventory, TileEntityBase tile, int x, int y, int z, World world){ public GuiCoffeeMachine(InventoryPlayer inventory, TileEntityBase tile, int x, int y, int z, World world){
super(new ContainerCoffeeMachine(inventory, tile)); super(new ContainerCoffeeMachine(inventory, tile));
this.machine = (TileEntityCoffeeMachine)tile; this.machine = (TileEntityCoffeeMachine)tile;
@ -58,6 +61,9 @@ public class GuiCoffeeMachine extends GuiContainer{
GuiButton buttonOkay = new GuiButton(0, this.guiLeft+60, this.guiTop+11, 58, 20, StringUtil.localize("info."+ModUtil.MOD_ID+".gui.ok")); GuiButton buttonOkay = new GuiButton(0, this.guiLeft+60, this.guiTop+11, 58, 20, StringUtil.localize("info."+ModUtil.MOD_ID+".gui.ok"));
this.buttonList.add(buttonOkay); this.buttonList.add(buttonOkay);
this.energy = new EnergyDisplay(this.guiLeft+16, this.guiTop+5, this.machine.storage);
this.fluid = new FluidDisplay(this.guiLeft-30, this.guiTop+1, this.machine.tank, true, false);
} }
@Override @Override
@ -77,6 +83,9 @@ public class GuiCoffeeMachine extends GuiContainer{
if(x >= this.guiLeft+40 && y >= this.guiTop+25 && x <= this.guiLeft+49 && y <= this.guiTop+56){ if(x >= this.guiLeft+40 && y >= this.guiTop+25 && x <= this.guiLeft+49 && y <= this.guiTop+56){
this.drawHoveringText(Collections.singletonList(text2), x, y); this.drawHoveringText(Collections.singletonList(text2), x, y);
} }
this.energy.drawOverlay(x, y);
this.fluid.drawOverlay(x, y);
} }
@Override @Override
@ -94,15 +103,6 @@ public class GuiCoffeeMachine extends GuiContainer{
this.mc.getTextureManager().bindTexture(RES_LOC); this.mc.getTextureManager().bindTexture(RES_LOC);
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93);
if(this.machine.storage.getEnergyStored() > 0){
int i = this.machine.getEnergyScaled(83);
this.drawTexturedModalRect(this.guiLeft+17, this.guiTop+89-i, 176, 0, 6, i);
}
if(this.machine.tank.getFluidAmount() > 0){
int i = this.machine.getWaterScaled(64);
this.drawTexturedModalRect(this.guiLeft+27, this.guiTop+70-i, 182, 0, 6, i);
}
if(this.machine.coffeeCacheAmount > 0){ if(this.machine.coffeeCacheAmount > 0){
int i = this.machine.getCoffeeScaled(30); int i = this.machine.getCoffeeScaled(30);
this.drawTexturedModalRect(this.guiLeft+41, this.guiTop+56-i, 192, 0, 8, i); this.drawTexturedModalRect(this.guiLeft+41, this.guiTop+56-i, 192, 0, 8, i);
@ -115,6 +115,9 @@ public class GuiCoffeeMachine extends GuiContainer{
int j = this.machine.getBrewScaled(26); int j = this.machine.getBrewScaled(26);
this.drawTexturedModalRect(this.guiLeft+99+25-j, this.guiTop+44, 192+25-j, 46, j, 12); this.drawTexturedModalRect(this.guiLeft+99+25-j, this.guiTop+44, 192+25-j, 46, j, 12);
} }
this.energy.draw();
this.fluid.draw();
} }
@Override @Override

View file

@ -28,6 +28,7 @@ public class GuiDirectionalBreaker extends GuiContainer{
private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("guiDirectionalBreaker"); private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("guiDirectionalBreaker");
private final TileEntityDirectionalBreaker breaker; private final TileEntityDirectionalBreaker breaker;
private EnergyDisplay energy;
public GuiDirectionalBreaker(InventoryPlayer inventory, TileEntityBase tile){ public GuiDirectionalBreaker(InventoryPlayer inventory, TileEntityBase tile){
super(new ContainerDirectionalBreaker(inventory, tile)); super(new ContainerDirectionalBreaker(inventory, tile));
@ -36,14 +37,17 @@ public class GuiDirectionalBreaker extends GuiContainer{
this.ySize = 93+86; this.ySize = 93+86;
} }
@Override
public void initGui(){
super.initGui();
this.energy = new EnergyDisplay(this.guiLeft+42, this.guiTop+5, this.breaker.storage);
}
@Override @Override
public void drawScreen(int x, int y, float f){ public void drawScreen(int x, int y, float f){
super.drawScreen(x, y, f); super.drawScreen(x, y, f);
String text1 = this.breaker.storage.getEnergyStored()+"/"+this.breaker.storage.getMaxEnergyStored()+" RF"; this.energy.drawOverlay(x, y);
if(x >= this.guiLeft+43 && y >= this.guiTop+6 && x <= this.guiLeft+58 && y <= this.guiTop+88){
this.drawHoveringText(Collections.singletonList(text1), x, y);
}
} }
@Override @Override
@ -61,9 +65,6 @@ public class GuiDirectionalBreaker extends GuiContainer{
this.mc.getTextureManager().bindTexture(RES_LOC); this.mc.getTextureManager().bindTexture(RES_LOC);
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93);
if(this.breaker.storage.getEnergyStored() > 0){ this.energy.draw();
int i = this.breaker.getEnergyScaled(83);
this.drawTexturedModalRect(this.guiLeft+43, this.guiTop+89-i, 176, 29, 16, i);
}
} }
} }

View file

@ -28,6 +28,7 @@ public class GuiEnergizer extends GuiContainer{
private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("guiEnergizer"); private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("guiEnergizer");
private final TileEntityEnergizer energizer; private final TileEntityEnergizer energizer;
private EnergyDisplay energy;
public GuiEnergizer(EntityPlayer inventory, TileEntityBase tile){ public GuiEnergizer(EntityPlayer inventory, TileEntityBase tile){
super(new ContainerEnergizer(inventory, tile)); super(new ContainerEnergizer(inventory, tile));
@ -36,13 +37,16 @@ public class GuiEnergizer extends GuiContainer{
this.ySize = 93+86; this.ySize = 93+86;
} }
@Override
public void initGui(){
super.initGui();
this.energy = new EnergyDisplay(this.guiLeft+56, this.guiTop+5, this.energizer.storage);
}
@Override @Override
public void drawScreen(int x, int y, float f){ public void drawScreen(int x, int y, float f){
super.drawScreen(x, y, f); super.drawScreen(x, y, f);
String text1 = this.energizer.storage.getEnergyStored()+"/"+this.energizer.storage.getMaxEnergyStored()+" RF"; this.energy.drawOverlay(x, y);
if(x >= this.guiLeft+57 && y >= this.guiTop+6 && x <= this.guiLeft+72 && y <= this.guiTop+88){
this.drawHoveringText(Collections.singletonList(text1), x, y);
}
} }
@Override @Override
@ -60,9 +64,6 @@ public class GuiEnergizer extends GuiContainer{
this.mc.getTextureManager().bindTexture(RES_LOC); this.mc.getTextureManager().bindTexture(RES_LOC);
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93);
if(this.energizer.storage.getEnergyStored() > 0){ this.energy.draw();
int i = this.energizer.getEnergyScaled(83);
this.drawTexturedModalRect(this.guiLeft+57, this.guiTop+89-i, 176, 0, 16, i);
}
} }
} }

View file

@ -28,6 +28,7 @@ public class GuiEnervator extends GuiContainer{
private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("guiEnergizer"); private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("guiEnergizer");
private final TileEntityEnervator enervator; private final TileEntityEnervator enervator;
private EnergyDisplay energy;
public GuiEnervator(EntityPlayer inventory, TileEntityBase tile){ public GuiEnervator(EntityPlayer inventory, TileEntityBase tile){
super(new ContainerEnervator(inventory, tile)); super(new ContainerEnervator(inventory, tile));
@ -36,13 +37,16 @@ public class GuiEnervator extends GuiContainer{
this.ySize = 93+86; this.ySize = 93+86;
} }
@Override
public void initGui(){
super.initGui();
this.energy = new EnergyDisplay(this.guiLeft+56, this.guiTop+5, this.enervator.storage);
}
@Override @Override
public void drawScreen(int x, int y, float f){ public void drawScreen(int x, int y, float f){
super.drawScreen(x, y, f); super.drawScreen(x, y, f);
String text1 = this.enervator.storage.getEnergyStored()+"/"+this.enervator.storage.getMaxEnergyStored()+" RF"; this.energy.drawOverlay(x, y);
if(x >= this.guiLeft+57 && y >= this.guiTop+6 && x <= this.guiLeft+72 && y <= this.guiTop+88){
this.drawHoveringText(Collections.singletonList(text1), x, y);
}
} }
@Override @Override
@ -60,9 +64,6 @@ public class GuiEnervator extends GuiContainer{
this.mc.getTextureManager().bindTexture(RES_LOC); this.mc.getTextureManager().bindTexture(RES_LOC);
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93);
if(this.enervator.storage.getEnergyStored() > 0){ this.energy.draw();
int i = this.enervator.getEnergyScaled(83);
this.drawTexturedModalRect(this.guiLeft+57, this.guiTop+89-i, 176, 0, 16, i);
}
} }
} }

View file

@ -29,6 +29,8 @@ public class GuiFermentingBarrel extends GuiContainer{
private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("guiFermentingBarrel"); private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("guiFermentingBarrel");
private final TileEntityFermentingBarrel press; private final TileEntityFermentingBarrel press;
private FluidDisplay input;
private FluidDisplay output;
public GuiFermentingBarrel(InventoryPlayer inventory, TileEntityBase tile){ public GuiFermentingBarrel(InventoryPlayer inventory, TileEntityBase tile){
super(new ContainerFermentingBarrel(inventory, tile)); super(new ContainerFermentingBarrel(inventory, tile));
@ -40,16 +42,15 @@ public class GuiFermentingBarrel extends GuiContainer{
@Override @Override
public void drawScreen(int x, int y, float f){ public void drawScreen(int x, int y, float f){
super.drawScreen(x, y, f); super.drawScreen(x, y, f);
this.input.drawOverlay(x, y);
String text1 = StringUtil.getFluidInfo(this.press.canolaTank); this.output.drawOverlay(x, y);
if(x >= this.guiLeft+61 && y >= this.guiTop+6 && x <= this.guiLeft+76 && y <= this.guiTop+88){
this.drawHoveringText(Collections.singletonList(text1), x, y);
} }
String text2 = StringUtil.getFluidInfo(this.press.oilTank); @Override
if(x >= this.guiLeft+99 && y >= this.guiTop+6 && x <= this.guiLeft+114 && y <= this.guiTop+88){ public void initGui(){
this.drawHoveringText(Collections.singletonList(text2), x, y); super.initGui();
} this.input = new FluidDisplay(this.guiLeft+60, this.guiTop+5, this.press.canolaTank);
this.output = new FluidDisplay(this.guiLeft+98, this.guiTop+5, this.press.oilTank);
} }
@Override @Override
@ -67,19 +68,12 @@ public class GuiFermentingBarrel extends GuiContainer{
this.mc.getTextureManager().bindTexture(RES_LOC); this.mc.getTextureManager().bindTexture(RES_LOC);
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93);
if(this.press.canolaTank.getFluidAmount() > 0){
int i = this.press.getCanolaTankScaled(83);
this.drawTexturedModalRect(this.guiLeft+61, this.guiTop+89-i, 192, 29, 16, i);
}
if(this.press.oilTank.getFluidAmount() > 0){
int i = this.press.getOilTankScaled(83);
this.drawTexturedModalRect(this.guiLeft+99, this.guiTop+89-i, 176, 29, 16, i);
}
if(this.press.currentProcessTime > 0){ if(this.press.currentProcessTime > 0){
int i = this.press.getProcessScaled(29); int i = this.press.getProcessScaled(29);
this.drawTexturedModalRect(this.guiLeft+82, this.guiTop+34, 176, 0, 12, i); this.drawTexturedModalRect(this.guiLeft+82, this.guiTop+34, 176, 0, 12, i);
} }
this.input.draw();
this.output.draw();
} }
} }

View file

@ -29,6 +29,7 @@ public class GuiFluidCollector extends GuiContainer{
private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("guiFluidCollector"); private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("guiFluidCollector");
private final TileEntityFluidCollector collector; private final TileEntityFluidCollector collector;
private FluidDisplay fluid;
public GuiFluidCollector(InventoryPlayer inventory, TileEntityBase tile){ public GuiFluidCollector(InventoryPlayer inventory, TileEntityBase tile){
super(new ContainerFluidCollector(inventory, tile)); super(new ContainerFluidCollector(inventory, tile));
@ -41,10 +42,13 @@ public class GuiFluidCollector extends GuiContainer{
public void drawScreen(int x, int y, float f){ public void drawScreen(int x, int y, float f){
super.drawScreen(x, y, f); super.drawScreen(x, y, f);
String text2 = StringUtil.getFluidInfo(this.collector.tank); this.fluid.drawOverlay(x, y);
if(x >= this.guiLeft+68 && y >= this.guiTop+6 && x <= this.guiLeft+83 && y <= this.guiTop+88){
this.drawHoveringText(Collections.singletonList(text2), x, y);
} }
@Override
public void initGui(){
super.initGui();
this.fluid = new FluidDisplay(this.guiLeft+67, this.guiTop+5, this.collector.tank);
} }
@Override @Override
@ -62,9 +66,6 @@ public class GuiFluidCollector extends GuiContainer{
this.mc.getTextureManager().bindTexture(RES_LOC); this.mc.getTextureManager().bindTexture(RES_LOC);
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93);
if(this.collector.tank.getFluidAmount() > 0){ this.fluid.draw();
int i = this.collector.getTankScaled(83);
this.drawTexturedModalRect(this.guiLeft+68, this.guiTop+89-i, 176, 0, 16, i);
}
} }
} }

View file

@ -28,6 +28,7 @@ public class GuiFurnaceDouble extends GuiContainer{
private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("guiFurnaceDouble"); private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("guiFurnaceDouble");
private final TileEntityFurnaceDouble tileFurnace; private final TileEntityFurnaceDouble tileFurnace;
private EnergyDisplay energy;
public GuiFurnaceDouble(InventoryPlayer inventory, TileEntityBase tile){ public GuiFurnaceDouble(InventoryPlayer inventory, TileEntityBase tile){
super(new ContainerFurnaceDouble(inventory, tile)); super(new ContainerFurnaceDouble(inventory, tile));
@ -39,10 +40,13 @@ public class GuiFurnaceDouble extends GuiContainer{
@Override @Override
public void drawScreen(int x, int y, float f){ public void drawScreen(int x, int y, float f){
super.drawScreen(x, y, f); super.drawScreen(x, y, f);
String text = this.tileFurnace.storage.getEnergyStored()+"/"+this.tileFurnace.storage.getMaxEnergyStored()+" RF"; this.energy.drawOverlay(x, y);
if(x >= this.guiLeft+28 && y >= this.guiTop+6 && x <= this.guiLeft+43 && y <= this.guiTop+88){
this.drawHoveringText(Collections.singletonList(text), x, y);
} }
@Override
public void initGui(){
super.initGui();
this.energy = new EnergyDisplay(this.guiLeft+27, this.guiTop+5, this.tileFurnace.storage);
} }
@Override @Override
@ -60,10 +64,6 @@ public class GuiFurnaceDouble extends GuiContainer{
this.mc.getTextureManager().bindTexture(RES_LOC); this.mc.getTextureManager().bindTexture(RES_LOC);
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93);
if(this.tileFurnace.storage.getEnergyStored() > 0){
int i = this.tileFurnace.getEnergyScaled(83);
this.drawTexturedModalRect(this.guiLeft+28, this.guiTop+89-i, 176, 44, 16, i);
}
if(this.tileFurnace.firstSmeltTime > 0){ if(this.tileFurnace.firstSmeltTime > 0){
int i = this.tileFurnace.getFirstTimeToScale(23); int i = this.tileFurnace.getFirstTimeToScale(23);
this.drawTexturedModalRect(this.guiLeft+51, this.guiTop+40, 176, 0, 24, i); this.drawTexturedModalRect(this.guiLeft+51, this.guiTop+40, 176, 0, 24, i);
@ -72,5 +72,7 @@ public class GuiFurnaceDouble extends GuiContainer{
int i = this.tileFurnace.getSecondTimeToScale(23); int i = this.tileFurnace.getSecondTimeToScale(23);
this.drawTexturedModalRect(this.guiLeft+101, this.guiTop+40, 176, 22, 24, i); this.drawTexturedModalRect(this.guiLeft+101, this.guiTop+40, 176, 22, 24, i);
} }
this.energy.draw();
} }
} }

View file

@ -30,6 +30,7 @@ public class GuiGrinder extends GuiContainer{
private static final ResourceLocation RES_LOC_DOUBLE = AssetUtil.getGuiLocation("guiGrinderDouble"); private static final ResourceLocation RES_LOC_DOUBLE = AssetUtil.getGuiLocation("guiGrinderDouble");
private final TileEntityGrinder tileGrinder; private final TileEntityGrinder tileGrinder;
private final boolean isDouble; private final boolean isDouble;
private EnergyDisplay energy;
public GuiGrinder(InventoryPlayer inventoryPlayer, TileEntityBase tile){ public GuiGrinder(InventoryPlayer inventoryPlayer, TileEntityBase tile){
this(inventoryPlayer, tile, false); this(inventoryPlayer, tile, false);
@ -43,13 +44,16 @@ public class GuiGrinder extends GuiContainer{
this.ySize = 93+86; this.ySize = 93+86;
} }
@Override
public void initGui(){
super.initGui();
this.energy = new EnergyDisplay(this.guiLeft+(this.isDouble ? 13 : 42), this.guiTop+5, this.tileGrinder.storage);
}
@Override @Override
public void drawScreen(int x, int y, float f){ public void drawScreen(int x, int y, float f){
super.drawScreen(x, y, f); super.drawScreen(x, y, f);
String text = this.tileGrinder.storage.getEnergyStored()+"/"+this.tileGrinder.storage.getMaxEnergyStored()+" RF"; this.energy.drawOverlay(x, y);
if((this.isDouble && x >= this.guiLeft+14 && y >= this.guiTop+6 && x <= this.guiLeft+29 && y <= this.guiTop+88) || (!this.isDouble && x >= this.guiLeft+43 && y >= this.guiTop+6 && x <= this.guiLeft+58 && y <= this.guiTop+88)){
this.drawHoveringText(Collections.singletonList(text), x, y);
}
} }
@Override @Override
@ -67,10 +71,6 @@ public class GuiGrinder extends GuiContainer{
this.mc.getTextureManager().bindTexture(this.isDouble ? RES_LOC_DOUBLE : RES_LOC); this.mc.getTextureManager().bindTexture(this.isDouble ? RES_LOC_DOUBLE : RES_LOC);
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93);
if(this.tileGrinder.storage.getEnergyStored() > 0){
int i = this.tileGrinder.getEnergyScaled(83);
this.drawTexturedModalRect(this.guiLeft+(this.isDouble ? 14 : 43), this.guiTop+89-i, 176, (this.isDouble ? 44 : 23), 16, i);
}
if(this.tileGrinder.firstCrushTime > 0){ if(this.tileGrinder.firstCrushTime > 0){
int i = this.tileGrinder.getFirstTimeToScale(23); int i = this.tileGrinder.getFirstTimeToScale(23);
this.drawTexturedModalRect(this.guiLeft+(this.isDouble ? 51 : 80), this.guiTop+40, 176, 0, 24, i); this.drawTexturedModalRect(this.guiLeft+(this.isDouble ? 51 : 80), this.guiTop+40, 176, 0, 24, i);
@ -81,6 +81,8 @@ public class GuiGrinder extends GuiContainer{
this.drawTexturedModalRect(this.guiLeft+101, this.guiTop+40, 176, 22, 24, i); this.drawTexturedModalRect(this.guiLeft+101, this.guiTop+40, 176, 22, 24, i);
} }
} }
this.energy.draw();
} }
public static class GuiGrinderDouble extends GuiGrinder{ public static class GuiGrinderDouble extends GuiGrinder{

View file

@ -30,6 +30,9 @@ public class GuiOilGenerator extends GuiContainer{
private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("guiOilGenerator"); private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("guiOilGenerator");
private final TileEntityOilGenerator generator; private final TileEntityOilGenerator generator;
private EnergyDisplay energy;
private FluidDisplay fluid;
public GuiOilGenerator(InventoryPlayer inventory, TileEntityBase tile){ public GuiOilGenerator(InventoryPlayer inventory, TileEntityBase tile){
super(new ContainerOilGenerator(inventory, tile)); super(new ContainerOilGenerator(inventory, tile));
this.generator = (TileEntityOilGenerator)tile; this.generator = (TileEntityOilGenerator)tile;
@ -37,17 +40,18 @@ public class GuiOilGenerator extends GuiContainer{
this.ySize = 93+86; this.ySize = 93+86;
} }
@Override
public void initGui(){
super.initGui();
this.energy = new EnergyDisplay(this.guiLeft+42, this.guiTop+5, this.generator.storage);
this.fluid = new FluidDisplay(this.guiLeft+116, this.guiTop+5, this.generator.tank);
}
@Override @Override
public void drawScreen(int x, int y, float f){ public void drawScreen(int x, int y, float f){
super.drawScreen(x, y, f); super.drawScreen(x, y, f);
String text1 = this.generator.storage.getEnergyStored()+"/"+this.generator.storage.getMaxEnergyStored()+" RF"; this.energy.drawOverlay(x, y);
if(x >= this.guiLeft+43 && y >= this.guiTop+6 && x <= this.guiLeft+58 && y <= this.guiTop+88){ this.fluid.drawOverlay(x, y);
this.drawHoveringText(Collections.singletonList(text1), x, y);
}
String text2 = StringUtil.getFluidInfo(this.generator.tank);
if(x >= this.guiLeft+117 && y >= this.guiTop+6 && x <= this.guiLeft+132 && y <= this.guiTop+88){
this.drawHoveringText(Collections.singletonList(text2), x, y);
}
} }
@Override @Override
@ -65,19 +69,12 @@ public class GuiOilGenerator extends GuiContainer{
this.mc.getTextureManager().bindTexture(RES_LOC); this.mc.getTextureManager().bindTexture(RES_LOC);
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93);
if(this.generator.storage.getEnergyStored() > 0){
int i = this.generator.getEnergyScaled(83);
this.drawTexturedModalRect(this.guiLeft+43, this.guiTop+89-i, 176, 0, 16, i);
}
if(this.generator.tank.getFluidAmount() > 0){
int i = this.generator.getTankScaled(83);
this.drawTexturedModalRect(this.guiLeft+117, this.guiTop+89-i, 192, 0, 16, i);
}
if(this.generator.currentBurnTime > 0){ if(this.generator.currentBurnTime > 0){
int i = this.generator.getBurningScaled(13); int i = this.generator.getBurningScaled(13);
this.drawTexturedModalRect(this.guiLeft+72, this.guiTop+44+12-i, 176, 96-i, 14, i); this.drawTexturedModalRect(this.guiLeft+72, this.guiTop+44+12-i, 176, 96-i, 14, i);
} }
this.energy.draw();
this.fluid.draw();
} }
} }

View file

@ -28,6 +28,7 @@ public class GuiRepairer extends GuiContainer{
private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("guiRepairer"); private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("guiRepairer");
private final TileEntityItemRepairer tileRepairer; private final TileEntityItemRepairer tileRepairer;
private EnergyDisplay energy;
public GuiRepairer(InventoryPlayer inventory, TileEntityBase tile){ public GuiRepairer(InventoryPlayer inventory, TileEntityBase tile){
super(new ContainerRepairer(inventory, tile)); super(new ContainerRepairer(inventory, tile));
@ -36,13 +37,16 @@ public class GuiRepairer extends GuiContainer{
this.ySize = 93+86; this.ySize = 93+86;
} }
@Override
public void initGui(){
super.initGui();
this.energy = new EnergyDisplay(this.guiLeft+27, this.guiTop+5, this.tileRepairer.storage);
}
@Override @Override
public void drawScreen(int x, int y, float f){ public void drawScreen(int x, int y, float f){
super.drawScreen(x, y, f); super.drawScreen(x, y, f);
String text = this.tileRepairer.storage.getEnergyStored()+"/"+this.tileRepairer.storage.getMaxEnergyStored()+" RF"; this.energy.drawOverlay(x, y);
if(x >= this.guiLeft+28 && y >= this.guiTop+6 && x <= this.guiLeft+43 && y <= this.guiTop+88){
this.drawHoveringText(Collections.singletonList(text), x, y);
}
} }
@Override @Override
@ -60,13 +64,11 @@ public class GuiRepairer extends GuiContainer{
this.mc.getTextureManager().bindTexture(RES_LOC); this.mc.getTextureManager().bindTexture(RES_LOC);
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93);
if(this.tileRepairer.storage.getEnergyStored() > 0){
int i = this.tileRepairer.getEnergyScaled(83);
this.drawTexturedModalRect(this.guiLeft+28, this.guiTop+89-i, 176, 44, 16, i);
}
if(TileEntityItemRepairer.canBeRepaired(this.tileRepairer.slots[TileEntityItemRepairer.SLOT_INPUT])){ if(TileEntityItemRepairer.canBeRepaired(this.tileRepairer.slots[TileEntityItemRepairer.SLOT_INPUT])){
int i = this.tileRepairer.getItemDamageToScale(22); int i = this.tileRepairer.getItemDamageToScale(22);
this.drawTexturedModalRect(this.guiLeft+73, this.guiTop+52, 176, 28, i, 16); this.drawTexturedModalRect(this.guiLeft+73, this.guiTop+52, 176, 28, i, 16);
} }
this.energy.draw();
} }
} }

View file

@ -10,16 +10,14 @@
package de.ellpeck.actuallyadditions.mod.tile; package de.ellpeck.actuallyadditions.mod.tile;
import cofh.api.energy.EnergyStorage;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
public interface IEnergyDisplay{ public interface IEnergyDisplay{
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
int getEnergy(); EnergyStorage getEnergyStorage();
@SideOnly(Side.CLIENT)
int getMaxEnergy();
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
boolean needsHoldShift(); boolean needsHoldShift();

View file

@ -202,9 +202,8 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
} }
@Override @Override
@SideOnly(Side.CLIENT) public EnergyStorage getEnergyStorage(){
public int getMaxEnergy(){ return this.storage;
return this.storage.getMaxEnergyStored();
} }
@Override @Override

View file

@ -104,13 +104,8 @@ public class TileEntityDisplayStand extends TileEntityInventoryBase implements I
} }
@Override @Override
public int getEnergy(){ public EnergyStorage getEnergyStorage(){
return this.storage.getEnergyStored(); return this.storage;
}
@Override
public int getMaxEnergy(){
return this.storage.getMaxEnergyStored();
} }
@Override @Override

View file

@ -166,14 +166,8 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyRece
} }
@Override @Override
public int getEnergy(){ public EnergyStorage getEnergyStorage(){
return this.storage.getEnergyStored(); return this.storage;
}
@Override
@SideOnly(Side.CLIENT)
public int getMaxEnergy(){
return this.storage.getMaxEnergyStored();
} }
@Override @Override

View file

@ -90,14 +90,8 @@ public class TileEntityFurnaceSolar extends TileEntityBase implements IEnergyPro
} }
@Override @Override
public int getEnergy(){ public EnergyStorage getEnergyStorage(){
return this.storage.getEnergyStored(); return this.storage;
}
@Override
@SideOnly(Side.CLIENT)
public int getMaxEnergy(){
return this.storage.getMaxEnergyStored();
} }
@Override @Override

View file

@ -101,16 +101,9 @@ public class TileEntityHeatCollector extends TileEntityBase implements IEnergyPr
} }
@Override @Override
public int getEnergy(){ public EnergyStorage getEnergyStorage(){
return this.storage.getEnergyStored(); return this.storage;
} }
@Override
@SideOnly(Side.CLIENT)
public int getMaxEnergy(){
return this.storage.getMaxEnergyStored();
}
@Override @Override
public boolean needsHoldShift(){ public boolean needsHoldShift(){
return false; return false;

View file

@ -122,14 +122,8 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I
} }
@Override @Override
public int getEnergy(){ public EnergyStorage getEnergyStorage(){
return this.storage.getEnergyStored(); return this.storage;
}
@Override
@SideOnly(Side.CLIENT)
public int getMaxEnergy(){
return this.storage.getMaxEnergyStored();
} }
@Override @Override

View file

@ -123,14 +123,8 @@ public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyPr
} }
@Override @Override
public int getEnergy(){ public EnergyStorage getEnergyStorage(){
return this.storage.getEnergyStored(); return this.storage;
}
@Override
@SideOnly(Side.CLIENT)
public int getMaxEnergy(){
return this.storage.getMaxEnergyStored();
} }
@Override @Override

View file

@ -234,14 +234,8 @@ public class TileEntityMiner extends TileEntityInventoryBase implements IEnergyR
} }
@Override @Override
public int getEnergy(){ public EnergyStorage getEnergyStorage(){
return this.storage.getEnergyStored(); return this.storage;
}
@Override
@SideOnly(Side.CLIENT)
public int getMaxEnergy(){
return this.storage.getMaxEnergyStored();
} }
@Override @Override

View file

@ -216,13 +216,8 @@ public class TileEntityPlayerInterface extends TileEntityInventoryBase implement
} }
@Override @Override
public int getEnergy(){ public EnergyStorage getEnergyStorage(){
return this.storage.getEnergyStored(); return this.storage;
}
@Override
public int getMaxEnergy(){
return this.storage.getMaxEnergyStored();
} }
@Override @Override

View file

@ -98,13 +98,8 @@ public class TileEntityShockSuppressor extends TileEntityBase implements IEnergy
} }
@Override @Override
public int getEnergy(){ public EnergyStorage getEnergyStorage(){
return this.storage.getEnergyStored(); return this.storage;
}
@Override
public int getMaxEnergy(){
return this.storage.getMaxEnergyStored();
} }
@Override @Override

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB