mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-22 04:52:26 +00:00
Clean up fluids a bit
This commit is contained in:
1 parent
85b71c785a
commit
ead630aa51
7 files changed
+33
-57
No files matched your search
@@ -92,7 +92,7 @@ public class PluginFluids extends BlankForestryPlugin {
|
||||
|
||||
@Override
|
||||
public void registerItemsAndBlocks() {
|
||||
for (Fluids fluidType : Fluids.FORESTRY_FLUIDs) {
|
||||
for (Fluids fluidType : Fluids.values()) {
|
||||
createFluid(fluidType);
|
||||
}
|
||||
|
||||
|
||||
@@ -242,8 +242,8 @@ public class Config {
|
||||
|
||||
private static void loadConfigFluids(File configFile) {
|
||||
configFluid = new LocalizedConfiguration(configFile, "1.0.0");
|
||||
|
||||
for (Fluids fluid : Fluids.FORESTRY_FLUIDs) {
|
||||
|
||||
for (Fluids fluid : Fluids.values()) {
|
||||
String fluidName = Translator.translateToLocal("fluid." + fluid.getTag());
|
||||
|
||||
boolean enabledFluid = !Config.disabledFluids.contains(fluid.getTag());
|
||||
|
||||
@@ -51,7 +51,7 @@ public class BlockForestryFluid extends BlockFluidClassic implements IItemModelR
|
||||
}
|
||||
|
||||
public BlockForestryFluid(Fluids forestryFluid, int flammability, boolean flammable) {
|
||||
this(forestryFluid.getFluid(), flammability, flammable, forestryFluid.getColor());
|
||||
this(forestryFluid.getFluid(), flammability, flammable, forestryFluid.getParticleColor());
|
||||
}
|
||||
|
||||
private BlockForestryFluid(Fluid fluid, int flammability, boolean flammable, Color color) {
|
||||
|
||||
@@ -120,19 +120,8 @@ public enum Fluids {
|
||||
public Block makeBlock() {
|
||||
return new BlockForestryFluid(this);
|
||||
}
|
||||
},
|
||||
// Vanilla
|
||||
WATER(new Color(0x2432ec)),
|
||||
LAVA(new Color(0xfd461f)),
|
||||
// BuildCraft
|
||||
FUEL(new Color(0xffff00)),
|
||||
OIL(new Color(0x404040)),
|
||||
// Railcraft
|
||||
CREOSOTE(new Color(0x635c03)),
|
||||
STEAM(new Color(0x91938F));
|
||||
|
||||
public static final Fluids[] FORESTRY_FLUIDs = {BIO_ETHANOL, BIOMASS, GLASS, FOR_HONEY, ICE, JUICE, MILK, SEED_OIL, SHORT_MEAD};
|
||||
|
||||
};
|
||||
|
||||
private static final Map<String, Fluids> tagToFluid = new HashMap<>();
|
||||
|
||||
static {
|
||||
@@ -144,17 +133,17 @@ public enum Fluids {
|
||||
private final String tag;
|
||||
private final int density, viscosity;
|
||||
@Nonnull
|
||||
private final Color color;
|
||||
private final Color particleColor;
|
||||
|
||||
private final ResourceLocation[] resources = new ResourceLocation[2];
|
||||
|
||||
Fluids(@Nonnull Color color) {
|
||||
this(color, 1000, 1000);
|
||||
|
||||
Fluids(@Nonnull Color particleColor) {
|
||||
this(particleColor, 1000, 1000);
|
||||
}
|
||||
|
||||
Fluids(@Nonnull Color color, int density, int viscosity) {
|
||||
|
||||
Fluids(@Nonnull Color particleColor, int density, int viscosity) {
|
||||
this.tag = name().toLowerCase(Locale.ENGLISH).replace('_', '.');
|
||||
this.color = color;
|
||||
this.particleColor = particleColor;
|
||||
this.density = density;
|
||||
this.viscosity = viscosity;
|
||||
|
||||
@@ -197,8 +186,8 @@ public enum Fluids {
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public final Color getColor() {
|
||||
return color;
|
||||
public final Color getParticleColor() {
|
||||
return particleColor;
|
||||
}
|
||||
|
||||
public final boolean is(Fluid fluid) {
|
||||
@@ -231,21 +220,6 @@ public enum Fluids {
|
||||
return a.isFluidEqual(b);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static Color getFluidColor(FluidStack fluidStack) {
|
||||
if (fluidStack != null) {
|
||||
Fluid fluid = fluidStack.getFluid();
|
||||
if (fluid != null) {
|
||||
Fluids fluidDefinition = tagToFluid.get(fluid.getName());
|
||||
if (fluidDefinition != null) {
|
||||
return fluidDefinition.getColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Fluids.WATER.getColor();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Fluids getFluidDefinition(FluidStack fluidStack) {
|
||||
if (fluidStack != null) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import forestry.core.blocks.BlockBase;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.IRenderableTile;
|
||||
import forestry.core.tiles.TileBase;
|
||||
@@ -171,8 +172,10 @@ public class RenderMachine extends TileEntitySpecialRenderer<TileBase> {
|
||||
if (textureResourceTankLevel == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Color primaryTankColor = renderInfo.getFluidColor();
|
||||
|
||||
// TODO: render fluid overlay on tank
|
||||
Fluids fluidDefinition = Fluids.getFluidDefinition(renderInfo.getFluidStack());
|
||||
Color primaryTankColor = fluidDefinition == null ? Color.BLUE : fluidDefinition.getParticleColor();
|
||||
float[] colors = new float[3];
|
||||
primaryTankColor.getRGBColorComponents(colors);
|
||||
GlStateManager.color(colors[0], colors[1], colors[2], 1.0f);
|
||||
|
||||
@@ -11,34 +11,33 @@
|
||||
package forestry.core.render;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.awt.Color;
|
||||
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
import forestry.core.fluids.Fluids;
|
||||
|
||||
public class TankRenderInfo {
|
||||
public static final TankRenderInfo EMPTY = new TankRenderInfo(Fluids.WATER.getColor(), EnumTankLevel.EMPTY);
|
||||
public static final TankRenderInfo EMPTY = new TankRenderInfo(new FluidStack(FluidRegistry.WATER, 0), EnumTankLevel.EMPTY);
|
||||
|
||||
@Nonnull
|
||||
private final Color fluidColor;
|
||||
private final FluidStack fluidStack;
|
||||
@Nonnull
|
||||
private final EnumTankLevel level;
|
||||
|
||||
public TankRenderInfo(@Nonnull IFluidTank fluidTank) {
|
||||
this(Fluids.getFluidColor(fluidTank.getFluid()), EnumTankLevel.rateTankLevel(fluidTank));
|
||||
this(fluidTank.getFluid(), EnumTankLevel.rateTankLevel(fluidTank));
|
||||
}
|
||||
|
||||
public TankRenderInfo(@Nonnull Color fluidColor, @Nonnull EnumTankLevel level) {
|
||||
this.fluidColor = fluidColor;
|
||||
|
||||
public TankRenderInfo(@Nonnull FluidStack fluidStack, @Nonnull EnumTankLevel level) {
|
||||
this.fluidStack = fluidStack;
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
|
||||
@Nonnull
|
||||
public Color getFluidColor() {
|
||||
return fluidColor;
|
||||
public FluidStack getFluidStack() {
|
||||
return fluidStack;
|
||||
}
|
||||
|
||||
|
||||
@Nonnull
|
||||
public EnumTankLevel getLevel() {
|
||||
return level;
|
||||
|
||||
Reference in new issue
Block a user