diff options
| author | BlueWeabo <ilia.iliev@tuta.com> | 2024-08-30 18:16:57 +0300 |
|---|---|---|
| committer | BlueWeabo <ilia.iliev@tuta.com> | 2024-08-30 18:16:57 +0300 |
| commit | 3ed88dde64660e29c3f318d2c61b76082cc52ed9 (patch) | |
| tree | dc56fdfef9a0dd30005bf926e0b46c23900d264d /src/main/java/com/detrav/utils | |
| parent | 557fb75ff46f2ad422e64b45887a33a42fe6cafb (diff) | |
| download | GT5-Unofficial-3ed88dde64660e29c3f318d2c61b76082cc52ed9.tar.gz GT5-Unofficial-3ed88dde64660e29c3f318d2c61b76082cc52ed9.tar.bz2 GT5-Unofficial-3ed88dde64660e29c3f318d2c61b76082cc52ed9.zip | |
merge sources and fix dependencies
Diffstat (limited to 'src/main/java/com/detrav/utils')
| -rw-r--r-- | src/main/java/com/detrav/utils/BartWorksHelper.java | 23 | ||||
| -rw-r--r-- | src/main/java/com/detrav/utils/DetravCreativeTab.java | 52 | ||||
| -rw-r--r-- | src/main/java/com/detrav/utils/FluidColors.java | 87 | ||||
| -rw-r--r-- | src/main/java/com/detrav/utils/GTppHelper.java | 67 |
4 files changed, 229 insertions, 0 deletions
diff --git a/src/main/java/com/detrav/utils/BartWorksHelper.java b/src/main/java/com/detrav/utils/BartWorksHelper.java new file mode 100644 index 0000000000..bac23893c1 --- /dev/null +++ b/src/main/java/com/detrav/utils/BartWorksHelper.java @@ -0,0 +1,23 @@ +package com.detrav.utils; + +import net.minecraft.block.Block; +import net.minecraft.world.chunk.Chunk; + +import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_Ores; +import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_SmallOres; + +public class BartWorksHelper { + + public static boolean isOre(Block tBlock) { + return tBlock instanceof BW_MetaGenerated_Ores; + } + + public static boolean isSmallOre(Block tBlock) { + return tBlock instanceof BW_MetaGenerated_SmallOres; + } + + 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/com/detrav/utils/DetravCreativeTab.java b/src/main/java/com/detrav/utils/DetravCreativeTab.java new file mode 100644 index 0000000000..ba79c55ab2 --- /dev/null +++ b/src/main/java/com/detrav/utils/DetravCreativeTab.java @@ -0,0 +1,52 @@ +package com.detrav.utils; + +import java.util.List; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Items; +import net.minecraft.item.Item; + +import com.detrav.items.DetravMetaGeneratedTool01; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * 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/com/detrav/utils/FluidColors.java b/src/main/java/com/detrav/utils/FluidColors.java new file mode 100644 index 0000000000..a5cd94e492 --- /dev/null +++ b/src/main/java/com/detrav/utils/FluidColors.java @@ -0,0 +1,87 @@ +package com.detrav.utils; + +import static com.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/com/detrav/utils/GTppHelper.java b/src/main/java/com/detrav/utils/GTppHelper.java new file mode 100644 index 0000000000..59db67eac7 --- /dev/null +++ b/src/main/java/com/detrav/utils/GTppHelper.java @@ -0,0 +1,67 @@ +package com.detrav.utils; + +import java.util.HashMap; + +import net.minecraft.block.Block; + +import gtPlusPlus.core.block.base.BlockBaseOre; +import gtPlusPlus.core.material.ALLOY; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.material.MISC_MATERIALS; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.nuclear.FLUORIDES; + +/** + * 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 < gtPlusPlus.core.material.ORES.class.getFields().length; ++n) { + try { + Short i = (short) (n + 1); + Material m = ((Material) gtPlusPlus.core.material.ORES.class.getFields()[n] + .get(gtPlusPlus.core.material.ORES.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), FLUORIDES.FLUORITE); + encodeoresGTpp.put(FLUORIDES.FLUORITE, (short) (n + 1)); + // Rare Earths + decodeoresGTpp.put((short) (++n + 1), MISC_MATERIALS.RARE_EARTH_LOW); + encodeoresGTpp.put(MISC_MATERIALS.RARE_EARTH_LOW, (short) (n + 1)); + decodeoresGTpp.put((short) (++n + 1), MISC_MATERIALS.RARE_EARTH_MID); + encodeoresGTpp.put(MISC_MATERIALS.RARE_EARTH_MID, (short) (n + 1)); + decodeoresGTpp.put((short) (++n + 1), MISC_MATERIALS.RARE_EARTH_HIGH); + encodeoresGTpp.put(MISC_MATERIALS.RARE_EARTH_HIGH, (short) (n + 1)); + // Koboldite + decodeoresGTpp.put((short) (++n + 1), ALLOY.KOBOLDITE); + encodeoresGTpp.put(ALLOY.KOBOLDITE, (short) (n + 1)); + // Runite + decodeoresGTpp.put((short) (++n + 1), ELEMENT.STANDALONE.RUNITE); + encodeoresGTpp.put(ELEMENT.STANDALONE.RUNITE, (short) (n + 1)); + // Ancient granite + decodeoresGTpp.put((short) (++n + 1), ELEMENT.STANDALONE.GRANITE); + encodeoresGTpp.put(ELEMENT.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(); + } + +} |
