This commit is contained in:
CovertJaguar 2013-12-03 15:48:28 -08:00
commit d443f279a6
9 changed files with 78 additions and 20 deletions

View file

@ -23,6 +23,7 @@ import net.minecraftforge.fluids.FluidTank;
public class Tank extends FluidTank {
private final String name;
public int colorRenderCache = 0xFFFFFF;
public Tank(String name, int capacity, TileEntity tile) {
super(capacity);

View file

@ -115,6 +115,7 @@ public class TankManager<T extends Tank> extends ForwardingList<T> implements IF
if (fluidStack != null && fluidStack.getFluid() != null) {
data.writeShort(fluidStack.getFluid().getID());
data.writeInt(fluidStack.amount);
data.writeInt(fluidStack.getFluid().getColor(fluidStack));
} else {
data.writeShort(-1);
}
@ -125,10 +126,13 @@ public class TankManager<T extends Tank> extends ForwardingList<T> implements IF
public void readData(DataInputStream data) throws IOException {
for (Tank tank : tanks) {
int fluidId = data.readShort();
if (fluidId > 0)
if (fluidId > 0) {
tank.setFluid(new FluidStack(fluidId, data.readInt()));
else
tank.colorRenderCache = data.readInt();
} else {
tank.setFluid(null);
tank.colorRenderCache = 0xFFFFFF;
}
}
}
}

View file

@ -11,7 +11,6 @@ import java.util.LinkedList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
@ -45,8 +44,8 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
public static float COOLDOWN_RATE = 0.05F;
public static int MAX_COOLANT_PER_TICK = 40;
int burnTime = 0;
private Tank tankFuel = new Tank("tankFuel", MAX_LIQUID, this);
private Tank tankCoolant = new Tank("tankCoolant", MAX_LIQUID, this);
public Tank tankFuel = new Tank("tankFuel", MAX_LIQUID, this);
public Tank tankCoolant = new Tank("tankCoolant", MAX_LIQUID, this);
private TankManager tankManager = new TankManager();
private Fuel currentFuel = null;
public int penaltyCooling = 0;
@ -292,7 +291,7 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
tankFuel.getFluid().amount = value;
}
break;
// Fluid coolant amount
// Fluid Coolant amount
case 18:
if (tankCoolant.getFluid() == null) {
tankCoolant.setFluid(new FluidStack(0, value));
@ -300,6 +299,14 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
tankCoolant.getFluid().amount = value;
}
break;
//Fluid Fuel color
case 19:
tankFuel.colorRenderCache = value;
break;
//Fluid Coolant color
case 20:
tankCoolant.colorRenderCache = value;
break;
}
}
@ -310,6 +317,8 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
iCrafting.sendProgressBarUpdate(containerEngine, 16, tankCoolant.getFluid() != null ? tankCoolant.getFluid().fluidID : 0);
iCrafting.sendProgressBarUpdate(containerEngine, 17, tankFuel.getFluid() != null ? tankFuel.getFluid().amount : 0);
iCrafting.sendProgressBarUpdate(containerEngine, 18, tankCoolant.getFluid() != null ? tankCoolant.getFluid().amount : 0);
iCrafting.sendProgressBarUpdate(containerEngine, 19, tankFuel.colorRenderCache);
iCrafting.sendProgressBarUpdate(containerEngine, 20, tankCoolant.colorRenderCache);
}
@Override

View file

@ -7,16 +7,16 @@
*/
package buildcraft.energy.gui;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.Icon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import buildcraft.core.DefaultProps;
import buildcraft.core.fluids.Tank;
import buildcraft.core.utils.StringUtils;
import buildcraft.energy.TileEngineIron;
import buildcraft.energy.TileEngineWithInventory;
@ -47,15 +47,15 @@ public class GuiCombustionEngine extends GuiEngine {
TileEngineIron engine = (TileEngineIron) tile;
if (engine.getScaledBurnTime(58) > 0) {
displayGauge(j, k, 19, 104, engine.getScaledBurnTime(58), engine.getFuel());
displayGauge(j, k, 19, 104, engine.getScaledBurnTime(58), engine.getFuel(), engine.tankFuel);
}
if (engine.getScaledCoolant(58) > 0) {
displayGauge(j, k, 19, 122, engine.getScaledCoolant(58), engine.getCoolant());
displayGauge(j, k, 19, 122, engine.getScaledCoolant(58), engine.getCoolant(), engine.tankCoolant);
}
}
private void displayGauge(int j, int k, int line, int col, int squaled, FluidStack liquid) {
private void displayGauge(int j, int k, int line, int col, int squaled, FluidStack liquid, Tank tank) {
if (liquid == null) {
return;
}
@ -63,11 +63,16 @@ public class GuiCombustionEngine extends GuiEngine {
Icon liquidIcon = null;
Fluid fluid = liquid.getFluid();
int color = tank.colorRenderCache;
if (fluid != null && fluid.getStillIcon() != null) {
liquidIcon = fluid.getStillIcon();
}
mc.renderEngine.bindTexture(BLOCK_TEXTURE);
float red = (float) (color >> 16 & 255) / 255.0F;
float green = (float) (color >> 8 & 255) / 255.0F;
float blue = (float) (color & 255) / 255.0F;
GL11.glColor4f(red, green, blue, 1.0F);
if (liquidIcon != null) {
while (true) {
int x;
@ -89,6 +94,7 @@ public class GuiCombustionEngine extends GuiEngine {
}
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(TEXTURE);
drawTexturedModalRect(j + col, k + line, 176, 0, 16, 60);
}

View file

@ -70,6 +70,7 @@ public class RenderRefinery extends TileEntitySpecialRenderer implements IInvent
private void render(TileRefinery tile, double x, double y, double z) {
FluidStack liquid1 = null, liquid2 = null, liquidResult = null;
int color1 = 0xFFFFFF, color2 = 0xFFFFFF, colorResult = 0xFFFFFF;
float anim = 0;
int angle = 0;
@ -77,14 +78,17 @@ public class RenderRefinery extends TileEntitySpecialRenderer implements IInvent
if (tile != null) {
if (tile.tank1.getFluid() != null) {
liquid1 = tile.tank1.getFluid();
color1 = tile.tank1.colorRenderCache;
}
if (tile.tank2.getFluid() != null) {
liquid2 = tile.tank2.getFluid();
color2 = tile.tank2.colorRenderCache;
}
if (tile.result.getFluid() != null) {
liquidResult = tile.result.getFluid();
colorResult = tile.result.colorRenderCache;
}
anim = tile.getAnimationStage();
@ -183,7 +187,10 @@ public class RenderRefinery extends TileEntitySpecialRenderer implements IInvent
if (list1 != null) {
bindTexture(FluidRenderer.getFluidSheet(liquid1));
FluidRenderer.setColorForFluidStack(liquid1);
float red = (float) (color1 >> 16 & 255) / 255.0F;
float green = (float) (color1 >> 8 & 255) / 255.0F;
float blue = (float) (color1 & 255) / 255.0F;
GL11.glColor4f(red, green, blue, 1.0F);
GL11.glCallList(list1[getDisplayListIndex(tile.tank1)]);
}
}
@ -195,7 +202,10 @@ public class RenderRefinery extends TileEntitySpecialRenderer implements IInvent
GL11.glPushMatrix();
GL11.glTranslatef(0, 0, 1);
bindTexture(FluidRenderer.getFluidSheet(liquid2));
FluidRenderer.setColorForFluidStack(liquid2);
float red = (float) (color2 >> 16 & 255) / 255.0F;
float green = (float) (color2 >> 8 & 255) / 255.0F;
float blue = (float) (color2 & 255) / 255.0F;
GL11.glColor4f(red, green, blue, 1.0F);
GL11.glCallList(list2[getDisplayListIndex(tile.tank2)]);
GL11.glPopMatrix();
}
@ -209,7 +219,10 @@ public class RenderRefinery extends TileEntitySpecialRenderer implements IInvent
GL11.glPushMatrix();
GL11.glTranslatef(1, 0, 0.5F);
bindTexture(FluidRenderer.getFluidSheet(liquidResult));
FluidRenderer.setColorForFluidStack(liquidResult);
float red = (float) (colorResult >> 16 & 255) / 255.0F;
float green = (float) (colorResult >> 8 & 255) / 255.0F;
float blue = (float) (colorResult & 255) / 255.0F;
GL11.glColor4f(red, green, blue, 1.0F);
GL11.glCallList(list3[getDisplayListIndex(tile.result)]);
GL11.glPopMatrix();
}

View file

@ -22,6 +22,7 @@ public class RenderTank extends TileEntitySpecialRenderer {
TileTank tank = ((TileTank) tileentity);
FluidStack liquid = tank.tank.getFluid();
int color = tank.tank.colorRenderCache;
if (liquid == null || liquid.amount <= 0) {
return;
}
@ -39,7 +40,10 @@ public class RenderTank extends TileEntitySpecialRenderer {
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
bindTexture(FluidRenderer.getFluidSheet(liquid));
FluidRenderer.setColorForFluidStack(liquid);
float red = (float) (color >> 16 & 255) / 255.0F;
float green = (float) (color >> 8 & 255) / 255.0F;
float blue = (float) (color & 255) / 255.0F;
GL11.glColor4f(red, green, blue, 1.0F);
GL11.glTranslatef((float) x + 0.125F, (float) y + 0.5F, (float) z + 0.125F);
GL11.glScalef(0.75F, 0.999F, 0.75F);

View file

@ -141,6 +141,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
public short travelDelay = 12;
public short flowRate = 10;
public FluidStack[] renderCache = new FluidStack[orientations.length];
public int[] colorRenderCache = new int[orientations.length];
public final PipeSection[] internalTanks = new PipeSection[orientations.length];
private final TransferState[] transferState = new TransferState[directions.length];
private final int[] inputPerTick = new int[directions.length];
@ -229,6 +230,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
}
FluidStack[] renderCache = this.renderCache.clone();
int[] colorRenderCache = this.colorRenderCache.clone();
for (ForgeDirection dir : orientations) {
FluidStack current = internalTanks[dir.ordinal()].getFluid();
@ -241,6 +243,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
if (prev == null && current != null) {
changed = true;
renderCache[dir.ordinal()] = current.copy();
colorRenderCache[dir.ordinal()] = current.getFluid().getColor(current);
delta.set(dir.ordinal() * 3 + 0);
delta.set(dir.ordinal() * 3 + 1);
delta.set(dir.ordinal() * 3 + 2);
@ -250,6 +253,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
if (prev != null && current == null) {
changed = true;
renderCache[dir.ordinal()] = null;
colorRenderCache[dir.ordinal()] = 0xFFFFFF;
delta.set(dir.ordinal() * 3 + 0);
delta.set(dir.ordinal() * 3 + 1);
delta.set(dir.ordinal() * 3 + 2);
@ -259,6 +263,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
if (!prev.equals(current) || initPacket) {
changed = true;
renderCache[dir.ordinal()] = current;
colorRenderCache[dir.ordinal()] = current.getFluid().getColor(current);
delta.set(dir.ordinal() * 3 + 0);
delta.set(dir.ordinal() * 3 + 1);
}
@ -278,11 +283,13 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
if (persistChange) {
this.renderCache = renderCache;
this.colorRenderCache = colorRenderCache;
}
if (changed || initPacket) {
PacketFluidUpdate packet = new PacketFluidUpdate(container.xCoord, container.yCoord, container.zCoord, initPacket);
packet.renderCache = renderCache;
packet.colorRenderCache = colorRenderCache;
packet.delta = delta;
return packet;
}
@ -485,6 +492,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
internalTanks[direction.ordinal()].reset();
transferState[direction.ordinal()] = TransferState.None;
renderCache[direction.ordinal()] = null;
colorRenderCache[direction.ordinal()] = 0xFFFFFF;
}
}
}

View file

@ -17,6 +17,7 @@ import net.minecraftforge.fluids.FluidStack;
public class PacketFluidUpdate extends PacketCoordinates {
public FluidStack[] renderCache = new FluidStack[ForgeDirection.values().length];
public int[] colorRenderCache = new int[ForgeDirection.values().length];
public BitSet delta;
public PacketFluidUpdate(int xCoord, int yCoord, int zCoord) {
@ -53,6 +54,7 @@ public class PacketFluidUpdate extends PacketCoordinates {
PipeTransportFluids transLiq = ((PipeTransportFluids) pipe.pipe.transport);
renderCache = transLiq.renderCache;
colorRenderCache = transLiq.colorRenderCache;
byte[] dBytes = new byte[3];
data.read(dBytes);
@ -63,7 +65,8 @@ public class PacketFluidUpdate extends PacketCoordinates {
for (ForgeDirection dir : ForgeDirection.values()) {
if (delta.get(dir.ordinal() * 3 + 0)) {
int amt = renderCache[dir.ordinal()] != null ? renderCache[dir.ordinal()].amount : 0;
renderCache[dir.ordinal()] = new FluidStack(data.readInt(),amt);
renderCache[dir.ordinal()] = new FluidStack(data.readInt(), amt);
colorRenderCache[dir.ordinal()] = data.readInt();
}
if (delta.get(dir.ordinal() * 3 + 2)) {
if (renderCache[dir.ordinal()] == null) {
@ -88,8 +91,10 @@ public class PacketFluidUpdate extends PacketCoordinates {
if (delta.get(dir.ordinal() * 3 + 0)) {
if (liquid != null) {
data.writeInt(liquid.fluidID);
data.writeInt(colorRenderCache[dir.ordinal()]);
} else {
data.writeInt(0);
data.writeInt(0xFFFFFF);
}
}
if (delta.get(dir.ordinal() * 3 + 2)) {

View file

@ -597,6 +597,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
int i = side.ordinal();
FluidStack fluidStack = trans.renderCache[i];
int color = trans.colorRenderCache[i];
if (fluidStack == null || fluidStack.amount <= 0)
continue;
@ -638,12 +639,16 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
default:
}
bindTexture(TextureMap.locationBlocksTexture);
FluidRenderer.setColorForFluidStack(fluidStack);
float red = (float) (color >> 16 & 255) / 255.0F;
float green = (float) (color >> 8 & 255) / 255.0F;
float blue = (float) (color & 255) / 255.0F;
GL11.glColor4f(red, green, blue, 1.0F);
GL11.glCallList(list);
GL11.glPopMatrix();
}
// CENTER
FluidStack fluidStack = trans.renderCache[ForgeDirection.UNKNOWN.ordinal()];
int color = trans.colorRenderCache[ForgeDirection.UNKNOWN.ordinal()];
if (fluidStack != null && fluidStack.amount > 0) {
DisplayFluidList d = getListFromBuffer(fluidStack, pipe.container.worldObj);
@ -652,7 +657,10 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
int stage = (int) ((float) fluidStack.amount / (float) (trans.getCapacity()) * (LIQUID_STAGES - 1));
bindTexture(TextureMap.locationBlocksTexture);
FluidRenderer.setColorForFluidStack(fluidStack);
float red = (float) (color >> 16 & 255) / 255.0F;
float green = (float) (color >> 8 & 255) / 255.0F;
float blue = (float) (color & 255) / 255.0F;
GL11.glColor4f(red, green, blue, 1.0F);
if (above) {
GL11.glCallList(d.centerVertical[stage]);