Added color as field with setter to Fluid class. (#4460)

This commit is contained in:
jabelar authored and LexManos committed 2017-12-08 02:18:45 -08:00
1 parent 49596910fc
commit 07c4da8f36
8 files changed
+144 -1

No files matched your search

@@ -20,6 +20,8 @@
package net.minecraftforge.fluids;
import javax.annotation.Nullable;
import java.awt.Color;
import java.util.Locale;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
@@ -125,7 +127,29 @@ public class Fluid
* The default value of null should remain for any Fluid without a Block implementation.
*/
protected Block block = null;
/**
* Color used by universal bucket and the ModelFluid baked model.
* Note that this int includes the alpha so converting this to RGB with alpha would be
* float r = ((color >> 16) & 0xFF) / 255f; // red
* float g = ((color >> 8) & 0xFF) / 255f; // green
* float b = ((color >> 0) & 0xFF) / 255f; // blue
* float a = ((color >> 24) & 0xFF) / 255f; // alpha
*/
protected int color = 0xFFFFFFFF;
public Fluid(String fluidName, ResourceLocation still, ResourceLocation flowing, Color color)
{
this(fluidName, still, flowing);
this.setColor(color);
}
public Fluid(String fluidName, ResourceLocation still, ResourceLocation flowing, int color)
{
this(fluidName, still, flowing);
this.setColor(color);
}
public Fluid(String fluidName, ResourceLocation still, ResourceLocation flowing)
{
this.fluidName = fluidName.toLowerCase(Locale.ENGLISH);
@@ -201,6 +225,18 @@ public class Fluid
this.emptySound = emptySound;
return this;
}
public Fluid setColor(Color color)
{
this.color = color.getRGB();
return this;
}
public Fluid setColor(int color)
{
this.color = color;
return this;
}
public final String getName()
{
@@ -311,7 +347,7 @@ public class Fluid
public int getColor()
{
return 0xFFFFFFFF;
return color;
}
public ResourceLocation getStill()