aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/detrav/DetravLoaderAfterGTPreload.java21
-rw-r--r--src/main/java/detrav/DetravScannerMod.java9
-rw-r--r--src/main/java/detrav/net/ProspectingPacket.java15
-rw-r--r--src/main/java/detrav/utils/FluidColors.java137
-rw-r--r--src/main/java/gregtech/api/enums/Dimensions.java4
-rw-r--r--src/main/java/gregtech/api/enums/UndergroundFluidNames.java67
6 files changed, 79 insertions, 174 deletions
diff --git a/src/main/java/detrav/DetravLoaderAfterGTPreload.java b/src/main/java/detrav/DetravLoaderAfterGTPreload.java
deleted file mode 100644
index 45ce3c2381..0000000000
--- a/src/main/java/detrav/DetravLoaderAfterGTPreload.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package detrav;
-
-import detrav.items.DetravMetaGeneratedTool01;
-import detrav.items.processing.ProcessingDetravToolProspector;
-
-/**
- * Created by wital_000 on 18.03.2016.
- */
-public class DetravLoaderAfterGTPreload implements Runnable {
-
- @Override
- public void run() {
-
- // items
- new DetravMetaGeneratedTool01();
-
- // recipes and etc
- new ProcessingDetravToolProspector();
-
- }
-}
diff --git a/src/main/java/detrav/DetravScannerMod.java b/src/main/java/detrav/DetravScannerMod.java
index d79ed76010..c65bc49a34 100644
--- a/src/main/java/detrav/DetravScannerMod.java
+++ b/src/main/java/detrav/DetravScannerMod.java
@@ -10,10 +10,11 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
+import detrav.items.DetravMetaGeneratedTool01;
+import detrav.items.processing.ProcessingDetravToolProspector;
import detrav.net.DetravNetwork;
import detrav.proxies.CommonProxy;
import detrav.utils.DetravCreativeTab;
-import detrav.utils.FluidColors;
import detrav.utils.GTppHelper;
import gregtech.GT_Version;
import gregtech.api.GregTechAPI;
@@ -35,7 +36,10 @@ public class DetravScannerMod {
public static DetravScannerMod instance;
public DetravScannerMod() {
- GregTechAPI.sAfterGTPreload.add(new DetravLoaderAfterGTPreload());
+ GregTechAPI.sAfterGTPreload.add(() -> {
+ new DetravMetaGeneratedTool01(); // items
+ new ProcessingDetravToolProspector(); // recipes and etc
+ });
new DetravNetwork();
}
@@ -61,6 +65,5 @@ public class DetravScannerMod {
public void onPostLoad(FMLPostInitializationEvent aEvent) {
proxy.onPostLoad();
GTppHelper.generate_OreIDs();
- FluidColors.makeColors();
}
}
diff --git a/src/main/java/detrav/net/ProspectingPacket.java b/src/main/java/detrav/net/ProspectingPacket.java
index bfa22511e3..901a57d932 100644
--- a/src/main/java/detrav/net/ProspectingPacket.java
+++ b/src/main/java/detrav/net/ProspectingPacket.java
@@ -20,6 +20,7 @@ import bartworks.system.material.Werkstoff;
import detrav.DetravScannerMod;
import detrav.gui.DetravScannerGUI;
import detrav.gui.textures.DetravMapTexture;
+import detrav.utils.FluidColors;
import detrav.utils.GTppHelper;
import gregtech.api.GregTechAPI;
import gregtech.api.enums.Materials;
@@ -39,7 +40,6 @@ public class ProspectingPacket extends DetravPacket {
public final HashMap<Byte, Short>[][] map;
public final HashMap<String, Integer> ores;
public final HashMap<Short, String> metaMap;
- public static final HashMap<Integer, short[]> fluidColors = new HashMap<>();
public int level = -1;
@@ -56,9 +56,8 @@ public class ProspectingPacket extends DetravPacket {
}
private static void addOre(ProspectingPacket packet, byte y, int i, int j, short meta) {
+ final short[] rgba;
final String name;
- short[] rgba;
-
try {
if (packet.ptype == 0 || packet.ptype == 1) {
// Ore or Small Ore
@@ -72,7 +71,7 @@ public class ProspectingPacket extends DetravPacket {
final Werkstoff werkstoff = Werkstoff.werkstoffHashMap.getOrDefault((short) (meta * -1), null);
String translated = GTLanguageManager.getTranslation("bw.blocktype.ore");
name = translated.replace("%material", werkstoff.getLocalizedName());
- rgba = werkstoff != null ? werkstoff.getRGBA() : new short[] { 0, 0, 0, 0 };
+ rgba = werkstoff.getRGBA();
}
} else {
gtPlusPlus.core.material.Material pMaterial = GTppHelper.decodeoresGTpp.get((short) (meta - 7000));
@@ -81,13 +80,7 @@ public class ProspectingPacket extends DetravPacket {
}
} else if (packet.ptype == 2) {
// Fluid
- rgba = fluidColors.get((int) meta);
- if (rgba == null) {
- DetravScannerMod.proxy
- .sendPlayerExeption("Unknown fluid ID = " + meta + " Please add to FluidColors.java!");
- rgba = new short[] { 0, 0, 0, 0 };
- }
-
+ rgba = FluidColors.getColor(meta);
name = Objects.firstNonNull(
FluidRegistry.getFluid(meta)
.getLocalizedName(new FluidStack(FluidRegistry.getFluid(meta), 0)),
diff --git a/src/main/java/detrav/utils/FluidColors.java b/src/main/java/detrav/utils/FluidColors.java
index 6d18a3adda..29e2181bea 100644
--- a/src/main/java/detrav/utils/FluidColors.java
+++ b/src/main/java/detrav/utils/FluidColors.java
@@ -1,122 +1,51 @@
package detrav.utils;
-import static detrav.net.ProspectingPacket.fluidColors;
+import java.util.HashMap;
-import java.util.Arrays;
-import java.util.Objects;
+import javax.annotation.Nonnull;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
-import gregtech.api.enums.Materials;
+import gregtech.GTMod;
+import gregtech.api.enums.UndergroundFluidNames;
public class FluidColors {
- public static void makeColors() {
-
- reFillFluidColors();
-
- Arrays.stream(Materials.values())
- .forEach(mat -> {
- if (mat.getSolid(0) != null) fluidColors.putIfAbsent(
- mat.getSolid(0)
- .getFluidID(),
- mat.mRGBa);
- if (mat.getGas(0) != null) fluidColors.putIfAbsent(
- mat.getGas(0)
- .getFluidID(),
- mat.mRGBa);
- if (mat.getFluid(0) != null) fluidColors.putIfAbsent(
- mat.getFluid(0)
- .getFluidID(),
- mat.mRGBa);
- if (mat.getMolten(0) != null) fluidColors.putIfAbsent(
- mat.getMolten(0)
- .getFluidID(),
- mat.mRGBa);
- });
- FluidRegistry.getRegisteredFluids()
- .values()
- .stream()
- .filter(Objects::nonNull)
- .forEach(fluid -> { fluidColors.putIfAbsent(fluid.getID(), convertColorInt(fluid.getColor())); });
- }
-
- private static void reFillFluidColors() {
-
- // Should probably be put somewhere else, but I suck at Java
- fluidColors.put(Materials.NatruralGas.mGas.getID(), new short[] { 0x00, 0xff, 0xff });
- fluidColors.put(Materials.OilLight.mFluid.getID(), new short[] { 0xff, 0xff, 0x00 });
- fluidColors.put(Materials.OilMedium.mFluid.getID(), new short[] { 0x00, 0xFF, 0x00 });
- fluidColors.put(Materials.OilHeavy.mFluid.getID(), new short[] { 0xFF, 0x00, 0xFF });
- fluidColors.put(Materials.Oil.mFluid.getID(), new short[] { 0x00, 0x00, 0x00 });
- fluidColors.put(Materials.Helium_3.mGas.getID(), new short[] { 0x80, 0x20, 0xe0 });
- fluidColors.put(Materials.SaltWater.mFluid.getID(), new short[] { 0x80, 0xff, 0x80 });
- fluidColors.put(
- Materials.Lead.getMolten(0)
- .getFluid()
- .getID(),
- new short[] { 0xd0, 0xd0, 0xd0 });
- fluidColors.put(Materials.Chlorobenzene.mFluid.getID(), new short[] { 0x40, 0x80, 0x40 });
- fluidColors.put(
- FluidRegistry.getFluid("liquid_extra_heavy_oil")
- .getID(),
- new short[] { 0x00, 0x00, 0x50 });
- fluidColors.put(Materials.Oxygen.mGas.getID(), new short[] { 0x40, 0x40, 0xA0 });
- fluidColors.put(Materials.Nitrogen.mGas.getID(), new short[] { 0x00, 0x80, 0xd0 });
- fluidColors.put(Materials.Methane.mGas.getID(), new short[] { 0x80, 0x20, 0x20 });
- fluidColors.put(Materials.Ethane.mGas.getID(), new short[] { 0x40, 0x80, 0x20 });
- fluidColors.put(Materials.Ethylene.mGas.getID(), new short[] { 0xd0, 0xd0, 0xd0 });
- fluidColors.put(FluidRegistry.LAVA.getID(), new short[] { 0xFF, 0x00, 0x00 });
- Fluid unknownWater = FluidRegistry.getFluid("unknowwater");
- if (unknownWater != null) {
- fluidColors.put(
- FluidRegistry.getFluid("unknowwater")
- .getID(),
- new short[] { 0x8A, 0x2B, 0xE2 });
+ private static boolean initialized;
+ private static final HashMap<Integer, short[]> fluidColors = new HashMap<>();
+
+ private static void generateFluidColors() {
+ for (UndergroundFluidNames value : UndergroundFluidNames.values()) {
+ final Fluid fluid = FluidRegistry.getFluid(value.name);
+ if (fluid != null) {
+ if (value.renderColor != null) {
+ fluidColors.put(fluid.getID(), value.renderColor);
+ } else {
+ fluidColors.put(fluid.getID(), convertColorInt(fluid.getColor()));
+ }
+ } else {
+ GTMod.GT_FML_LOGGER.error("[FluidColors] no registered fluid named " + value.name);
+ }
}
- fluidColors.put(Materials.Hydrogen.mGas.getID(), new short[] { 0x32, 0x32, 0xD6 });
- fluidColors.put(Materials.SulfuricAcid.mFluid.getID(), new short[] { 0xFF, 0xB9, 0x0F });
- fluidColors.put(Materials.HydricSulfide.mGas.getID(), new short[] { 0xFF, 0x8F, 0x43 });
- fluidColors.put(Materials.CarbonMonoxide.mGas.getID(), new short[] { 0x10, 0x4E, 0x8B });
- fluidColors.put(Materials.CarbonDioxide.mGas.getID(), new short[] { 0x69, 0x69, 0x69 });
- fluidColors.put(
- FluidRegistry.getFluid("ic2distilledwater")
- .getID(),
- new short[] { 0x1E, 0x90, 0xFF });
- fluidColors.put(Materials.Deuterium.mGas.getID(), new short[] { 0xFF, 0xE3, 0x9F });
- fluidColors.put(
- Materials.Iron.getMolten(0)
- .getFluid()
- .getID(),
- new short[] { 0x8B, 0x88, 0x78 });
- fluidColors.put(
- Materials.Tin.getMolten(0)
- .getFluid()
- .getID(),
- new short[] { 0xE7, 0xE7, 0xE4 });
- fluidColors.put(
- Materials.Copper.getMolten(0)
- .getFluid()
- .getID(),
- new short[] { 0xFF, 0x7F, 0x24 });
- fluidColors.put(
- FluidRegistry.getFluid("fluorine")
- .getID(),
- new short[] { 0x99, 0xC1, 0xAD });
- fluidColors.put(
- FluidRegistry.getFluid("hydrofluoricacid")
- .getID(),
- new short[] { 0x00, 0xCE, 0xD1 });
- fluidColors.put(Materials.PhosphoricAcid.mFluid.getID(), new short[] { 0xEE, 0x76, 0x00 });
-
- // possible nulls
- fluidColors.put(Materials.LiquidAir.mFluid.getID(), new short[] { 0x99, 0x99, 0xEA });
-
}
private static short[] convertColorInt(int color) {
return new short[] { (short) (color << 16 & 0xff), (short) (color << 8 & 0xff), (short) (color & 0xff) };
}
+ @Nonnull
+ public static short[] getColor(int fluidID) {
+ if (!initialized) {
+ generateFluidColors();
+ initialized = true;
+ }
+ final short[] color = fluidColors.get(fluidID);
+ if (color == null) {
+ GTMod.GT_FML_LOGGER.error("Unknown fluid ID = " + fluidID + " This shouldn't happen!");
+ return new short[] { 0, 0, 0, 0 };
+ }
+ return color;
+ }
+
}
diff --git a/src/main/java/gregtech/api/enums/Dimensions.java b/src/main/java/gregtech/api/enums/Dimensions.java
index 21dee59977..d4c681e83f 100644
--- a/src/main/java/gregtech/api/enums/Dimensions.java
+++ b/src/main/java/gregtech/api/enums/Dimensions.java
@@ -23,11 +23,11 @@ public enum Dimensions {
BarnardaF("BarnardaF"),
TCetiE("TCetiE"),
Ross128b("Ross128b"),
- Ross128ba("Ross128ba"),;
+ Ross128ba("Ross128ba");
public final String id;
- private Dimensions(String id) {
+ Dimensions(String id) {
this.id = id;
}
}
diff --git a/src/main/java/gregtech/api/enums/UndergroundFluidNames.java b/src/main/java/gregtech/api/enums/UndergroundFluidNames.java
index 5e96544bd2..40d9e9cfd2 100644
--- a/src/main/java/gregtech/api/enums/UndergroundFluidNames.java
+++ b/src/main/java/gregtech/api/enums/UndergroundFluidNames.java
@@ -2,42 +2,43 @@ package gregtech.api.enums;
public enum UndergroundFluidNames {
- carbonDioxide("carbondioxide"),
- carbonMonoxide("carbonmonoxide"),
- chlorobenzene("chlorobenzene"),
- deuterium("deuterium"),
- distilledWater("ic2distilledwater"),
- ethane("ethane"),
- ethylene("ethylene"),
- fluorine("fluorine"),
- heavyOil("liquid_heavy_oil"),
- helium3("helium-3"),
- hydrofluoricAcid("hydrofluoricacid_gt5u"),
- hydrogen("hydrogen"),
- hydrogenSulfide("liquid_hydricsulfur"),
- lava("lava"),
- lightOil("liquid_light_oil"),
- liquidAir("liquidair"),
- mediumOil("liquid_medium_oil"),
- methane("methane"),
- moltenCopper("molten.copper"),
- moltenIron("molten.iron"),
- moltenLead("molten.lead"),
- moltenTin("molten.tin"),
- naturalGas("gas_natural_gas"),
- nitrogen("nitrogen"),
- oil("oil"),
- oxygen("oxygen"),
- saltWater("saltwater"),
- sulfuricAcid("sulfuricacid"),
- unknownWater("unknowwater"),
- veryHeavyOil("liquid_extra_heavy_oil"),
-
- ;
+ carbonDioxide("carbondioxide", new short[] { 0x69, 0x69, 0x69 }),
+ carbonMonoxide("carbonmonoxide", new short[] { 0x10, 0x4E, 0x8B }),
+ chlorobenzene("chlorobenzene", new short[] { 0x40, 0x80, 0x40 }),
+ deuterium("deuterium", new short[] { 0xFF, 0xE3, 0x9F }),
+ distilledWater("ic2distilledwater", new short[] { 0x1E, 0x90, 0xFF }),
+ ethane("ethane", new short[] { 0x40, 0x80, 0x20 }),
+ ethylene("ethylene", new short[] { 0xd0, 0xd0, 0xd0 }),
+ fluorine("fluorine", new short[] { 0x99, 0xC1, 0xAD }),
+ heavyOil("liquid_heavy_oil", new short[] { 10, 10, 10 }),
+ helium3("helium-3", new short[] { 0x80, 0x20, 0xe0 }),
+ hydrofluoricAcid("hydrofluoricacid_gt5u", new short[] { 0x00, 0xCE, 0xD1 }),
+ hydrogen("hydrogen", new short[] { 0x32, 0x32, 0xD6 }),
+ hydrogenSulfide("liquid_hydricsulfur", null),
+ lava("lava", new short[] { 0xFF, 0x00, 0x00 }),
+ lightOil("liquid_light_oil", new short[] { 0xff, 0xff, 0x00 }),
+ liquidAir("liquidair", new short[] { 0x99, 0x99, 0xEA }),
+ mediumOil("liquid_medium_oil", new short[] { 0x00, 0xFF, 0x00 }),
+ methane("methane", new short[] { 0x80, 0x20, 0x20 }),
+ moltenCopper("molten.copper", new short[] { 0xFF, 0x7F, 0x24 }),
+ moltenIron("molten.iron", new short[] { 0x8B, 0x88, 0x78 }),
+ moltenLead("molten.lead", new short[] { 0xd0, 0xd0, 0xd0 }),
+ moltenTin("molten.tin", new short[] { 0xE7, 0xE7, 0xE4 }),
+ naturalGas("gas_natural_gas", new short[] { 0x00, 0xff, 0xff }),
+ nitrogen("nitrogen", new short[] { 0x00, 0x80, 0xd0 }),
+ oil("oil", new short[] { 0x00, 0x00, 0x00 }),
+ oxygen("oxygen", new short[] { 0x40, 0x40, 0xA0 }),
+ saltWater("saltwater", new short[] { 0x80, 0xff, 0x80 }),
+ sulfuricAcid("sulfuricacid", new short[] { 0xFF, 0xB9, 0x0F }),
+ unknownWater("unknowwater", new short[] { 0x8A, 0x2B, 0xE2 }),
+ veryHeavyOil("liquid_extra_heavy_oil", new short[] { 0x00, 0x00, 0x50 });
public final String name;
+ // color override used for detrav ore scanner
+ public final short[] renderColor;
- private UndergroundFluidNames(String name) {
+ UndergroundFluidNames(String name, short[] renderColor) {
this.name = name;
+ this.renderColor = renderColor;
}
}