basic tint support for gasses

This commit is contained in:
Xander Victory committed 2017-11-08 16:59:45 +08:00
1 parent 8a9f63470d
commit 532744f598
4 files changed
+33 -4

No files matched your search

+21
View File
@@ -31,6 +31,8 @@ public class Gas
private boolean from_fluid = false;
private int tint = 0xFFFFFF;
/**
* Creates a new Gas object with a defined name or key value.
* @param s - name or key to associate this Gas with
@@ -50,6 +52,7 @@ public class Gas
iconLocation = f.getStill();
fluid = f;
from_fluid = true;
tint = f.getColor() & 0xFFFFFF;
}
/**
@@ -255,4 +258,22 @@ public class Gas
{
return name;
}
/**
* Get the tint for rendering the gas
* @return int representation of color in 0xRRGGBB format
*/
public int getTint()
{
return tint;
}
/**
* Sets the tint for the gas
* @param tint int representation of color in 0xRRGGBB format
*/
public void setTint(int tint)
{
this.tint = tint;
}
}
@@ -279,9 +279,7 @@ public class RenderMechanicalPipe extends RenderTransmitterBase<TileEntityMechan
int color = fn.buffer != null ? fn.buffer.getFluid().getColor(fn.buffer) : fn.refFluid.getColor();
ColourRGBA c = new ColourRGBA(1.0, 1.0, 1.0, pipe.currentScale);
if (color != 0xFFFFFFFF){
c.valR = (byte)((color >> 16) & 0xFF);
c.valG = (byte)((color >> 8) & 0xFF);
c.valB = (byte)( color & 0xFF);
c.setRGBFromInt(color);
}
renderTransparency(renderer, tex, getModelForSide(pipe, side), c);
@@ -1,5 +1,6 @@
package mekanism.client.render.transmitter;
import mekanism.api.gas.Gas;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.ColourRGBA;
import mekanism.common.config.MekanismConfig.client;
@@ -47,6 +48,9 @@ public class RenderPressurizedTube extends RenderTransmitterBase<TileEntityPress
public void renderGasSide(BufferBuilder renderer, EnumFacing side, TileEntityPressurizedTube tube)
{
bindTexture(MekanismRenderer.getBlocksTexture());
renderTransparency(renderer, tube.getTransmitter().getTransmitterNetwork().refGas.getSprite(), getModelForSide(tube, side), new ColourRGBA(1.0, 1.0, 1.0, tube.currentScale));
Gas gas = tube.getTransmitter().getTransmitterNetwork().refGas;
ColourRGBA c = new ColourRGBA(1.0, 1.0, 1.0, tube.currentScale);
c.setRGBFromInt(gas.getTint());
renderTransparency(renderer, gas.getSprite(), getModelForSide(tube, side), c);
}
}
@@ -32,4 +32,10 @@ public class ColourRGBA
{
return (valA & 0xFF) << 24 | (valR & 0xFF) << 16 | (valG & 0xFF) << 8 | (valB & 0xFF);
}
public void setRGBFromInt(int color){
valR = (byte)((color >> 16) & 0xFF);
valG = (byte)((color >> 8) & 0xFF);
valB = (byte)( color & 0xFF);
}
}