aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/bartworks/API
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/bartworks/API')
-rw-r--r--src/main/java/bartworks/API/APIConfigValues.java20
-rw-r--r--src/main/java/bartworks/API/BioObjectAdder.java196
-rw-r--r--src/main/java/bartworks/API/BioVatLogicAdder.java237
-rw-r--r--src/main/java/bartworks/API/BorosilicateGlass.java211
-rw-r--r--src/main/java/bartworks/API/GlassTier.java78
-rw-r--r--src/main/java/bartworks/API/INoiseGen.java29
-rw-r--r--src/main/java/bartworks/API/IRadMaterial.java39
-rw-r--r--src/main/java/bartworks/API/ITileAddsInformation.java19
-rw-r--r--src/main/java/bartworks/API/ITileDropsContent.java23
-rw-r--r--src/main/java/bartworks/API/ITileHasDifferentTextureSides.java39
-rw-r--r--src/main/java/bartworks/API/SideReference.java39
-rw-r--r--src/main/java/bartworks/API/VoidMinerDropAdder.java24
-rw-r--r--src/main/java/bartworks/API/WerkstoffAPI.java35
-rw-r--r--src/main/java/bartworks/API/WerkstoffAdderRegistry.java31
-rw-r--r--src/main/java/bartworks/API/modularUI/BWUITextures.java68
-rw-r--r--src/main/java/bartworks/API/recipe/BWNBTDependantCraftingRecipe.java76
-rw-r--r--src/main/java/bartworks/API/recipe/BacterialVatFrontend.java92
-rw-r--r--src/main/java/bartworks/API/recipe/BartWorksRecipeMaps.java89
-rw-r--r--src/main/java/bartworks/API/recipe/DynamicGTRecipe.java33
-rw-r--r--src/main/java/bartworks/API/recipe/RadioHatchFrontend.java45
20 files changed, 1423 insertions, 0 deletions
diff --git a/src/main/java/bartworks/API/APIConfigValues.java b/src/main/java/bartworks/API/APIConfigValues.java
new file mode 100644
index 0000000000..7ab0326802
--- /dev/null
+++ b/src/main/java/bartworks/API/APIConfigValues.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
+ * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial
+ * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+package bartworks.API;
+
+public class APIConfigValues {
+
+ // One-Side-Only
+ public static boolean debugLog = true;
+}
diff --git a/src/main/java/bartworks/API/BioObjectAdder.java b/src/main/java/bartworks/API/BioObjectAdder.java
new file mode 100644
index 0000000000..d82124ac57
--- /dev/null
+++ b/src/main/java/bartworks/API/BioObjectAdder.java
@@ -0,0 +1,196 @@
+/*
+ * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
+ * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial
+ * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+package bartworks.API;
+
+import static gregtech.api.enums.Mods.Gendustry;
+import static gregtech.api.recipe.RecipeMaps.centrifugeRecipes;
+import static gregtech.api.util.GTRecipeBuilder.SECONDS;
+
+import java.awt.Color;
+
+import net.minecraft.item.EnumRarity;
+import net.minecraftforge.fluids.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+
+import bartworks.util.BioCulture;
+import bartworks.util.BioDNA;
+import bartworks.util.BioData;
+import bartworks.util.BioPlasmid;
+import gregtech.api.enums.FluidState;
+import gregtech.api.enums.GTValues;
+import gregtech.api.enums.Materials;
+import gregtech.api.enums.TierEU;
+import gregtech.api.fluid.GTFluidFactory;
+import gregtech.api.util.GTUtility;
+
+public final class BioObjectAdder {
+
+ /**
+ * @param color the color of the Culture
+ * @param name the name of the Culture
+ * @param plasmid the cultures plasmid, get it from createAndRegisterBioPlasmid
+ * @param dna the cultures dna, get it from createAndRegisterBioDNA
+ * @param breedable if the culture can be inserted into the BacterialVat
+ * @param rarity visual
+ * @return
+ */
+ public static BioCulture createAndRegisterBioCulture(Color color, String name, BioPlasmid plasmid, BioDNA dna,
+ EnumRarity rarity, boolean breedable) {
+ if (BioCulture.BIO_CULTURE_ARRAY_LIST.size() > 1)
+ return BioCulture.createAndRegisterBioCulture(color, name, plasmid, dna, rarity, breedable);
+ new Exception(
+ "Too Early to register a BioCulture! You MUST run this either after:bartworks OR in the init Phase!")
+ .printStackTrace();
+ return null;
+ }
+
+ /**
+ * rarity inherits from dna
+ *
+ * @param color the color of the Culture
+ * @param name the name of the Culture
+ * @param plasmid the cultures plasmid, get it from createAndRegisterBioPlasmid
+ * @param dna the cultures dna, get it from createAndRegisterBioDNA
+ * @param breedable if the culture can be inserted into the BacterialVat
+ * @return
+ */
+ public static BioCulture createAndRegisterBioCulture(Color color, String name, BioPlasmid plasmid, BioDNA dna,
+ boolean breedable) {
+ if (BioCulture.BIO_CULTURE_ARRAY_LIST.size() > 1)
+ return BioCulture.createAndRegisterBioCulture(color, name, plasmid, dna, breedable);
+ new Exception(
+ "Too Early to register a BioCulture! You MUST run this either after:bartworks OR in the init Phase!")
+ .printStackTrace();
+ return null;
+ }
+
+ /**
+ * unspecific Biodata that can be converted into DNA and Plasmid with the propper methodes
+ *
+ * @param aName the name of the Biodata
+ * @param rarity visual only
+ * @param chance the chanche to extract this BioData
+ * @param tier the tier of this BioData 0=HV, 1=EV etc.
+ * @return
+ */
+ public static BioData createAndRegisterBioData(String aName, EnumRarity rarity, int chance, int tier) {
+ if (BioData.BIO_DATA_ARRAY_LIST.size() > 1)
+ return BioData.createAndRegisterBioData(aName, rarity, chance, tier);
+ new Exception("Too Early to register a BioData! You MUST run this either after:bartworks OR in the init Phase!")
+ .printStackTrace();
+ return null;
+ }
+
+ /**
+ * Default Constructor for HV Tier DNA with 75% extraction rate
+ *
+ * @param aName Name of the DNA String
+ * @param rarity visual
+ * @return
+ */
+ public static BioDNA createAndRegisterBioDNA(String aName, EnumRarity rarity) {
+ if (BioData.BIO_DATA_ARRAY_LIST.size() > 1) return BioDNA.createAndRegisterBioDNA(aName, rarity);
+ new Exception("Too Early to register a BioData! You MUST run this either after:bartworks OR in the init Phase!")
+ .printStackTrace();
+ return null;
+ }
+
+ /**
+ * Default Constructor for HV Tier Plasmid with 75% extraction rate
+ *
+ * @param aName Name of the Plasmid
+ * @param rarity visual
+ * @return
+ */
+ public static BioPlasmid createAndRegisterBioPlasmid(String aName, EnumRarity rarity) {
+ if (BioData.BIO_DATA_ARRAY_LIST.size() > 1) return BioPlasmid.createAndRegisterBioPlasmid(aName, rarity);
+ new Exception("Too Early to register a BioData! You MUST run this either after:bartworks OR in the init Phase!")
+ .printStackTrace();
+ return null;
+ }
+
+ /**
+ * @param aName Name of the DNA String
+ * @param rarity visual
+ * @param chance chanche of extracting
+ * @param tier tier needed to extract 0=HV, 1=EV etc.
+ * @return
+ */
+ public static BioDNA createAndRegisterBioDNA(String aName, EnumRarity rarity, int chance, int tier) {
+ if (BioData.BIO_DATA_ARRAY_LIST.size() > 1) return BioDNA.createAndRegisterBioDNA(aName, rarity, chance, tier);
+ new Exception("Too Early to register a BioData! You MUST run this either after:bartworks OR in the init Phase!")
+ .printStackTrace();
+ return null;
+ }
+
+ /**
+ * @param aName Name of the Plasmid
+ * @param rarity visual
+ * @param chance chanche of extracting
+ * @param tier tier needed to extract 0=HV, 1=EV etc.
+ * @return
+ */
+ public static BioPlasmid createAndRegisterBioPlasmid(String aName, EnumRarity rarity, int chance, int tier) {
+ if (BioData.BIO_DATA_ARRAY_LIST.size() > 1)
+ return BioPlasmid.createAndRegisterBioPlasmid(aName, rarity, chance, tier);
+ new Exception("Too Early to register a BioData! You MUST run this either after:bartworks OR in the init Phase!")
+ .printStackTrace();
+ return null;
+ }
+
+ /**
+ * @param voltageTier (i.e. 6 for LuV, 7 for ZPM, only intresting for LuV+)
+ * @return the propper Bacteria Tier (at least 0)
+ */
+ public static int getBacteriaTierFromVoltageTier(int voltageTier) {
+ return Math.max(voltageTier - 6, 0);
+ }
+
+ /**
+ * If you get NPE's related to BioCultures (most likely because of Load Order or creating BioCultures after the
+ * postinit Phase) execute this.
+ */
+ public static void regenerateBioFluids() {
+ FluidStack dnaFluid = Gendustry.isModLoaded() ? FluidRegistry.getFluidStack("liquiddna", 100)
+ : Materials.Biomass.getFluid(100L);
+ for (BioCulture B : BioCulture.BIO_CULTURE_ARRAY_LIST) {
+ if (B.getFluidNotSet()) {
+ B.setFluid(
+ GTFluidFactory.builder(
+ B.getName()
+ .replace(" ", "")
+ .toLowerCase() + "fluid")
+ .withTextureName("molten.autogenerated")
+ .withColorRGBA(
+ new short[] { (short) B.getColor()
+ .getRed(),
+ (short) B.getColor()
+ .getBlue(),
+ (short) B.getColor()
+ .getGreen() })
+ .withStateAndTemperature(FluidState.LIQUID, 300)
+ .buildAndRegister()
+ .asFluid());
+
+ GTValues.RA.stdBuilder()
+ .itemInputs(GTUtility.getIntegratedCircuit(10))
+ .fluidInputs(new FluidStack(B.getFluid(), 1000))
+ .fluidOutputs(dnaFluid)
+ .duration(25 * SECONDS)
+ .eut(TierEU.RECIPE_MV)
+ .addTo(centrifugeRecipes);
+ }
+ }
+ }
+}
diff --git a/src/main/java/bartworks/API/BioVatLogicAdder.java b/src/main/java/bartworks/API/BioVatLogicAdder.java
new file mode 100644
index 0000000000..26e612c407
--- /dev/null
+++ b/src/main/java/bartworks/API/BioVatLogicAdder.java
@@ -0,0 +1,237 @@
+/*
+ * Copyright (c) 2018-2020 bartimaeusnek Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
+ * conditions: The above copyright notice and this permission notice shall be included in all copies or substantial
+ * portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+package bartworks.API;
+
+import static gregtech.api.enums.Mods.IndustrialCraft2;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Objects;
+
+import net.minecraft.item.ItemStack;
+
+import bartworks.system.material.BWNonMetaMaterialItems;
+import bartworks.system.material.WerkstoffLoader;
+import bartworks.util.BWUtil;
+import gregtech.api.enums.ItemList;
+import gregtech.api.enums.Materials;
+import gregtech.api.util.GTModHandler;
+
+public final class BioVatLogicAdder {
+
+ public static class RadioHatch {
+
+ public static void runBasicItemIntegration() {
+ giveItemStackRadioHatchAbilites(ItemList.ThoriumCell_1.get(1), Materials.Thorium, 3);
+ giveItemStackRadioHatchAbilites(ItemList.ThoriumCell_2.get(1), Materials.Thorium, 6);
+ giveItemStackRadioHatchAbilites(ItemList.ThoriumCell_4.get(1), Materials.Thorium, 12);
+
+ giveItemStackRadioHatchAbilites(ItemList.NaquadahCell_1.get(1), Materials.Naquadah, 3);
+ giveItemStackRadioHatchAbilites(ItemList.NaquadahCell_2.get(1), Materials.Naquadah, 6);
+ giveItemStackRadioHatchAbilites(ItemList.NaquadahCell_4.get(1), Materials.Naquadah, 12);
+
+ giveItemStackRadioHatchAbilites(ItemList.Moxcell_1.get(1), Materials.Plutonium, 3);
+ giveItemStackRadioHatchAbilites(ItemList.Moxcell_2.get(1), Materials.Plutonium, 6);
+ giveItemStackRadioHatchAbilites(ItemList.Moxcell_4.get(1), Materials.Plutonium, 12);
+
+ giveItemStackRadioHatchAbilites(ItemList.Uraniumcell_1.get(1), Materials.Uranium, 3);
+ giveItemStackRadioHatchAbilites(ItemList.Uraniumcell_2.get(1), Materials.Uranium, 6);
+ giveItemStackRadioHatchAbilites(ItemList.Uraniumcell_4.get(1), Materials.Uranium, 12);
+
+ giveItemStackRadioHatchAbilites(
+ BWNonMetaMaterialItems.TiberiumCell_1.get(1),
+ WerkstoffLoader.Tiberium.getBridgeMaterial(),
+ 3);
+ giveItemStackRadioHatchAbilites(
+ BWNonMetaMaterialItems.TiberiumCell_2.get(1),
+ WerkstoffLoader.Tiberium.getBridgeMaterial(),
+ 6);
+ giveItemStackRadioHatchAbilites(
+ BWNonMetaMaterialItems.TiberiumCell_4.get(1),
+ WerkstoffLoader.Tiberium.getBridgeMaterial(),
+ 12);
+
+ giveItemStackRadioHatchAbilites(BWNonMetaMaterialItems.TheCoreCell.get(1), Materials.Naquadah, 96);
+
+ giveItemStackRadioHatchAbilites(ItemList.Depleted_Thorium_1.get(1), Materials.Thorium, 3, 10);
+ giveItemStackRadioHatchAbilites(ItemList.Depleted_Thorium_2.get(1), Materials.Thorium, 6, 10);
+ giveItemStackRadioHatchAbilites(ItemList.Depleted_Thorium_4.get(1), Materials.Thorium, 12, 10);
+
+ giveItemStackRadioHatchAbilites(ItemList.Depleted_Naquadah_1.get(1), Materials.Naquadah, 3, 10);
+ giveItemStackRadioHatchAbilites(ItemList.Depleted_Naquadah_2.get(1), Materials.Naquadah, 6, 10);
+ giveItemStackRadioHatchAbilites(ItemList.Depleted_Naquadah_4.get(1), Materials.Naquadah, 12, 10);
+
+ giveItemStackRadioHatchAbilites(
+ GTModHandler.getModItem(IndustrialCraft2.ID, "reactorMOXSimpledepleted", 1),
+ Materials.Plutonium,
+ 3,
+ 10);
+ giveItemStackRadioHatchAbilites(
+ GTModHandler.getModItem(IndustrialCraft2.ID, "reactorMOXDualdepleted", 1),
+ Materials.Plutonium,
+ 6,
+ 10);
+ giveItemStackRadioHatchAbilites(
+ GTModHandler.getModItem(IndustrialCraft2.ID, "reactorMOXQuaddepleted", 1),
+ Materials.Plutonium,
+ 12,
+ 10);
+
+ giveItemStackRadioHatchAbilites(
+ GTModHandler.getModItem(IndustrialCraft2.ID, "reactorUraniumSimpledepleted", 1),
+ Materials.Uranium,
+ 3,
+ 10);
+ giveItemStackRadioHatchAbilites(
+ GTModHandler.getModItem(IndustrialCraft2.ID, "reactorUraniumDualdepleted", 1),
+ Materials.Uranium,
+ 6,
+ 10);
+ giveItemStackRadioHatchAbilites(
+ GTModHandler.getModItem(IndustrialCraft2.ID, "reactorUraniumQuaddepleted", 1),
+ Materials.Uranium,
+ 12,
+ 10);
+
+ giveItemStackRadioHatchAbilites(
+ BWNonMetaMaterialItems.Depleted_Tiberium_1.get(1),
+ WerkstoffLoader.Tiberium.getBridgeMaterial(),
+ 3,
+ 10);
+ giveItemStackRadioHatchAbilites(
+ BWNonMetaMaterialItems.Depleted_Tiberium_2.get(1),
+ WerkstoffLoader.Tiberium.getBridgeMaterial(),
+ 6,
+ 10);
+ giveItemStackRadioHatchAbilites(
+ BWNonMetaMaterialItems.Depleted_Tiberium_4.get(1),
+ WerkstoffLoader.Tiberium.getBridgeMaterial(),
+ 12,
+ 10);
+
+ giveItemStackRadioHatchAbilites(
+ BWNonMetaMaterialItems.Depleted_TheCoreCell.get(1),
+ Materials.Naquadah,
+ 96,
+ 10);
+
+ giveItemStackRadioHatchAbilites(ItemList.MNqCell_1.get(1), Materials.Naquadria, 3);
+ giveItemStackRadioHatchAbilites(ItemList.MNqCell_2.get(1), Materials.Naquadria, 6);
+ giveItemStackRadioHatchAbilites(ItemList.MNqCell_4.get(1), Materials.Naquadria, 12);
+ giveItemStackRadioHatchAbilites(ItemList.Depleted_MNq_1.get(1), Materials.Naquadria, 3, 10);
+ giveItemStackRadioHatchAbilites(ItemList.Depleted_MNq_2.get(1), Materials.Naquadria, 6, 10);
+ giveItemStackRadioHatchAbilites(ItemList.Depleted_MNq_4.get(1), Materials.Naquadria, 12, 10);
+ }
+
+ private static final HashSet<BioVatLogicAdder.MaterialSvPair> MaSv = new HashSet<>();
+ private static final HashMap<ItemStack, Integer> IsSv = new HashMap<>();
+ private static final HashMap<ItemStack, Integer> IsKg = new HashMap<>();
+ private static final HashMap<ItemStack, short[]> IsColor = new HashMap<>();
+
+ public static HashSet<BioVatLogicAdder.MaterialSvPair> getMaSv() {
+ return RadioHatch.MaSv;
+ }
+
+ public static HashMap<ItemStack, Integer> getIsKg() {
+ return IsKg;
+ }
+
+ public static HashMap<ItemStack, Integer> getIsSv() {
+ return RadioHatch.IsSv;
+ }
+
+ public static HashMap<ItemStack, short[]> getIsColor() {
+ return IsColor;
+ }
+
+ public static void setOverrideSvForMaterial(Materials m, int sv) {
+ MaSv.add(new BioVatLogicAdder.MaterialSvPair(m, sv));
+ }
+
+ public static void giveItemStackRadioHatchAbilites(ItemStack stack, int sv) {
+ IsSv.put(stack, sv);
+ }
+
+ public static void giveItemStackRadioHatchAbilites(ItemStack stack, Materials materials) {
+ IsSv.put(stack, BWUtil.calculateSv(materials));
+ }
+
+ public static void giveItemStackRadioHatchAbilites(ItemStack stack, int sv, int kg) {
+ IsSv.put(stack, sv);
+ IsKg.put(stack, kg);
+ }
+
+ public static void giveItemStackRadioHatchAbilites(ItemStack stack, Materials materials, int kg) {
+ giveItemStackRadioHatchAbilites(stack, BWUtil.calculateSv(materials), kg);
+ IsColor.put(stack, materials.getRGBA());
+ }
+
+ public static void giveItemStackRadioHatchAbilites(ItemStack stack, Materials materials, int kg, int divider) {
+ giveItemStackRadioHatchAbilites(stack, BWUtil.calculateSv(materials) / divider, kg);
+ IsColor.put(stack, materials.getRGBA());
+ }
+
+ public static void giveItemStackRadioHatchAbilites(ItemStack stack, int sv, int kg, short[] color) {
+ giveItemStackRadioHatchAbilites(stack, sv, kg);
+ IsColor.put(stack, color);
+ }
+
+ public static int MaxSV = 150;
+
+ public static int getMaxSv() {
+ int ret = MaxSV;
+ for (MaterialSvPair pair : RadioHatch.getMaSv()) {
+ if (pair.getSievert() > ret) ret = pair.getSievert();
+ }
+ for (ItemStack is : RadioHatch.IsSv.keySet()) {
+ if (RadioHatch.IsSv.get(is) > ret) ret = RadioHatch.IsSv.get(is);
+ }
+ return ret;
+ }
+ }
+
+ public static class MaterialSvPair {
+
+ final Materials materials;
+ final Integer sievert;
+
+ public MaterialSvPair(Materials materials, Integer sievert) {
+ this.materials = materials;
+ this.sievert = sievert;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || this.getClass() != o.getClass()) return false;
+ BioVatLogicAdder.MaterialSvPair that = (BioVatLogicAdder.MaterialSvPair) o;
+ return Objects.equals(this.getMaterials(), that.getMaterials())
+ && Objects.equals(this.getSievert(), that.getSievert());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(this.getMaterials(), this.getSievert());
+ }
+
+ public Materials getMaterials() {
+ return this.materials;
+ }
+
+ public Integer getSievert() {
+ return this.sievert;
+ }
+ }
+
+}
diff --git a/src/main/java/bartworks/API/BorosilicateGlass.java b/src/main/java/bartworks/API/BorosilicateGlass.java
new file mode 100644
index 0000000000..cc61ec1337
--- /dev/null
+++ b/src/main/java/bartworks/API/BorosilicateGlass.java
@@ -0,0 +1,211 @@
+package bartworks.API;
+
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockAdder;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockAnyMeta;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlocksTiered;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.PriorityQueue;
+import java.util.function.BiConsumer;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+import net.minecraft.block.Block;
+
+import org.apache.commons.lang3.tuple.Pair;
+
+import com.google.common.collect.HashBasedTable;
+import com.google.common.collect.LinkedHashMultimap;
+import com.google.common.collect.SetMultimap;
+import com.google.common.collect.Table;
+import com.gtnewhorizon.structurelib.structure.IStructureElement;
+
+import bartworks.common.loaders.ItemRegistry;
+import cpw.mods.fml.common.Loader;
+import cpw.mods.fml.common.LoaderState;
+
+/**
+ * API for bartworks borosilicate glass.
+ * <p>
+ * You might have noticed this API does not expose any Block instance, but only IStructureElements. This is in case we
+ * add more glass blocks later, and we run out of meta id for only one block.
+ * <p>
+ * IStructureElements returned from this class <b>SHOULD NOT</b> have its methods called before post init, or else you
+ * might end up with wrong autoplace hints.
+ */
+public class BorosilicateGlass {
+
+ private static List<Pair<Block, Integer>> representatives;
+ private static SetMultimap<Byte, Pair<Block, Integer>> allLevels;
+ private static final Table<Block, Integer, Byte> allLevelsReverse = HashBasedTable.create();
+
+ private static boolean isValidTier(int tier) {
+ return tier > 0 && tier <= Byte.MAX_VALUE;
+ }
+
+ public static Block getGlassBlock() {
+ return ItemRegistry.bw_realglas;
+ }
+
+ public static Block getGlassBlock2() {
+ return ItemRegistry.bw_realglas;
+ }
+
+ private static void doRegister(byte level, Block block, int meta,
+ SetMultimap<Byte, Pair<Block, Integer>> allLevels) {
+ allLevels.put(level, Pair.of(block, meta));
+ allLevelsReverse.put(block, meta, level);
+ }
+
+ private static SetMultimap<Byte, Pair<Block, Integer>> getAllLevels() {
+ if (allLevels == null) {
+ SetMultimap<Byte, Pair<Block, Integer>> ret = LinkedHashMultimap.create();
+ Block block = getGlassBlock();
+ doRegister((byte) 3, block, 0, ret);
+ doRegister((byte) 4, block, 1, ret);
+ doRegister((byte) 5, block, 12, ret);
+ doRegister((byte) 5, block, 2, ret);
+ doRegister((byte) 6, block, 3, ret);
+ doRegister((byte) 7, block, 4, ret);
+ doRegister((byte) 8, block, 5, ret);
+ for (int i = 6; i < 12; i++) {
+ doRegister((byte) 3, block, i, ret);
+ }
+ doRegister((byte) 9, block, 13, ret);
+ doRegister((byte) 10, block, 14, ret);
+ doRegister((byte) 11, block, 15, ret);
+ block = getGlassBlock2();
+ doRegister((byte) 12, block, 0, ret);
+ allLevels = ret;
+ }
+ return allLevels;
+ }
+
+ private static List<Pair<Block, Integer>> getRepresentatives() {
+ if (representatives == null) {
+ SetMultimap<Byte, Pair<Block, Integer>> allLevels = getAllLevels();
+ ArrayList<Pair<Block, Integer>> ret = new ArrayList<>();
+ for (Byte level : new PriorityQueue<>(allLevels.keySet())) {
+ ret.add(
+ allLevels.get(level)
+ .iterator()
+ .next());
+ }
+ representatives = ret;
+ }
+ return representatives;
+ }
+
+ private static Byte checkWithinBound(byte val, byte lo, byte hi) {
+ return val > hi || val < lo ? null : val;
+ }
+
+ /**
+ * ONLY registers borosilicate glass. Without this, {@link #getTier} won't work properly in environments that don't
+ * have the coremod.
+ */
+ public static void registerBorosilicateGlass() {
+ getAllLevels();
+ }
+
+ /**
+ * Register a new block as valid borosilicate glass with given tier (even if it doesn't contain boron at all)
+ *
+ * Does not support matching by more complex stuff like tile entity!
+ *
+ * Can only be called at INIT stage.
+ */
+ public static void registerGlass(Block block, int meta, byte tier) {
+ if (Loader.instance()
+ .hasReachedState(LoaderState.POSTINITIALIZATION)) throw new IllegalStateException("register too late!");
+ if (!Loader.instance()
+ .hasReachedState(LoaderState.INITIALIZATION)) throw new IllegalStateException("register too early!");
+ if (!isValidTier(tier)) throw new IllegalArgumentException("not a valid tier: " + tier);
+ doRegister(tier, block, meta, getAllLevels());
+ }
+
+ /**
+ * Check if there is at least one type of boroglass in that tier.
+ */
+ public static boolean hasGlassInTier(int tier) {
+ return getAllLevels().containsKey((byte) tier);
+ }
+
+ /**
+ * Get a structure element for a certain tier of <b>borosilicate</b> glass. DOES NOT accept other glass like
+ * reinforced glass, magic mirror, vanilla glass, etc. unless these glass are explicitly registered as a
+ * borosilicate glass.
+ * <p>
+ * Use this if you just want boroglass here and doesn't care what tier it is.
+ */
+ public static <T> IStructureElement<T> ofBoroGlass(int tier) {
+ if (!hasGlassInTier(tier)) throw new IllegalArgumentException();
+ return lazy(t -> {
+ Pair<Block, Integer> pair = getRepresentatives().get(tier - 3);
+ return ofBlockAdder((t1, block1, meta) -> getTier(block1, meta) == tier, pair.getKey(), pair.getValue());
+ });
+ }
+
+ /**
+ * Get a structure element for any kind of <b>borosilicate</b> glass. DOES NOT accept other glass like reinforced
+ * glass, magic mirror, vanilla glass, etc. unless these glass are explicitly registered as a borosilicate glass.
+ * <p>
+ * Use this if you just want boroglass here and doesn't care what tier it is.
+ */
+ public static <T> IStructureElement<T> ofBoroGlassAnyTier() {
+ return lazy(t -> ofBlockAnyMeta(getGlassBlock()));
+ }
+
+ /**
+ * Get a structure element for <b>borosilicate</b> glass. DOES NOT accept other glass like reinforced glass, magic
+ * mirror, vanilla glass, etc. unless these glass are explicitly registered as a borosilicate glass.
+ * <p>
+ * This assumes you want all glass used to be of the same tier.
+ * <p>
+ * NOTE: This will accept the basic boron glass (HV tier) as well. You might not want this. Use the other overload
+ * to filter this out.
+ *
+ * @param initialValue the value set before structure check started
+ */
+ public static <T> IStructureElement<T> ofBoroGlass(byte initialValue, BiConsumer<T, Byte> setter,
+ Function<T, Byte> getter) {
+ return lazy(
+ t -> ofBlocksTiered(BorosilicateGlass::getTier, getRepresentatives(), initialValue, setter, getter));
+ }
+
+ /**
+ * Get a structure element for <b>borosilicate</b> glass. DOES NOT accept other glass like reinforced glass, magic
+ * mirror, vanilla glass, etc. unless these glass are explicitly registered as a borosilicate glass.
+ *
+ * @param initialValue the value set before structure check started
+ * @param minTier minimal accepted tier. inclusive. must be greater than 0.
+ * @param maxTier maximal accepted tier. inclusive.
+ */
+ public static <T> IStructureElement<T> ofBoroGlass(byte initialValue, byte minTier, byte maxTier,
+ BiConsumer<T, Byte> setter, Function<T, Byte> getter) {
+ if (minTier > maxTier || minTier < 0) throw new IllegalArgumentException();
+ return lazy(
+ t -> ofBlocksTiered(
+ (block1, meta) -> checkWithinBound(getTier(block1, meta), minTier, maxTier),
+ getRepresentatives().stream()
+ .skip(Math.max(minTier - 3, 0))
+ .limit(maxTier - minTier + 1)
+ .collect(Collectors.toList()),
+ initialValue,
+ setter,
+ getter));
+ }
+
+ /**
+ * Get the tier of this <b>borosilicate</b> glass. DOES NOT consider other glass like reinforced glass, magic
+ * mirror, vanilla glass, etc. unless these glass are explicitly registered as a borosilicate glass.
+ *
+ * @return glass tier, or -1 if is not a borosilicate glass
+ */
+ public static byte getTier(Block block, int meta) {
+ Byte ret = allLevelsReverse.get(block, meta);
+ return ret == null ? -1 : ret;
+ }
+}
diff --git a/src/main/java/bartworks/API/GlassTier.java b/src/main/java/bartworks/API/GlassTier.java
new file mode 100644
index 0000000000..381dae28e1
--- /dev/null
+++ b/src/main/java/bartworks/API/GlassTier.java
@@ -0,0 +1,78 @@
+package bartworks.API;
+
+import static cpw.mods.fml.common.registry.GameRegistry.findBlock;
+
+import java.util.HashMap;
+import java.util.Objects;
+
+import net.minecraft.block.Block;
+
+import org.jetbrains.annotations.NotNull;
+
+public class GlassTier {
+
+ private static final HashMap<BlockMetaPair, Integer> glasses = new HashMap<>();
+
+ /**
+ * @param modname The modid owning the block
+ * @param unlocalisedBlockName The name of the block itself
+ * @param meta The meta of the block
+ * @param tier the glasses Tier = Voltage tier (MIN 3)
+ */
+ public static void addCustomGlass(String modname, String unlocalisedBlockName, int meta, int tier) {
+ Block block = findBlock(modname, unlocalisedBlockName);
+ if (block != null) {
+ addCustomGlass(block, meta, tier);
+ } else {
+ new IllegalArgumentException(
+ "Block: " + unlocalisedBlockName
+ + " of the Mod: "
+ + modname
+ + " was NOT found when attempting to register a glass!").printStackTrace();
+ }
+ }
+
+ public static void addCustomGlass(@NotNull Block block, int meta, int tier) {
+ GlassTier.glasses.put(new BlockMetaPair(block, (byte) meta), tier);
+ }
+
+ public static HashMap<BlockMetaPair, Integer> getGlassMap() {
+ return glasses;
+ }
+
+ public static int getGlassTier(Block block, int meta) {
+ return glasses.getOrDefault(new BlockMetaPair(block, (byte) meta), 0);
+ }
+
+ public static class BlockMetaPair {
+
+ private final Block block;
+ private final int meta;
+
+ public BlockMetaPair(Block block, int aByte) {
+ this.block = block;
+ this.meta = aByte;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || this.getClass() != o.getClass()) return false;
+ BlockMetaPair that = (BlockMetaPair) o;
+ return Objects.equals(this.getBlock(), that.