Some UI and texture work.

This commit is contained in:
cp committed 2014-03-29 01:09:06 +08:00
1 parent cbaee02e9b
commit 8577283d26
15 files changed
+84 -23

No files matched your search

@@ -1,10 +1,24 @@
package crazypants.enderio.fluid;
import crazypants.util.Lang;
import net.minecraftforge.fluids.IFluidTank;
public class Fluids {
public static final String NUTRIENT_DISTILLATION_NAME = "nutrientdistillation";
public static final String NUTRIENT_DISTILLATION_NAME = "nutrient_distillation";
public static final String HOOTCH_NAME = "hootch";
public static String toCapactityString(IFluidTank tank) {
if(tank == null) {
return "0/0 " + MB();
}
return tank.getFluidAmount() + "/" + tank.getCapacity() + " " + MB();
}
public static String MB() {
return Lang.localize("fluid.millibucket.abr");
}
}
@@ -42,7 +42,7 @@ public class BlockVat extends AbstractMachineBlock<TileVat> {
return super.onBlockActivated(world, x, y, z, entityPlayer, par6, par7, par8, par9);
}
//check for filled fluid containers and see if we can fill up
//check for filled fluid containers and see if we can empty them into our input tank
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(item);
if(fluid == null) {
if(item.getItem() == Items.water_bucket) {
@@ -56,11 +56,11 @@ public class BlockVat extends AbstractMachineBlock<TileVat> {
int filled = vat.fill(ForgeDirection.UP, fluid, false);
if(filled >= fluid.amount) {
vat.fill(ForgeDirection.UP, fluid, true);
if(!entityPlayer.capabilities.isCreativeMode) {
entityPlayer.inventory.setInventorySlotContents(entityPlayer.inventory.currentItem, Util.consumeItem(item));
}
return true;
}
if(!entityPlayer.capabilities.isCreativeMode) {
entityPlayer.inventory.setInventorySlotContents(entityPlayer.inventory.currentItem, Util.consumeItem(item));
}
return true;
}
//now check for empty fluid containers to fill
@@ -72,7 +72,7 @@ public class BlockVat extends AbstractMachineBlock<TileVat> {
if(filled == null) { //this shouldn't be necessary but it appears to be a bug as the above method doesnt work
FluidContainerData[] datas = FluidContainerRegistry.getRegisteredFluidContainerData();
for (FluidContainerData data : datas) {
if(data.fluid.getFluid().getName().equals(available.getFluid().getName())) {
if(data.fluid.getFluid().getName().equals(available.getFluid().getName()) && data.emptyContainer.isItemEqual(item)) {
res = data.filledContainer.copy();
filled = FluidContainerRegistry.getFluidForFilledItem(res);
}
@@ -1,5 +1,7 @@
package crazypants.enderio.machine.still;
import java.awt.Rectangle;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.IIcon;
import net.minecraftforge.fluids.FluidStack;
@@ -7,18 +9,55 @@ import net.minecraftforge.fluids.FluidTank;
import org.lwjgl.opengl.GL11;
import crazypants.enderio.fluid.Fluids;
import crazypants.enderio.machine.GuiMachineBase;
import crazypants.enderio.machine.IMachineRecipe.ResultStack;
import crazypants.enderio.machine.power.PowerDisplayUtil;
import crazypants.enderio.machine.MachineRecipeInput;
import crazypants.gui.GuiToolTip;
import crazypants.render.RenderUtil;
import crazypants.util.Lang;
public class GuiVat extends GuiMachineBase {
private final TileVat still;
private static final String GUI_TEXTURE = "enderio:textures/gui/vat.png";
private final TileVat vat;
public GuiVat(InventoryPlayer inventory, TileVat te) {
super(te, new ContainerVat(inventory, te));
still = te;
vat = te;
addToolTip(new GuiToolTip(new Rectangle(30, 12, 15, 47), "") {
@Override
protected void updateText() {
text.clear();
String heading = Lang.localize("vat.inputTank");
if(vat.inputTank.getFluid() != null) {
heading += ": " + vat.inputTank.getFluid().getFluid().getLocalizedName();
}
text.add(heading);
text.add(Fluids.toCapactityString(vat.inputTank));
}
});
addToolTip(new GuiToolTip(new Rectangle(132,12,15,47), "") {
@Override
protected void updateText() {
text.clear();
String heading = Lang.localize("vat.outputTank");
if(vat.outputTank.getFluid() != null) {
heading += ": " + vat.outputTank.getFluid().getFluid().getLocalizedName();
}
text.add(heading);
text.add(Fluids.toCapactityString(vat.outputTank));
}
});
}
/**
@@ -28,41 +67,41 @@ public class GuiVat extends GuiMachineBase {
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
RenderUtil.bindTexture("enderio:textures/gui/still.png");
RenderUtil.bindTexture(GUI_TEXTURE);
int guiLeft = (width - xSize) / 2;
int guiTop = (height - ySize) / 2;
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
if(still.getProgress() < 1 && still.getProgress() > 0) {
int scaled = still.getProgressScaled(12);
if(vat.getProgress() < 1 && vat.getProgress() > 0) {
int scaled = vat.getProgressScaled(12);
drawTexturedModalRect(guiLeft + 81, guiTop + 76 - scaled, 176, 12 - scaled, 14, scaled + 2);
IIcon inputIcon = null;
for (MachineRecipeInput input : still.getCurrentTask().getInputs()) {
for (MachineRecipeInput input : vat.getCurrentTask().getInputs()) {
if(input.fluid != null && input.fluid.getFluid() != null) {
inputIcon = input.fluid.getFluid().getStillIcon();
break;
}
}
VatMachineRecipe rec = (VatMachineRecipe) still.getCurrentTask().getRecipe();
VatMachineRecipe rec = (VatMachineRecipe) vat.getCurrentTask().getRecipe();
IIcon outputIcon = null;
for (ResultStack res : rec.getCompletedResult(1.0f, still.getCurrentTask().getInputs())) {
for (ResultStack res : rec.getCompletedResult(1.0f, vat.getCurrentTask().getInputs())) {
if(res.fluid != null && res.fluid.getFluid() != null) {
outputIcon = res.fluid.getFluid().getStillIcon();
}
}
if(inputIcon != null && outputIcon != null) {
renderVat(inputIcon, outputIcon, still.getProgress());
renderVat(inputIcon, outputIcon, vat.getProgress());
}
}
RenderUtil.bindBlockTexture();
renderTank(still.inputTank, 30);
renderTank(still.outputTank, 132);
renderTank(vat.inputTank, 30);
renderTank(vat.outputTank, 132);
RenderUtil.bindTexture("enderio:textures/gui/still.png");
RenderUtil.bindTexture(GUI_TEXTURE);
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
}
@@ -82,7 +121,7 @@ public class GuiVat extends GuiMachineBase {
GL11.glDisable(GL11.GL_BLEND);
GL11.glColor4f(1, 1, 1, 1);
RenderUtil.bindTexture("enderio:textures/gui/still.png");
RenderUtil.bindTexture(GUI_TEXTURE);
drawTexturedModalRect(x, y, 0, 256 - 28, 26, 28);
}