aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/detrav/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/detrav/utils')
-rw-r--r--src/main/java/detrav/utils/BartWorksHelper.java23
-rw-r--r--src/main/java/detrav/utils/DetravCreativeTab.java51
-rw-r--r--src/main/java/detrav/utils/FluidColors.java135
-rw-r--r--src/main/java/detrav/utils/GTppHelper.java67
4 files changed, 276 insertions, 0 deletions
diff --git a/src/main/java/detrav/utils/BartWorksHelper.java b/src/main/java/detrav/utils/BartWorksHelper.java
new file mode 100644
index 0000000000..1bbadc71c7
--- /dev/null
+++ b/src/main/java/detrav/utils/BartWorksHelper.java
@@ -0,0 +1,23 @@
+package detrav.utils;
+
+import net.minecraft.block.Block;
+import net.minecraft.world.chunk.Chunk;
+
+import bartworks.system.material.BWMetaGeneratedOres;
+import bartworks.system.material.BWMetaGeneratedSmallOres;
+
+public class BartWorksHelper {
+
+ public static boolean isOre(Block tBlock) {
+ return tBlock instanceof BWMetaGeneratedOres;
+ }
+
+ public static boolean isSmallOre(Block tBlock) {
+ return tBlock instanceof BWMetaGeneratedSmallOres;
+ }
+
+ public static short getMetaFromBlock(Chunk c, int x, int y, int z, Block tBlock) {
+ return (short) (tBlock.getDamageValue(c.worldObj, c.xPosition * 16 + x, y, c.zPosition * 16 + z) * -1);
+ }
+
+}
diff --git a/src/main/java/detrav/utils/DetravCreativeTab.java b/src/main/java/detrav/utils/DetravCreativeTab.java
new file mode 100644
index 0000000000..4550e7ec4b
--- /dev/null
+++ b/src/main/java/detrav/utils/DetravCreativeTab.java
@@ -0,0 +1,51 @@
+package detrav.utils;
+
+import java.util.List;
+
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.init.Items;
+import net.minecraft.item.Item;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import detrav.items.DetravMetaGeneratedTool01;
+
+/**
+ * Created by wital_000 on 19.03.2016.
+ */
+public class DetravCreativeTab extends CreativeTabs {
+
+ public DetravCreativeTab() {
+ super("Detrav Scanner");
+ }
+
+ @Override
+ public Item getTabIconItem() {
+ return Items.stick;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void displayAllReleventItems(List p_78018_1_) {
+ for (Object o : Item.itemRegistry) {
+ Item item = (Item) o;
+
+ if (item == null) {
+ continue;
+ }
+
+ for (CreativeTabs tab : item.getCreativeTabs()) {
+ if (tab == this) {
+ item.getSubItems(item, this, p_78018_1_);
+ if (item instanceof DetravMetaGeneratedTool01) {
+ ((DetravMetaGeneratedTool01) item).getDetravSubItems(item, this, p_78018_1_);
+ }
+ }
+ }
+ }
+
+ if (this.func_111225_m() != null) {
+ this.addEnchantmentBooksToList(p_78018_1_, this.func_111225_m());
+ }
+ }
+}
diff --git a/src/main/java/detrav/utils/FluidColors.java b/src/main/java/detrav/utils/FluidColors.java
new file mode 100644
index 0000000000..3bb52bb76b
--- /dev/null
+++ b/src/main/java/detrav/utils/FluidColors.java
@@ -0,0 +1,135 @@
+package detrav.utils;
+
+import static detrav.net.ProspectingPacket.fluidColors;
+
+import java.util.Arrays;
+import java.util.Objects;
+
+import net.minecraftforge.fluids.FluidRegistry;
+
+import gregtech.api.enums.Materials;
+
+public class FluidColors {
+
+ public static void makeColors() {
+
+ reFillFluidColors();
+
+ // ProgressManager.ProgressBar progressBar = ProgressManager.push("Making Fluid Colors", (int)
+ // (Materials.values().length +
+ // FluidRegistry.getRegisteredFluids().values().stream().filter(Objects::nonNull).count()));
+ Arrays.stream(Materials.values())
+ .forEach(mat -> {
+ // progressBar.step(mat.mDefaultLocalName);
+ 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 -> {
+ // progressBar.step(fluid.getName());
+ fluidColors.putIfAbsent(fluid.getID(), convertColorInt(fluid.getColor()));
+ });
+ // ProgressManager.pop(progressBar);
+ }
+
+ private static void reFillFluidColors() {
+ try {
+ // 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.Naquadah.getMolten(0).getFluid().getID(), new short[]{0x20, 0x20, 0x20});
+ // fluidColors.put(Materials.NaquadahEnriched.getMolten(0).getFluid().getID(), new short[]{0x60, 0x60,
+ // 0x60});
+ 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 });
+ fluidColors.put(
+ FluidRegistry.getFluid("unknowwater")
+ .getID(),
+ new short[] { 0x8A, 0x2B, 0xE2 });
+ 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.mFluid.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 });
+ } catch (Exception ignored) {}
+ /*
+ * Set set = fluidColors.entrySet(); Iterator iterator = set.iterator(); System.out.println(
+ * "DETRAV SCANNER DEBUG" ); while(iterator.hasNext()) { Map.Entry mentry = (Map.Entry) iterator.next();
+ * System.out.println( "key is: "+ (Integer)mentry.getKey() + " & Value is: " + ((short[])mentry.getValue())[0]
+ * + " " + ((short[])mentry.getValue())[1] + " " + ((short[])mentry.getValue())[2] ); }
+ */
+ }
+
+ private static short[] convertColorInt(int color) {
+ return new short[] { (short) (color << 16 & 0xff), (short) (color << 8 & 0xff), (short) (color & 0xff) };
+ }
+
+}
diff --git a/src/main/java/detrav/utils/GTppHelper.java b/src/main/java/detrav/utils/GTppHelper.java
new file mode 100644
index 0000000000..985ca3386b
--- /dev/null
+++ b/src/main/java/detrav/utils/GTppHelper.java
@@ -0,0 +1,67 @@
+package detrav.utils;
+
+import java.util.HashMap;
+
+import net.minecraft.block.Block;
+
+import gtPlusPlus.core.block.base.BlockBaseOre;
+import gtPlusPlus.core.material.Material;
+import gtPlusPlus.core.material.MaterialMisc;
+import gtPlusPlus.core.material.MaterialsAlloy;
+import gtPlusPlus.core.material.MaterialsElements;
+import gtPlusPlus.core.material.MaterialsOres;
+import gtPlusPlus.core.material.nuclear.MaterialsFluorides;
+
+/**
+ * Created by bartimaeusnek on 19.04.2018.
+ */
+public class GTppHelper {
+
+ public static final HashMap<Short, Material> decodeoresGTpp = new HashMap<>();
+ public static final HashMap<Material, Short> encodeoresGTpp = new HashMap<>();
+
+ public static void generate_OreIDs() {
+ short n = 0;
+ for (; n < MaterialsOres.class.getFields().length; ++n) {
+ try {
+ Short i = (short) (n + 1);
+ Material m = ((Material) MaterialsOres.class.getFields()[n].get(MaterialsOres.class.getFields()[n]));
+ decodeoresGTpp.put(i, m);
+ encodeoresGTpp.put(m, i);
+ } catch (Exception ignored) {}
+ }
+ // Manually add ores from other places than the ore class
+ // Fluorite
+ decodeoresGTpp.put((short) (++n + 1), MaterialsFluorides.FLUORITE);
+ encodeoresGTpp.put(MaterialsFluorides.FLUORITE, (short) (n + 1));
+ // Rare Earths
+ decodeoresGTpp.put((short) (++n + 1), MaterialMisc.RARE_EARTH_LOW);
+ encodeoresGTpp.put(MaterialMisc.RARE_EARTH_LOW, (short) (n + 1));
+ decodeoresGTpp.put((short) (++n + 1), MaterialMisc.RARE_EARTH_MID);
+ encodeoresGTpp.put(MaterialMisc.RARE_EARTH_MID, (short) (n + 1));
+ decodeoresGTpp.put((short) (++n + 1), MaterialMisc.RARE_EARTH_HIGH);
+ encodeoresGTpp.put(MaterialMisc.RARE_EARTH_HIGH, (short) (n + 1));
+ // Koboldite
+ decodeoresGTpp.put((short) (++n + 1), MaterialsAlloy.KOBOLDITE);
+ encodeoresGTpp.put(MaterialsAlloy.KOBOLDITE, (short) (n + 1));
+ // Runite
+ decodeoresGTpp.put((short) (++n + 1), MaterialsElements.STANDALONE.RUNITE);
+ encodeoresGTpp.put(MaterialsElements.STANDALONE.RUNITE, (short) (n + 1));
+ // Ancient granite
+ decodeoresGTpp.put((short) (++n + 1), MaterialsElements.STANDALONE.GRANITE);
+ encodeoresGTpp.put(MaterialsElements.STANDALONE.GRANITE, (short) (n + 1));
+ }
+
+ public static boolean isGTppBlock(Block tBlock) {
+ return tBlock instanceof BlockBaseOre;
+ }
+
+ public static short getGTppMeta(Block tBlock) {
+ return (short) (GTppHelper.encodeoresGTpp.get(((BlockBaseOre) tBlock).getMaterialEx()) + 7000);
+ }
+
+ public static String getGTppVeinName(Block tBlock) {
+ return tBlock.getLocalizedName();
+ }
+
+}