diff options
Diffstat (limited to 'src/main/java/bartworks')
213 files changed, 39152 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.getBlock()) && Objects.equals(this.getMeta(), that.getMeta()); + } + + @Override + public int hashCode() { + return Objects.hash(this.getBlock(), this.getMeta()); + } + + public Block getBlock() { + return this.block; + } + + public int getMeta() { + return this.meta; + } + } +} diff --git a/src/main/java/bartworks/API/INoiseGen.java b/src/main/java/bartworks/API/INoiseGen.java new file mode 100644 index 0000000000..6048b8e45a --- /dev/null +++ b/src/main/java/bartworks/API/INoiseGen.java @@ -0,0 +1,29 @@ +/* + * 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 interface INoiseGen { + + double getNoise(int x, int z); + + double[][] getNoiseForRegion(int xStart, int zStart, int xEnd, int zEnd); + + void setOctaves(int octaves); + + void setFrequency(double freq); + + void setSeed(long seed); + + void setAmplitude(double amplitude); +} diff --git a/src/main/java/bartworks/API/IRadMaterial.java b/src/main/java/bartworks/API/IRadMaterial.java new file mode 100644 index 0000000000..498f56cc6f --- /dev/null +++ b/src/main/java/bartworks/API/IRadMaterial.java @@ -0,0 +1,39 @@ +/* + * 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 net.minecraft.item.ItemStack; + +public interface IRadMaterial { + + /** + * @return the amount of Radiation (0-150, commonly, higher values are possible but not recommended!) + */ + int getRadiationLevel(ItemStack aStack); + + /** + * @return 1 for stick, 2 for long rods, 3 for fuel rods + */ + byte getAmountOfMaterial(ItemStack aStack); + + /** + * @return the color of the material for display purposes + */ + short[] getColorForGUI(ItemStack aStack); + + /** + * @return the name of the material for display purposes + */ + String getNameForGUI(ItemStack aStack); +} diff --git a/src/main/java/bartworks/API/ITileAddsInformation.java b/src/main/java/bartworks/API/ITileAddsInformation.java new file mode 100644 index 0000000000..ad3c9bbb7c --- /dev/null +++ b/src/main/java/bartworks/API/ITileAddsInformation.java @@ -0,0 +1,19 @@ +/* + * 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 interface ITileAddsInformation { + + String[] getInfoData(); +} diff --git a/src/main/java/bartworks/API/ITileDropsContent.java b/src/main/java/bartworks/API/ITileDropsContent.java new file mode 100644 index 0000000000..c7a2b05afc --- /dev/null +++ b/src/main/java/bartworks/API/ITileDropsContent.java @@ -0,0 +1,23 @@ +/* + * 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 net.minecraft.inventory.ISidedInventory; + +public interface ITileDropsContent extends ISidedInventory { + + default int[] getDropSlots() { + return new int[] { 0 }; + } +} diff --git a/src/main/java/bartworks/API/ITileHasDifferentTextureSides.java b/src/main/java/bartworks/API/ITileHasDifferentTextureSides.java new file mode 100644 index 0000000000..649129ebcc --- /dev/null +++ b/src/main/java/bartworks/API/ITileHasDifferentTextureSides.java @@ -0,0 +1,39 @@ +/* + * 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 net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; +import net.minecraftforge.common.util.ForgeDirection; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public interface ITileHasDifferentTextureSides { + + IIcon[] texture = new IIcon[7]; + + @SideOnly(Side.CLIENT) + default IIcon getTextureForSide(ForgeDirection side, int meta) { + return texture[side.ordinal()]; + } + + @SideOnly(Side.CLIENT) + default IIcon getTextureForSide(int side, int meta) { + return this.getTextureForSide(ForgeDirection.values()[side], meta); + } + + @SideOnly(Side.CLIENT) + void registerBlockIcons(IIconRegister par1IconRegister); +} diff --git a/src/main/java/bartworks/API/SideReference.java b/src/main/java/bartworks/API/SideReference.java new file mode 100644 index 0000000000..83d083741a --- /dev/null +++ b/src/main/java/bartworks/API/SideReference.java @@ -0,0 +1,39 @@ +/* + * 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 cpw.mods.fml.common.FMLCommonHandler; + +public class SideReference { + + public static class EffectiveSide { + + public static final boolean Server = FMLCommonHandler.instance() + .getEffectiveSide() + .isServer(); + public static final boolean Client = FMLCommonHandler.instance() + .getEffectiveSide() + .isClient(); + } + + public static class Side { + + public static final boolean Server = FMLCommonHandler.instance() + .getSide() + .isServer(); + public static final boolean Client = FMLCommonHandler.instance() + .getSide() + .isClient(); + } +} diff --git a/src/main/java/bartworks/API/VoidMinerDropAdder.java b/src/main/java/bartworks/API/VoidMinerDropAdder.java new file mode 100644 index 0000000000..de55ade363 --- /dev/null +++ b/src/main/java/bartworks/API/VoidMinerDropAdder.java @@ -0,0 +1,24 @@ +/* + * 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 bwcrossmod.galacticgreg.VoidMinerUtility; +import gregtech.api.interfaces.ISubTagContainer; + +public class VoidMinerDropAdder { + + public static void addDropsToDim(int dimID, ISubTagContainer material, float chance) { + VoidMinerUtility.addMaterialToDimensionList(dimID, material, chance); + } +} diff --git a/src/main/java/bartworks/API/WerkstoffAPI.java b/src/main/java/bartworks/API/WerkstoffAPI.java new file mode 100644 index 0000000000..d23ef1b75c --- /dev/null +++ b/src/main/java/bartworks/API/WerkstoffAPI.java @@ -0,0 +1,35 @@ +/* + * 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 bartworks.system.material.Werkstoff; + +public final class WerkstoffAPI { + + @SuppressWarnings("rawtypes") + static Class w; + + static { + try { + w = Class.forName("bartworks.system.material.WerkstoffLoader"); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + } + + public static Werkstoff getWerkstoff(String aName) throws NoSuchFieldException, IllegalAccessException { + return (Werkstoff) w.getField(aName) + .get(null); + } +} diff --git a/src/main/java/bartworks/API/WerkstoffAdderRegistry.java b/src/main/java/bartworks/API/WerkstoffAdderRegistry.java new file mode 100644 index 0000000000..1e122c0c3d --- /dev/null +++ b/src/main/java/bartworks/API/WerkstoffAdderRegistry.java @@ -0,0 +1,31 @@ +/* + * 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 java.util.HashSet; + +public final class WerkstoffAdderRegistry { + + private static final HashSet<Runnable> toRun = new HashSet<>(); + + private WerkstoffAdderRegistry() {} + + public static void addWerkstoffAdder(Runnable adder) { + toRun.add(adder); + } + + public static void run() { + for (Runnable r : toRun) r.run(); + } +} diff --git a/src/main/java/bartworks/API/modularUI/BWUITextures.java b/src/main/java/bartworks/API/modularUI/BWUITextures.java new file mode 100644 index 0000000000..86043e697d --- /dev/null +++ b/src/main/java/bartworks/API/modularUI/BWUITextures.java @@ -0,0 +1,68 @@ +package bartworks.API.modularUI; + +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +import com.gtnewhorizons.modularui.api.drawable.AdaptableUITexture; +import com.gtnewhorizons.modularui.api.drawable.UITexture; + +import bartworks.MainMod; + +public class BWUITextures { + + public static final AdaptableUITexture BACKGROUND_BROWN = AdaptableUITexture + .of(MainMod.MOD_ID, "GUI/background/brown", 176, 166, 3); + public static final UITexture BACKGROUND_CIRCUIT_PROGRAMMER = UITexture + .fullImage(MainMod.MOD_ID, "GUI/background/circuit_programmer"); + + public static final AdaptableUITexture SLOT_BROWN = AdaptableUITexture + .of(MainMod.MOD_ID, "GUI/slot/brown", 18, 18, 1); + + public static final UITexture OVERLAY_SLOT_DISH = UITexture.fullImage(MainMod.MOD_ID, "GUI/overlay_slot/dish"); + public static final UITexture OVERLAY_SLOT_DNA_FLASK = UITexture + .fullImage(MainMod.MOD_ID, "GUI/overlay_slot/dna_flask"); + public static final UITexture OVERLAY_SLOT_MODULE = UITexture.fullImage(MainMod.MOD_ID, "GUI/overlay_slot/module"); + public static final UITexture OVERLAY_SLOT_ROD = UITexture.fullImage(MainMod.MOD_ID, "GUI/overlay_slot/rod"); + public static final UITexture OVERLAY_SLOT_CROSS = UITexture.fullImage(MainMod.MOD_ID, "GUI/overlay_slot/cross"); + + public static final UITexture PROGRESSBAR_SIEVERT = UITexture.fullImage(MainMod.MOD_ID, "GUI/progressbar/sievert"); + public static final UITexture PROGRESSBAR_STORED_EU_116 = UITexture + .fullImage(MainMod.MOD_ID, "GUI/progressbar/stored_eu_116"); + public static final UITexture PROGRESSBAR_FUEL = UITexture.fullImage(MainMod.MOD_ID, "GUI/progressbar/fuel"); + + public static final UITexture PICTURE_BW_LOGO_47X21 = UITexture + .fullImage(MainMod.MOD_ID, "GUI/picture/bw_logo_47x21"); + public static final UITexture PICTURE_SIEVERT_CONTAINER = UITexture + .fullImage(MainMod.MOD_ID, "GUI/picture/sievert_container"); + public static final UITexture PICTURE_DECAY_TIME_CONTAINER = UITexture + .fullImage(MainMod.MOD_ID, "GUI/picture/decay_time_container"); + public static final UITexture PICTURE_DECAY_TIME_INSIDE = UITexture + .fullImage(MainMod.MOD_ID, "GUI/picture/decay_time_inside"); + public static final UITexture PICTURE_RADIATION = UITexture.fullImage(MainMod.MOD_ID, "GUI/picture/radiation"); + public static final UITexture PICTURE_WINDMILL_EMPTY = UITexture + .fullImage(MainMod.MOD_ID, "GUI/picture/windmill_empty"); + public static final UITexture[] PICTURE_WINDMILL_ROTATING = IntStream.range(0, 4) + .mapToObj( + i -> UITexture + .partly(MainMod.MOD_ID, "GUI/picture/windmill_rotating", 32, 128, 0, i * 32, 32, (i + 1) * 32)) + .collect(Collectors.toList()) + .toArray(new UITexture[0]); + public static final UITexture PICTURE_STORED_EU_FRAME = UITexture + .fullImage(MainMod.MOD_ID, "GUI/picture/stored_eu_frame"); + public static final UITexture PICTURE_RADIATION_SHUTTER_FRAME = UITexture + .fullImage(MainMod.MOD_ID, "GUI/picture/radiation_shutter_frame"); + public static final AdaptableUITexture PICTURE_RADIATION_SHUTTER_INSIDE = AdaptableUITexture + .of(MainMod.MOD_ID, "GUI/picture/radiation_shutter_inside", 51, 48, 1); + + public static final AdaptableUITexture TAB_TITLE_BROWN = AdaptableUITexture + .of(MainMod.MOD_ID, "GUI/tab/title_brown", 28, 28, 4); + public static final AdaptableUITexture TAB_TITLE_DARK_BROWN = AdaptableUITexture + .of(MainMod.MOD_ID, "GUI/tab/title_dark_brown", 28, 28, 4); + public static final AdaptableUITexture TAB_TITLE_ANGULAR_BROWN = AdaptableUITexture + .of(MainMod.MOD_ID, "GUI/tab/title_angular_brown", 28, 28, 4); + + public static final UITexture OVERLAY_BUTTON_ASSEMBLER_MODE = UITexture + .fullImage(MainMod.MOD_ID, "GUI/overlay_button/assembler_mode"); + public static final UITexture OVERLAY_BUTTON_LINE_MODE = UITexture + .fullImage(MainMod.MOD_ID, "GUI/overlay_button/line_mode"); +} diff --git a/src/main/java/bartworks/API/recipe/BWNBTDependantCraftingRecipe.java b/src/main/java/bartworks/API/recipe/BWNBTDependantCraftingRecipe.java new file mode 100644 index 0000000000..9d7e8ca38c --- /dev/null +++ b/src/main/java/bartworks/API/recipe/BWNBTDependantCraftingRecipe.java @@ -0,0 +1,76 @@ +package bartworks.API.recipe; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.world.World; + +import bartworks.util.BWUtil; + +public class BWNBTDependantCraftingRecipe implements IRecipe { + + ItemStack result; + Map<Character, ItemStack> charToStackMap = new HashMap<>(9, 1); + String[] shape; + + @SuppressWarnings({ "SuspiciousSystemArraycopy" }) + public BWNBTDependantCraftingRecipe(ItemStack result, Object... recipe) { + this.result = result; + this.shape = new String[3]; + System.arraycopy(recipe, 0, this.shape, 0, 3); + this.charToStackMap.put(' ', null); + for (int i = 3; i < recipe.length; i += 2) { + this.charToStackMap.put((char) recipe[i], ((ItemStack) recipe[i + 1]).copy()); + } + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof BWNBTDependantCraftingRecipe that)) return false; + + if (!Objects.equals(this.result, that.result) || !Objects.equals(this.charToStackMap, that.charToStackMap)) + return false; + // Probably incorrect - comparing Object[] arrays with Arrays.equals + return Arrays.equals(this.shape, that.shape); + } + + @Override + public int hashCode() { + int result1 = this.result != null ? this.result.hashCode() : 0; + result1 = 31 * result1 + (this.charToStackMap != null ? this.charToStackMap.hashCode() : 0); + return 31 * result1 + Arrays.hashCode(this.shape); + } + + @Override + public boolean matches(InventoryCrafting p_77569_1_, World p_77569_2_) { + for (int x = 0; x < 3; x++) { + for (int y = 0; y < 3; y++) { + ItemStack toCheck = p_77569_1_.getStackInRowAndColumn(y, x); + ItemStack ref = this.charToStackMap.get(this.shape[x].toCharArray()[y]); + if (!BWUtil.areStacksEqualOrNull(toCheck, ref)) return false; + } + } + return true; + } + + @Override + public ItemStack getCraftingResult(InventoryCrafting p_77572_1_) { + return this.result.copy(); + } + + @Override + public int getRecipeSize() { + return 10; + } + + @Override + public ItemStack getRecipeOutput() { + return this.result; + } +} diff --git a/src/main/java/bartworks/API/recipe/BacterialVatFrontend.java b/src/main/java/bartworks/API/recipe/BacterialVatFrontend.java new file mode 100644 index 0000000000..afca4274d9 --- /dev/null +++ b/src/main/java/bartworks/API/recipe/BacterialVatFrontend.java @@ -0,0 +1,92 @@ +package bartworks.API.recipe; + +import java.util.Arrays; +import java.util.List; + +import javax.annotation.ParametersAreNonnullByDefault; + +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; + +import com.gtnewhorizons.modularui.api.math.Alignment; + +import bartworks.common.tileentities.multis.MTEBioVat; +import gregtech.api.recipe.BasicUIPropertiesBuilder; +import gregtech.api.recipe.NEIRecipePropertiesBuilder; +import gregtech.api.recipe.RecipeMapFrontend; +import gregtech.api.util.MethodsReturnNonnullByDefault; +import gregtech.nei.GTNEIDefaultHandler; +import gregtech.nei.RecipeDisplayInfo; +import gregtech.nei.formatter.INEISpecialInfoFormatter; + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public class BacterialVatFrontend extends RecipeMapFrontend { + + public BacterialVatFrontend(BasicUIPropertiesBuilder uiPropertiesBuilder, + NEIRecipePropertiesBuilder neiPropertiesBuilder) { + super( + uiPropertiesBuilder, + neiPropertiesBuilder.neiSpecialInfoFormatter(new BacterialVatSpecialValueFormatter())); + } + + @Override + protected List<String> handleNEIItemInputTooltip(List<String> currentTip, + GTNEIDefaultHandler.FixedPositionedStack pStack) { + if (pStack.isFluid()) { + currentTip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("nei.biovat.input.tooltip")); + return currentTip; + } + return super.handleNEIItemInputTooltip(currentTip, pStack); + } + + @Override + protected List<String> handleNEIItemOutputTooltip(List<String> currentTip, + GTNEIDefaultHandler.FixedPositionedStack pStack) { + if (pStack.isFluid()) { + currentTip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("nei.biovat.output.tooltip")); + return currentTip; + } + return super.handleNEIItemOutputTooltip(currentTip, pStack); + } + + @Override + protected void drawNEIOverlayForInput(GTNEIDefaultHandler.FixedPositionedStack stack) { + drawFluidOverlay(stack); + } + + @Override + protected void drawNEIOverlayForOutput(GTNEIDefaultHandler.FixedPositionedStack stack) { + drawFluidOverlay(stack); + } + + private void drawFluidOverlay(GTNEIDefaultHandler.FixedPositionedStack stack) { + if (stack.isFluid()) { + drawNEIOverlayText( + "+", + stack, + colorOverride.getTextColorOrDefault("nei_overlay_yellow", 0xFDD835), + 0.5f, + true, + Alignment.TopRight); + return; + } + super.drawNEIOverlayForOutput(stack); + } + + private static class BacterialVatSpecialValueFormatter implements INEISpecialInfoFormatter { + + @Override + public List<String> format(RecipeDisplayInfo recipeInfo) { + int[] tSpecialA = MTEBioVat.specialValueUnpack(recipeInfo.recipe.mSpecialValue); + String glassTier = StatCollector.translateToLocalFormatted("nei.biovat.0.name", tSpecialA[0]); + String sievert; + if (tSpecialA[2] == 1) { + sievert = StatCollector.translateToLocalFormatted("nei.biovat.1.name", tSpecialA[3]); + } else { + sievert = StatCollector.translateToLocalFormatted("nei.biovat.2.name", tSpecialA[3]); + } + return Arrays.asList(glassTier, sievert); + } + } +} diff --git a/src/main/java/bartworks/API/recipe/BartWorksRecipeMaps.java b/src/main/java/bartworks/API/recipe/BartWorksRecipeMaps.java new file mode 100644 index 0000000000..a367cca300 --- /dev/null +++ b/src/main/java/bartworks/API/recipe/BartWorksRecipeMaps.java @@ -0,0 +1,89 @@ +package bartworks.API.recipe; + +import bartworks.API.modularUI.BWUITextures; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMapBackend; +import gregtech.api.recipe.RecipeMapBuilder; +import gregtech.api.recipe.maps.FuelBackend; +import gregtech.nei.formatter.FuelSpecialValueFormatter; + +public class BartWorksRecipeMaps { + + public static final RecipeMap<RecipeMapBackend> bioLabRecipes = RecipeMapBuilder.of("bw.recipe.biolab") + .maxIO(6, 2, 1, 0) + .minInputs(1, 1) + .useSpecialSlot() + .slotOverlays((index, isFluid, isOutput, isSpecial) -> { + if (isSpecial) { + return BWUITextures.OVERLAY_SLOT_MODULE; + } + if (isFluid) { + return GTUITextures.OVERLAY_SLOT_VIAL_2; + } + if (!isOutput) { + switch (index) { + case 0: + return BWUITextures.OVERLAY_SLOT_DISH; + case 1: + return BWUITextures.OVERLAY_SLOT_DNA_FLASK; + case 2: + return GTUITextures.OVERLAY_SLOT_CIRCUIT; + case 3: + return GTUITextures.OVERLAY_SLOT_MOLECULAR_1; + case 4: + return GTUITextures.OVERLAY_SLOT_MOLECULAR_2; + case 5: + return GTUITextures.OVERLAY_SLOT_DATA_ORB; + } + } + return null; + }) + .progressBar(GTUITextures.PROGRESSBAR_ARROW_MULTIPLE) + .logo(BWUITextures.PICTURE_BW_LOGO_47X21) + .logoSize(47, 21) + .logoPos(125, 3) + .disableRegisterNEI() + .build(); + public static final RecipeMap<RecipeMapBackend> bacterialVatRecipes = RecipeMapBuilder.of("bw.recipe.BacteriaVat") + .maxIO(6, 2, 1, 1) + .minInputs(0, 1) + .useSpecialSlot() + .specialSlotSensitive() + .progressBar(GTUITextures.PROGRESSBAR_ARROW_MULTIPLE) + .frontend(BacterialVatFrontend::new) + .disableRegisterNEI() + .build(); + public static final RecipeMap<FuelBackend> acidGenFuels = RecipeMapBuilder.of("bw.fuels.acidgens", FuelBackend::new) + .maxIO(1, 1, 0, 0) + .neiSpecialInfoFormatter(FuelSpecialValueFormatter.INSTANCE) + .build(); + public static final RecipeMap<RecipeMapBackend> circuitAssemblyLineRecipes = RecipeMapBuilder.of("bw.recipe.cal") + .maxIO(6, 1, 1, 0) + .minInputs(1, 1) + .useSpecialSlot() + .specialSlotSensitive() + .progressBar(GTUITextures.PROGRESSBAR_CIRCUIT_ASSEMBLER) + .build(); + public static final RecipeMap<RecipeMapBackend> radioHatchRecipes = RecipeMapBuilder.of("bw.recipe.radhatch") + .maxIO(1, 0, 0, 0) + .minInputs(1, 0) + .slotOverlays((index, isFluid, isOutput, isSpecial) -> BWUITextures.OVERLAY_SLOT_ROD) + .logo(BWUITextures.PICTURE_BW_LOGO_47X21) + .logoSize(47, 21) + .logoPos(118, 55) + .dontUseProgressBar() + .addSpecialTexture(74, 20, 29, 27, BWUITextures.PICTURE_RADIATION) + .frontend(RadioHatchFrontend::new) + .build(); + public static final RecipeMap<RecipeMapBackend> electricImplosionCompressorRecipes = RecipeMapBuilder + .of("gt.recipe.electricimplosioncompressor") + .maxIO(6, 2, 1, 1) + .slotOverlays( + (index, isFluid, isOutput, isSpecial) -> !isFluid && !isOutput ? GTUITextures.OVERLAY_SLOT_IMPLOSION : null) + .progressBar(GTUITextures.PROGRESSBAR_COMPRESS) + .build(); + public static final RecipeMap<RecipeMapBackend> htgrFakeRecipes = RecipeMapBuilder.of("bw.recipe.htgr") + .maxIO(1, 1, 0, 0) + .build(); +} diff --git a/src/main/java/bartworks/API/recipe/DynamicGTRecipe.java b/src/main/java/bartworks/API/recipe/DynamicGTRecipe.java new file mode 100644 index 0000000000..3739c28042 --- /dev/null +++ b/src/main/java/bartworks/API/recipe/DynamicGTRecipe.java @@ -0,0 +1,33 @@ +package bartworks.API.recipe; + +import java.util.ArrayList; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import bartworks.MainMod; +import gregtech.api.util.GTRecipe; + +public class DynamicGTRecipe extends GTRecipe { + + public DynamicGTRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, + int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, + int aSpecialValue, GTRecipe originalRecipe) { + super( + aOptimize, + aInputs, + aOutputs, + aSpecialItems, + aChances, + aFluidInputs, + aFluidOutputs, + aDuration, + aEUt, + aSpecialValue); + if (originalRecipe != null) { + this.owners = new ArrayList<>(originalRecipe.owners); + this.stackTraces = new ArrayList<>(originalRecipe.stackTraces); + this.setOwner(MainMod.MOD_ID); + } + } +} diff --git a/src/main/java/bartworks/API/recipe/RadioHatchFrontend.java b/src/main/java/bartworks/API/recipe/RadioHatchFrontend.java new file mode 100644 index 0000000000..1335323f4e --- /dev/null +++ b/src/main/java/bartworks/API/recipe/RadioHatchFrontend.java @@ -0,0 +1,45 @@ +package bartworks.API.recipe; + +import java.util.Arrays; +import java.util.List; + +import javax.annotation.ParametersAreNonnullByDefault; + +import net.minecraft.util.StatCollector; + +import gregtech.api.recipe.BasicUIPropertiesBuilder; +import gregtech.api.recipe.NEIRecipePropertiesBuilder; +import gregtech.api.recipe.RecipeMapFrontend; +import gregtech.api.util.MethodsReturnNonnullByDefault; +import gregtech.nei.RecipeDisplayInfo; +import gregtech.nei.formatter.INEISpecialInfoFormatter; + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public class RadioHatchFrontend extends RecipeMapFrontend { + + public RadioHatchFrontend(BasicUIPropertiesBuilder uiPropertiesBuilder, + NEIRecipePropertiesBuilder neiPropertiesBuilder) { + super(uiPropertiesBuilder, neiPropertiesBuilder.neiSpecialInfoFormatter(new RadioHatchSpecialInfoFormatter())); + } + + @Override + protected void drawEnergyInfo(RecipeDisplayInfo recipeInfo) {} + + @Override + protected void drawDurationInfo(RecipeDisplayInfo recipeInfo) {} + + private static class RadioHatchSpecialInfoFormatter implements INEISpecialInfoFormatter { + + @Override + public List<String> format(RecipeDisplayInfo recipeInfo) { + int radioLevel = recipeInfo.recipe.mEUt; + int amount = recipeInfo.recipe.mDuration; + long time = recipeInfo.recipe.mSpecialValue; + return Arrays.asList( + StatCollector.translateToLocalFormatted("BW.NEI.display.radhatch.0", radioLevel), + StatCollector.translateToLocalFormatted("BW.NEI.display.radhatch.1", amount), + StatCollector.translateToLocalFormatted("BW.NEI.display.radhatch.2", time * amount / 20.0)); + } + } +} diff --git a/src/main/java/bartworks/ASM/BWCoreStaticReplacementMethodes.java b/src/main/java/bartworks/ASM/BWCoreStaticReplacementMethodes.java new file mode 100644 index 0000000000..8a20495472 --- /dev/null +++ b/src/main/java/bartworks/ASM/BWCoreStaticReplacementMethodes.java @@ -0,0 +1,112 @@ +/* + * 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.ASM; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; + +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.world.World; + +import bartworks.util.NonNullWrappedHashSet; +import bartworks.util.accessprioritylist.AccessPriorityList; +import bartworks.util.accessprioritylist.AccessPriorityListNode; + +public class BWCoreStaticReplacementMethodes { + + private static ThreadLocal<AccessPriorityList<IRecipe>> RECENTLYUSEDRECIPES = ThreadLocal + .withInitial(AccessPriorityList::new); + + public static void clearRecentlyUsedRecipes() { + // the easiest way to ensure the cache is flushed without causing synchronization overhead + // is to just replace the whole ThreadLocal instance. + RECENTLYUSEDRECIPES = ThreadLocal.withInitial(AccessPriorityList::new); + } + + public static ItemStack findCachedMatchingRecipe(InventoryCrafting inventoryCrafting, World world) { + int i = 0; + ItemStack itemstack = null; + ItemStack itemstack1 = null; + int j; + + for (j = 0; j < inventoryCrafting.getSizeInventory(); ++j) { + ItemStack itemstack2 = inventoryCrafting.getStackInSlot(j); + + if (itemstack2 != null) { + if (i == 0) itemstack = itemstack2; + + if (i == 1) itemstack1 = itemstack2; + + ++i; + } + } + + if (i == 2 && itemstack.getItem() == itemstack1.getItem() + && itemstack.stackSize == 1 + && itemstack1.stackSize == 1 + && itemstack.getItem() + .isRepairable()) { + Item item = itemstack.getItem(); + int j1 = item.getMaxDamage() - itemstack.getItemDamageForDisplay(); + int k = item.getMaxDamage() - itemstack1.getItemDamageForDisplay(); + int l = j1 + k + item.getMaxDamage() * 5 / 100; + int i1 = item.getMaxDamage() - l; + + if (i1 < 0) i1 = 0; + + return new ItemStack(itemstack.getItem(), 1, i1); + + } + IRecipe iPossibleRecipe = null; + AccessPriorityList<IRecipe> cache = RECENTLYUSEDRECIPES.get(); + Iterator<AccessPriorityListNode<IRecipe>> it = cache.nodeIterator(); + + while (it.hasNext()) { + AccessPriorityListNode<IRecipe> recipeNode = it.next(); + iPossibleRecipe = recipeNode.getELEMENT(); + + if (!iPossibleRecipe.matches(inventoryCrafting, world)) continue; + + cache.addPrioToNode(recipeNode); + return iPossibleRecipe.getCraftingResult(inventoryCrafting); + } + + HashSet<IRecipe> recipeSet = new NonNullWrappedHashSet<>(); + List<IRecipe> recipeList = CraftingManager.getInstance() + .getRecipeList(); + + for (IRecipe r : recipeList) { + if (r.matches(inventoryCrafting, world)) recipeSet.add(r); + } + + Object[] arr = recipeSet.toArray(); + + if (arr.length == 0) return null; + + IRecipe recipe = (IRecipe) arr[0]; + ItemStack stack = recipe.getCraftingResult(inventoryCrafting); + + if (arr.length != 1) return stack; + + if (stack != null) cache.addLast(recipe); + + return stack; + } + +} diff --git a/src/main/java/bartworks/GuiHandler.java b/src/main/java/bartworks/GuiHandler.java new file mode 100644 index 0000000000..2e89e0e7a2 --- /dev/null +++ b/src/main/java/bartworks/GuiHandler.java @@ -0,0 +1,34 @@ +/* + * 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; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +import bartworks.API.SideReference; +import cpw.mods.fml.common.network.IGuiHandler; + +public class GuiHandler implements IGuiHandler { + + @Override + public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + return null; + } + + @Override + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + if (!SideReference.Side.Client) return this.getServerGuiElement(ID, player, world, x, y, z); + return null; + } +} diff --git a/src/main/java/bartworks/MainMod.java b/src/main/java/bartworks/MainMod.java new file mode 100644 index 0000000000..7356fa9cc8 --- /dev/null +++ b/src/main/java/bartworks/MainMod.java @@ -0,0 +1,214 @@ +/* + * 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; + +import static bartworks.common.loaders.BioRecipeLoader.runOnServerStarted; +import static bartworks.system.material.WerkstoffLoader.removeIC2Recipes; +import static gregtech.api.enums.Mods.BartWorks; + +import java.io.IOException; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraftforge.common.MinecraftForge; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import bartworks.API.APIConfigValues; +import bartworks.API.BioObjectAdder; +import bartworks.API.BioVatLogicAdder; +import bartworks.API.SideReference; +import bartworks.client.ClientEventHandler.TooltipEventHandler; +import bartworks.client.creativetabs.BartWorksTab; +import bartworks.client.creativetabs.BioTab; +import bartworks.client.creativetabs.GT2Tab; +import bartworks.client.textures.PrefixTextureLinker; +import bartworks.common.configs.ConfigHandler; +import bartworks.common.items.BWItemBlocks; +import bartworks.common.loaders.ArtificialMicaLine; +import bartworks.common.loaders.BioCultureLoader; +import bartworks.common.loaders.BioLabLoader; +import bartworks.common.loaders.ItemRegistry; +import bartworks.common.loaders.LocalisationLoader; +import bartworks.common.loaders.RadioHatchMaterialLoader; +import bartworks.common.loaders.RecipeLoader; +import bartworks.common.loaders.RegisterGlassTiers; +import bartworks.common.loaders.RegisterServerCommands; +import bartworks.common.loaders.StaticRecipeChangeLoaders; +import bartworks.common.net.BWNetwork; +import bartworks.server.EventHandler.ServerEventHandler; +import bartworks.system.material.CircuitGeneration.CircuitImprintLoader; +import bartworks.system.material.CircuitGeneration.CircuitPartLoader; +import bartworks.system.material.Werkstoff; +import bartworks.system.material.WerkstoffLoader; +import bartworks.system.material.gtenhancement.PlatinumSludgeOverHaul; +import bartworks.system.material.processingLoaders.DownTierLoader; +import bartworks.system.oredict.OreDictHandler; +import bartworks.util.ResultWrongSievert; +import bartworks.util.log.DebugLog; +import bwcrossmod.galacticgreg.VoidMinerUtility; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLLoadCompleteEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.event.FMLServerStartedEvent; +import cpw.mods.fml.common.event.FMLServerStartingEvent; +import cpw.mods.fml.common.network.IGuiHandler; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.GT_Version; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.Mods; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; + +@Mod(modid = MainMod.MOD_ID, name = MainMod.NAME, version = GT_Version.VERSION, dependencies = """ + required-after:IC2;\ + required-after:gregtech;\ + after:berriespp;\ + after:tectech;\ + after:GalacticraftMars;\ + after:GalacticraftCore;\ + after:Forestry;\ + after:ProjRed|Illumination;\ + after:RandomThings;\ + before:miscutils;""") +public final class MainMod { + + public static final String NAME = "BartWorks"; + public static final String MOD_ID = Mods.Names.BART_WORKS; + public static final String APIVERSION = "11"; + public static final Logger LOGGER = LogManager.getLogger(MainMod.NAME); + public static final CreativeTabs GT2 = new GT2Tab("GT2C"); + public static final CreativeTabs BIO_TAB = new BioTab("BioTab"); + public static final CreativeTabs BWT = new BartWorksTab(BartWorks.ID); + public static final IGuiHandler GH = new GuiHandler(); + + @Mod.Instance(MainMod.MOD_ID) + public static MainMod instance; + + public static BWNetwork BW_Network_instance = new BWNetwork(); + + public MainMod() { + + } + + @Mod.EventHandler + public void preInit(FMLPreInitializationEvent preinit) { + MainMod.LOGGER.info("Found GT++, continuing"); + + GameRegistry.registerBlock(ItemRegistry.bw_glasses[0], BWItemBlocks.class, "BW_GlasBlocks"); + GameRegistry.registerBlock(ItemRegistry.bw_glasses[1], BWItemBlocks.class, "BW_GlasBlocks2"); + + if (APIConfigValues.debugLog) { + try { + DebugLog.initDebugLog(preinit); + } catch (IOException e) { + MainMod.LOGGER.catching(e); + } + } + + WerkstoffLoader.setUp(); + + BioCultureLoader.run(); + + Werkstoff.init(); + GregTechAPI.sAfterGTPostload.add(new CircuitPartLoader()); + if (SideReference.Side.Client) { + GregTechAPI.sBeforeGTLoad.add(new PrefixTextureLinker()); + } + + RegisterGlassTiers.run(); + } + + @Mod.EventHandler + public void init(FMLInitializationEvent init) { + if (SideReference.Side.Client && ConfigHandler.tooltips) + MinecraftForge.EVENT_BUS.register(new TooltipEventHandler()); + ServerEventHandler serverEventHandler = new ServerEventHandler(); + if (SideReference.Side.Server) { + MinecraftForge.EVENT_BUS.register(serverEventHandler); + } + FMLCommonHandler.instance() + .bus() + .register(serverEventHandler); + BioLabLoader.run(); + + WerkstoffLoader.runInit(); + + ItemRegistry.run(); + } + + @Mod.EventHandler + public void postInit(FMLPostInitializationEvent postinit) { + + RecipeLoader.run(); + + NetworkRegistry.INSTANCE.registerGuiHandler(MainMod.instance, MainMod.GH); + + ArtificialMicaLine.runArtificialMicaRecipe(); + BioObjectAdder.regenerateBioFluids(); + + WerkstoffLoader.run(); + LocalisationLoader.localiseAll(); + + CheckRecipeResultRegistry.register(new ResultWrongSievert(0, ResultWrongSievert.NeededSievertType.EXACTLY)); + + RadioHatchMaterialLoader.run(); + } + + @Mod.EventHandler + public void onServerStarting(FMLServerStartingEvent event) { + RegisterServerCommands.registerAll(event); + } + + @Mod.EventHandler + public void onServerStarted(FMLServerStartedEvent event) { + MainMod.runOnPlayerJoined(ConfigHandler.classicMode, ConfigHandler.disableExtraGassesForEBF); + } + + @Mod.EventHandler + public void onModLoadingComplete(FMLLoadCompleteEvent event) { + removeIC2Recipes(); + StaticRecipeChangeLoaders.addElectricImplosionCompressorRecipes(); + PlatinumSludgeOverHaul.replacePureElements(); + + runOnServerStarted(); + StaticRecipeChangeLoaders.unificationRecipeEnforcer(); + VoidMinerUtility.generateDropMaps(); + } + + private static boolean recipesAdded; + + public static void runOnPlayerJoined(boolean classicMode, boolean disableExtraGasRecipes) { + OreDictHandler.adaptCacheForWorld(); + CircuitImprintLoader.run(); + BioVatLogicAdder.RadioHatch.runBasicItemIntegration(); + if (!recipesAdded) { + if (!disableExtraGasRecipes) StaticRecipeChangeLoaders.addEBFGasRecipes(); + + if (classicMode) DownTierLoader.run(); + + recipesAdded = true; + } + + // Accept recipe map changes into Buffers + RecipeMap.ALL_RECIPE_MAPS.values() + .forEach( + map -> map.getBackend() + .reInit()); + } +} diff --git a/src/main/java/bartworks/client/ClientEventHandler/TooltipEventHandler.java b/src/main/java/bartworks/client/ClientEventHandler/TooltipEventHandler.java new file mode 100644 index 0000000000..554bcd8ba8 --- /dev/null +++ b/src/main/java/bartworks/client/ClientEventHandler/TooltipEventHandler.java @@ -0,0 +1,36 @@ +package bartworks.client.ClientEventHandler; + +import static gregtech.api.util.GTUtility.getColoredTierNameFromTier; + +import net.minecraft.block.Block; +import net.minecraft.util.StatCollector; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; + +import bartworks.API.GlassTier; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class TooltipEventHandler { + + @SideOnly(Side.CLIENT) + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void getTooltip(ItemTooltipEvent event) { + + if (event == null || event.itemStack == null || event.itemStack.getItem() == null) return; + + final Block block = Block.getBlockFromItem(event.itemStack.getItem()); + final int meta = event.itemStack.getItemDamage(); + + int tier = GlassTier.getGlassTier(block, meta); + + if (tier == 0) return; + + event.toolTip.add( + StatCollector.translateToLocal("tooltip.glass_tier.0.name") + " " + + getColoredTierNameFromTier((byte) tier)); + + } +} diff --git a/src/main/java/bartworks/client/creativetabs/BartWorksTab.java b/src/main/java/bartworks/client/creativetabs/BartWorksTab.java new file mode 100644 index 0000000000..435e4f8e73 --- /dev/null +++ b/src/main/java/bartworks/client/creativetabs/BartWorksTab.java @@ -0,0 +1,31 @@ +/* + * 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.client.creativetabs; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; + +import bartworks.common.loaders.ItemRegistry; + +public class BartWorksTab extends CreativeTabs { + + public BartWorksTab(String lable) { + super(lable); + } + + @Override + public Item getTabIconItem() { + return ItemRegistry.ROCKCUTTER_HV; + } +} diff --git a/src/main/java/bartworks/client/creativetabs/BioTab.java b/src/main/java/bartworks/client/creativetabs/BioTab.java new file mode 100644 index 0000000000..633402412e --- /dev/null +++ b/src/main/java/bartworks/client/creativetabs/BioTab.java @@ -0,0 +1,32 @@ +/* + * 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.client.creativetabs; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; + +import bartworks.common.loaders.BioItemList; + +public class BioTab extends CreativeTabs { + + public BioTab(String lable) { + super(lable); + } + + @Override + public Item getTabIconItem() { + return BioItemList.getPetriDish(null) + .getItem(); + } +} diff --git a/src/main/java/bartworks/client/creativetabs/GT2Tab.java b/src/main/java/bartworks/client/creativetabs/GT2Tab.java new file mode 100644 index 0000000000..d5095c96f6 --- /dev/null +++ b/src/main/java/bartworks/client/creativetabs/GT2Tab.java @@ -0,0 +1,31 @@ +/* + * 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.client.creativetabs; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; + +import bartworks.common.loaders.ItemRegistry; + +public class GT2Tab extends CreativeTabs { + + public GT2Tab(String lable) { + super(lable); + } + + @Override + public Item getTabIconItem() { + return ItemRegistry.TAB; + } +} diff --git a/src/main/java/bartworks/client/gui/GuiContainerRotorBlock.java b/src/main/java/bartworks/client/gui/GuiContainerRotorBlock.java new file mode 100644 index 0000000000..cb819b8cb6 --- /dev/null +++ b/src/main/java/bartworks/client/gui/GuiContainerRotorBlock.java @@ -0,0 +1,89 @@ +/* + * 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.client.gui; + +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +import org.lwjgl.opengl.GL11; + +import bartworks.MainMod; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.core.block.kineticgenerator.container.ContainerWindKineticGenerator; +import ic2.core.block.kineticgenerator.gui.GuiWindKineticGenerator; +import ic2.core.util.GuiTooltipHelper; + +@SideOnly(Side.CLIENT) +public class GuiContainerRotorBlock extends GuiWindKineticGenerator { + + public ContainerWindKineticGenerator container; + public String name; + + public GuiContainerRotorBlock(ContainerWindKineticGenerator container1) { + super(container1); + this.container = container1; + this.name = StatCollector.translateToLocal("tile.BWRotorBlock.0.name"); + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + this.fontRendererObj + .drawString(this.name, (this.xSize - this.fontRendererObj.getStringWidth(this.name)) / 2, 6, 2157374); + if (this.container.base.checkrotor()) { + if (!this.container.base.rotorspace()) { + this.fontRendererObj.drawString( + StatCollector.translateToLocal("ic2.WindKineticGenerator.gui.rotorspace"), + 27, + 52, + 2157374); + } else if (this.container.base.checkrotor() && !this.container.base.guiisminWindStrength()) { + this.fontRendererObj.drawString( + StatCollector.translateToLocal("ic2.WindKineticGenerator.gui.windweak1"), + 27, + 52, + 2157374); + } else { + this.fontRendererObj.drawString(this.container.base.getRotorhealth() + " %", 46, 52, 2157374); + if (this.container.base.guiisoverload()) { + GuiTooltipHelper.drawAreaTooltip( + mouseX - this.guiLeft, + mouseY - this.guiTop, + StatCollector.translateToLocal("ic2.WindKineticGenerator.error.overload"), + 44, + 27, + 79, + 52); + } + } + } else { + this.fontRendererObj + .drawString(StatCollector.translateToLocal("ic2.WindKineticGenerator.gui.rotormiss"), 27, 52, 2157374); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { + GL11.glColor3f(0.5f, 0.25f, 0.07f); + this.mc.getTextureManager() + .bindTexture(new ResourceLocation(MainMod.MOD_ID, "textures/GUI/GUIPrimitiveKUBox.png")); + int j = (this.width - this.xSize) / 2; + int k = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(j, k, 0, 0, this.xSize, this.ySize); + if (this.container.base.guiisoverload() && this.container.base.checkrotor()) { + this.drawTexturedModalRect(j + 44, k + 20, 176, 0, 30, 26); + this.drawTexturedModalRect(j + 102, k + 20, 176, 0, 30, 26); + } + } +} diff --git a/src/main/java/bartworks/client/renderer/BWBlockOreRenderer.java b/src/main/java/bartworks/client/renderer/BWBlockOreRenderer.java new file mode 100644 index 0000000000..781ead228e --- /dev/null +++ b/src/main/java/bartworks/client/renderer/BWBlockOreRenderer.java @@ -0,0 +1,159 @@ +/* + * 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.client.renderer; + +import static gregtech.common.render.GTRendererBlock.renderNegativeXFacing; +import static gregtech.common.render.GTRendererBlock.renderNegativeYFacing; +import static gregtech.common.render.GTRendererBlock.renderNegativeZFacing; +import static gregtech.common.render.GTRendererBlock.renderPositiveXFacing; +import static gregtech.common.render.GTRendererBlock.renderPositiveYFacing; +import static gregtech.common.render.GTRendererBlock.renderPositiveZFacing; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.util.ForgeDirection; + +import org.lwjgl.opengl.GL11; + +import com.gtnewhorizons.angelica.api.ThreadSafeISBRH; + +import bartworks.system.material.BWMetaGeneratedBlocks; +import bartworks.system.material.TileEntityMetaGeneratedBlock; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; +import gregtech.GTMod; + +@ThreadSafeISBRH(perThread = true) +public class BWBlockOreRenderer implements ISimpleBlockRenderingHandler { + + public static BWBlockOreRenderer INSTANCE; + public static int renderID; + public static final float blockMin = 0.0F; + public static final float blockMax = 1.0F; + + public static void register() { + renderID = RenderingRegistry.getNextAvailableRenderId(); + INSTANCE = new BWBlockOreRenderer(); + RenderingRegistry.registerBlockHandler(INSTANCE); + } + + @Override + public void renderInventoryBlock(Block aBlock, int aMeta, int modelId, RenderBlocks aRenderer) { + TileEntityMetaGeneratedBlock tTileEntity = ((BWMetaGeneratedBlocks) aBlock).getProperTileEntityForRendering(); + tTileEntity.mMetaData = (short) aMeta; + aRenderer.enableAO = false; + aRenderer.useInventoryTint = true; + aBlock.setBlockBoundsForItemRender(); + aRenderer.setRenderBoundsFromBlock(aBlock); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + renderNegativeYFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + tTileEntity.getTexture(aBlock, ForgeDirection.DOWN), + true); + renderPositiveYFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + tTileEntity.getTexture(aBlock, ForgeDirection.UP), + true); + renderNegativeZFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + tTileEntity.getTexture(aBlock, ForgeDirection.NORTH), + true); + renderPositiveZFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + tTileEntity.getTexture(aBlock, ForgeDirection.SOUTH), + true); + renderNegativeXFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + tTileEntity.getTexture(aBlock, ForgeDirection.WEST), + true); + renderPositiveXFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + tTileEntity.getTexture(aBlock, ForgeDirection.EAST), + true); + aRenderer.setRenderBoundsFromBlock(aBlock); + aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, blockMax, blockMax); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + aRenderer.useInventoryTint = false; + } + + // spotless:off + @Override + public boolean renderWorldBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, int modelId, RenderBlocks aRenderer) { + BWMetaGeneratedBlocks tBlock = (BWMetaGeneratedBlocks) aBlock; + if(tBlock == null) return false; + + TileEntityMetaGeneratedBlock fakeTileEntity = tBlock.getProperTileEntityForRendering(); // meh + if(fakeTileEntity == null) return false; + + TileEntityMetaGeneratedBlock actualTileEntity = (TileEntityMetaGeneratedBlock) aWorld.getTileEntity(aX, aY, aZ); + if(actualTileEntity == null) return false; + + fakeTileEntity.mMetaData = actualTileEntity.mMetaData; + aRenderer.useInventoryTint = false; + aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, blockMax, blockMax); + aRenderer.enableAO = Minecraft.isAmbientOcclusionEnabled() && GTMod.gregtechproxy.mRenderTileAmbientOcclusion; + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.DOWN), true); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.UP), true); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.NORTH), true); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.SOUTH), true); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.WEST), true); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.EAST), true); + return true; + } + // spotless:on + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return renderID; + } +} diff --git a/src/main/java/bartworks/client/renderer/BWItemRenderer.java b/src/main/java/bartworks/client/renderer/BWItemRenderer.java new file mode 100644 index 0000000000..590ffd163c --- /dev/null +++ b/src/main/java/bartworks/client/renderer/BWItemRenderer.java @@ -0,0 +1,136 @@ +/* + * 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.client.renderer; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.MinecraftForgeClient; + +import org.lwjgl.opengl.GL11; + +import bartworks.system.material.CircuitGeneration.BWMetaItems; +import bartworks.system.material.CircuitGeneration.CircuitImprintLoader; +import bartworks.util.BWUtil; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.util.GTUtility; +import gregtech.common.render.GTRenderUtil; + +@SideOnly(Side.CLIENT) +public class BWItemRenderer implements IItemRenderer { + + public BWItemRenderer() { + for (BWMetaItems.BW_GT_MetaGen_Item_Hook tItem : BWMetaItems.BW_GT_MetaGen_Item_Hook.sInstances) { + MinecraftForgeClient.registerItemRenderer(tItem, this); + } + } + + @Override + public boolean handleRenderType(ItemStack aStack, IItemRenderer.ItemRenderType aType) { + if (!GTUtility.isStackInvalid(aStack) && aStack.getItemDamage() >= 0) { + return aType == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON + || aType == IItemRenderer.ItemRenderType.INVENTORY + || aType == IItemRenderer.ItemRenderType.EQUIPPED + || aType == IItemRenderer.ItemRenderType.ENTITY; + } + return false; + } + + @Override + public boolean shouldUseRenderHelper(IItemRenderer.ItemRenderType aType, ItemStack aStack, + IItemRenderer.ItemRendererHelper aHelper) { + if (GTUtility.isStackInvalid(aStack)) { + return false; + } + return aType == IItemRenderer.ItemRenderType.ENTITY; + } + + @Override + public void renderItem(IItemRenderer.ItemRenderType type, ItemStack aStack, Object... data) { + if (!GTUtility.isStackInvalid(aStack)) { + short aMetaData = (short) aStack.getItemDamage(); + if (aMetaData >= 0) { + BWMetaItems.BW_GT_MetaGen_Item_Hook aItem = (BWMetaItems.BW_GT_MetaGen_Item_Hook) aStack.getItem(); + GL11.glEnable(3042); + if (type == IItemRenderer.ItemRenderType.ENTITY) { + if (RenderItem.renderInFrame) { + GL11.glScalef(0.85F, 0.85F, 0.85F); + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + } + GL11.glTranslated(-0.5D, -0.42D, 0.0D); + } + + GL11.glColor3f(1.0F, 1.0F, 1.0F); + IIcon tIcon = (IIcon) BWUtil.get2DCoordFrom1DArray(aMetaData, 0, 2, aItem.mIconList); + + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glBlendFunc(770, 771); + if (IItemRenderer.ItemRenderType.INVENTORY.equals(type)) { + if (aMetaData < CircuitImprintLoader.reverseIDs) + GTRenderUtil.renderItemIcon(tIcon, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); + else { + for (int i = 0; i < 4; i++) { + GTRenderUtil.renderItemIcon( + tIcon, + 0.0D + i * 2D, + 0.0D + i * 2D, + 10.0D + i * 2D, + 10.0D + i * 2D, + 0.001D, + 0.0F, + 0.0F, + -1.0F); + } + } + } else if (aMetaData < CircuitImprintLoader.reverseIDs) ItemRenderer.renderItemIn2D( + Tessellator.instance, + tIcon.getMaxU(), + tIcon.getMinV(), + tIcon.getMinU(), + tIcon.getMaxV(), + tIcon.getIconWidth(), + tIcon.getIconHeight(), + 0.0625F); + + IIcon tOverlay = (IIcon) BWUtil.get2DCoordFrom1DArray(aMetaData, 1, 2, aItem.mIconList); + GL11.glColor3f(1.0F, 1.0F, 1.0F); + if (tOverlay != null) { + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glBlendFunc(770, 771); + if (IItemRenderer.ItemRenderType.INVENTORY.equals(type)) { + GTRenderUtil.renderItemIcon(tOverlay, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); + } else { + ItemRenderer.renderItemIn2D( + Tessellator.instance, + tOverlay.getMaxU(), + tOverlay.getMinV(), + tOverlay.getMinU(), + tOverlay.getMaxV(), + tOverlay.getIconWidth(), + tOverlay.getIconHeight(), + 0.0625F); + } + } + } + + GL11.glDisable(3042); + } + } +} diff --git a/src/main/java/bartworks/client/renderer/BWVanillaTexture.java b/src/main/java/bartworks/client/renderer/BWVanillaTexture.java new file mode 100644 index 0000000000..5b5e119f5b --- /dev/null +++ b/src/main/java/bartworks/client/renderer/BWVanillaTexture.java @@ -0,0 +1,56 @@ +/* + * 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.client.renderer; + +import net.minecraft.block.Block; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.ForgeDirection; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.interfaces.IIconContainer; + +@SideOnly(Side.CLIENT) +public class BWVanillaTexture implements IIconContainer { + + IIcon packed; + + public BWVanillaTexture(Block block, ForgeDirection side) { + this.packed = block.getBlockTextureFromSide(side.flag); + } + + public BWVanillaTexture(Block block, int side) { + this.packed = block.getBlockTextureFromSide(side); + } + + public BWVanillaTexture(IIcon packed) { + this.packed = packed; + } + + @Override + public IIcon getIcon() { + return this.packed; + } + + @Override + public IIcon getOverlayIcon() { + return null; + } + + @Override + public ResourceLocation getTextureFile() { + return new ResourceLocation(this.packed.getIconName()); + } +} diff --git a/src/main/java/bartworks/client/renderer/EICPistonVisualizer.java b/src/main/java/bartworks/client/renderer/EICPistonVisualizer.java new file mode 100644 index 0000000000..f56a12d718 --- /dev/null +++ b/src/main/java/bartworks/client/renderer/EICPistonVisualizer.java @@ -0,0 +1,112 @@ +package bartworks.client.renderer; + +import net.minecraft.block.Block; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import org.apache.commons.lang3.tuple.Pair; +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTechAPI; + +@SideOnly(Side.CLIENT) +public class EICPistonVisualizer extends EntityFX { + + public EICPistonVisualizer(World world, int x, int y, int z, int age) { + super(world, x, y, z); + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.particleMaxAge = age; + } + + @Override + public void onUpdate() { + if (this.particleAge++ >= this.particleMaxAge) this.setDead(); + } + + @Override + public void renderParticle(Tessellator p_70539_1_, float p_70539_2_, float p_70539_3_, float p_70539_4_, + float p_70539_5_, float p_70539_6_, float p_70539_7_) { + Tessellator tessellator = Tessellator.instance; + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDepthMask(false); + + RenderBlocks.getInstance().blockAccess = this.worldObj; + RenderBlocks.getInstance() + .setRenderFromInside(false); + + // Look at nearby block for correct tiered block to use + Pair<Block, Integer> tieredBlock; + if (this.worldObj != null) { + int nX = (int) this.posX; + int nY = (int) this.posY + 1; + int nZ = (int) this.posZ; + Block neighborBlock = this.worldObj.getBlock(nX, nY, nZ); + int neighborMeta = this.worldObj.getBlockMetadata(nX, nY, nZ); + tieredBlock = Pair.of(neighborBlock, neighborMeta); + } else { + tieredBlock = Pair.of(GregTechAPI.sBlockMetal5, 2); + } + + IIcon icon = tieredBlock.getKey() + .getIcon(0, tieredBlock.getValue()); + + double x = this.posX + 1; + double z = this.posZ; + + double f11 = x - interpPosX; + double f12 = this.posY - interpPosY; + double f13 = z - interpPosZ; + tessellator.setTranslation(f11 - x, f12 - this.posY, f13 - z); + RenderBlocks.getInstance() + .renderBlockUsingTexture(tieredBlock.getKey(), (int) x, (int) this.posY, (int) z, icon); + + x = this.posX - 1; + z = this.posZ; + + f11 = x - interpPosX; + f13 = z - interpPosZ; + tessellator.setTranslation(f11 - x, f12 - this.posY, f13 - z); + RenderBlocks.getInstance() + .renderBlockUsingTexture(tieredBlock.getKey(), (int) x, (int) this.posY, (int) z, icon); + + x = this.posX; + z = this.posZ + 1; + + f11 = x - interpPosX; + f13 = z - interpPosZ; + tessellator.setTranslation(f11 - x, f12 - this.posY, f13 - z); + RenderBlocks.getInstance() + .renderBlockUsingTexture(tieredBlock.getKey(), (int) x, (int) this.posY, (int) z, icon); + + x = this.posX; + z = this.posZ - 1; + + f11 = x - interpPosX; + f13 = z - interpPosZ; + tessellator.setTranslation(f11 - x, f12 - this.posY, f13 - z); + RenderBlocks.getInstance() + .renderBlockUsingTexture(tieredBlock.getKey(), (int) x, (int) this.posY, (int) z, icon); + + tessellator.setTranslation(0d, 0d, 0d); + + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glDepthMask(true); + } + + @Override + public int getFXLayer() { + return 1; + } + + @Override + public boolean shouldRenderInPass(int pass) { + return pass == 2; + } +} diff --git a/src/main/java/bartworks/client/renderer/RendererGlassBlock.java b/src/main/java/bartworks/client/renderer/RendererGlassBlock.java new file mode 100644 index 0000000000..1af553ff59 --- /dev/null +++ b/src/main/java/bartworks/client/renderer/RendererGlassBlock.java @@ -0,0 +1,112 @@ +/* + * 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.client.renderer; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.world.IBlockAccess; + +import org.lwjgl.opengl.GL11; + +import com.gtnewhorizons.angelica.api.ThreadSafeISBRH; + +import bartworks.common.blocks.BWBlocksGlass; +import bartworks.common.blocks.BWBlocksGlass2; +import bartworks.common.loaders.ItemRegistry; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +@ThreadSafeISBRH(perThread = false) +public class RendererGlassBlock implements ISimpleBlockRenderingHandler { + + public static int renderID; + public static RendererGlassBlock INSTANCE; + + public static void register() { + renderID = RenderingRegistry.getNextAvailableRenderId(); + INSTANCE = new RendererGlassBlock(); + RenderingRegistry.registerBlockHandler(INSTANCE); + } + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + Tessellator tessellator = Tessellator.instance; + block.setBlockBoundsForItemRender(); + renderer.setRenderBoundsFromBlock(block); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 0, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 1, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 2, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 3, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 4, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 5, metadata)); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + + // spotless:off + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, + RenderBlocks renderer) { + boolean flag = false; + if (block instanceof BWBlocksGlass) { + flag |= renderer.renderStandardBlock(ItemRegistry.bw_fake_glasses, x, y, z); + flag |= renderer.renderStandardBlockWithColorMultiplier(block, x, y, z, + ((BWBlocksGlass) block).getColor(world.getBlockMetadata(x, y, z))[0] / 255f, + ((BWBlocksGlass) block).getColor(world.getBlockMetadata(x, y, z))[1] / 255f, + ((BWBlocksGlass) block).getColor(world.getBlockMetadata(x, y, z))[2] / 255f); + } + if (block instanceof BWBlocksGlass2) { + flag |= renderer.renderStandardBlock(ItemRegistry.bw_fake_glasses2, x, y, z); + flag |= renderer.renderStandardBlockWithColorMultiplier(block, x, y, z, + ((BWBlocksGlass2) block).getColor(world.getBlockMetadata(x, y, z))[0] / 255f, + ((BWBlocksGlass2) block).getColor(world.getBlockMetadata(x, y, z))[1] / 255f, + ((BWBlocksGlass2) block).getColor(world.getBlockMetadata(x, y, z))[2] / 255f); + } + return flag; + } + // spotless:on + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return RendererGlassBlock.renderID; + } +} diff --git a/src/main/java/bartworks/client/renderer/RendererSwitchingColorFluid.java b/src/main/java/bartworks/client/renderer/RendererSwitchingColorFluid.java new file mode 100644 index 0000000000..ba565cc2aa --- /dev/null +++ b/src/main/java/bartworks/client/renderer/RendererSwitchingColorFluid.java @@ -0,0 +1,333 @@ +/* + * 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.client.renderer; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.fluids.BlockFluidBase; +import net.minecraftforge.fluids.IFluidBlock; + +import com.gtnewhorizons.angelica.api.ThreadSafeISBRH; + +import bartworks.common.blocks.BlockBioFluid; +import bartworks.common.loaders.FluidLoader; +import bartworks.common.tileentities.multis.MTEBioVat; +import bartworks.util.Coords; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +@ThreadSafeISBRH(perThread = false) +public class RendererSwitchingColorFluid implements ISimpleBlockRenderingHandler { + + private static final float LIGHT_Y_NEG = 0.5f; + private static final float LIGHT_Y_POS = 1f; + private static final float LIGHT_XZ_NEG = 0.8f; + private static final float LIGHT_XZ_POS = 0.6f; + private static final float THREE_QUARTERS_FILLED = 0.875f; + private static final double RENDER_OFFSET = 0.0010000000474974513; + + public static RendererSwitchingColorFluid instance; + + public static void register() { + instance = new RendererSwitchingColorFluid(); + } + + private float getFluidHeightAverage(float[] flow) { + float total = 0.0f; + int count = 0; + float end = 0.0f; + for (float aFlow : flow) { + if (aFlow >= RendererSwitchingColorFluid.THREE_QUARTERS_FILLED + && end != RendererSwitchingColorFluid.LIGHT_Y_POS) { + end = aFlow; + } + if (aFlow >= 0.0f) { + total += aFlow; + ++count; + } + } + if (end == 0.0f && count != 0) { + end = total / count; + } + return end; + } + + private float getFluidHeightForRender(IBlockAccess world, int x, int y, int z, BlockFluidBase block) { + + if (world.getBlock(x, y, z) == block) { + Block vOrigin = world.getBlock(x, y + 1, z); + if (vOrigin.getMaterial() + .isLiquid() || vOrigin instanceof IFluidBlock) { + return RendererSwitchingColorFluid.LIGHT_Y_POS; + } + if (world.getBlockMetadata(x, y, z) == block.getMaxRenderHeightMeta()) { + return RendererSwitchingColorFluid.THREE_QUARTERS_FILLED; + } + } + return !world.getBlock(x, y, z) + .getMaterial() + .isSolid() && world.getBlock(x, y + 1, z) == block ? RendererSwitchingColorFluid.LIGHT_Y_POS + : block.getQuantaPercentage(world, x, y, z) * RendererSwitchingColorFluid.THREE_QUARTERS_FILLED; + } + + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {} + + @SideOnly(Side.CLIENT) + public boolean renderWorldBlock(IBlockAccess iBlockAccess, int x, int y, int z, Block block, int modelId, + RenderBlocks renderer) { + if (!(block instanceof BlockBioFluid)) return false; + Tessellator tessellator = Tessellator.instance; + Coords blockat = new Coords( + x, + y, + z, + iBlockAccess.getTileEntity(x, y, z) + .getWorldObj().provider.dimensionId); + Integer rgb = MTEBioVat.staticColorMap.get(blockat); + + int r, g, b; + + if (rgb != null) { + r = rgb >> 16 & 0xFF; + g = rgb >> 8 & 0xFF; + b = rgb & 0xFF; + } else { + r = 0; + g = 0; + b = 255; + } + float red = r / 255f, green = g / 255f, blue = b / 255f; + + BlockFluidBase blockFluidBase = (BlockFluidBase) block; + boolean renderTop = iBlockAccess.getBlock(x, y + 1, z) != blockFluidBase; + boolean renderBottom = block.shouldSideBeRendered(iBlockAccess, x, y - 1, z, 0) + && iBlockAccess.getBlock(x, y - 1, z) != blockFluidBase; + boolean[] renderSides = { block.shouldSideBeRendered(iBlockAccess, x, y, z - 1, 2), + block.shouldSideBeRendered(iBlockAccess, x, y, z + 1, 3), + block.shouldSideBeRendered(iBlockAccess, x - 1, y, z, 4), + block.shouldSideBeRendered(iBlockAccess, x + 1, y, z, 5) }; + if (!renderTop && !renderBottom && !renderSides[0] && !renderSides[1] && !renderSides[2] && !renderSides[3]) { + return false; + } + boolean rendered = false; + float fluidHeightForRender = this.getFluidHeightForRender(iBlockAccess, x, y, z, blockFluidBase); + double heightNW, heightSW, heightSE, heightNE; + + if (fluidHeightForRender != RendererSwitchingColorFluid.LIGHT_Y_POS) { + float fluidHeightForRender1 = this.getFluidHeightForRender(iBlockAccess, x - 1, y, z - 1, blockFluidBase); + float fluidHeightForRender2 = this.getFluidHeightForRender(iBlockAccess, x - 1, y, z, blockFluidBase); + float fluidHeightForRender3 = this.getFluidHeightForRender(iBlockAccess, x - 1, y, z + 1, blockFluidBase); + float fluidHeightForRender4 = this.getFluidHeightForRender(iBlockAccess, x, y, z - 1, blockFluidBase); + float fluidHeightForRender5 = this.getFluidHeightForRender(iBlockAccess, x, y, z + 1, blockFluidBase); + float fluidHeightForRender6 = this.getFluidHeightForRender(iBlockAccess, x + 1, y, z - 1, blockFluidBase); + float fluidHeightForRender7 = this.getFluidHeightForRender(iBlockAccess, x + 1, y, z, blockFluidBase); + float fluidHeightForRender8 = this.getFluidHeightForRender(iBlockAccess, x + 1, y, z + 1, blockFluidBase); + heightNW = this.getFluidHeightAverage( + new float[] { fluidHeightForRender1, fluidHeightForRender2, fluidHeightForRender4, + fluidHeightForRender }); + heightSW = this.getFluidHeightAverage( + new float[] { fluidHeightForRender2, fluidHeightForRender3, fluidHeightForRender5, + fluidHeightForRender }); + heightSE = this.getFluidHeightAverage( + new float[] { fluidHeightForRender5, fluidHeightForRender7, fluidHeightForRender8, + fluidHeightForRender }); + heightNE = this.getFluidHeightAverage( + new float[] { fluidHeightForRender4, fluidHeightForRender6, fluidHeightForRender7, + fluidHeightForRender }); + } else { + heightNW = fluidHeightForRender; + heightSW = fluidHeightForRender; + heightSE = fluidHeightForRender; + heightNE = fluidHeightForRender; + } + + if (renderer.renderAllFaces || renderTop) { + rendered = true; + IIcon iconStill = this.getNullCheckedIiconOrFallbackTexture(); + float flowDir = (float) BlockFluidBase.getFlowDirection(iBlockAccess, x, y, z); + + heightNW -= RendererSwitchingColorFluid.RENDER_OFFSET; + heightSW -= RendererSwitchingColorFluid.RENDER_OFFSET; + heightSE -= RendererSwitchingColorFluid.RENDER_OFFSET; + heightNE -= RendererSwitchingColorFluid.RENDER_OFFSET; + + double dInterpolatedU, dInterpolatedV, dInterpolatedU2, dInterpolatedV2, dInterpolatedU3, dInterpolatedV3, + dInterpolatedU4, dInterpolatedV4; + + if (flowDir < -999.0f) { + dInterpolatedU = iconStill.getInterpolatedU(0.0); + dInterpolatedV = iconStill.getInterpolatedV(0.0); + dInterpolatedU2 = dInterpolatedU; + dInterpolatedV2 = iconStill.getInterpolatedV(16.0); + dInterpolatedU3 = iconStill.getInterpolatedU(16.0); + dInterpolatedV3 = dInterpolatedV2; + dInterpolatedU4 = dInterpolatedU3; + dInterpolatedV4 = dInterpolatedV; + } else { + float xFlow = MathHelper.sin(flowDir) * 0.25f, zFlow = MathHelper.cos(flowDir) * 0.25f; + dInterpolatedU = iconStill.getInterpolatedU(8.0f + (-zFlow - xFlow) * 16.0f); + dInterpolatedV = iconStill.getInterpolatedV(8.0f + (-zFlow + xFlow) * 16.0f); + dInterpolatedU2 = iconStill.getInterpolatedU(8.0f + (-zFlow + xFlow) * 16.0f); + dInterpolatedV2 = iconStill.getInterpolatedV(8.0f + (zFlow + xFlow) * 16.0f); + dInterpolatedU3 = iconStill.getInterpolatedU(8.0f + (zFlow + xFlow) * 16.0f); + dInterpolatedV3 = iconStill.getInterpolatedV(8.0f + (zFlow - xFlow) * 16.0f); + dInterpolatedU4 = iconStill.getInterpolatedU(8.0f + (zFlow - xFlow) * 16.0f); + dInterpolatedV4 = iconStill.getInterpolatedV(8.0f + (-zFlow - xFlow) * 16.0f); + } + + tessellator.setBrightness(block.getMixedBrightnessForBlock(iBlockAccess, x, y, z)); + tessellator.setColorOpaque_F( + RendererSwitchingColorFluid.LIGHT_Y_POS * red, + RendererSwitchingColorFluid.LIGHT_Y_POS * green, + RendererSwitchingColorFluid.LIGHT_Y_POS * blue); + + tessellator.addVertexWithUV(x, y + heightNW, z, dInterpolatedU, dInterpolatedV); + tessellator.addVertexWithUV(x, y + heightSW, z + 1, dInterpolatedU2, dInterpolatedV2); + tessellator.addVertexWithUV(x + 1, y + heightSE, z + 1, dInterpolatedU3, dInterpolatedV3); + tessellator.addVertexWithUV(x + 1, y + heightNE, z, dInterpolatedU4, dInterpolatedV4); + tessellator.addVertexWithUV(x, y + heightNW, z, dInterpolatedU, dInterpolatedV); + tessellator.addVertexWithUV(x + 1, y + heightNE, z, dInterpolatedU4, dInterpolatedV4); + tessellator.addVertexWithUV(x + 1, y + heightSE, z + 1, dInterpolatedU3, dInterpolatedV3); + tessellator.addVertexWithUV(x, y + heightSW, z + 1, dInterpolatedU2, dInterpolatedV2); + } + + if (renderer.renderAllFaces || renderBottom) { + rendered = true; + tessellator.setBrightness(block.getMixedBrightnessForBlock(iBlockAccess, x, y - 1, z)); + tessellator.setColorOpaque_F( + RendererSwitchingColorFluid.LIGHT_Y_NEG * red, + RendererSwitchingColorFluid.LIGHT_Y_NEG * green, + RendererSwitchingColorFluid.LIGHT_Y_NEG * blue); + renderer.renderFaceYNeg( + block, + x, + y + RendererSwitchingColorFluid.RENDER_OFFSET, + z, + this.getNullCheckedIiconOrFallbackTexture()); + } + + for (int side = 0; side < 4; ++side) { + int x2 = x, z2 = z; + + switch (side) { + case 0: + --z2; + break; + case 1: + ++z2; + break; + case 2: + --x2; + break; + case 3: + ++x2; + break; + default: + break; + } + + IIcon iconFlow = this.getNullCheckedIiconOrFallbackTexture(); + + if (renderer.renderAllFaces || renderSides[side]) { + rendered = true; + double dHeight1, dHeight2, dXcoord1, dXcoord2, dZcoord1, dZcoord2; + dZcoord2 = switch (side) { + case 0 -> { + dHeight1 = heightNW; + dHeight2 = heightNE; + dXcoord1 = x; + dXcoord2 = x + 1; + dZcoord1 = z + RendererSwitchingColorFluid.RENDER_OFFSET; + yield z + RendererSwitchingColorFluid.RENDER_OFFSET; + } + case 1 -> { + dHeight1 = heightSE; + dHeight2 = heightSW; + dXcoord1 = x + 1; + dXcoord2 = x; + dZcoord1 = z + 1 - RendererSwitchingColorFluid.RENDER_OFFSET; + yield z + 1 - RendererSwitchingColorFluid.RENDER_OFFSET; + } + case 2 -> { + dHeight1 = heightSW; + dHeight2 = heightNW; + dXcoord1 = x + RendererSwitchingColorFluid.RENDER_OFFSET; + dXcoord2 = x + RendererSwitchingColorFluid.RENDER_OFFSET; + dZcoord1 = z + 1; + yield z; + } + default -> { + dHeight1 = heightNE; + dHeight2 = heightSE; + dXcoord1 = x + 1 - RendererSwitchingColorFluid.RENDER_OFFSET; + dXcoord2 = x + 1 - RendererSwitchingColorFluid.RENDER_OFFSET; + dZcoord1 = z; + yield z + 1; + } + }; + float u1Flow = iconFlow.getInterpolatedU(0.0); + float u2Flow = iconFlow.getInterpolatedU(8.0); + float v1Flow = iconFlow.getInterpolatedV((1.0 - dHeight1) * 16.0 * 0.5); + float v2Flow = iconFlow.getInterpolatedV((1.0 - dHeight2) * 16.0 * 0.5); + float v3Flow = iconFlow.getInterpolatedV(8.0); + tessellator.setBrightness(block.getMixedBrightnessForBlock(iBlockAccess, x2, y, z2)); + float sideLighting; + if (side < 2) { + sideLighting = RendererSwitchingColorFluid.LIGHT_XZ_NEG; + } else { + sideLighting = RendererSwitchingColorFluid.LIGHT_XZ_POS; + } + tessellator.setColorOpaque_F( + RendererSwitchingColorFluid.LIGHT_Y_POS * sideLighting * red, + RendererSwitchingColorFluid.LIGHT_Y_POS * sideLighting * green, + RendererSwitchingColorFluid.LIGHT_Y_POS * sideLighting * blue); + + tessellator.addVertexWithUV(dXcoord1, y + dHeight1, dZcoord1, u1Flow, v1Flow); + tessellator.addVertexWithUV(dXcoord2, y + dHeight2, dZcoord2, u2Flow, v2Flow); + tessellator.addVertexWithUV(dXcoord2, y, dZcoord2, u2Flow, v3Flow); + tessellator.addVertexWithUV(dXcoord1, y, dZcoord1, u1Flow, v3Flow); + tessellator.addVertexWithUV(dXcoord1, y + dHeight1, dZcoord1, u1Flow, v1Flow); + tessellator.addVertexWithUV(dXcoord1, y, dZcoord1, u1Flow, v3Flow); + tessellator.addVertexWithUV(dXcoord2, y, dZcoord2, u2Flow, v3Flow); + tessellator.addVertexWithUV(dXcoord2, y + dHeight2, dZcoord2, u2Flow, v2Flow); + } + } + renderer.renderMinY = 0.0; + renderer.renderMaxY = 1.0; + return rendered; + } + + public boolean shouldRender3DInInventory(int modelId) { + return false; + } + + public int getRenderId() { + return FluidLoader.renderID; + } + + private IIcon getNullCheckedIiconOrFallbackTexture() { + return FluidLoader.autogenIIcon != null ? FluidLoader.autogenIIcon + : ((TextureMap) Minecraft.getMinecraft() + .getTextureManager() + .getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno"); + } +} diff --git a/src/main/java/bartworks/client/textures/PrefixTextureLinker.java b/src/main/java/bartworks/client/textures/PrefixTextureLinker.java new file mode 100644 index 0000000000..d406a994e4 --- /dev/null +++ b/src/main/java/bartworks/client/textures/PrefixTextureLinker.java @@ -0,0 +1,91 @@ +/* + * 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.client.textures; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Stream; + +import bartworks.system.material.Werkstoff; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TextureSet; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; + +@SideOnly(Side.CLIENT) +public class PrefixTextureLinker implements Runnable { + + public static Map<OrePrefixes, HashMap<TextureSet, Textures.ItemIcons.CustomIcon>> texMap = new HashMap<>(); + public static Map<OrePrefixes, HashMap<TextureSet, IIconContainer>> texMapBlocks = new HashMap<>(); + public static Map<TextureSet, Short> blockTexMap = new HashMap<>(); + + private static void fillBlockTexMap() { + blockTexMap.put(TextureSet.SET_QUARTZ, TextureSet.INDEX_block4); + Stream.of(OrePrefixes.blockCasing, OrePrefixes.blockCasingAdvanced) + .forEach(prefixes -> { + HashMap<TextureSet, IIconContainer> curr = new HashMap<>(); + Arrays.stream(TextureSet.class.getFields()) + .filter( + field -> field.getName() + .contains("SET")) + .forEach(SET -> { + try { + curr.put( + (TextureSet) SET.get(null), + new Textures.BlockIcons.CustomIcon( + "materialicons/" + SET.getName() + .substring(4) + "/" + prefixes)); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + }); + texMapBlocks.put(prefixes, curr); + }); + } + + private static void fillItemTexMap() { + Arrays.stream(OrePrefixes.values()) + .filter( + prefixes -> prefixes != OrePrefixes.rod && prefixes.mTextureIndex == -1 + && Werkstoff.GenerationFeatures.getPrefixDataRaw(prefixes) != 0) + .forEach(prefixes -> { + HashMap<TextureSet, Textures.ItemIcons.CustomIcon> curr = new HashMap<>(); + Arrays.stream(TextureSet.class.getFields()) + .filter( + field -> field.getName() + .contains("SET")) + .forEach(SET -> { + try { + curr.put( + (TextureSet) SET.get(null), + new Textures.ItemIcons.CustomIcon( + "materialicons/" + SET.getName() + .substring(4) + "/" + prefixes)); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + }); + texMap.put(prefixes, curr); + }); + } + + @Override + public void run() { + fillItemTexMap(); + fillBlockTexMap(); + } +} diff --git a/src/main/java/bartworks/common/blocks/BWBlocks.java b/src/main/java/bartworks/common/blocks/BWBlocks.java new file mode 100644 index 0000000000..84d4a2f942 --- /dev/null +++ b/src/main/java/bartworks/common/blocks/BWBlocks.java @@ -0,0 +1,134 @@ +/* + * 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.common.blocks; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import bartworks.MainMod; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTechAPI; + +public class BWBlocks extends Block { + + @SideOnly(Side.CLIENT) + protected IIcon[] texture; + + String[] textureNames; + protected String name; + + public BWBlocks(String name, String[] texture) { + super(Material.anvil); + this.setHardness(15.0F); + this.setResistance(30.0F); + this.name = name; + this.textureNames = texture; + this.setCreativeTab(MainMod.GT2); + GregTechAPI.registerMachineBlock(this, -1); + } + + public BWBlocks(String name, String[] texture, CreativeTabs tabs) { + super(Material.anvil); + this.setHardness(15.0F); + this.setResistance(30.0F); + this.name = name; + this.textureNames = texture; + this.setCreativeTab(tabs); + GregTechAPI.registerMachineBlock(this, -1); + } + + public BWBlocks(String name, String[] texture, CreativeTabs tabs, Material material) { + super(material); + this.setHardness(15.0F); + this.setResistance(30.0F); + this.name = name; + this.textureNames = texture; + this.setCreativeTab(tabs); + GregTechAPI.registerMachineBlock(this, -1); + } + + @Override + public int damageDropped(int meta) { + return meta; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) { + for (int i = 0; i < this.textureNames.length; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + return meta < this.texture.length ? this.texture[meta] : this.texture[0]; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + this.texture = new IIcon[this.textureNames.length]; + for (int i = 0; i < this.textureNames.length; i++) { + this.texture[i] = par1IconRegister.registerIcon(this.textureNames[i]); + } + } + + @Override + public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { + if (GregTechAPI.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { + GregTechAPI.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } + + @Override + public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetaData) { + if (GregTechAPI.isMachineBlock(this, aMetaData)) { + GregTechAPI.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } + + @Override + public String getUnlocalizedName() { + return this.name; + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { + return false; + } + + @Override + public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { + return false; + } + + @Override + public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { + return false; + } +} diff --git a/src/main/java/bartworks/common/blocks/BWBlocksGlass.java b/src/main/java/bartworks/common/blocks/BWBlocksGlass.java new file mode 100644 index 0000000000..be3ffbf07e --- /dev/null +++ b/src/main/java/bartworks/common/blocks/BWBlocksGlass.java @@ -0,0 +1,187 @@ +/* + * 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.common.blocks; + +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.util.ForgeDirection; + +import bartworks.API.SideReference; +import bartworks.client.renderer.RendererGlassBlock; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BWBlocksGlass extends BWBlocks { + + @SideOnly(Side.CLIENT) + private IIcon[] connectedTexture; + + private final boolean connectedTex; + private boolean fake; + private short[][] color = new short[this.textureNames.length][3]; + + public BWBlocksGlass(String name, String[] texture, CreativeTabs tabs) { + super(name, texture, tabs, Material.glass); + this.connectedTex = false; + } + + public BWBlocksGlass(String name, String[] texture, short[][] color, CreativeTabs tabs, boolean connectedTex, + boolean fake) { + super(name, texture, tabs, Material.glass); + this.connectedTex = connectedTex; + this.color = color; + this.fake = fake; + } + + public short[] getColor(int meta) { + return meta < this.texture.length ? this.color[meta] : this.color[0]; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess worldClient, int xCoord, int yCoord, int zCoord, int aSide) { + if (worldClient.getBlock(xCoord, yCoord, zCoord) instanceof BWBlocksGlass) return false; + return super.shouldSideBeRendered(worldClient, xCoord, yCoord, zCoord, aSide); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + return meta < this.texture.length ? this.texture[meta] : this.texture[0]; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + if (!this.connectedTex) { + this.texture = new IIcon[this.textureNames.length]; + for (int i = 0; i < this.textureNames.length; i++) { + this.texture[i] = par1IconRegister.registerIcon(this.textureNames[i]); + } + return; + } + this.texture = new IIcon[this.textureNames.length]; + this.connectedTexture = new IIcon[16]; + for (int i = 0; i < this.textureNames.length; i++) { + this.texture[i] = par1IconRegister.registerIcon(this.textureNames[i]); + String[] splitname = this.textureNames[0].split(":"); + for (int j = 0; j < 16; j++) { + this.connectedTexture[j] = par1IconRegister + .registerIcon(splitname[0] + ":connectedTex/" + splitname[1] + '/' + splitname[1] + '_' + j); + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess worldClient, int xCoord, int yCoord, int zCoord, int aSide) { + if (!this.connectedTex) return super.getIcon(worldClient, xCoord, yCoord, zCoord, aSide); + + ForgeDirection dir = ForgeDirection.getOrientation(aSide); + byte sides = 0; + switch (dir) { + case UP: + case DOWN: { + if (worldClient.getBlock(xCoord, yCoord, zCoord - 1) instanceof BWBlocksGlass) + sides = (byte) (sides | 0b0001); + if (worldClient.getBlock(xCoord, yCoord, zCoord + 1) instanceof BWBlocksGlass) + sides = (byte) (sides | 0b0010); + if (worldClient.getBlock(xCoord - 1, yCoord, zCoord) instanceof BWBlocksGlass) + sides = (byte) (sides | 0b0100); + if (worldClient.getBlock(xCoord + 1, yCoord, zCoord) instanceof BWBlocksGlass) + sides = (byte) (sides | 0b1000); + break; + } + case EAST: { + if (worldClient.getBlock(xCoord, yCoord + 1, zCoord) instanceof BWBlocksGlass) + sides = (byte) (sides | 0b0001); + if (worldClient.getBlock(xCoord, yCoord - 1, zCoord) instanceof BWBlocksGlass) + sides = (byte) (sides | 0b0010); + if (worldClient.getBlock(xCoord, yCoord, zCoord + 1) instanceof BWBlocksGlass) + sides = (byte) (sides | 0b0100); + if (worldClient.getBlock(xCoord, yCoord, zCoord - 1) instanceof BWBlocksGlass) + sides = (byte) (sides | 0b1000); + break; + } + case WEST: { + if (worldClient.getBlock(xCoord, yCoord + 1, zCoord) instanceof BWBlocksGlass) + sides = (byte) (sides | 0b0001); + if (worldClient.getBlock(xCoord, yCoord - 1, zCoord) instanceof BWBlocksGlass) + sides = (byte) (sides | 0b0010); + if (worldClient.getBlock(xCoord, yCoord, zCoord - 1) instanceof BWBlocksGlass) + sides = (byte) (sides | 0b0100); + if (worldClient.getBlock(xCoord, yCoord, zCoord + 1) instanceof BWBlocksGlass) + sides = (byte) (sides | 0b1000); + break; + } + case NORTH: { + if (worldClient.getBlock(xCoord, yCoord + 1, zCoord) instanceof BWBlocksGlass) + sides = (byte) (sides | 0b0001); + if (worldClient.getBlock(xCoord, yCoord - 1, zCoord) instanceof BWBlocksGlass) + sides = (byte) (sides | 0b0010); + if (worldClient.getBlock(xCoord + 1, yCoord, zCoord) instanceof BWBlocksGlass) + sides = (byte) (sides | 0b0100); + if (worldClient.getBlock(xCoord - 1, yCoord, zCoord) instanceof BWBlocksGlass) + sides = (byte) (sides | 0b1000); + break; + } + case SOUTH: { + if (worldClient.getBlock(xCoord, yCoord + 1, zCoord) instanceof BWBlocksGlass) + sides = (byte) (sides | 0b0001); + if (worldClient.getBlock(xCoord, yCoord - 1, zCoord) instanceof BWBlocksGlass) + sides = (byte) (sides | 0b0010); + if (worldClient.getBlock(xCoord - 1, yCoord, zCoord) instanceof BWBlocksGlass) + sides = (byte) (sides | 0b0100); + if (worldClient.getBlock(xCoord + 1, yCoord, zCoord) instanceof BWBlocksGlass) + sides = (byte) (sides | 0b1000); + break; + } + case UNKNOWN: + default: { + break; + } + } + return this.connectedTexture[sides]; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + return 1; + } + + @Override + public int getRenderType() { + if (!this.fake && SideReference.Side.Client) return RendererGlassBlock.renderID; + return 0; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + protected boolean canSilkHarvest() { + return false; + } +} diff --git a/src/main/java/bartworks/common/blocks/BWBlocksGlass2.java b/src/main/java/bartworks/common/blocks/BWBlocksGlass2.java new file mode 100644 index 0000000000..4c0d928049 --- /dev/null +++ b/src/main/java/bartworks/common/blocks/BWBlocksGlass2.java @@ -0,0 +1,179 @@ +package bartworks.common.blocks; + +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.util.ForgeDirection; + +import bartworks.API.SideReference; +import bartworks.client.renderer.RendererGlassBlock; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BWBlocksGlass2 extends BWBlocks { + + @SideOnly(Side.CLIENT) + private IIcon[] connectedTexture; + + private final boolean connectedTex; + private boolean fake; + private short[][] color = new short[this.textureNames.length][3]; + + public BWBlocksGlass2(String name, String[] texture, CreativeTabs tabs) { + super(name, texture, tabs, Material.glass); + this.connectedTex = false; + } + + public BWBlocksGlass2(String name, String[] texture, short[][] color, CreativeTabs tabs, boolean connectedTex, + boolean fake) { + super(name, texture, tabs, Material.glass); + this.connectedTex = connectedTex; + this.color = color; + this.fake = fake; + } + + public short[] getColor(int meta) { + return meta < this.texture.length ? this.color[meta] : this.color[0]; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess worldClient, int xCoord, int yCoord, int zCoord, int aSide) { + if (worldClient.getBlock(xCoord, yCoord, zCoord) instanceof BWBlocksGlass2) return false; + return super.shouldSideBeRendered(worldClient, xCoord, yCoord, zCoord, aSide); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + return meta < this.texture.length ? this.texture[meta] : this.texture[0]; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + if (!this.connectedTex) { + this.texture = new IIcon[this.textureNames.length]; + for (int i = 0; i < this.textureNames.length; i++) { + this.texture[i] = par1IconRegister.registerIcon(this.textureNames[i]); + } + return; + } + this.texture = new IIcon[this.textureNames.length]; + this.connectedTexture = new IIcon[16]; + for (int i = 0; i < this.textureNames.length; i++) { + this.texture[i] = par1IconRegister.registerIcon(this.textureNames[i]); + String[] splitname = this.textureNames[0].split(":"); + for (int j = 0; j < 16; j++) { + this.connectedTexture[j] = par1IconRegister.registerIcon( + splitname[0] + ":connectedTex/" + + "BoronSilicateGlassBlock" + + '/' + + "BoronSilicateGlassBlock" + + '_' + + j); + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess worldClient, int xCoord, int yCoord, int zCoord, int aSide) { + if (!this.connectedTex) return super.getIcon(worldClient, xCoord, yCoord, zCoord, aSide); + + ForgeDirection dir = ForgeDirection.getOrientation(aSide); + byte sides = 0; + switch (dir) { + case UP: + case DOWN: { + if (worldClient.getBlock(xCoord, yCoord, zCoord - 1) instanceof BWBlocksGlass2) + sides = (byte) (sides | 0b0001); + if (worldClient.getBlock(xCoord, yCoord, zCoord + 1) instanceof BWBlocksGlass2) + sides = (byte) (sides | 0b0010); + if (worldClient.getBlock(xCoord - 1, yCoord, zCoord) instanceof BWBlocksGlass2) + sides = (byte) (sides | 0b0100); + if (worldClient.getBlock(xCoord + 1, yCoord, zCoord) instanceof BWBlocksGlass2) + sides = (byte) (sides | 0b1000); + break; + } + case EAST: { + if (worldClient.getBlock(xCoord, yCoord + 1, zCoord) instanceof BWBlocksGlass2) + sides = (byte) (sides | 0b0001); + if (worldClient.getBlock(xCoord, yCoord - 1, zCoord) instanceof BWBlocksGlass2) + sides = (byte) (sides | 0b0010); + if (worldClient.getBlock(xCoord, yCoord, zCoord + 1) instanceof BWBlocksGlass2) + sides = (byte) (sides | 0b0100); + if (worldClient.getBlock(xCoord, yCoord, zCoord - 1) instanceof BWBlocksGlass2) + sides = (byte) (sides | 0b1000); + break; + } + case WEST: { + if (worldClient.getBlock(xCoord, yCoord + 1, zCoord) instanceof BWBlocksGlass2) + sides = (byte) (sides | 0b0001); + if (worldClient.getBlock(xCoord, yCoord - 1, zCoord) instanceof BWBlocksGlass2) + sides = (byte) (sides | 0b0010); + if (worldClient.getBlock(xCoord, yCoord, zCoord - 1) instanceof BWBlocksGlass2) + sides = (byte) (sides | 0b0100); + if (worldClient.getBlock(xCoord, yCoord, zCoord + 1) instanceof BWBlocksGlass2) + sides = (byte) (sides | 0b1000); + break; + } + case NORTH: { + if (worldClient.getBlock(xCoord, yCoord + 1, zCoord) instanceof BWBlocksGlass2) + sides = (byte) (sides | 0b0001); + if (worldClient.getBlock(xCoord, yCoord - 1, zCoord) instanceof BWBlocksGlass2) + sides = (byte) (sides | 0b0010); + if (worldClient.getBlock(xCoord + 1, yCoord, zCoord) instanceof BWBlocksGlass2) + sides = (byte) (sides | 0b0100); + if (worldClient.getBlock(xCoord - 1, yCoord, zCoord) instanceof BWBlocksGlass2) + sides = (byte) (sides | 0b1000); + break; + } + case SOUTH: { + if (worldClient.getBlock(xCoord, yCoord + 1, zCoord) instanceof BWBlocksGlass2) + sides = (byte) (sides | 0b0001); + if (worldClient.getBlock(xCoord, yCoord - 1, zCoord) instanceof BWBlocksGlass2) + sides = (byte) (sides | 0b0010); + if (worldClient.getBlock(xCoord - 1, yCoord, zCoord) instanceof BWBlocksGlass2) + sides = (byte) (sides | 0b0100); + if (worldClient.getBlock(xCoord + 1, yCoord, zCoord) instanceof BWBlocksGlass2) + sides = (byte) (sides | 0b1000); + break; + } + case UNKNOWN: + default: { + break; + } + } + return this.connectedTexture[sides]; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + return 1; + } + + @Override + public int getRenderType() { + if (!this.fake && SideReference.Side.Client) return RendererGlassBlock.renderID; + return 0; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + protected boolean canSilkHarvest() { + return false; + } +} diff --git a/src/main/java/bartworks/common/blocks/BWMachineBlockContainer.java b/src/main/java/bartworks/common/blocks/BWMachineBlockContainer.java new file mode 100644 index 0000000000..1c652a0984 --- /dev/null +++ b/src/main/java/bartworks/common/blocks/BWMachineBlockContainer.java @@ -0,0 +1,43 @@ +/* + * 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.common.blocks; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import gregtech.api.GregTechAPI; + +public class BWMachineBlockContainer extends BWTileEntityContainer { + + public BWMachineBlockContainer(Material p_i45386_1_, Class<? extends TileEntity> tileEntity, String blockName) { + super(p_i45386_1_, tileEntity, blockName); + GregTechAPI.registerMachineBlock(this, -1); + } + + @Override + public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { + if (GregTechAPI.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { + GregTechAPI.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } + + @Override + public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetaData) { + if (GregTechAPI.isMachineBlock(this, aMetaData)) { + GregTechAPI.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } +} diff --git a/src/main/java/bartworks/common/blocks/BWMultipleTileEntityContainer.java b/src/main/java/bartworks/common/blocks/BWMultipleTileEntityContainer.java new file mode 100644 index 0000000000..ad7bbcf5c9 --- /dev/null +++ b/src/main/java/bartworks/common/blocks/BWMultipleTileEntityContainer.java @@ -0,0 +1,164 @@ +/* + * 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.common.blocks; + +import java.util.List; + +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import com.gtnewhorizons.modularui.api.UIInfos; +import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; + +import bartworks.MainMod; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.api.tile.IWrenchable; +import ic2.core.IC2; +import ic2.core.IHasGui; + +public class BWMultipleTileEntityContainer extends BlockContainer { + + protected final String[] textureNames; + protected final String name; + protected final Class<? extends TileEntity>[] tileEntityArray; + + @SideOnly(Side.CLIENT) + protected IIcon[] texture; + + public BWMultipleTileEntityContainer(Material p_i45386_1_, Class<? extends TileEntity>[] tileEntity, + String blockName, String[] textureNames, CreativeTabs tabs) { + super(p_i45386_1_); + this.setHardness(15.0F); + this.setResistance(30.0F); + this.tileEntityArray = tileEntity; + this.name = blockName; + this.textureNames = textureNames; + this.setCreativeTab(tabs); + this.setBlockName(blockName); + this.setBlockTextureName(MainMod.MOD_ID + ":" + blockName); + } + + @Override + public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlayer player, int side, float subX, + float subY, float subZ) { + if (worldObj.isRemote) { + return true; + } + if (!player.isSneaking()) { + TileEntity tile = worldObj.getTileEntity(x, y, z); + if (tile instanceof IHasGui) { + return worldObj.isRemote || IC2.platform.launchGui(player, (IHasGui) tile); + } + if (tile instanceof ITileWithModularUI && !worldObj.isRemote) { + UIInfos.TILE_MODULAR_UI.open(player, worldObj, x, y, z); + } + } + + return false; + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemStack) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile instanceof IWrenchable tile2 && itemStack != null) { + int meta = itemStack.getItemDamage(); + world.setBlockMetadataWithNotify(x, y, z, meta, 2); + if (entity != null) { + int face = MathHelper.floor_double(entity.rotationYaw * 4.0f / 360.0f + 0.5) & 0x3; + switch (face) { + case 0: + tile2.setFacing((short) 2); + break; + case 1: + tile2.setFacing((short) 5); + break; + case 2: + tile2.setFacing((short) 3); + break; + case 3: + tile2.setFacing((short) 4); + break; + } + } + } + } + + @Override + public int damageDropped(int meta) { + return meta; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item item, CreativeTabs tab, List<ItemStack> list) { + for (int i = 0; i < this.textureNames.length; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + return meta < this.texture.length ? this.texture[meta] : this.texture[0]; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + this.texture = new IIcon[this.textureNames.length]; + for (int i = 0; i < this.textureNames.length; i++) { + this.texture[i] = par1IconRegister.registerIcon(this.textureNames[i]); + } + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { + return false; + } + + @Override + public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { + return false; + } + + @Override + public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { + return false; + } + + @Override + public TileEntity createNewTileEntity(World worldIn, int meta) { + try { + return this.tileEntityArray[meta].getConstructor() + .newInstance(); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/src/main/java/bartworks/common/blocks/BWTileEntityContainer.java b/src/main/java/bartworks/common/blocks/BWTileEntityContainer.java new file mode 100644 index 0000000000..2a699f8340 --- /dev/null +++ b/src/main/java/bartworks/common/blocks/BWTileEntityContainer.java @@ -0,0 +1,204 @@ +/* + * 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.common.blocks; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.fluids.IFluidContainerItem; + +import com.gtnewhorizons.modularui.api.UIInfos; +import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; + +import bartworks.API.ITileAddsInformation; +import bartworks.API.ITileDropsContent; +import bartworks.API.ITileHasDifferentTextureSides; +import bartworks.MainMod; +import bartworks.common.tileentities.classic.TileEntityHeatedWaterPump; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.api.tile.IWrenchable; +import ic2.core.IC2; +import ic2.core.IHasGui; + +public class BWTileEntityContainer extends BlockContainer implements ITileAddsInformation { + + protected Class<? extends TileEntity> tileEntity; + + public BWTileEntityContainer(Material p_i45386_1_, Class<? extends TileEntity> tileEntity, String blockName) { + super(p_i45386_1_); + this.tileEntity = tileEntity; + this.setHardness(15.0F); + this.setResistance(30.0F); + this.setCreativeTab(MainMod.BWT); + this.setBlockName(blockName); + this.setBlockTextureName(MainMod.MOD_ID + ":" + blockName); + } + + @Override + public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlayer player, int side, float subX, + float subY, float subZ) { + if (worldObj.isRemote) { + return false; + } + TileEntity tile = worldObj.getTileEntity(x, y, z); + if (tile instanceof TileEntityHeatedWaterPump) { + if (player.getHeldItem() != null && (player.getHeldItem() + .getItem() + .equals(Items.bucket) + || player.getHeldItem() + .getItem() instanceof IFluidContainerItem) + && ((TileEntityHeatedWaterPump) tile).drain(1000, false) != null) + if (player.getHeldItem() + .getItem() + .equals(Items.bucket) && ((TileEntityHeatedWaterPump) tile).drain(1000, false).amount == 1000) { + ((TileEntityHeatedWaterPump) tile).drain(1000, true); + player.getHeldItem().stackSize--; + if (player.getHeldItem().stackSize <= 0) + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + player.inventory.addItemStackToInventory(new ItemStack(Items.water_bucket)); + return true; + } + } + if (!player.isSneaking()) { + if (tile instanceof IHasGui) { + return worldObj.isRemote || IC2.platform.launchGui(player, (IHasGui) tile); + } + if (tile instanceof ITileWithModularUI) { + if (!worldObj.isRemote) { + UIInfos.TILE_MODULAR_UI.open(player, worldObj, x, y, z); + } + return true; + } + } + return false; + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemStack) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile instanceof IWrenchable tile2 && itemStack != null) { + int meta = itemStack.getItemDamage(); + world.setBlockMetadataWithNotify(x, y, z, meta, 2); + if (entity != null) { + int face = MathHelper.floor_double(entity.rotationYaw * 4.0f / 360.0f + 0.5) & 0x3; + switch (face) { + case 0: + tile2.setFacing((short) 2); + break; + case 1: + tile2.setFacing((short) 5); + break; + case 2: + tile2.setFacing((short) 3); + break; + case 3: + tile2.setFacing((short) 4); + break; + } + } + } + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + TileEntity t = world.getTileEntity(x, y, z); + if (t instanceof ITileDropsContent) { + int[] dropSlots = ((ITileDropsContent) t).getDropSlots(); + for (int dropSlot : dropSlots) { + if (((ITileDropsContent) t).getStackInSlot(dropSlot) != null) world.spawnEntityInWorld( + new EntityItem(world, x, y, z, ((TileEntityHeatedWaterPump) t).getStackInSlot(dropSlot))); + } + } + super.breakBlock(world, x, y, z, block, meta); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + if (!ITileHasDifferentTextureSides.class.isAssignableFrom(this.tileEntity)) return super.getIcon(side, meta); + try { + return ((ITileHasDifferentTextureSides) this.tileEntity.getConstructor() + .newInstance()).getTextureForSide(side, meta); + } catch (Exception e) { + e.printStackTrace(); + return super.getIcon(side, meta); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + if (ITileHasDifferentTextureSides.class.isAssignableFrom(this.tileEntity)) { + try { + ((ITileHasDifferentTextureSides) this.tileEntity.getConstructor() + .newInstance()).registerBlockIcons(par1IconRegister); + } catch (Exception e) { + e.printStackTrace(); + } + } else super.registerBlockIcons(par1IconRegister); + } + + @Override + public TileEntity createNewTileEntity(World worldIn, int meta) { + try { + return this.tileEntity.getConstructor() + .newInstance(); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { + return false; + } + + @Override + public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { + return false; + } + + @Override + public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { + return false; + } + + @Override + public String[] getInfoData() { + if (ITileAddsInformation.class.isAssignableFrom(this.tileEntity)) { + try { + return ((ITileAddsInformation) this.tileEntity.getConstructor() + .newInstance()).getInfoData(); + } catch (Exception e) { + e.printStackTrace(); + } + } + return new String[0]; + } +} diff --git a/src/main/java/bartworks/common/blocks/BlockBioFluid.java b/src/main/java/bartworks/common/blocks/BlockBioFluid.java new file mode 100644 index 0000000000..df18ed4a9d --- /dev/null +++ b/src/main/java/bartworks/common/blocks/BlockBioFluid.java @@ -0,0 +1,92 @@ +/* + * 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.common.blocks; + +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.fluids.BlockFluidBase; +import net.minecraftforge.fluids.FluidStack; + +import bartworks.common.loaders.FluidLoader; +import bartworks.common.tileentities.classic.TileEntityDimIDBridge; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BlockBioFluid extends BlockFluidBase implements ITileEntityProvider { + + public BlockBioFluid() { + super(FluidLoader.ff, Material.water); + this.setBlockName("BioFluidBlock"); + // this.setCreativeTab(MainMod.BioTab); + this.textureName = "gregtech:fluids/fluid.molten.autogenerated"; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister reg) { + FluidLoader.autogenIIcon = this.blockIcon = reg.registerIcon(this.getTextureName()); + } + + @Override + public int getQuantaValue(IBlockAccess world, int x, int y, int z) { + return 0; + } + + @Override + public boolean canCollideCheck(int meta, boolean fullHit) { + return false; + } + + @Override + public int getMaxRenderHeightMeta() { + return 0; + } + + @Override + public int getRenderType() { + return FluidLoader.renderID; + } + + @Override + public FluidStack drain(World world, int x, int y, int z, boolean doDrain) { + return null; + } + + @Override + public boolean canDrain(World world, int x, int y, int z) { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess worldIn, int x, int y, int z, int side) { + return FluidLoader.autogenIIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + return FluidLoader.autogenIIcon; + } + + @Override + public TileEntity createNewTileEntity(World worldIn, int meta) { + return new TileEntityDimIDBridge(); + } +} diff --git a/src/main/java/bartworks/common/commands/ChangeConfig.java b/src/main/java/bartworks/common/commands/ChangeConfig.java new file mode 100644 index 0000000000..8e7edc765f --- /dev/null +++ b/src/main/java/bartworks/common/commands/ChangeConfig.java @@ -0,0 +1,72 @@ +/* + * 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.common.commands; + +import java.lang.reflect.Field; + +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.util.ChatComponentText; + +import bartworks.common.configs.ConfigHandler; + +public class ChangeConfig extends CommandBase { + + @Override + public String getCommandName() { + return "bwcfg"; + } + + @Override + public String getCommandUsage(ICommandSender sender) { + return "bwcfg <NameOfVariable> <newValue>"; + } + + @Override + @SuppressWarnings("rawtypes") + public void processCommand(ICommandSender sender, String[] args) { + try { + Field f = ConfigHandler.class.getField(args[0]); + Class c = f.getType(); + if (c.equals(int.class)) { + int l; + try { + l = Integer.parseInt(args[1]); + } catch (NumberFormatException e) { + sender.addChatMessage(new ChatComponentText("you need to enter a number!")); + return; + } + f.setInt(null, l); + } else if (c.equals(long.class)) { + long l; + try { + l = Long.parseLong(args[1]); + } catch (NumberFormatException e) { + sender.addChatMessage(new ChatComponentText("you need to enter a number!")); + return; + } + f.setLong(null, l); + } else if (c.equals(boolean.class)) { + if ("true".equalsIgnoreCase(args[1]) || "1".equalsIgnoreCase(args[1])) f.setBoolean(null, true); + else if ("false".equalsIgnoreCase(args[1]) || "0".equalsIgnoreCase(args[1])) f.setBoolean(null, false); + else { + sender.addChatMessage(new ChatComponentText("booleans need to be set to true or false")); + } + } + sender.addChatMessage(new ChatComponentText("Set " + args[0] + " to " + args[1])); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/bartworks/common/commands/ClearCraftingCache.java b/src/main/java/bartworks/common/commands/ClearCraftingCache.java new file mode 100644 index 0000000000..9e164d12f7 --- /dev/null +++ b/src/main/java/bartworks/common/commands/ClearCraftingCache.java @@ -0,0 +1,39 @@ +/* + * 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.common.commands; + +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.util.ChatComponentText; + +import bartworks.ASM.BWCoreStaticReplacementMethodes; + +public class ClearCraftingCache extends CommandBase { + + @Override + public String getCommandName() { + return "bwclr"; + } + + @Override + public String getCommandUsage(ICommandSender sender) { + return "bwclr"; + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + BWCoreStaticReplacementMethodes.clearRecentlyUsedRecipes(); + sender.addChatMessage(new ChatComponentText("Recipe Cache cleared ")); + } +} diff --git a/src/main/java/bartworks/common/commands/GetWorkingDirectory.java b/src/main/java/bartworks/common/commands/GetWorkingDirectory.java new file mode 100644 index 0000000000..b52e067dea --- /dev/null +++ b/src/main/java/bartworks/common/commands/GetWorkingDirectory.java @@ -0,0 +1,37 @@ +/* + * 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.common.commands; + +import net.minecraft.client.Minecraft; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.util.ChatComponentText; + +public class GetWorkingDirectory extends CommandBase { + + @Override + public String getCommandName() { + return "bwgwd"; + } + + @Override + public String getCommandUsage(ICommandSender sender) { + return "bwgwd"; + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + sender.addChatMessage(new ChatComponentText(Minecraft.getMinecraft().mcDataDir.getAbsolutePath())); + } +} diff --git a/src/main/java/bartworks/common/commands/PrintRecipeListToFile.java b/src/main/java/bartworks/common/commands/PrintRecipeListToFile.java new file mode 100644 index 0000000000..05ed514cbf --- /dev/null +++ b/src/main/java/bartworks/common/commands/PrintRecipeListToFile.java @@ -0,0 +1,62 @@ +/* + * 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.common.commands; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.item.crafting.CraftingManager; + +public class PrintRecipeListToFile extends CommandBase { + + @Override + public String getCommandName() { + return "prltf"; + } + + @Override + public String getCommandUsage(ICommandSender sender) { + return "prltf <FilePath>"; + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + File file = new File(args[0]); + try { + + BufferedWriter fw = new BufferedWriter(new FileWriter(file)); + CraftingManager.getInstance() + .getRecipeList() + .forEach(e -> { + try { + fw.write( + e.toString() + " = " + + e.getRecipeOutput() + .getDisplayName() + + "\n"); + } catch (IOException ex) { + ex.printStackTrace(); + } + }); + fw.flush(); + fw.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/bartworks/common/commands/RunGC.java b/src/main/java/bartworks/common/commands/RunGC.java new file mode 100644 index 0000000000..079e4083d8 --- /dev/null +++ b/src/main/java/bartworks/common/commands/RunGC.java @@ -0,0 +1,38 @@ +/* + * 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.common.commands; + +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.util.ChatComponentText; + +public class RunGC extends CommandBase { + + @Override + public String getCommandName() { + return "bwgc"; + } + + @Override + public String getCommandUsage(ICommandSender sender) { + return "bwgc"; + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + Runtime.getRuntime() + .gc(); + sender.addChatMessage(new ChatComponentText("Ran GC!")); + } +} diff --git a/src/main/java/bartworks/common/commands/SummonRuin.java b/src/main/java/bartworks/common/commands/SummonRuin.java new file mode 100644 index 0000000000..c531c8f1f4 --- /dev/null +++ b/src/main/java/bartworks/common/commands/SummonRuin.java @@ -0,0 +1,46 @@ +/* + * 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.common.commands; + +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; + +import bartworks.system.worldgen.MapGenRuins; + +public class SummonRuin extends CommandBase { + + @Override + public String getCommandName() { + return "SummonRuin"; + } + + @Override + public String getCommandUsage(ICommandSender sender) { + return "SummonRuin <x> <z>"; + } + + @Override + public void processCommand(ICommandSender iCommandSender, String[] args) { + try { + new MapGenRuins.RuinsBase().generate( + iCommandSender.getEntityWorld(), + iCommandSender.getEntityWorld().rand, + Integer.parseInt(args[0]), + 256, + Integer.parseInt(args[1])); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/bartworks/common/configs/ConfigHandler.java b/src/main/java/bartworks/common/configs/ConfigHandler.java new file mode 100644 index 0000000000..e378819ad1 --- /dev/null +++ b/src/main/java/bartworks/common/configs/ConfigHandler.java @@ -0,0 +1,301 @@ +/* + * 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.common.configs; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import net.minecraftforge.common.config.Configuration; + +import bartworks.API.APIConfigValues; + +public class ConfigHandler { + + public static Configuration c; + + public static int megaMachinesMax = 256; + public static int mbWaterperSec = 150; + public static int ross128BID = -64; + public static int ross128BAID = -63; + public static int ross128btier = 3; + public static int ross128batier = 3; + public static int landerType = 3; + public static int ross128bRuinChance = 512; + public static int bioVatMaxParallelBonus = 1000; + public static int cutoffTier = 5; + public static int[][][] metasForTiers; + + public static long energyPerCell = 1000000L; + + public static boolean Ross128Enabled = true; + + public static boolean disableExtraGassesForEBF; + public static boolean disableMagicalForest; + public static boolean DEHPDirectSteam; + public static boolean teslastaff; + public static boolean classicMode; + + public static boolean GTppLogDisabler; + public static boolean tooltips = true; + public static boolean sharedItemStackTooltip = true; + public static boolean[] enabledPatches; + + public static byte maxTierRoss; + + public static boolean disableBoltedBlocksCasing = false; + public static boolean disableReboltedBlocksCasing = false; + + public static int pollutionHeatedWaterPumpSecond = 5; + public static int basePollutionMBFSecond = 400; + + public static Set<String> voidMinerBlacklist = Collections.unmodifiableSet(new HashSet<>()); + + public static boolean disablePistonInEIC = false; + + private static final int[][] METAFORTIERS_ENERGY = { { 100, 101, 102, 105 }, { 1110, 1115, 1120, 1127 }, + { 1111, 12726, 1116, 1121, 1128 }, { 1112, 12727, 1117, 1122, 1129 }, { 12728, 1190, 1130, 12685 }, + { 1191, 1174, 695, 12686 }, }; + private static final int[][] METAFORTIERS_BUFFER = { { 5133, 5123 }, { 161, 171, 181, 191 }, { 162, 172, 182, 192 }, + { 163, 173, 183, 193 }, { 164, 174, 184, 194 }, { 165, 175, 185, 195 }, }; + private static final int[][] METAFORTIERS_CABLE = { { 5133, 5123 }, { 1210, 1230, 1250, 1270, 1290 }, + { 1310, 1330, 1350, 1370, 1390 }, { 1410, 1430, 1450, 1470, 1490 }, { 1510, 1530, 1550, 1570, 1590 }, + { 1650, 1670, 1690 }, }; + private static final int[][] METAFORTIERS_MACHINE = { + { 103, 104, 106, 107, 109, 110, 112, 113, 115, 116, 118, 119 }, + { 201, 211, 221, 231, 241, 251, 261, 271, 281, 291, 301, 311, 321, 331, 341, 351, 361, 371, 381, 391, 401, 411, + 421, 431, 441, 451, 461, 471, 481, 491, 501, 511, 521, 531, 541, 551, 561, 571, 581, 591, 601, 611, 621, + 631, 641, 651, 661, 671 }, + { 202, 212, 222, 232, 242, 252, 262, 272, 282, 292, 302, 312, 322, 332, 342, 352, 362, 372, 382, 392, 402, 412, + 422, 432, 442, 452, 462, 472, 482, 492, 502, 512, 522, 532, 542, 552, 562, 572, 582, 592, 602, 612, 622, + 632, 642, 652, 662, 672 }, + { 203, 213, 223, 233, 243, 253, 263, 273, 283, 293, 303, 313, 323, 333, 343, 353, 363, 373, 383, 393, 403, 413, + 423, 433, 443, 453, 463, 473, 483, 493, 503, 513, 523, 533, 543, 553, 563, 573, 583, 593, 603, 613, 623, + 633, 643, 653, 663, 673 }, + { 204, 214, 224, 234, 244, 254, 264, 274, 284, 294, 304, 314, 324, 334, 344, 354, 364, 374, 384, 394, 404, 414, + 424, 434, 444, 454, 464, 474, 484, 494, 504, 514, 524, 534, 544, 554, 564, 574, 584, 594, 604, 614, 624, + 634, 644, 654, 664, 674 }, + { 205, 215, 225, 235, 245, 255, 265, 275, 285, 295, 305, 315, 325, 335, 345, 355, 365, 375, 385, 395, 405, 415, + 425, 435, 445, 455, 465, 475, 485, 495, 505, 515, 525, 535, 545, 555, 565, 575, 585, 595, 605, 615, 625, + 635, 645, 655, 665, 675 }, }; + private static int[][][] defaultMetasForTiers = { METAFORTIERS_ENERGY, METAFORTIERS_BUFFER, METAFORTIERS_CABLE, + METAFORTIERS_MACHINE }; + private static final String[] VOLTAGE_NAMES = { "High Pressure Steam", "Low Voltage", "Medium Voltage", + "High Voltage", "Extreme Voltage", "Insane Voltage", "Ludicrous Voltage", "ZPM Voltage", "Ultimate Voltage", + "Ultimate High Voltage", "Ultimate Extreme Voltage", "Ultimate Insane Voltage", "Ultimate Mega Voltage", + "Ultimate Extended Mega Voltage", "Overpowered Voltage", "Maximum Voltage" }; + private static final String[] names = { "Generators", "Buffers", "Cables", "Machines" }; + + public static final String[] ASM_TRANSFORMER_DESCRIPTIONS = { "REMOVING RAIN FROM LAST MILLENNIUM (EXU)", + "REMOVING CREATURES FROM LAST MILLENNIUM (EXU)", "PATCHING THAUMCRAFT WAND PEDESTAL TO PREVENT VIS DUPLICATION", + "PATCHING CRAFTING MANAGER FOR CACHING RECIPES" }; + public static final String[] ASM_TRANSFORMER_CLASSES = { + "com.rwtema.extrautils.worldgen.endoftime.WorldProviderEndOfTime", + "com.rwtema.extrautils.worldgen.endoftime.ChunkProviderEndOfTime", "thaumcraft.common.tiles.TileWandPedestal", + "net.minecraft.item.crafting.CraftingManager" }; + + public ConfigHandler(Configuration C) { + ConfigHandler.c = C; + ConfigHandler.classicMode = ConfigHandler.c + .get( + "System", + "Enable Classic Mode", + false, + "Enables the classic Mode (all recipes in normal machines are doable in MV") + .getBoolean(false); + + ConfigHandler.tooltips = ConfigHandler.c + .get("System", "BartWorksToolTips", true, "If you wish to enable extra tooltips") + .getBoolean(true); + ConfigHandler.sharedItemStackTooltip = ConfigHandler.c + .get( + "System", + "BartWorksSharedItemStackToolTips", + true, + "If you wish to enable \"Shared Item Stack\" tooltips") + .getBoolean(true); + + ConfigHandler.teslastaff = ConfigHandler.c + .get( + "System", + "Enable Teslastaff", + false, + "Enables the Teslastaff, an Item used to destroy Electric Armors") + .getBoolean(false); + + ConfigHandler.cutoffTier = ConfigHandler.c + .get( + "System", + "Tier to nerf circuits", + 5, + "This switch sets the lowest unnerfed Circuit Recipe Tier. -1 to disable it completely.", + -1, + VOLTAGE_NAMES.length) + .getInt(5); + ConfigHandler.cutoffTier = ConfigHandler.cutoffTier == -1 ? VOLTAGE_NAMES.length : ConfigHandler.cutoffTier; + ConfigHandler.disableExtraGassesForEBF = ConfigHandler.c + .get( + "System", + "Disable Extra Gases for EBF", + false, + "This switch disables extra gas recipes for the EBF, i.e. Xenon instead of Nitrogen") + .getBoolean(false); + ConfigHandler.disableBoltedBlocksCasing = ConfigHandler.c + .get("System", "Disable Bolted Casings", false, "This switch disable the generation of bolted casings") + .getBoolean(false); + ConfigHandler.disableReboltedBlocksCasing = ConfigHandler.c + .get("System", "Disable Rebolted Casings", false, "This switch disable the generation of rebolted casings") + .getBoolean(false); + + ConfigHandler.mbWaterperSec = ConfigHandler.c.get("Singleblocks", "mL Water per Sec for the StirlingPump", 150) + .getInt(150); + + ConfigHandler.energyPerCell = ConfigHandler.c + .get( + "Multiblocks", + "energyPerLESUCell", + 1000000, + "This will set Up the Energy per LESU Cell", + 1000000, + Integer.MAX_VALUE) + .getInt(1000000); + ConfigHandler.DEHPDirectSteam = ConfigHandler.c.get( + "Multiblocks", + "DEHP Direct Steam Mode", + false, + "This switch enables the Direct Steam Mode of the DEHP. If enabled it will take in Waterand output steam. If disabled it will Input IC2Coolant and output hot coolant") + .getBoolean(false); + ConfigHandler.megaMachinesMax = ConfigHandler.c + .get( + "Multiblocks", + "Mega Machines Maximum Recipes per Operation", + 256, + "This changes the Maximum Recipes per Operation to the specified Valure") + .getInt(256); + ConfigHandler.bioVatMaxParallelBonus = ConfigHandler.c + .get( + "Multiblocks", + "BioVat Maximum Bonus on Recipes", + 1000, + "This are the maximum parallel Operations the BioVat can do, when the output is half full.") + .getInt(1000); + ConfigHandler.voidMinerBlacklist = Collections.unmodifiableSet( + new HashSet<>( + Arrays.asList( + ConfigHandler.c.get( + "Multiblocks", + "Void Miner Blacklist", + new String[0], + "This is a blacklist for the Void Miner, blacklisted ores will not enter the drop prize pool. Please fill in the Unique Identifier of Ore and connect Damage with a colon, For example: gregtech:gt.blockores:32") + .getStringList()))); + ConfigHandler.disablePistonInEIC = ConfigHandler.c + .get( + "Multiblocks", + "Disable Electric Implosion Compressor piston", + false, + "This switch completely disables piston animation in Electric Implosion Compressor multiblock") + .getBoolean(false); + + ConfigHandler.pollutionHeatedWaterPumpSecond = ConfigHandler.c + .get( + "Pollution", + "Pollution produced per second by the water pump", + ConfigHandler.pollutionHeatedWaterPumpSecond, + "How much should the Simple Stirling Water Pump produce pollution per second") + .getInt(ConfigHandler.pollutionHeatedWaterPumpSecond); + ConfigHandler.basePollutionMBFSecond = ConfigHandler.c.get( + "Pollution", + "Pollution produced per tick by the MBF per ingot", + ConfigHandler.basePollutionMBFSecond, + "How much should the MBF produce pollution per tick per ingot. Then it'll be multiplied by the amount of ingots done in parallel") + .getInt(ConfigHandler.basePollutionMBFSecond); + + ConfigHandler.GTppLogDisabler = ConfigHandler.c + .get("System", "Disable GT++ Logging", false, "Enables or Disables GT++ Logging.") + .getBoolean(false); + APIConfigValues.debugLog = ConfigHandler.c + .get("System", "Enable Debug Log", false, "Enables or Disables the debug log.") + .getBoolean(false); + + ConfigHandler.enabledPatches = new boolean[ASM_TRANSFORMER_CLASSES.length]; + for (int i = 0; i < ASM_TRANSFORMER_CLASSES.length; i++) ConfigHandler.enabledPatches[i] = ConfigHandler.c + .get("ASM fixes", ASM_TRANSFORMER_DESCRIPTIONS[i] + " in class: " + ASM_TRANSFORMER_CLASSES[i], true) + .getBoolean(true); + + ConfigHandler.ross128BID = ConfigHandler.c + .get("CrossMod Interactions", "DimID - Ross128b", -64, "The Dim ID for Ross128b") + .getInt(-64); + ConfigHandler.ross128BAID = ConfigHandler.c + .get("CrossMod Interactions", "DimID - Ross128ba", -63, "The Dim ID for Ross128ba (Ross128b's Moon)") + .getInt(-63); + ConfigHandler.ross128btier = ConfigHandler.c + .get("CrossMod Interactions", "Rocket Tier - Ross128b", 3, "The Rocket Tier for Ross128b") + .getInt(3); + ConfigHandler.ross128batier = ConfigHandler.c + .get("CrossMod Interactions", "Rocket Tier - Ross128ba", 3, "The Rocket Tier for Ross128a") + .getInt(3); + ConfigHandler.ross128bRuinChance = ConfigHandler.c + .get("CrossMod Interactions", "Ruin Chance - Ross128b", 512, "Higher Values mean lesser Ruins.") + .getInt(512); + ConfigHandler.Ross128Enabled = ConfigHandler.c + .get( + "CrossMod Interactions", + "Galacticraft - Activate Ross128 System", + true, + "If the Ross128 System should be activated, DO NOT CHANGE AFTER WORLD GENERATION") + .getBoolean(true); + ConfigHandler.landerType = ConfigHandler.c + .get("CrossMod Interactions", "LanderType", 3, "1 = Moon Lander, 2 = Landing Balloons, 3 = Asteroid Lander") + .getInt(3); + ConfigHandler.disableMagicalForest = ConfigHandler.c + .get( + "CrossMod Interactions", + "Disable Magical Forest - Ross128b", + false, + "True disables the magical Forest Biome on Ross for more performance during World generation.") + .getBoolean(false); + + ConfigHandler.maxTierRoss = (byte) ConfigHandler.c + .get("Ross Ruin Metas", "A_Ruin Machine Tiers", 6, "", 0, VOLTAGE_NAMES.length) + .getInt(6); + ConfigHandler.metasForTiers = new int[4][maxTierRoss][]; + + for (int i = 0; i < 4; i++) { + if (maxTierRoss > ConfigHandler.defaultMetasForTiers[i].length) + ConfigHandler.defaultMetasForTiers[i] = new int[maxTierRoss][0]; + for (int j = 0; j < maxTierRoss; j++) ConfigHandler.metasForTiers[i][j] = ConfigHandler.c + .get( + "Ross Ruin Metas", + j + "_Ruin " + names[i] + " Tier " + VOLTAGE_NAMES[j], + ConfigHandler.defaultMetasForTiers[i][j]) + .getIntList(); + } + + ConfigHandler.setUpComments(); + + if (ConfigHandler.c.hasChanged()) ConfigHandler.c.save(); + } + + private static void setUpComments() { + ConfigHandler.c.addCustomCategoryComment("ASM fixes", "Disable ASM fixes here."); + ConfigHandler.c.addCustomCategoryComment("Singleblocks", "Singleblock Options can be set here."); + ConfigHandler.c.addCustomCategoryComment("Multiblocks", "Multiblock Options can be set here."); + ConfigHandler.c.addCustomCategoryComment("System", "Different System Settings can be set here."); + ConfigHandler.c.addCustomCategoryComment( + "CrossMod Interactions", + "CrossMod Interaction Settings can be set here. For Underground Fluid settings change the Gregtech.cfg!"); + ConfigHandler.c.addCustomCategoryComment("Ross Ruin Metas", "Ruin Metas and Tiers can be set here."); + } +} diff --git a/src/main/java/bartworks/common/items/BWItemBlocks.java b/src/main/java/bartworks/common/items/BWItemBlocks.java new file mode 100644 index 0000000000..e540093bf8 --- /dev/null +++ b/src/main/java/bartworks/common/items/BWItemBlocks.java @@ -0,0 +1,84 @@ +/* + * 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.common.items; + +import java.util.Arrays; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import bartworks.API.ITileAddsInformation; +import bartworks.MainMod; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.util.GTLanguageManager; + +public class BWItemBlocks extends ItemBlock { + + private final String mNoMobsToolTip = GTLanguageManager + .addStringLocalization("gt.nomobspawnsonthisblock", "Mobs cannot Spawn on this Block"); + private final String mNoTileEntityToolTip = GTLanguageManager + .addStringLocalization("gt.notileentityinthisblock", "This is NOT a TileEntity!"); + + public BWItemBlocks(Block par1) { + super(par1); + this.setMaxDamage(0); + this.setHasSubtypes(true); + this.setCreativeTab(MainMod.GT2); + } + + @Override + public int getMetadata(int aMeta) { + return aMeta; + } + + @Override + public String getUnlocalizedName(ItemStack aStack) { + return this.field_150939_a.getUnlocalizedName() + "." + this.getDamage(aStack); + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List<String> aList, boolean aF3_H) { + + if (this.field_150939_a instanceof ITileAddsInformation) { + aList.addAll(Arrays.asList(((ITileAddsInformation) this.field_150939_a).getInfoData())); + } + aList.add(this.mNoMobsToolTip); + if (!(this.field_150939_a instanceof ITileEntityProvider)) aList.add(this.mNoTileEntityToolTip); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(ItemStack stack, int pass) { + return this.field_150939_a.getIcon(0, stack.getItemDamage()); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + return this.getIcon(stack, renderPass); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamageForRenderPass(int p_77618_1_, int p_77618_2_) { + return this.field_150939_a.getIcon(0, p_77618_2_); + } +} diff --git a/src/main/java/bartworks/common/items/ItemCircuitProgrammer.java b/src/main/java/bartworks/common/items/ItemCircuitProgrammer.java new file mode 100644 index 0000000000..c7150451a1 --- /dev/null +++ b/src/main/java/bartworks/common/items/ItemCircuitProgrammer.java @@ -0,0 +1,236 @@ +/* + * 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.common.items; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import com.gtnewhorizons.modularui.api.ModularUITextures; +import com.gtnewhorizons.modularui.api.forge.IItemHandlerModifiable; +import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.screen.IItemWithModularUI; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; + +import bartworks.API.modularUI.BWUITextures; +import bartworks.MainMod; +import bartworks.util.BWUtil; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.gui.modularui.GTUIInfos; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.items.GTGenericItem; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.GTUtility; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; + +public class ItemCircuitProgrammer extends GTGenericItem implements IElectricItem, IItemWithModularUI { + + private static final int COST_PER_USE = 100; + + public ItemCircuitProgrammer() { + super("BWCircuitProgrammer", "Circuit Programmer", "Programs Integrated Circuits"); + this.setMaxStackSize(1); + this.setNoRepair(); + this.setHasSubtypes(false); + this.setCreativeTab(MainMod.BWT); + GregTechAPI.registerCircuitProgrammer( + s -> s.getItem() instanceof ItemCircuitProgrammer && ElectricItem.manager.canUse(s, COST_PER_USE), + (s, p) -> { + ElectricItem.manager.use(s, COST_PER_USE, p); + return s; + }); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List<String> aList, boolean aF3_H) { + super.addInformation(aStack, aPlayer, aList, aF3_H); + if (aStack != null && aStack.getTagCompound() != null) aList.add( + StatCollector.translateToLocal("tooltip.cp.0.name") + " " + + (aStack.getTagCompound() + .getBoolean("HasChip") ? StatCollector.translateToLocal("tooltip.bw.yes.name") + : StatCollector.translateToLocal("tooltip.bw.no.name"))); + } + + @Override + public ItemStack onItemRightClick(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + if (ElectricItem.manager.use(aStack, COST_PER_USE, aPlayer)) { + GTUIInfos.openPlayerHeldItemUI(aPlayer); + } + return aStack; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List<ItemStack> itemList) { + ItemStack itemStack = new ItemStack(this, 1); + if (this.getChargedItem(itemStack) == this) { + ItemStack charged = new ItemStack(this, 1); + ElectricItem.manager.charge(charged, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false); + itemList.add(charged); + } + if (this.getEmptyItem(itemStack) == this) { + itemList.add(new ItemStack(this, 1, this.getMaxDamage())); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aIconRegister) { + this.mIcon = aIconRegister.registerIcon("bartworks:CircuitProgrammer"); + } + + @Override + public int getTier(ItemStack var1) { + return 1; + } + + @Override + public boolean canProvideEnergy(ItemStack itemStack) { + return false; + } + + @Override + public Item getChargedItem(ItemStack itemStack) { + return this; + } + + @Override + public Item getEmptyItem(ItemStack itemStack) { + return this; + } + + @Override + public double getMaxCharge(ItemStack itemStack) { + return 10000; + } + + @Override + public double getTransferLimit(ItemStack itemStack) { + return GTValues.V[1]; + } + + private static final String NBT_KEY_HAS_CHIP = "HasChip"; + private static final String NBT_KEY_CHIP_CONFIG = "ChipConfig"; + + @Override + public ModularWindow createWindow(UIBuildContext buildContext, ItemStack heldStack) { + ModularWindow.Builder builder = ModularWindow.builder(256, 166); + builder.setBackground(BWUITextures.BACKGROUND_CIRCUIT_PROGRAMMER); + builder.bindPlayerInventory(buildContext.getPlayer(), new Pos2d(86, 83), ModularUITextures.ITEM_SLOT); + + ItemStackHandler inventoryHandler = new ItemStackHandler(1) { + + @Override + public int getSlotLimit(int slot) { + return 1; + } + }; + SlotWidget circuitSlotWidget = new SlotWidget(new BaseSlot(inventoryHandler, 0) { + + @Override + public void putStack(ItemStack stack) { + if (ItemCircuitProgrammer.this.isLVCircuit(stack)) { + stack = ItemCircuitProgrammer.this.createRealCircuit(0); + } + ((IItemHandlerModifiable) this.getItemHandler()).setStackInSlot(this.getSlotIndex(), stack); + this.onSlotChanged(); + } + }); + + ItemStack initialStack = null; + NBTTagCompound tag = heldStack.getTagCompound(); + if (tag != null && tag.getBoolean(NBT_KEY_HAS_CHIP)) { + initialStack = this.createRealCircuit(tag.getByte(NBT_KEY_CHIP_CONFIG)); + } + circuitSlotWidget.getMcSlot() + .putStack(initialStack); + + builder.widget(circuitSlotWidget.setChangeListener(widget -> { + ItemStack stack = widget.getMcSlot() + .getStack(); + ItemStack heldItem = widget.getContext() + .getPlayer() + .getHeldItem(); + NBTTagCompound tag2 = heldItem.getTagCompound(); + if (tag2 == null) { + tag2 = new NBTTagCompound(); + } + + if (stack != null) { + tag2.setBoolean(NBT_KEY_HAS_CHIP, true); + tag2.setByte(NBT_KEY_CHIP_CONFIG, (byte) stack.getItemDamage()); + } else { + tag2.setBoolean(NBT_KEY_HAS_CHIP, false); + } + heldItem.setTagCompound(tag2); + }) + .setFilter(stack -> this.isProgrammedCircuit(stack) || this.isLVCircuit(stack)) + .setBackground(ModularUITextures.ITEM_SLOT, GTUITextures.OVERLAY_SLOT_INT_CIRCUIT) + .setPos(122, 60)); + + for (int i = 0; i < 24; i++) { + final int index = i; + builder.widget(new ButtonWidget().setOnClick((clickData, widget) -> { + if (circuitSlotWidget.getMcSlot() + .getHasStack() + && this.isProgrammedCircuit( + circuitSlotWidget.getMcSlot() + .getStack())) { + circuitSlotWidget.getMcSlot() + .putStack(this.createRealCircuit(index + 1)); + } + }) + .setPos(32 + i % 12 * 18, 21 + i / 12 * 18) + .setSize(18, 18)); + } + + return builder.build(); + } + + private ItemStack createRealCircuit(int config) { + return ItemList.Circuit_Integrated.getWithDamage(1, config); + } + + private boolean isProgrammedCircuit(ItemStack stack) { + return stack.getItem() + .equals( + GTUtility.getIntegratedCircuit(0) + .getItem()); + } + + private boolean isLVCircuit(ItemStack stack) { + return BWUtil.checkStackAndPrefix(stack) + && OrePrefixes.circuit.equals(GTOreDictUnificator.getAssociation(stack).mPrefix) + && GTOreDictUnificator.getAssociation(stack).mMaterial.mMaterial.equals(Materials.LV); + } +} diff --git a/src/main/java/bartworks/common/items/ItemLabModule.java b/src/main/java/bartworks/common/items/ItemLabModule.java new file mode 100644 index 0000000000..65931c4181 --- /dev/null +++ b/src/main/java/bartworks/common/items/ItemLabModule.java @@ -0,0 +1,41 @@ +/* + * 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.common.items; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; + +import bartworks.MainMod; + +public class ItemLabModule extends SimpleSubItemClass { + + public ItemLabModule(String[] tex) { + super(tex); + this.setCreativeTab(MainMod.BIO_TAB); + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return "labModule." + super.getUnlocalizedName(stack); + } + + @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List<String> aList, boolean p_77624_4_) { + aList.add(StatCollector.translateToLocal("tooltip.labmodule.0.name")); + super.addInformation(p_77624_1_, p_77624_2_, aList, p_77624_4_); + } +} diff --git a/src/main/java/bartworks/common/items/ItemLabParts.java b/src/main/java/bartworks/common/items/ItemLabParts.java new file mode 100644 index 0000000000..4a45a7915f --- /dev/null +++ b/src/main/java/bartworks/common/items/ItemLabParts.java @@ -0,0 +1,150 @@ +/* + * 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.common.items; + +import java.util.List; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; + +import bartworks.MainMod; +import bartworks.common.loaders.BioItemList; +import bartworks.util.BWColorUtil; +import bartworks.util.BWUtil; +import bartworks.util.BioCulture; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ItemLabParts extends SimpleSubItemClass { + + public ItemLabParts(String[] tex) { + super(tex); + this.setCreativeTab(MainMod.BIO_TAB); + } + + @Override + public EnumRarity getRarity(ItemStack itemStack) { + + if (itemStack == null || itemStack.getTagCompound() == null) return EnumRarity.common; + + return switch (itemStack.getItemDamage()) { + case 0 -> BWUtil.getRarityFromByte( + itemStack.getTagCompound() + .getCompoundTag("DNA") + .getByte("Rarity")); + case 1, 2 -> BWUtil.getRarityFromByte( + itemStack.getTagCompound() + .getByte("Rarity")); + default -> EnumRarity.common; + }; + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack stack, int p_82790_2_) { + if (stack.getItemDamage() == 0 && stack.getTagCompound() != null + && stack.getTagCompound() + .getIntArray("Color") != null + && stack.getTagCompound() + .getIntArray("Color").length > 0) { + int[] rgb = stack.getTagCompound() + .getIntArray("Color"); + return BWColorUtil.getColorFromRGBArray(rgb); + } + return super.getColorFromItemStack(stack, p_82790_2_); + } + + @Override + public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List<String> list, boolean b) { + if (itemStack == null) return; + + if (itemStack.getTagCompound() == null) { + switch (itemStack.getItemDamage()) { + case 0: + list.add(StatCollector.translateToLocal("tooltip.labparts.0.name")); + break; + case 1: + list.add(StatCollector.translateToLocal("tooltip.labparts.1.name")); + break; + case 2: + list.add(StatCollector.translateToLocal("tooltip.labparts.2.name")); + break; + case 3: + list.add(StatCollector.translateToLocal("tooltip.labparts.3.name")); + break; + case 4: + list.add(StatCollector.translateToLocal("tooltip.labparts.4.name")); + break; + default: + break; + } + super.addInformation(itemStack, entityPlayer, list, b); + return; + } + + BioCulture culture = BioCulture.getBioCulture( + itemStack.getTagCompound() + .getString("Name")); + + switch (itemStack.getItemDamage()) { + case 0: + list.add( + StatCollector.translateToLocal("tooltip.labparts.5.name") + " " + + itemStack.getTagCompound() + .getString("Name") + + (culture != null ? " (" + culture.getLocalisedName() + ")" : "")); + if (!itemStack.getTagCompound() + .getBoolean("Breedable")) { + list.add(StatCollector.translateToLocal("tooltip.labparts.6.name")); + } + break; + case 1: + list.add( + StatCollector.translateToLocal("tooltip.labparts.7.name") + " " + + itemStack.getTagCompound() + .getString("Name") + + (culture != null ? " (" + culture.getLocalisedName() + ")" : "")); + break; + case 2: + list.add( + StatCollector.translateToLocal("tooltip.labparts.8.name") + " " + + itemStack.getTagCompound() + .getString("Name") + + (culture != null ? " (" + culture.getLocalisedName() + ")" : "")); + break; + default: + break; + } + super.addInformation(itemStack, entityPlayer, list, b); + } + + @Override + public void getSubItems(Item item, CreativeTabs creativeTabs, List<ItemStack> list) { + list.addAll(BioItemList.getAllPetriDishes()); + list.addAll(BioItemList.getAllDNASampleFlasks()); + list.addAll(BioItemList.getAllPlasmidCells()); + super.getSubItems(item, creativeTabs, list); + } + + @Override + public String getUnlocalizedName(ItemStack itemStack) { + if (itemStack.getItemDamage() == 0 && itemStack.getTagCompound() != null) + return "filled.item." + this.tex[itemStack.getItemDamage()].replace('/', '.'); + return super.getUnlocalizedName(itemStack); + } +} diff --git a/src/main/java/bartworks/common/items/ItemRockCutter.java b/src/main/java/bartworks/common/items/ItemRockCutter.java new file mode 100644 index 0000000000..45682fc457 --- /dev/null +++ b/src/main/java/bartworks/common/items/ItemRockCutter.java @@ -0,0 +1,183 @@ +/* + * 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.common.items; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemTool; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import com.google.common.collect.Sets; + +import bartworks.MainMod; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.GTValues; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; + +public class ItemRockCutter extends ItemTool implements IElectricItem { + + private static Set<Block> mineableBlocks = Sets + .newHashSet(Blocks.stone, Blocks.cobblestone, Blocks.sand, Blocks.clay); + private final int mCharge; + private final int mTransfer; + public int mTier; + + @SideOnly(Side.CLIENT) + private IIcon icon; + + private final int multi; + + public ItemRockCutter(int aTier) { + super(2 * aTier, Item.ToolMaterial.EMERALD, ItemRockCutter.mineableBlocks); + this.mTier = aTier; + this.multi = (int) Math.pow(10, this.mTier - 1); + ItemRockCutter.mineableBlocks = new HashSet<>(); + this.maxStackSize = 1; + this.mCharge = 10000 * this.multi; + this.mTransfer = (int) GTValues.V[this.mTier]; + this.efficiencyOnProperMaterial = 2.0f * this.mTier; + this.setCreativeTab(MainMod.GT2); + this.setMaxDamage(27 + 10 * this.multi); + this.setNoRepair(); + this.setUnlocalizedName("GT_Rockcutter_Item_" + GTValues.VN[this.mTier]); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List<String> aList, boolean aF3_H) { + aList.add(StatCollector.translateToLocal("tooltip.bw.tier.name") + " " + GTValues.VN[this.mTier]); + } + + @Override + public void onUpdate(ItemStack aStack, World worldIn, Entity entityIn, int p_77663_4_, boolean p_77663_5_) { + if (!ElectricItem.manager.canUse(aStack, 500 * this.multi)) { + if (aStack.isItemEnchanted()) { + aStack.getTagCompound() + .removeTag("ench"); + } + } else if (!aStack.isItemEnchanted()) { + aStack.addEnchantment(Enchantment.silkTouch, 3); + } + } + + @Override + public boolean onItemUse(ItemStack aStack, EntityPlayer aPlayer, World p_77648_3_, int p_77648_4_, int p_77648_5_, + int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { + ElectricItem.manager.use(aStack, 0, aPlayer); + return false; + } + + @Override + public boolean onBlockDestroyed(ItemStack var1, World var2, Block var3, int var4, int var5, int var6, + EntityLivingBase var7) { + ElectricItem.manager.use(var1, 0, var7); + if (ElectricItem.manager.canUse(var1, 500 * this.multi)) { + ElectricItem.manager.use(var1, 500 * this.multi, var7); + } else { + ElectricItem.manager.discharge(var1, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, false); + } + return true; + } + + @Override + public boolean canHarvestBlock(Block par1Block, ItemStack itemStack) { + return par1Block.getMaterial() + .equals(Material.glass) + || par1Block.getMaterial() + .equals(Material.clay) + || par1Block.getMaterial() + .equals(Material.packedIce) + || par1Block.getMaterial() + .equals(Material.ice) + || par1Block.getMaterial() + .equals(Material.sand) + || par1Block.getMaterial() + .equals(Material.ground) + || par1Block.getMaterial() + .equals(Material.rock) + || mineableBlocks.contains(par1Block); + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List<ItemStack> itemList) { + ItemStack itemStack = new ItemStack(this, 1); + if (this.getChargedItem(itemStack) == this) { + ItemStack charged = new ItemStack(this, 1); + ElectricItem.manager.charge(charged, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false); + itemList.add(charged); + } + if (this.getEmptyItem(itemStack) == this) { + itemList.add(new ItemStack(this, 1, this.getMaxDamage())); + } + } + + @Override + public boolean canProvideEnergy(ItemStack itemStack) { + return false; + } + + @Override + public Item getChargedItem(ItemStack itemStack) { + return this; + } + + @Override + public Item getEmptyItem(ItemStack itemStack) { + return this; + } + + @Override + public double getMaxCharge(ItemStack itemStack) { + return this.mCharge; + } + + @Override + public int getTier(ItemStack itemStack) { + return this.mTier; + } + + @Override + public double getTransferLimit(ItemStack itemStack) { + return this.mTransfer; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + this.icon = iconRegister.registerIcon("bartworks:GT_Rockcutter"); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) { + return this.icon; + } +} diff --git a/src/main/java/bartworks/common/items/ItemSimpleWindMeter.java b/src/main/java/bartworks/common/items/ItemSimpleWindMeter.java new file mode 100644 index 0000000000..a477fbf37c --- /dev/null +++ b/src/main/java/bartworks/common/items/ItemSimpleWindMeter.java @@ -0,0 +1,76 @@ +/* + * 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.common.items; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import bartworks.MainMod; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.core.WorldData; + +public class ItemSimpleWindMeter extends Item { + + public ItemSimpleWindMeter() { + this.maxStackSize = 1; + this.setMaxDamage(15); + this.setCreativeTab(MainMod.BWT); + this.hasSubtypes = false; + this.setUnlocalizedName("BW_SimpleWindMeter"); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister register) { + this.itemIcon = register.registerIcon(MainMod.MOD_ID + ":BW_SimpleWindMeter"); + } + + @Override + public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List<String> list, boolean p_77624_4_) { + super.addInformation(itemStack, entityPlayer, list, p_77624_4_); + list.add(StatCollector.translateToLocal("tooltip.windmeter.0.name")); + list.add( + StatCollector.translateToLocal("tooltip.windmeter.1.name") + " " + + (this.getMaxDamage() - this.getDamage(itemStack)) + + "/" + + this.getMaxDamage()); + } + + @Override + public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) { + if (entityPlayer.worldObj.isRemote || world == null + || WorldData.get(world) == null + || WorldData.get(world).windSim == null) return itemStack; + + float windStrength = (float) WorldData.get(world).windSim.getWindAt(entityPlayer.posY); + String windS = windStrength < 1f ? StatCollector.translateToLocal("tooltip.windmeter.2.name") + : windStrength < 10f ? StatCollector.translateToLocal("tooltip.windmeter.3.name") + : windStrength < 20f ? StatCollector.translateToLocal("tooltip.windmeter.4.name") + : windStrength < 30f ? StatCollector.translateToLocal("tooltip.windmeter.5.name") + : windStrength < 50f ? StatCollector.translateToLocal("tooltip.windmeter.6.name") + : StatCollector.translateToLocal("tooltip.windmeter.7.name"); + entityPlayer.addChatMessage( + new ChatComponentText(StatCollector.translateToLocal("tooltip.windmeter.8.name") + " " + windS + ".")); + itemStack.damageItem(1, entityPlayer); + return itemStack; + } +} diff --git a/src/main/java/bartworks/common/items/ItemStonageRotors.java b/src/main/java/bartworks/common/items/ItemStonageRotors.java new file mode 100644 index 0000000000..913c7c4fd4 --- /dev/null +++ b/src/main/java/bartworks/common/items/ItemStonageRotors.java @@ -0,0 +1,162 @@ +/* + * 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.common.items; + +import static ic2.api.item.IKineticRotor.GearboxType.WATER; +import static ic2.api.item.IKineticRotor.GearboxType.WIND; + +import java.util.List; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +import bartworks.MainMod; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.api.item.IKineticRotor; +import ic2.core.block.kineticgenerator.gui.GuiWaterKineticGenerator; +import ic2.core.block.kineticgenerator.gui.GuiWindKineticGenerator; +import ic2.core.util.StackUtil; + +public class ItemStonageRotors extends Item implements IKineticRotor { + + private final int[] DiaMinMax = new int[3]; + private final float eff; + private final IKineticRotor.GearboxType type; + private final ResourceLocation tex; + private final String itemTex; + private final int speed; + private final float mRotor; + private final int maxDamageEx; + private int dura; + + public ItemStonageRotors(int diameter, float eff, int speed, float mRotor, int min, int max, int durability, + IKineticRotor.GearboxType type, ResourceLocation tex, String Name, String itemTex) { + this.DiaMinMax[0] = diameter; + this.DiaMinMax[1] = min; + this.DiaMinMax[2] = max; + this.eff = eff; + this.mRotor = mRotor; + this.speed = speed; + this.type = type; + this.tex = tex; + this.setMaxDamage(30000); + this.maxDamageEx = durability; + this.setUnlocalizedName(Name); + this.setCreativeTab(MainMod.BWT); + this.itemTex = itemTex; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + this.itemIcon = iconRegister.registerIcon(MainMod.MOD_ID + ":" + this.itemTex); + } + + @Override + public void addInformation(ItemStack itemStack, EntityPlayer player, List<String> info, boolean b) { + info.add( + StatCollector.translateToLocalFormatted("ic2.itemrotor.wind.info", this.DiaMinMax[1], this.DiaMinMax[2])); + IKineticRotor.GearboxType type = null; + if (Minecraft.getMinecraft().currentScreen instanceof GuiWaterKineticGenerator) { + type = WATER; + } else if (Minecraft.getMinecraft().currentScreen instanceof GuiWindKineticGenerator) { + type = WIND; + } + info.add(StatCollector.translateToLocal("tooltip.rotor.0.name") + " " + this.DiaMinMax[0]); + info.add( + StatCollector.translateToLocal("tooltip.rotor.1.name") + " " + + (this.getMaxDamageEx() - this.getDamageOfStack(itemStack)) / 100 + + "/" + + this.getMaxDamageEx() / 100); + info.add(StatCollector.translateToLocal("tooltip.rotor.2.name") + " " + this.eff); + info.add(StatCollector.translateToLocal("tooltip.rotor.3.name") + " " + this.speed); + info.add(StatCollector.translateToLocal("tooltip.rotor.4.name") + " " + this.mRotor); + if (type != null) { + info.add(StatCollector.translateToLocal("ic2.itemrotor.fitsin." + this.isAcceptedType(itemStack, type))); + } + } + + @Override + public int getDiameter(ItemStack itemStack) { + return this.DiaMinMax[0]; + } + + @Override + public ResourceLocation getRotorRenderTexture(ItemStack itemStack) { + return this.tex; + } + + @Override + public float getEfficiency(ItemStack itemStack) { + return this.eff; + } + + @Override + public int getMinWindStrength(ItemStack itemStack) { + return this.DiaMinMax[1]; + } + + @Override + public int getMaxWindStrength(ItemStack itemStack) { + return this.DiaMinMax[2]; + } + + @Override + public boolean isAcceptedType(ItemStack itemStack, IKineticRotor.GearboxType gearboxType) { + return gearboxType.equals(this.type); + } + + public int getSpeed() { + return this.speed; + } + + public float getmRotor() { + return this.mRotor; + } + + public void setDamageForStack(ItemStack stack, int advDmg) { + NBTTagCompound nbtData = StackUtil.getOrCreateNbtData(stack); + nbtData.setInteger("DmgEx", advDmg); + if (this.maxDamageEx > 0) { + double p = (double) advDmg / (double) this.maxDamageEx; + int newDmg = (int) (stack.getMaxDamage() * p); + if (newDmg >= stack.getMaxDamage()) { + newDmg = stack.getMaxDamage() - 1; + } + stack.setItemDamage(newDmg); + this.dura = newDmg; + } + } + + public int getDamageOfStack(ItemStack stack) { + NBTTagCompound nbtData = StackUtil.getOrCreateNbtData(stack); + this.dura = nbtData.getInteger("DmgEx"); + return this.dura; + } + + public int getMaxDamageEx() { + return this.maxDamageEx; + } + + public void damageItemStack(ItemStack stack, int Dmg) { + this.setDamageForStack(stack, this.getDamageOfStack(stack) + Dmg); + } +} diff --git a/src/main/java/bartworks/common/items/ItemTeslaStaff.java b/src/main/java/bartworks/common/items/ItemTeslaStaff.java new file mode 100644 index 0000000000..292a48cd91 --- /dev/null +++ b/src/main/java/bartworks/common/items/ItemTeslaStaff.java @@ -0,0 +1,141 @@ +/* + * 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.common.items; + +import java.util.List; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemTool; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; + +import com.google.common.collect.Sets; + +import bartworks.MainMod; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; + +public class ItemTeslaStaff extends ItemTool implements IElectricItem { + + private static final Set<Block> effective = Sets.newHashSet(Blocks.web); + private final double mCharge; + private final double mTransfer; + public int mTier; + + @SideOnly(Side.CLIENT) + private IIcon icon; + + public ItemTeslaStaff() { + super(0, Item.ToolMaterial.GOLD, ItemTeslaStaff.effective); + this.setCreativeTab(MainMod.GT2); + this.setNoRepair(); + this.mCharge = 10000000D; + this.mTransfer = 8192D; + this.mTier = 4; + this.setMaxStackSize(1); + this.setMaxDamage(27); + this.setUnlocalizedName("GT_Teslastaff_Item"); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List<String> aList, boolean aF3_H) { + aList.add(StatCollector.translateToLocal("tooltip.teslastaff.0.name")); + } + + @Override + public boolean hitEntity(ItemStack aStack, EntityLivingBase aTarget, EntityLivingBase aPlayer) { + if (aTarget instanceof EntityLiving tTarget && ElectricItem.manager.canUse(aStack, 9000000)) { + ElectricItem.manager.use(aStack, 9000000, aPlayer); + for (int i = 1; i < 5; ++i) { + if (tTarget.getEquipmentInSlot(i) != null && tTarget.getEquipmentInSlot(i) + .getItem() instanceof IElectricItem) { + tTarget.setCurrentItemOrArmor(i, null); + } + } + } + return true; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List<ItemStack> itemList) { + ItemStack itemStack = new ItemStack(this, 1); + if (this.getChargedItem(itemStack) == this) { + ItemStack charged = new ItemStack(this, 1); + ElectricItem.manager.charge(charged, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false); + itemList.add(charged); + } + if (this.getEmptyItem(itemStack) == this) { + itemList.add(new ItemStack(this, 1, this.getMaxDamage())); + } + } + + @Override + public boolean canProvideEnergy(ItemStack itemStack) { + return false; + } + + @Override + public Item getChargedItem(ItemStack itemStack) { + return this; + } + + @Override + public Item getEmptyItem(ItemStack itemStack) { + return this; + } + + @Override + public double getMaxCharge(ItemStack itemStack) { + return this.mCharge; + } + + @Override + public boolean isRepairable() { + return false; + } + + @Override + public int getTier(ItemStack itemStack) { + return this.mTier; + } + + @Override + public double getTransferLimit(ItemStack itemStack) { + return this.mTransfer; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + this.icon = iconRegister.registerIcon("bartworks:GT_Teslastaff"); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) { + return this.icon; + } +} diff --git a/src/main/java/bartworks/common/items/SimpleIconItem.java b/src/main/java/bartworks/common/items/SimpleIconItem.java new file mode 100644 index 0000000000..bf5a2c9ee0 --- /dev/null +++ b/src/main/java/bartworks/common/items/SimpleIconItem.java @@ -0,0 +1,35 @@ +/* + * 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.common.items; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.Item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class SimpleIconItem extends Item { + + private final String tex; + + public SimpleIconItem(String tex) { + this.tex = tex; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + this.itemIcon = iconRegister.registerIcon("bartworks:" + this.tex); + } +} diff --git a/src/main/java/bartworks/common/items/SimpleSubItemClass.java b/src/main/java/bartworks/common/items/SimpleSubItemClass.java new file mode 100644 index 0000000000..4240aa1b83 --- /dev/null +++ b/src/main/java/bartworks/common/items/SimpleSubItemClass.java @@ -0,0 +1,69 @@ +/* + * 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.common.items; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import bartworks.MainMod; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class SimpleSubItemClass extends Item { + + @SideOnly(Side.CLIENT) + protected IIcon[] itemIcon; + + String[] tex; + + public SimpleSubItemClass(String... tex) { + this.tex = tex; + this.hasSubtypes = true; + this.setCreativeTab(MainMod.BWT); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + this.itemIcon = new IIcon[this.tex.length]; + for (int i = 0; i < this.tex.length; i++) { + this.itemIcon[i] = iconRegister.registerIcon(MainMod.MOD_ID + ":" + this.tex[i]); + } + } + + @Override + public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List<ItemStack> p_150895_3_) { + for (int i = 0; i < this.tex.length; i++) { + p_150895_3_.add(new ItemStack(p_150895_1_, 1, i)); + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int p_77617_1_) { + if (p_77617_1_ < this.tex.length) return this.itemIcon[p_77617_1_]; + return this.itemIcon[0]; + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + if (stack.getItemDamage() < this.tex.length) return "item." + this.tex[stack.getItemDamage()].replace('/', '.'); + return "WrongDamageItemDestroyIt"; + } +} diff --git a/src/main/java/bartworks/common/loaders/ArtificialMicaLine.java b/src/main/java/bartworks/common/loaders/ArtificialMicaLine.java new file mode 100644 index 0000000000..4ec5f2edf8 --- /dev/null +++ b/src/main/java/bartworks/common/loaders/ArtificialMicaLine.java @@ -0,0 +1,191 @@ +package bartworks.common.loaders; + +import static gregtech.api.enums.Mods.NewHorizonsCoreMod; +import static gregtech.api.recipe.RecipeMaps.benderRecipes; +import static gregtech.api.recipe.RecipeMaps.blastFurnaceRecipes; +import static gregtech.api.recipe.RecipeMaps.fluidExtractionRecipes; +import static gregtech.api.recipe.RecipeMaps.mixerRecipes; +import static gregtech.api.recipe.RecipeMaps.vacuumFreezerRecipes; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; +import static gregtech.api.util.GTRecipeBuilder.TICKS; +import static gregtech.api.util.GTRecipeConstants.COIL_HEAT; +import static gregtech.api.util.GTRecipeConstants.UniversalChemical; + +import bartworks.system.material.BWGTMaterialReference; +import bartworks.system.material.WerkstoffLoader; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTUtility; + +public class ArtificialMicaLine { + + public static void runArtificialMicaRecipe() { + // Mg + O = MgO + + GTValues.RA.stdBuilder() + .itemInputs(Materials.Magnesium.getDust(1)) + .itemOutputs(Materials.Magnesia.getDust(2)) + .fluidInputs(Materials.Oxygen.getGas(1000)) + .duration(2 * SECONDS) + .eut(8) + .addTo(UniversalChemical); + // Si + 6HF = H2SiF6 + 4H + + GTValues.RA.stdBuilder() + .itemInputs(Materials.Silicon.getDust(1), Materials.Empty.getCells(4)) + .itemOutputs(Materials.Hydrogen.getCells(4)) + .fluidInputs(Materials.HydrofluoricAcid.getFluid(6000)) + .fluidOutputs(WerkstoffLoader.HexafluorosilicicAcid.getFluidOrGas(1000)) + .duration(20 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(UniversalChemical); + // K + Cl = KCl + + GTValues.RA.stdBuilder() + .itemInputs(Materials.Potassium.getDust(1), GTUtility.getIntegratedCircuit(2)) + .itemOutputs(Materials.RockSalt.getDust(2)) + .fluidInputs(Materials.Chlorine.getGas(1000)) + .duration(20 * TICKS) + .eut(8) + .addTo(UniversalChemical); + + // 2KCl + H2SiF6 = 2HCl + K2SiF6 + GTValues.RA.stdBuilder() + .itemInputs(Materials.RockSalt.getDust(4)) + .itemOutputs(WerkstoffLoader.Potassiumfluorosilicate.get(OrePrefixes.dust, 9)) + .fluidInputs(WerkstoffLoader.HexafluorosilicicAcid.getFluidOrGas(1000)) + .fluidOutputs(Materials.HydrochloricAcid.getFluid(2000)) + .duration(1 * SECONDS) + .eut(8) + .addTo(mixerRecipes); + + // 2K + CO2 + O = K2CO3 + + GTValues.RA.stdBuilder() + .itemInputs(Materials.Potassium.getDust(2), Materials.CarbonDioxide.getCells(1)) + .itemOutputs(WerkstoffLoader.PotassiumCarbonate.get(OrePrefixes.dust, 6), Materials.Empty.getCells(1)) + .fluidInputs(Materials.Oxygen.getGas(1000)) + .duration(2 * SECONDS) + .eut(8) + .addTo(UniversalChemical); + // K2O + CO2 = K2CO3 + + GTValues.RA.stdBuilder() + .itemInputs(Materials.Potash.getDust(3), Materials.CarbonDioxide.getCells(1)) + .itemOutputs(WerkstoffLoader.PotassiumCarbonate.get(OrePrefixes.dust, 6), Materials.Empty.getCells(1)) + .duration(2 * SECONDS) + .eut(8) + .addTo(UniversalChemical); + + // 55Quartz Dust + 20K2SiF6 + 12Al2O3 + 4K2CO3 = 91Raw Fluorophlogopite Dust + GTValues.RA.stdBuilder() + .itemInputs( + Materials.QuartzSand.getDust(55), + WerkstoffLoader.Potassiumfluorosilicate.get(OrePrefixes.dust, 20), + WerkstoffLoader.Alumina.get(OrePrefixes.dust, 12), + WerkstoffLoader.PotassiumCarbonate.get(OrePrefixes.dust, 4), + GTUtility.getIntegratedCircuit(4)) + .itemOutputs( + WerkstoffLoader.RawFluorophlogopite.get(OrePrefixes.dust, 64), + WerkstoffLoader.RawFluorophlogopite.get(OrePrefixes.dust, 27)) + .duration(20 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(mixerRecipes); + + // 55Quartzite/Nether Quartz Dust + 20K2SiF6 + 57Al2O3 + 4K2CO3 = 136Raw Fluorophlogopite Dust + GTValues.RA.stdBuilder() + .itemInputs( + Materials.Quartzite.getDust(55), + WerkstoffLoader.Potassiumfluorosilicate.get(OrePrefixes.dust, 20), + WerkstoffLoader.Alumina.get(OrePrefixes.dust, 57), + WerkstoffLoader.PotassiumCarbonate.get(OrePrefixes.dust, 4), + GTUtility.getIntegratedCircuit(4)) + .itemOutputs( + WerkstoffLoader.RawFluorophlogopite.get(OrePrefixes.dust, 64), + WerkstoffLoader.RawFluorophlogopite.get(OrePrefixes.dust, 64), + WerkstoffLoader.RawFluorophlogopite.get(OrePrefixes.dust, 8)) + .fluidInputs() + .fluidOutputs() + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(mixerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs( + Materials.NetherQuartz.getDust(55), + WerkstoffLoader.Potassiumfluorosilicate.get(OrePrefixes.dust, 20), + WerkstoffLoader.Alumina.get(OrePrefixes.dust, 57), + WerkstoffLoader.PotassiumCarbonate.get(OrePrefixes.dust, 4), + GTUtility.getIntegratedCircuit(4)) + .itemOutputs( + WerkstoffLoader.RawFluorophlogopite.get(OrePrefixes.dust, 64), + WerkstoffLoader.RawFluorophlogopite.get(OrePrefixes.dust, 64), + WerkstoffLoader.RawFluorophlogopite.get(OrePrefixes.dust, 8)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(mixerRecipes); + + // 62Certus Quartz Dust + 10K2SiF6 + 12Al2O3 + 7K2CO3 = 91Raw Fluorophlogopite Dust + GTValues.RA.stdBuilder() + .itemInputs( + Materials.CertusQuartz.getDust(62), + WerkstoffLoader.Potassiumfluorosilicate.get(OrePrefixes.dust, 10), + WerkstoffLoader.Alumina.get(OrePrefixes.dust, 12), + WerkstoffLoader.PotassiumCarbonate.get(OrePrefixes.dust, 7), + GTUtility.getIntegratedCircuit(4)) + .itemOutputs( + WerkstoffLoader.RawFluorophlogopite.get(OrePrefixes.dust, 64), + WerkstoffLoader.RawFluorophlogopite.get(OrePrefixes.dust, 27)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(mixerRecipes); + + // MgO(s) = MgO(l) + + GTValues.RA.stdBuilder() + .itemInputs(Materials.Magnesia.getDust(1)) + .fluidOutputs(Materials.Magnesia.getMolten(144)) + .duration(20 * TICKS) + .eut(TierEU.RECIPE_MV) + .addTo(fluidExtractionRecipes); + + // 27Raw Fluorophlogopite Dust + 720MgO(l) = 4608Fluorophlogopite(l) + GTValues.RA.stdBuilder() + .itemInputs(WerkstoffLoader.RawFluorophlogopite.get(OrePrefixes.dust, 27)) + .itemOutputs(Materials.Glass.getDust(1)) + .fluidInputs(BWGTMaterialReference.Magnesia.getMolten(720)) + .fluidOutputs(WerkstoffLoader.HotFluorophlogopite.getFluidOrGas(4608)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_HV) + .metadata(COIL_HEAT, 1700) + .addTo(blastFurnaceRecipes); + + // 144Fluorophlogopite(l) = Fluorophlogopite + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Shape_Mold_Plate.get(0)) + .itemOutputs(WerkstoffLoader.Fluorophlogopite.get(OrePrefixes.plate, 1)) + .fluidInputs(WerkstoffLoader.HotFluorophlogopite.getFluidOrGas(144)) + .duration(10 * TICKS) + .eut(TierEU.RECIPE_MV) + .noOptimize() + .addTo(vacuumFreezerRecipes); + + // Fluorophlogopite = 4Insulator Foil + if (NewHorizonsCoreMod.isModLoaded()) { + + GTValues.RA.stdBuilder() + .itemInputs( + WerkstoffLoader.Fluorophlogopite.get(OrePrefixes.plate, 1), + GTUtility.getIntegratedCircuit(1)) + .itemOutputs(GTModHandler.getModItem(NewHorizonsCoreMod.ID, "item.MicaInsulatorFoil", 4)) + .duration(10 * TICKS) + .eut(600) + .addTo(benderRecipes); + + } + } +} diff --git a/src/main/java/bartworks/common/loaders/BioCultureLoader.java b/src/main/java/bartworks/common/loaders/BioCultureLoader.java new file mode 100644 index 0000000000..f97f23347f --- /dev/null +++ b/src/main/java/bartworks/common/loaders/BioCultureLoader.java @@ -0,0 +1,104 @@ +/* + * 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.common.loaders; + +import java.awt.Color; + +import net.minecraft.item.EnumRarity; + +import bartworks.util.BioCulture; +import bartworks.util.BioDNA; +import bartworks.util.BioData; +import bartworks.util.BioPlasmid; + +public class BioCultureLoader { + + public static final BioData BIO_DATA_BETA_LACMATASE = BioData + .createAndRegisterBioData("beta-Lactamase", EnumRarity.uncommon, 10000, 0); + private static final BioData BIO_DATA_YEAST = BioData + .createAndRegisterBioData("Saccharomyces cerevisiae", EnumRarity.common); + private static final BioDNA BIO_DNA_WHINE_YEAST = BioDNA + .createAndRegisterBioDNA("Saccharomyces cerevisiae var bayanus", EnumRarity.uncommon); + private static final BioDNA BIO_DNA_BEER_YEAST = BioDNA + .createAndRegisterBioDNA("Saccharomyces cerevisiae var cerevisiae", EnumRarity.uncommon); + private static final BioData eColiData = BioData + .createAndRegisterBioData("Escherichia koli", EnumRarity.uncommon, 10000, 0); + private static final BioDNA BIO_DNA_ANAEROBIC_OIL = BioDNA + .createAndRegisterBioDNA("Pseudomonas Veronii", EnumRarity.uncommon); + private static final BioData BIO_DATA_ANAEROBIC_OIL = BioData + .createAndRegisterBioData("Pseudomonas Veronii", EnumRarity.uncommon, 5000, 1); + public static BioCulture CommonYeast; + public static BioCulture WhineYeast; + public static BioCulture BeerYeast; + public static BioCulture rottenFleshBacteria; + public static BioCulture eColi; + public static BioCulture anaerobicOil; + public static BioCulture generalPurposeFermentingBacteria; + + public static void run() { + BioCultureLoader.CommonYeast = BioCulture.createAndRegisterBioCulture( + new Color(255, 248, 200), + "Saccharomyces cerevisiae", + BioPlasmid.convertDataToPlasmid(BioCultureLoader.BIO_DATA_YEAST), + BioDNA.convertDataToDNA(BioCultureLoader.BIO_DATA_YEAST), + true); + BioCultureLoader.WhineYeast = BioCulture.createAndRegisterBioCulture( + new Color(255, 248, 200), + "Saccharomyces cerevisiae var bayanus", + BioPlasmid.convertDataToPlasmid(BioCultureLoader.BIO_DNA_WHINE_YEAST), + BioCultureLoader.BIO_DNA_WHINE_YEAST, + EnumRarity.uncommon, + true); + BioCultureLoader.BeerYeast = BioCulture.createAndRegisterBioCulture( + new Color(255, 248, 200), + "Saccharomyces cerevisiae var cerevisiae", + BioPlasmid.convertDataToPlasmid(BioCultureLoader.BIO_DNA_BEER_YEAST), + BioCultureLoader.BIO_DNA_BEER_YEAST, + EnumRarity.uncommon, + true); + BioCultureLoader.rottenFleshBacteria = BioCulture.createAndRegisterBioCulture( + new Color(110, 40, 25), + "Escherichia cadaver", + BioPlasmid.convertDataToPlasmid(BioCultureLoader.BIO_DATA_BETA_LACMATASE), + BioDNA.convertDataToDNA(BioCultureLoader.BIO_DATA_BETA_LACMATASE), + false); + BioCultureLoader.eColi = BioCulture.createAndRegisterBioCulture( + new Color(149, 132, 75), + "Escherichia koli", + BioPlasmid.convertDataToPlasmid(BioCultureLoader.eColiData), + BioDNA.convertDataToDNA(BioCultureLoader.eColiData), + true); + BioCultureLoader.anaerobicOil = BioCulture.createAndRegisterBioCulture( + new Color(0, 0, 0), + "Pseudomonas Veronii", + BioPlasmid.convertDataToPlasmid(BioCultureLoader.BIO_DNA_ANAEROBIC_OIL), + BioDNA.convertDataToDNA(BioCultureLoader.BIO_DATA_ANAEROBIC_OIL), + true); + BioCultureLoader.generalPurposeFermentingBacteria = BioCulture.createAndRegisterBioCulture( + new Color(127, 69, 26), + "Saccharomyces escherichia", + BioCultureLoader.CommonYeast.getPlasmid(), + BioCultureLoader.eColi.getdDNA(), + EnumRarity.epic, + true); + + BioCultureLoader.CommonYeast.setLocalisedName("Common Yeast"); + BioCultureLoader.WhineYeast.setLocalisedName("Whine Yeast"); + BioCultureLoader.BeerYeast.setLocalisedName("Beer Yeast"); + BioCultureLoader.rottenFleshBacteria.setLocalisedName("Rotten Flesh Bacteria"); + BioCultureLoader.eColi.setLocalisedName("eColi Bacteria"); + BioCultureLoader.anaerobicOil.setLocalisedName("Anaerobic Oil Bacteria"); + BioCultureLoader.generalPurposeFermentingBacteria.setLocalisedName("General Purpose Fermenting Bacteria"); + } +} diff --git a/src/main/java/bartworks/common/loaders/BioItemList.java b/src/main/java/bartworks/common/loaders/BioItemList.java new file mode 100644 index 0000000000..d845c5048d --- /dev/null +++ b/src/main/java/bartworks/common/loaders/BioItemList.java @@ -0,0 +1,106 @@ +/* + * 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.common.loaders; + +import java.util.Collection; +import java.util.HashSet; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import bartworks.common.items.ItemLabModule; +import bartworks.common.items.ItemLabParts; +import bartworks.util.BioCulture; +import bartworks.util.BioDNA; +import bartworks.util.BioData; +import bartworks.util.BioPlasmid; +import cpw.mods.fml.common.registry.GameRegistry; + +public class BioItemList { + + private BioItemList() {} + + private static final Item mItemBioLabParts = new ItemLabModule( + new String[] { "DNAExtractionModule", "PCRThermoclyclingModule", "PlasmidSynthesisModule", + "TransformationModule", "ClonalCellularSynthesisModule" }); + public static final ItemStack[] mBioLabParts = { new ItemStack(BioItemList.mItemBioLabParts), + new ItemStack(BioItemList.mItemBioLabParts, 1, 1), new ItemStack(BioItemList.mItemBioLabParts, 1, 2), + new ItemStack(BioItemList.mItemBioLabParts, 1, 3), new ItemStack(BioItemList.mItemBioLabParts, 1, 4) }; + private static final Item vanillaBioLabParts = new ItemLabParts( + new String[] { "petriDish", "DNASampleFlask", "PlasmidCell", "DetergentPowder", "Agarose", "IncubationModule", + "PlasmaMembrane" }); + + public static void registerBioItems() { + GameRegistry.registerItem(BioItemList.mItemBioLabParts, "BioLabModules"); + GameRegistry.registerItem(BioItemList.vanillaBioLabParts, "BioLabParts"); + } + + public static Collection<ItemStack> getAllPetriDishes() { + HashSet<ItemStack> ret = new HashSet<>(); + for (BioCulture Culture : BioCulture.BIO_CULTURE_ARRAY_LIST) { + ret.add(BioItemList.getPetriDish(Culture)); + } + return ret; + } + + public static Collection<ItemStack> getAllDNASampleFlasks() { + HashSet<ItemStack> ret = new HashSet<>(); + for (BioData dna : BioData.BIO_DATA_ARRAY_LIST) { + ret.add(BioItemList.getDNASampleFlask(BioDNA.convertDataToDNA(dna))); + } + return ret; + } + + public static Collection<ItemStack> getAllPlasmidCells() { + HashSet<ItemStack> ret = new HashSet<>(); + for (BioData dna : BioData.BIO_DATA_ARRAY_LIST) { + ret.add(BioItemList.getPlasmidCell(BioPlasmid.convertDataToPlasmid(dna))); + } + return ret; + } + + public static ItemStack getPetriDish(BioCulture Culture) { + if (Culture == null) return new ItemStack(BioItemList.vanillaBioLabParts); + ItemStack ret = new ItemStack(BioItemList.vanillaBioLabParts); + ret.setTagCompound(BioCulture.getNBTTagFromCulture(Culture)); + return ret; + } + + public static ItemStack getDNASampleFlask(BioDNA dna) { + if (dna == null) return new ItemStack(BioItemList.vanillaBioLabParts, 1, 1); + + ItemStack ret = new ItemStack(BioItemList.vanillaBioLabParts, 1, 1); + ret.setTagCompound(BioData.getNBTTagFromBioData(dna)); + return ret; + } + + public static ItemStack getPlasmidCell(BioPlasmid plasmid) { + if (plasmid == null) return new ItemStack(BioItemList.vanillaBioLabParts, 1, 2); + ItemStack ret = new ItemStack(BioItemList.vanillaBioLabParts, 1, 2); + ret.setTagCompound(BioData.getNBTTagFromBioData(plasmid)); + return ret; + } + + /** + * 1 - Detergent Powder 2 - Agarose 3 - Incubation Module 4 - Plasma Membrane others are null + * + * @param selection see above + * @return the selected Item + */ + public static ItemStack getOther(int selection) { + if (selection < 1 || selection > 4) return null; + + return new ItemStack(BioItemList.vanillaBioLabParts, 1, 2 + selection); + } +} diff --git a/src/main/java/bartworks/common/loaders/BioLabLoader.java b/src/main/java/bartworks/common/loaders/BioLabLoader.java new file mode 100644 index 0000000000..4a625ea33c --- /dev/null +++ b/src/main/java/bartworks/common/loaders/BioLabLoader.java @@ -0,0 +1,23 @@ +/* + * 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.common.loaders; + +public class BioLabLoader { + + public static void run() { + FluidLoader.run(); + BioItemList.registerBioItems(); + BioRecipeLoader.run(); + } +} diff --git a/src/main/java/bartworks/common/loaders/BioRecipeLoader.java b/src/main/java/bartworks/common/loaders/BioRecipeLoader.java new file mode 100644 index 0000000000..77ae6b8c2c --- /dev/null +++ b/src/main/java/bartworks/common/loaders/BioRecipeLoader.java @@ -0,0 +1,211 @@ +/* + * 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.common.loaders; + +import static bartworks.API.recipe.BartWorksRecipeMaps.bacterialVatRecipes; +import static bartworks.API.recipe.BartWorksRecipeMaps.bioLabRecipes; +import static gregtech.api.enums.Mods.CropsPlusPlus; +import static gregtech.api.util.GTRecipeBuilder.MINUTES; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; +import static gregtech.api.util.GTRecipeBuilder.TICKS; +import static gregtech.api.util.GTRecipeConstants.SIEVERTS; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import gregtech.api.enums.GTValues; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.GTUtility; + +public class BioRecipeLoader { + + public static void run() { + registerWaterBasedBioLabIncubations(); + registerBacterialVatRecipes(); + } + + public static void registerWaterBasedBioLabIncubations() { + FluidStack[] easyFluids = { Materials.Water.getFluid(1000L), + FluidRegistry.getFluidStack("ic2distilledwater", 1000) }; + for (FluidStack fluidStack : easyFluids) { + + GTValues.RA.stdBuilder() + .itemInputs(BioItemList.getPetriDish(null), new ItemStack(Items.rotten_flesh)) + .itemOutputs(BioItemList.getPetriDish(BioCultureLoader.rottenFleshBacteria)) + .outputChances(33_00) + .fluidInputs(fluidStack) + .duration(25 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(bioLabRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(BioItemList.getPetriDish(null), new ItemStack(Items.fermented_spider_eye)) + .itemOutputs(BioItemList.getPetriDish(BioCultureLoader.eColi)) + .outputChances(45_00) + .fluidInputs(fluidStack) + .duration(25 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(bioLabRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(BioItemList.getPetriDish(null), ItemList.Food_Dough.get(1L)) + .itemOutputs(BioItemList.getPetriDish(BioCultureLoader.CommonYeast)) + .outputChances(75_00) + .fluidInputs(fluidStack) + .duration(25 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(bioLabRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(BioItemList.getPetriDish(null), ItemList.Food_Dough_Sugar.get(1L)) + .itemOutputs(BioItemList.getPetriDish(BioCultureLoader.WhineYeast)) + .outputChances(25_00) + .fluidInputs(fluidStack) + .duration(25 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(bioLabRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(BioItemList.getPetriDish(null), ItemList.Bottle_Wine.get(1L)) + .itemOutputs(BioItemList.getPetriDish(BioCultureLoader.WhineYeast)) + .outputChances(33_00) + .fluidInputs(fluidStack) + .duration(25 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(bioLabRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(BioItemList.getPetriDish(null), ItemList.Bottle_Beer.get(1L)) + .itemOutputs(BioItemList.getPetriDish(BioCultureLoader.BeerYeast)) + .outputChances(25_00) + .fluidInputs(fluidStack) + .duration(25 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(bioLabRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(BioItemList.getPetriDish(null), ItemList.Bottle_Dark_Beer.get(1L)) + .itemOutputs(BioItemList.getPetriDish(BioCultureLoader.BeerYeast)) + .outputChances(33_00) + .fluidInputs(fluidStack) + .duration(25 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(bioLabRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(BioItemList.getPetriDish(null), new ItemStack(Blocks.dirt)) + .itemOutputs(BioItemList.getPetriDish(BioCultureLoader.anaerobicOil)) + .outputChances(100) + .fluidInputs(fluidStack) + .duration(1 * MINUTES + 15 * SECONDS) + .eut(TierEU.RECIPE_EV) + .addTo(bioLabRecipes); + } + } + + public static void registerWaterBasedBacterialVatRecipes() { + FluidStack[] easyFluids = { Materials.Water.getFluid(1000L), + FluidRegistry.getFluidStack("ic2distilledwater", 1000) }; + for (FluidStack fluidStack : easyFluids) { + if (CropsPlusPlus.isModLoaded()) { + GTValues.RA.stdBuilder() + .itemInputs(GTUtility.getIntegratedCircuit(2), new ItemStack(Items.sugar, 64)) + .special(BioItemList.getPetriDish(BioCultureLoader.CommonYeast)) + .fluidInputs(new FluidStack(fluidStack, 100)) + .fluidOutputs(FluidRegistry.getFluidStack("potion.ghp", 1)) + .duration(17 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_EV) + .noOptimize() + .addTo(bacterialVatRecipes); + } + + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Crop_Drop_Grapes.get(16)) + .special(BioItemList.getPetriDish(BioCultureLoader.WhineYeast)) + .fluidInputs(new FluidStack(fluidStack, 100)) + .fluidOutputs(FluidRegistry.getFluidStack("potion.wine", 12)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_MV) + .noOptimize() + .addTo(bacterialVatRecipes); + + GTValues.RA.stdBuilder() + .itemInputs( + new ItemStack(Items.sugar, 4), + ItemList.IC2_Hops.get(16L), + GTOreDictUnificator.get(OrePrefixes.dust, Materials.Wheat, 8L)) + .special(BioItemList.getPetriDish(BioCultureLoader.BeerYeast)) + .fluidInputs(new FluidStack(fluidStack, 100)) + .fluidOutputs(FluidRegistry.getFluidStack("potion.beer", 5)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_LV) + .noOptimize() + .addTo(bacterialVatRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(ItemList.IC2_Hops.get(32L), GTOreDictUnificator.get(OrePrefixes.dust, Materials.Wheat, 16L)) + .special(BioItemList.getPetriDish(BioCultureLoader.BeerYeast)) + .fluidInputs(new FluidStack(fluidStack, 100)) + .fluidOutputs(FluidRegistry.getFluidStack("potion.darkbeer", 10)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_LV) + .noOptimize() + .addTo(bacterialVatRecipes); + } + } + + public static void registerBacterialVatRecipes() { + registerWaterBasedBacterialVatRecipes(); + + GTValues.RA.stdBuilder() + .special(BioItemList.getPetriDish(BioCultureLoader.WhineYeast)) + .fluidInputs(FluidRegistry.getFluidStack("potion.grapejuice", 100)) + .fluidOutputs(FluidRegistry.getFluidStack("potion.wine", 12)) + .duration(20 * SECONDS) + .eut(TierEU.RECIPE_LV) + .noOptimize() + .addTo(bacterialVatRecipes); + + GTValues.RA.stdBuilder() + .special(BioItemList.getPetriDish(BioCultureLoader.anaerobicOil)) + .fluidInputs(Materials.FermentedBiomass.getFluid(10000)) + .fluidOutputs(new FluidStack(FluidLoader.fulvicAcid, 1000)) + .duration(2 * MINUTES + 17 * SECONDS + 8 * TICKS) + .eut(TierEU.RECIPE_LV) + .noOptimize() + .addTo(bacterialVatRecipes); + } + + public static void runOnServerStarted() { + RecipeMaps.fermentingRecipes.getAllRecipes() + .forEach( + recipe -> GTValues.RA.stdBuilder() + .special(BioItemList.getPetriDish(BioCultureLoader.generalPurposeFermentingBacteria)) + .fluidInputs(recipe.mFluidInputs) + .fluidOutputs(recipe.mFluidOutputs) + .duration(recipe.mDuration) + .eut(recipe.mEUt) + .metadata(SIEVERTS, (int) GTUtility.getTier(recipe.mEUt)) + .addTo(bacterialVatRecipes)); + + } +} diff --git a/src/main/java/bartworks/common/loaders/ElectricImplosionCompressorRecipes.java b/src/main/java/bartworks/common/loaders/ElectricImplosionCompressorRecipes.java new file mode 100644 index 0000000000..9e1d896272 --- /dev/null +++ b/src/main/java/bartworks/common/loaders/ElectricImplosionCompressorRecipes.java @@ -0,0 +1,229 @@ +package bartworks.common.loaders; + +import static bartworks.API.recipe.BartWorksRecipeMaps.electricImplosionCompressorRecipes; +import static goodgenerator.loader.Loaders.highDensityPlutonium; +import static goodgenerator.loader.Loaders.highDensityPlutoniumNugget; +import static goodgenerator.loader.Loaders.highDensityThorium; +import static goodgenerator.loader.Loaders.highDensityThoriumNugget; +import static goodgenerator.loader.Loaders.highDensityUranium; +import static goodgenerator.loader.Loaders.highDensityUraniumNugget; +import static gregtech.api.enums.GTValues.M; +import static gregtech.api.enums.Mods.Avaritia; +import static gregtech.api.enums.Mods.EternalSingularity; +import static gregtech.api.enums.Mods.OpenComputers; +import static gregtech.api.enums.Mods.SuperSolarPanels; +import static gregtech.api.enums.Mods.UniversalSingularities; +import static gregtech.api.util.GTModHandler.getModItem; +import static gregtech.api.util.GTRecipeBuilder.MINUTES; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; +import static gregtech.api.util.GTRecipeBuilder.TICKS; + +import net.minecraft.item.ItemStack; + +import gregtech.api.enums.GTValues; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.MaterialsUEVplus; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.GTUtility; + +public class ElectricImplosionCompressorRecipes implements Runnable { + + @Override + public void run() { + // Custom electric implosion compressor recipes. Cannot be overclocked. + + if (EternalSingularity.isModLoaded()) { + + GTValues.RA.stdBuilder() + .itemOutputs(getModItem(EternalSingularity.ID, "eternal_singularity", 1L)) + .fluidInputs(MaterialsUEVplus.SpaceTime.getMolten(72L)) + .duration(1 * MINUTES + 40 * SECONDS) + .eut(TierEU.RECIPE_UMV) + .noOptimize() + .addTo(electricImplosionCompressorRecipes); + + if (UniversalSingularities.isModLoaded()) { + // Raw Exposed Optical Chip + GTValues.RA.stdBuilder() + .itemInputs( + ItemList.Circuit_Silicon_Wafer7.get(1L), + // Fluxed Electrum Singularity. + getModItem(UniversalSingularities.ID, "universal.general.singularity", 1L, 20)) + .itemOutputs(ItemList.Circuit_Chip_Optical.get(16L)) + .duration(5 * SECONDS) + .eut(TierEU.RECIPE_UMV) + .noOptimize() + .addTo(electricImplosionCompressorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs( + // fluxed electrum singularity + getModItem(UniversalSingularities.ID, "universal.general.singularity", 1L, 20)) + .fluidInputs(MaterialsUEVplus.Mellion.getMolten(4 * 144L)) + // spaghettic singularity + .itemOutputs(getModItem(EternalSingularity.ID, "combined_singularity", 1L, 2)) + .duration(1 * SECONDS) + .eut(TierEU.RECIPE_UMV) + .addTo(electricImplosionCompressorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs( + // iron singularity + getModItem(Avaritia.ID, "Singularity", 1L, 0)) + .fluidInputs(MaterialsUEVplus.Creon.getMolten(4 * 144L)) + // cryptic singularity + .itemOutputs(getModItem(EternalSingularity.ID, "combined_singularity", 1L, 4)) + .duration(1 * SECONDS) + .eut(TierEU.RECIPE_UMV) + .addTo(electricImplosionCompressorRecipes); + } + } + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(highDensityPlutoniumNugget, 5)) + .itemOutputs(new ItemStack(highDensityPlutonium, 1)) + .fluidInputs(Materials.Neutronium.getMolten(72L)) + .duration(1) + .eut(TierEU.RECIPE_UEV) + .noOptimize() + .addTo(electricImplosionCompressorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(highDensityUraniumNugget, 5)) + .itemOutputs(new ItemStack(highDensityUranium, 1)) + .fluidInputs(Materials.Neutronium.getMolten(72L)) + .duration(1) + .eut(TierEU.RECIPE_UEV) + .noOptimize() + .addTo(electricImplosionCompressorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(highDensityThoriumNugget, 5)) + .itemOutputs(new ItemStack(highDensityThorium, 1)) + .fluidInputs(Materials.Neutronium.getMolten(72L)) + .duration(1) + .eut(TierEU.RECIPE_UEV) + .noOptimize() + .addTo(electricImplosionCompressorRecipes); + + // Magneto material recipe for base fluid. + GTValues.RA.stdBuilder() + .itemInputs( + GTOreDictUnificator.get(OrePrefixes.nanite, MaterialsUEVplus.WhiteDwarfMatter, 1L), + GTOreDictUnificator.get(OrePrefixes.nanite, MaterialsUEVplus.Universium, 1L), + GTOreDictUnificator.get(OrePrefixes.nanite, MaterialsUEVplus.BlackDwarfMatter, 1L)) + .fluidInputs(MaterialsUEVplus.RawStarMatter.getFluid(64 * 144L)) + .fluidOutputs(MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter.getMolten(16 * 144L)) + .duration(4 * SECONDS) + .eut(TierEU.RECIPE_UXV) + .noOptimize() + .addTo(electricImplosionCompressorRecipes); + + // Infinity Catalyst + GTValues.RA.stdBuilder() + .itemInputs(GTOreDictUnificator.get(OrePrefixes.dust, Materials.InfinityCatalyst, 64L)) + .itemOutputs(getModItem(Avaritia.ID, "Resource", 1L, 5)) + .duration(1) + .eut(TierEU.RECIPE_UIV) + .noOptimize() + .addTo(electricImplosionCompressorRecipes); + + if (UniversalSingularities.isModLoaded()) { + // Fluxed Singularity + GTValues.RA.stdBuilder() + .itemInputs(GTOreDictUnificator.get(OrePrefixes.block, Materials.ElectrumFlux, 16L)) + .itemOutputs(getModItem(UniversalSingularities.ID, "universal.general.singularity", 1L, 20)) + .duration(1) + .eut(TierEU.RECIPE_UIV) + .noOptimize() + .addTo(electricImplosionCompressorRecipes); + + // Iron Singularity + GTValues.RA.stdBuilder() + .itemOutputs(getModItem(Avaritia.ID, "Singularity", 1L, 0)) + .fluidInputs(Materials.Iron.getMolten(7296 * 9 * 144L)) + .duration(1) + .eut(TierEU.RECIPE_UIV) + .noOptimize() + .addTo(electricImplosionCompressorRecipes); + + // Copper Singularity + GTValues.RA.stdBuilder() + .fluidInputs(Materials.Copper.getMolten(3648 * 9 * 144L)) + .itemOutputs(getModItem(Avaritia.ID, "Singularity", 1L, 5)) + .duration(1 * TICKS) + .eut(TierEU.RECIPE_UIV) + .addTo(electricImplosionCompressorRecipes); + + ItemStack diamondBlocks = GTUtility + .copyAmountUnsafe(729, GTOreDictUnificator.get(OrePrefixes.block, Materials.Diamond, 1L)); + // Diamond Singularity + GTValues.RA.stdBuilder() + .itemInputs(diamondBlocks) + .itemOutputs(getModItem(UniversalSingularities.ID, "universal.vanilla.singularity", 1L, 2)) + .duration(1 * TICKS) + .eut(TierEU.RECIPE_UIV) + .addTo(electricImplosionCompressorRecipes); + } + // MHDCSM V2 + GTValues.RA.stdBuilder() + .itemInputs(MaterialsUEVplus.Eternity.getNanite(1), MaterialsUEVplus.Universium.getNanite(1)) + .fluidInputs(MaterialsUEVplus.RawStarMatter.getFluid(128 * 144L)) + .fluidOutputs(MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter.getMolten(32 * 144L)) + .duration(4 * SECONDS) + .eut(TierEU.RECIPE_MAX) + .noOptimize() + .addTo(electricImplosionCompressorRecipes); + + this.addMagnetohydrodynamicallyConstrainedStarMatterPartRecipes(); + } + + private void addMagnetohydrodynamicallyConstrainedStarMatterPartRecipes() { + + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.frameGt, 1, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.nugget, 9, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.ingot, 1, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.plate, 1, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.plateDense, 1, 3); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.stick, 2, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.round, 8, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.bolt, 8, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.screw, 8, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.ring, 4, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.foil, 8, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.itemCasing, 2, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.gearGtSmall, 1, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.rotor, 1, 2); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.stickLong, 1, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.springSmall, 2, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.spring, 1, 1); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.gearGt, 1, 2); + this.addWhiteDwarfMagnetoEICRecipe(OrePrefixes.wireFine, 8, 1); + } + + private void addWhiteDwarfMagnetoEICRecipe(final OrePrefixes part, final int multiplier, + final int circuitMultiplier) { + + final int partFraction = (int) (144 * part.mMaterialAmount / M); + + GTValues.RA.stdBuilder() + .itemInputs( + new Object[] { OrePrefixes.circuit.get(Materials.UHV), circuitMultiplier }, + getModItem(SuperSolarPanels.ID, "solarsplitter", 1, 0), + getModItem(OpenComputers.ID, "hologram2", circuitMultiplier, 0), + GTOreDictUnificator.get(part, MaterialsUEVplus.Eternity, multiplier)) + .itemOutputs( + GTOreDictUnificator + .get(part, MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter, multiplier)) + .fluidInputs( + MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter + .getMolten((long) partFraction * multiplier)) + .duration((int) (multiplier * (20 * partFraction / 144.0))) + .eut(TierEU.RECIPE_UXV) + .noOptimize() + .addTo(electricImplosionCompressorRecipes); + } +} diff --git a/src/main/java/bartworks/common/loaders/FluidLoader.java b/src/main/java/bartworks/common/loaders/FluidLoader.java new file mode 100644 index 0000000000..b5f8283aa0 --- /dev/null +++ b/src/main/java/bartworks/common/loaders/FluidLoader.java @@ -0,0 +1,145 @@ +/* + * 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.common.loaders; + +import static gregtech.api.enums.Mods.Gendustry; +import static gregtech.api.enums.Mods.GregTech; +import static gregtech.api.recipe.RecipeMaps.centrifugeRecipes; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; + +import java.awt.Color; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import bartworks.API.SideReference; +import bartworks.client.renderer.RendererGlassBlock; +import bartworks.client.renderer.RendererSwitchingColorFluid; +import bartworks.common.blocks.BlockBioFluid; +import bartworks.common.tileentities.classic.TileEntityDimIDBridge; +import bartworks.util.BioCulture; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.GregTechAPI; +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; +import gregtech.common.items.MetaGeneratedItem98; + +public class FluidLoader { + + public static IIcon autogenIIcon; + public static Fluid ff; + public static int renderID; + public static Block bioFluidBlock; + public static Fluid[] BioLabFluidMaterials; + public static ItemStack[] BioLabFluidCells; + + // OilProcessing chain + public static Fluid fulvicAcid, heatedfulvicAcid, Kerogen; + + public static void run() { + renderID = RenderingRegistry.getNextAvailableRenderId(); + ff = new Fluid("BWfakeFluid"); + GregTechAPI.sGTBlockIconload.add( + () -> ff.setIcons( + GregTechAPI.sBlockIcons + .registerIcon(GregTech.getResourcePath("fluids", "fluid.molten.autogenerated")))); + fulvicAcid = createAndRegisterFluid("Fulvic Acid", new Color(20, 20, 20)); + heatedfulvicAcid = createAndRegisterFluid("Heated Fulvic Acid", new Color(40, 20, 20), 720); + Kerogen = createAndRegisterFluid("Kerogen", new Color(85, 85, 85)); + BioLabFluidMaterials = new Fluid[] { createAndRegisterFluid("FluorecentdDNA", new Color(125, 50, 170)), + createAndRegisterFluid("EnzymesSollution", new Color(240, 200, 125)), + createAndRegisterFluid("Penicillin", new Color(255, 255, 255)), + createAndRegisterFluid("Polymerase", new Color(110, 180, 110)) }; + + BioLabFluidCells = new ItemStack[BioLabFluidMaterials.length]; + + MetaGeneratedItem98.FluidCell[] fluidCells = { MetaGeneratedItem98.FluidCell.FLUORESCENT_DNA, + MetaGeneratedItem98.FluidCell.ENZYME_SOLUTION, MetaGeneratedItem98.FluidCell.PENICILLIN, + MetaGeneratedItem98.FluidCell.POLYMERASE, }; + for (int i = 0; i < fluidCells.length; i++) { + BioLabFluidCells[i] = fluidCells[i].get(); + } + + FluidStack dnaFluid = Gendustry.isModLoaded() ? FluidRegistry.getFluidStack("liquiddna", 100) + : Materials.Biomass.getFluid(100L); + for (BioCulture B : BioCulture.BIO_CULTURE_ARRAY_LIST) { + if (B.isBreedable()) { + 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() }) + .withLocalizedName(B.getLocalisedName() + " Fluid") + .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); + } + } + + bioFluidBlock = new BlockBioFluid(); + GameRegistry.registerBlock(bioFluidBlock, "coloredFluidBlock"); + GameRegistry.registerTileEntity(TileEntityDimIDBridge.class, "bwTEDimIDBridge"); + if (SideReference.Side.Client) { + RendererSwitchingColorFluid.register(); + RendererGlassBlock.register(); + } + } + + public static Fluid createAndRegisterFluid(String Name, Color color) { + return GTFluidFactory.builder(Name) + .withTextureName("molten.autogenerated") + .withColorRGBA( + new short[] { (short) color.getRed(), (short) color.getGreen(), (short) color.getBlue(), + (short) color.getAlpha() }) + .withStateAndTemperature(FluidState.LIQUID, 300) + .buildAndRegister() + .asFluid(); + } + + public static Fluid createAndRegisterFluid(String Name, Color color, int temperature) { + return GTFluidFactory.builder(Name) + .withTextureName("molten.autogenerated") + .withColorRGBA( + new short[] { (short) color.getRed(), (short) color.getGreen(), (short) color.getBlue(), + (short) color.getAlpha() }) + .withStateAndTemperature(FluidState.LIQUID, temperature) + .buildAndRegister() + .asFluid(); + } +} diff --git a/src/main/java/bartworks/common/loaders/ItemRegistry.java b/src/main/java/bartworks/common/loaders/ItemRegistry.java new file mode 100644 index 0000000000..4cf95866a1 --- /dev/null +++ b/src/main/java/bartworks/common/loaders/ItemRegistry.java @@ -0,0 +1,654 @@ +/* + * 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.common.loaders; + +import static gregtech.api.enums.MetaTileEntityIDs.AcidGeneratorEV; +import static gregtech.api.enums.MetaTileEntityIDs.AcidGeneratorHV; +import static gregtech.api.enums.MetaTileEntityIDs.AcidGeneratorLV; +import static gregtech.api.enums.MetaTileEntityIDs.AcidGeneratorMV; +import static gregtech.api.enums.MetaTileEntityIDs.CircuitAssemblyLine; +import static gregtech.api.enums.MetaTileEntityIDs.CompressedFluidHatch; +import static gregtech.api.enums.MetaTileEntityIDs.DeepEarthHeatingPump; +import static gregtech.api.enums.MetaTileEntityIDs.Diode12A_EV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode12A_HV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode12A_IV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode12A_LV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode12A_LuV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode12A_MAX; +import static gregtech.api.enums.MetaTileEntityIDs.Diode12A_MV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode12A_UEV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode12A_UHV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode12A_UIV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode12A_ULV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode12A_UMV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode12A_UV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode12A_UXV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode12A_ZPM; +import static gregtech.api.enums.MetaTileEntityIDs.Diode16A_EV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode16A_HV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode16A_IV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode16A_LV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode16A_LuV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode16A_MAX; +import static gregtech.api.enums.MetaTileEntityIDs.Diode16A_MV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode16A_UEV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode16A_UHV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode16A_UIV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode16A_ULV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode16A_UMV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode16A_UV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode16A_UXV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode16A_ZPM; +import static gregtech.api.enums.MetaTileEntityIDs.Diode2A_EV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode2A_HV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode2A_IV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode2A_LV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode2A_LuV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode2A_MAX; +import static gregtech.api.enums.MetaTileEntityIDs.Diode2A_MV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode2A_UEV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode2A_UHV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode2A_UIV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode2A_ULV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode2A_UMV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode2A_UV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode2A_UXV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode2A_ZPM; +import static gregtech.api.enums.MetaTileEntityIDs.Diode4A_EV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode4A_HV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode4A_IV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode4A_LV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode4A_LuV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode4A_MAX; +import static gregtech.api.enums.MetaTileEntityIDs.Diode4A_MV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode4A_UEV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode4A_UHV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode4A_UIV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode4A_ULV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode4A_UMV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode4A_UV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode4A_UXV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode4A_ZPM; +import static gregtech.api.enums.MetaTileEntityIDs.Diode8A_EV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode8A_HV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode8A_IV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode8A_LV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode8A_LuV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode8A_MAX; +import static gregtech.api.enums.MetaTileEntityIDs.Diode8A_MV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode8A_UEV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode8A_UHV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode8A_UIV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode8A_ULV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode8A_UMV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode8A_UV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode8A_UXV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode8A_ZPM; +import static gregtech.api.enums.MetaTileEntityIDs.ElectricImplosionCompressor; +import static gregtech.api.enums.MetaTileEntityIDs.EnergyDistributor_EV; +import static gregtech.api.enums.MetaTileEntityIDs.EnergyDistributor_HV; +import static gregtech.api.enums.MetaTileEntityIDs.EnergyDistributor_IV; +import static gregtech.api.enums.MetaTileEntityIDs.EnergyDistributor_LV; +import static gregtech.api.enums.MetaTileEntityIDs.EnergyDistributor_LuV; +import static gregtech.api.enums.MetaTileEntityIDs.EnergyDistributor_MAX; +import static gregtech.api.enums.MetaTileEntityIDs.EnergyDistributor_MV; +import static gregtech.api.enums.MetaTileEntityIDs.EnergyDistributor_UEV; +import static gregtech.api.enums.MetaTileEntityIDs.EnergyDistributor_UHV; +import static gregtech.api.enums.MetaTileEntityIDs.EnergyDistributor_UIV; +import static gregtech.api.enums.MetaTileEntityIDs.EnergyDistributor_ULV; +import static gregtech.api.enums.MetaTileEntityIDs.EnergyDistributor_UMV; +import static gregtech.api.enums.MetaTileEntityIDs.EnergyDistributor_UV; +import static gregtech.api.enums.MetaTileEntityIDs.EnergyDistributor_UXV; +import static gregtech.api.enums.MetaTileEntityIDs.EnergyDistributor_ZPM; +import static gregtech.api.enums.MetaTileEntityIDs.GiantOutputHatch; +import static gregtech.api.enums.MetaTileEntityIDs.HighTemperatureGasCooledReactor; +import static gregtech.api.enums.MetaTileEntityIDs.HumongousInputHatch; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserConverter128A_EV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserConverter128A_IV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserConverter128A_LuV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserConverter128A_ZPM; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserConverter32A_EV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserConverter32A_IV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserConverter32A_LuV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserConverter32A_ZPM; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserConverter64A_EV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserConverter64A_IV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserConverter64A_LuV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserConverter64A_ZPM; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserConverter96A_EV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserConverter96A_IV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserConverter96A_LuV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserConverter96A_ZPM; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserPipe; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserSourceHatch128A_EV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserSourceHatch128A_IV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserSourceHatch128A_LuV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserSourceHatch128A_ZPM; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserSourceHatch32A_EV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserSourceHatch32A_IV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserSourceHatch32A_LuV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserSourceHatch32A_ZPM; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserSourceHatch64A_EV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserSourceHatch64A_IV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserSourceHatch64A_LuV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserSourceHatch64A_ZPM; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserSourceHatch96A_EV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserSourceHatch96A_IV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserSourceHatch96A_LuV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserSourceHatch96A_ZPM; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserTargetHatch128A_EV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserTargetHatch128A_IV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserTargetHatch128A_LuV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserTargetHatch128A_ZPM; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserTargetHatch32A_EV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserTargetHatch32A_IV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserTargetHatch32A_LuV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserTargetHatch32A_ZPM; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserTargetHatch64A_EV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserTargetHatch64A_IV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserTargetHatch64A_LuV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserTargetHatch64A_ZPM; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserTargetHatch96A_EV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserTargetHatch96A_IV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserTargetHatch96A_LuV; +import static gregtech.api.enums.MetaTileEntityIDs.LowPowerLaserTargetHatch96A_ZPM; +import static gregtech.api.enums.MetaTileEntityIDs.MegaBlastFurnace; +import static gregtech.api.enums.MetaTileEntityIDs.MegaChemicalReactor; +import static gregtech.api.enums.MetaTileEntityIDs.MegaDistillationTower; +import static gregtech.api.enums.MetaTileEntityIDs.MegaOilCracker; +import static gregtech.api.enums.MetaTileEntityIDs.MegaVacuumFreezer; +import static gregtech.api.enums.MetaTileEntityIDs.ThoriumHighTemperatureReactor; +import static gregtech.api.enums.MetaTileEntityIDs.VoidMinerI; +import static gregtech.api.enums.MetaTileEntityIDs.VoidMinerII; +import static gregtech.api.enums.MetaTileEntityIDs.VoidMinerIII; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +import bartworks.API.BorosilicateGlass; +import bartworks.MainMod; +import bartworks.common.blocks.BWBlocks; +import bartworks.common.blocks.BWBlocksGlass; +import bartworks.common.blocks.BWBlocksGlass2; +import bartworks.common.blocks.BWMachineBlockContainer; +import bartworks.common.blocks.BWTileEntityContainer; +import bartworks.common.configs.ConfigHandler; +import bartworks.common.items.BWItemBlocks; +import bartworks.common.items.ItemCircuitProgrammer; +import bartworks.common.items.ItemRockCutter; +import bartworks.common.items.ItemSimpleWindMeter; +import bartworks.common.items.ItemStonageRotors; +import bartworks.common.items.ItemTeslaStaff; +import bartworks.common.items.SimpleIconItem; +import bartworks.common.items.SimpleSubItemClass; +import bartworks.common.tileentities.classic.TileEntityHeatedWaterPump; +import bartworks.common.tileentities.classic.TileEntityRotorBlock; +import bartworks.common.tileentities.debug.MTECreativeScanner; +import bartworks.common.tileentities.multis.MTECircuitAssemblyLine; +import bartworks.common.tileentities.multis.MTEDeepEarthHeatingPump; +import bartworks.common.tileentities.multis.MTEElectricImplosionCompressor; +import bartworks.common.tileentities.multis.MTEHighTempGasCooledReactor; +import bartworks.common.tileentities.multis.MTEThoriumHighTempReactor; +import bartworks.common.tileentities.multis.mega.MTEMegaBlastFurnace; +import bartworks.common.tileentities.multis.mega.MTEMegaChemicalReactor; +import bartworks.common.tileentities.multis.mega.MTEMegaDistillTower; +import bartworks.common.tileentities.multis.mega.MTEMegaOilCracker; +import bartworks.common.tileentities.multis.mega.MTEMegaVacuumFreezer; +import bartworks.common.tileentities.tiered.MTEAcidGenerator; +import bartworks.common.tileentities.tiered.MTECompressedFluidHatch; +import bartworks.common.tileentities.tiered.MTEDiode; +import bartworks.common.tileentities.tiered.MTEEnergyDistributor; +import bartworks.common.tileentities.tiered.MTEGiantOutputHatch; +import bartworks.common.tileentities.tiered.MTEHumongousInputHatch; +import bartworks.system.material.WerkstoffLoader; +import bwcrossmod.galacticgreg.MTEVoidMiners; +import bwcrossmod.tectech.tileentites.tiered.MTELowPowerLaserBox; +import bwcrossmod.tectech.tileentites.tiered.MTELowPowerLaserDynamo; +import bwcrossmod.tectech.tileentites.tiered.MTELowPowerLaserHatch; +import bwcrossmod.tectech.tileentites.tiered.MTELowPowerLaserPipe; +import cpw.mods.fml.common.registry.GameRegistry; +import fox.spiteful.avaritia.blocks.LudicrousBlocks; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.Materials; +import gregtech.api.enums.MetaTileEntityIDs; +import gregtech.api.enums.Mods; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GTOreDictUnificator; +import ic2.api.item.IKineticRotor; + +public class ItemRegistry { + + public static final Item TESLASTAFF = new ItemTeslaStaff(); + public static final Item ROCKCUTTER_LV = new ItemRockCutter(1); + public static final Item ROCKCUTTER_MV = new ItemRockCutter(2); + public static final Item ROCKCUTTER_HV = new ItemRockCutter(3); + public static final Item CIRCUIT_PROGRAMMER = new ItemCircuitProgrammer(); + public static final Block ROTORBLOCK = new BWMachineBlockContainer( + Material.wood, + TileEntityRotorBlock.class, + "BWRotorBlock"); + public static final Item LEATHER_ROTOR = new ItemStonageRotors( + 7, + 0.15f, + 5, + 1.15f, + 1, + 50, + 10000000, + IKineticRotor.GearboxType.WIND, + new ResourceLocation(MainMod.MOD_ID, "textures/items/rotors/rotorLeather.png"), + "BW_LeatherRotor", + "rotors/itemRotorLeather"); + public static final Item WOOL_ROTOR = new ItemStonageRotors( + 7, + 0.18f, + 3, + 1.35f, + 1, + 50, + 9000000, + IKineticRotor.GearboxType.WIND, + new ResourceLocation(MainMod.MOD_ID, "textures/items/rotors/rotorWool.png"), + "BW_WoolRotor", + "rotors/itemRotorWool"); + public static final Item PAPER_ROTOR = new ItemStonageRotors( + 7, + 0.2f, + 12, + 0.9f, + 1, + 50, + 800000, + IKineticRotor.GearboxType.WIND, + new ResourceLocation(MainMod.MOD_ID, "textures/items/rotors/rotorPaper.png"), + "BW_PaperRotor", + "rotors/itemRotorPaper"); + public static final Item COMBINED_ROTOR = new ItemStonageRotors( + 9, + 0.22f, + 7, + 1.05f, + 1, + 50, + 6000000, + IKineticRotor.GearboxType.WIND, + new ResourceLocation(MainMod.MOD_ID, "textures/items/rotors/rotorCombined.png"), + "BW_CombinedRotor", + "rotors/itemRotorCombined"); + public static final Item CRAFTING_PARTS = new SimpleSubItemClass( + "grindstone_top", + "grindstone_bottom", + "completed_grindstone", + "rotors/leatherParts", + "rotors/woolParts", + "rotors/paperParts", + "rotors/combinedParts"); + public static final Item TAB = new SimpleIconItem("GT2Coin"); + public static final Item WINDMETER = new ItemSimpleWindMeter(); + public static final Block PUMPBLOCK = new BWTileEntityContainer( + Material.anvil, + TileEntityHeatedWaterPump.class, + "BWHeatedWaterPump"); + public static final Item PUMPPARTS = new SimpleSubItemClass("BWrawtube", "BWmotor"); + + public static final Block bw_realglas = new BWBlocksGlass( + "BW_GlasBlocks", + new String[] { MainMod.MOD_ID + ":BoronSilicateGlassBlock", + MainMod.MOD_ID + ":TitaniumReinforcedBoronSilicateGlassBlock", + MainMod.MOD_ID + ":TungstenSteelReinforcedBoronSilicateGlassBlock", + MainMod.MOD_ID + ":LuVTierMaterialReinforcedBoronSilicateGlassBlock", + MainMod.MOD_ID + ":IridiumReinforcedBoronSilicateGlassBlock", + MainMod.MOD_ID + ":OsmiumReinforcedBoronSilicateGlassBlock", + MainMod.MOD_ID + ":ColoredBoronSilicateGlassBlock1", MainMod.MOD_ID + ":ColoredBoronSilicateGlassBlock2", + MainMod.MOD_ID + ":ColoredBoronSilicateGlassBlock3", MainMod.MOD_ID + ":ColoredBoronSilicateGlassBlock4", + MainMod.MOD_ID + ":ColoredBoronSilicateGlassBlock5", MainMod.MOD_ID + ":ColoredBoronSilicateGlassBlock6", + MainMod.MOD_ID + ":ThoriumYttriumGlass", MainMod.MOD_ID + ":NeutroniumReinforcedBoronSilicateGlassBlock", + MainMod.MOD_ID + ":CosmicNeutroniumReinforcedBoronSilicateGlassBlock", + MainMod.MOD_ID + ":InfinityReinforcedBoronSilicateGlassBlock", }, + new short[][] { Materials.BorosilicateGlass.getRGBA(), Materials.Titanium.getRGBA(), + Materials.TungstenSteel.getRGBA(), Materials.Chrome.getRGBA(), Materials.Iridium.getRGBA(), + Materials.Osmium.getRGBA(), new short[] { 0xff, 0, 0 }, new short[] { 0, 0xff, 0 }, + new short[] { 0x80, 0, 0xff }, new short[] { 0xff, 0xff, 0 }, new short[] { 0, 0xff, 0x80 }, + new short[] { 0x80, 0x33, 0 }, WerkstoffLoader.YttriumOxide.getRGBA(), Materials.Neutronium.getRGBA(), + Materials.CosmicNeutronium.getRGBA(), new short[] { 0xda, 0xeb, 0xff }, }, + MainMod.BIO_TAB, + true, + false); + public static final Block bw_realglas2 = new BWBlocksGlass2( + "BW_GlasBlocks2", + new String[] { MainMod.MOD_ID + ":TranscendentallyReinforcedBoronSilicateGlassBlock" }, + new short[][] { new short[] { 50, 50, 50 } }, + MainMod.BIO_TAB, + true, + false); + + public static final Block[] bw_glasses = { bw_realglas, bw_realglas2 }; + public static final Block bw_fake_glasses = new BWBlocksGlass( + "BW_GlasBlocks", + new String[] { MainMod.MOD_ID + ":BoronSilicateGlassBlockRandlos" }, + null, + null, + true, + true); + public static final Block bw_fake_glasses2 = new BWBlocksGlass2( + "BW_GlasBlocks2", + new String[] { MainMod.MOD_ID + ":BoronSilicateGlassBlockRandlos" }, + null, + null, + true, + true); + public static final Block[] BW_BLOCKS = { + new BWBlocks( + "BW_ItemBlocks", + new String[] { MainMod.MOD_ID + ":EtchedLapisCell", MainMod.MOD_ID + ":PlatedLapisCell", }, + MainMod.GT2), + new BWBlocks("GT_LESU_CASING", new String[] { MainMod.MOD_ID + ":LESU_CELL", }, MainMod.GT2), + new BWBlocks( + "BW_Machinery_Casings", + new String[] { MainMod.MOD_ID + ":NickelFerriteBlocks", MainMod.MOD_ID + ":TransformerCoil", + // MainMod.MOD_ID+":DEHP_Casing", + // MainMod.MOD_ID+":DEHP_Casing_Base" + }, + MainMod.BWT), }; + + public static ItemStack[] diode2A = new ItemStack[GTValues.VN.length]; + public static ItemStack[] diode4A = new ItemStack[GTValues.VN.length]; + public static ItemStack[] diode8A = new ItemStack[GTValues.VN.length]; + public static ItemStack[] diode12A = new ItemStack[GTValues.VN.length]; + public static ItemStack[] diode16A = new ItemStack[GTValues.VN.length]; + public static ItemStack[] energyDistributor = new ItemStack[GTValues.VN.length]; + public static ItemStack[] acidGens = new ItemStack[3]; + public static ItemStack acidGensLV; + public static ItemStack[] megaMachines = new ItemStack[5]; + public static ItemStack dehp; + public static ItemStack[] voidminer = new ItemStack[3]; + public static ItemStack THTR; + public static ItemStack HTGR; + public static ItemStack eic; + public static ItemStack cal; + public static ItemStack compressedHatch; + public static ItemStack giantOutputHatch; + public static ItemStack humongousInputHatch; + + public static ItemStack[][][] TecTechLaserAdditions = new ItemStack[3][4][4]; + public static ItemStack TecTechPipeEnergyLowPower; + + public static void run() { + GameRegistry.registerBlock(ItemRegistry.bw_fake_glasses, "BW_FakeGlasBlock"); + GameRegistry.registerBlock(ItemRegistry.bw_fake_glasses2, "BW_FakeGlasBlocks2"); + BorosilicateGlass.registerBorosilicateGlass(); + + GameRegistry.registerBlock(ItemRegistry.BW_BLOCKS[2], BWItemBlocks.class, "BW_Machinery_Casings"); + GameRegistry.registerItem(ItemRegistry.LEATHER_ROTOR, "BW_LeatherRotor"); + GameRegistry.registerItem(ItemRegistry.WOOL_ROTOR, "BW_WoolRotor"); + GameRegistry.registerItem(ItemRegistry.PAPER_ROTOR, "BW_PaperRotor"); + GameRegistry.registerItem(ItemRegistry.COMBINED_ROTOR, "BW_CombinedRotor"); + GameRegistry.registerItem(ItemRegistry.CRAFTING_PARTS, "craftingParts"); + GameRegistry.registerTileEntity(TileEntityRotorBlock.class, "BWRotorBlockTE"); + GameRegistry.registerBlock(ItemRegistry.ROTORBLOCK, BWItemBlocks.class, "BWRotorBlock"); + GameRegistry.registerTileEntity(TileEntityHeatedWaterPump.class, "BWHeatedWaterPumpTE"); + GameRegistry.registerBlock(ItemRegistry.PUMPBLOCK, BWItemBlocks.class, "BWHeatedWaterPumpBlock"); + GameRegistry.registerItem(ItemRegistry.PUMPPARTS, "BWPumpParts"); + GameRegistry.registerItem(ItemRegistry.WINDMETER, "BW_SimpleWindMeter"); + + // GT2 stuff + GameRegistry.registerBlock(ItemRegistry.BW_BLOCKS[0], BWItemBlocks.class, "BW_ItemBlocks"); + GameRegistry.registerBlock(ItemRegistry.BW_BLOCKS[1], BWItemBlocks.class, "GT_LESU_CASING"); + if (ConfigHandler.teslastaff) + GameRegistry.registerItem(ItemRegistry.TESLASTAFF, ItemRegistry.TESLASTAFF.getUnlocalizedName()); + + GameRegistry.registerItem(ItemRegistry.ROCKCUTTER_LV, ItemRegistry.ROCKCUTTER_LV.getUnlocalizedName()); + GameRegistry.registerItem(ItemRegistry.ROCKCUTTER_MV, ItemRegistry.ROCKCUTTER_MV.getUnlocalizedName()); + GameRegistry.registerItem(ItemRegistry.ROCKCUTTER_HV, ItemRegistry.ROCKCUTTER_HV.getUnlocalizedName()); + GameRegistry.registerItem(ItemRegistry.TAB, "tabIconGT2"); + + new MTECreativeScanner( + MetaTileEntityIDs.CreativeScanner.ID, + "Creative Debug Scanner", + "Creative Debug Scanner", + 14); + ItemRegistry.eic = new MTEElectricImplosionCompressor( + ElectricImplosionCompressor.ID, + "ElectricImplosionCompressor", + "Electric Implosion Compressor").getStackForm(1L); + + // EIC depend on neutronium block to pass on structure updates + int bitmask = GregTechAPI.sMachineIDs.getOrDefault(GregTechAPI.sBlockMetal5, 0) | 1 << 2; + GregTechAPI.registerMachineBlock(GregTechAPI.sBlockMetal5, bitmask); + + // Also spacetime, transcendent metal, and universium + bitmask = GregTechAPI.sMachineIDs.getOrDefault(GregTechAPI.sBlockMetal9, 0) | 1 << 3 | 1 << 4 | 1 << 8; + GregTechAPI.registerMachineBlock(GregTechAPI.sBlockMetal9, bitmask); + + if (Mods.Avaritia.isModLoaded()) { + // Also infinity + bitmask = GregTechAPI.sMachineIDs.getOrDefault(LudicrousBlocks.resource_block, 0) | 1 << 1; + GregTechAPI.registerMachineBlock(LudicrousBlocks.resource_block, bitmask); + } + + ItemRegistry.THTR = new MTEThoriumHighTempReactor( + ThoriumHighTemperatureReactor.ID, + "THTR", + "Thorium High Temperature Reactor").getStackForm(1L); + MTEThoriumHighTempReactor.THTRMaterials.registeraTHR_Materials(); + ItemRegistry.HTGR = new MTEHighTempGasCooledReactor( + HighTemperatureGasCooledReactor.ID, + "HTGR", + "High Temperature Gas-cooled Reactor").getStackForm(1L); + MTEHighTempGasCooledReactor.HTGRMaterials.registeraTHR_Materials(); + + // ID 12728 + 15 + 49 IS TAKEN !!! (12792) + + GTOreDictUnificator + .add(OrePrefixes.block, Materials.BorosilicateGlass, new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)); + GTOreDictUnificator + .registerOre(OrePrefixes.block, Materials.NickelZincFerrite, new ItemStack(ItemRegistry.BW_BLOCKS[2])); + + int[] Diode2A = new int[] { Diode2A_ULV.ID, Diode2A_LV.ID, Diode2A_MV.ID, Diode2A_HV.ID, Diode2A_EV.ID, + Diode2A_IV.ID, Diode2A_LuV.ID, Diode2A_ZPM.ID, Diode2A_UV.ID, Diode2A_UHV.ID, Diode2A_UEV.ID, + Diode2A_UIV.ID, Diode2A_UMV.ID, Diode2A_UXV.ID, Diode2A_MAX.ID }; + int[] Diode4A = new int[] { Diode4A_ULV.ID, Diode4A_LV.ID, Diode4A_MV.ID, Diode4A_HV.ID, Diode4A_EV.ID, + Diode4A_IV.ID, Diode4A_LuV.ID, Diode4A_ZPM.ID, Diode4A_UV.ID, Diode4A_UHV.ID, Diode4A_UEV.ID, + Diode4A_UIV.ID, Diode4A_UMV.ID, Diode4A_UXV.ID, Diode4A_MAX.ID }; + int[] Diode8A = new int[] { Diode8A_ULV.ID, Diode8A_LV.ID, Diode8A_MV.ID, Diode8A_HV.ID, Diode8A_EV.ID, + Diode8A_IV.ID, Diode8A_LuV.ID, Diode8A_ZPM.ID, Diode8A_UV.ID, Diode8A_UHV.ID, Diode8A_UEV.ID, + Diode8A_UIV.ID, Diode8A_UMV.ID, Diode8A_UXV.ID, Diode8A_MAX.ID }; + int[] Diode12A = new int[] { Diode12A_ULV.ID, Diode12A_LV.ID, Diode12A_MV.ID, Diode12A_HV.ID, Diode12A_EV.ID, + Diode12A_IV.ID, Diode12A_LuV.ID, Diode12A_ZPM.ID, Diode12A_UV.ID, Diode12A_UHV.ID, Diode12A_UEV.ID, + Diode12A_UIV.ID, Diode12A_UMV.ID, Diode12A_UXV.ID, Diode12A_MAX.ID }; + int[] Diode16A = new int[] { Diode16A_ULV.ID, Diode16A_LV.ID, Diode16A_MV.ID, Diode16A_HV.ID, Diode16A_EV.ID, + Diode16A_IV.ID, Diode16A_LuV.ID, Diode16A_ZPM.ID, Diode16A_UV.ID, Diode16A_UHV.ID, Diode16A_UEV.ID, + Diode16A_UIV.ID, Diode16A_UMV.ID, Diode16A_UXV.ID, Diode16A_MAX.ID }; + int[] EnergyDistributors = new int[] { EnergyDistributor_ULV.ID, EnergyDistributor_LV.ID, + EnergyDistributor_MV.ID, EnergyDistributor_HV.ID, EnergyDistributor_EV.ID, EnergyDistributor_IV.ID, + EnergyDistributor_LuV.ID, EnergyDistributor_ZPM.ID, EnergyDistributor_UV.ID, EnergyDistributor_UHV.ID, + EnergyDistributor_UEV.ID, EnergyDistributor_UIV.ID, EnergyDistributor_UMV.ID, EnergyDistributor_UXV.ID, + EnergyDistributor_MAX.ID }; + + for (int i = 0; i < GTValues.VN.length - 1; i++) { + ItemRegistry.diode2A[i] = new MTEDiode( + Diode2A[i], + "diode" + "2A" + GTValues.VN[i], + StatCollector.translateToLocal("tile.diode.name") + " 2A " + GTValues.VN[i], + i).getStackForm(1L); + ItemRegistry.diode4A[i] = new MTEDiode( + Diode4A[i], + "diode" + "4A" + GTValues.VN[i], + StatCollector.translateToLocal("tile.diode.name") + " 4A " + GTValues.VN[i], + i).getStackForm(1L); + ItemRegistry.diode8A[i] = new MTEDiode( + Diode8A[i], + "diode" + "8A" + GTValues.VN[i], + StatCollector.translateToLocal("tile.diode.name") + " 8A " + GTValues.VN[i], + i).getStackForm(1L); + ItemRegistry.diode12A[i] = new MTEDiode( + Diode12A[i], + "diode" + "12A" + GTValues.VN[i], + StatCollector.translateToLocal("tile.diode.name") + " 12A " + GTValues.VN[i], + i).getStackForm(1L); + ItemRegistry.diode16A[i] = new MTEDiode( + Diode16A[i], + "diode" + "16A" + GTValues.VN[i], + StatCollector.translateToLocal("tile.diode.name") + " 16A " + GTValues.VN[i], + i).getStackForm(1L); + ItemRegistry.energyDistributor[i] = new MTEEnergyDistributor( + EnergyDistributors[i], + "energydistributor" + GTValues.VN[i], + StatCollector.translateToLocal("tile.energydistributor.name") + " " + GTValues.VN[i], + i).getStackForm(1L); + } + + ItemRegistry.acidGens[0] = new MTEAcidGenerator( + AcidGeneratorMV.ID, + "acidgenerator" + GTValues.VN[2], + StatCollector.translateToLocal("tile.acidgenerator.name") + " " + GTValues.VN[2], + 2).getStackForm(1); + ItemRegistry.acidGens[1] = new MTEAcidGenerator( + AcidGeneratorHV.ID, + "acidgenerator" + GTValues.VN[3], + StatCollector.translateToLocal("tile.acidgenerator.name") + " " + GTValues.VN[3], + 3).getStackForm(1); + ItemRegistry.acidGens[2] = new MTEAcidGenerator( + AcidGeneratorEV.ID, + "acidgenerator" + GTValues.VN[4], + StatCollector.translateToLocal("tile.acidgenerator.name") + " " + GTValues.VN[4], + 4).getStackForm(1); + + ItemRegistry.acidGensLV = new MTEAcidGenerator( + AcidGeneratorLV.ID, + "acidgenerator" + GTValues.VN[1], + StatCollector.translateToLocal("tile.acidgenerator.name") + " " + GTValues.VN[1], + +1).getStackForm(1L); + + ItemRegistry.dehp = new MTEDeepEarthHeatingPump(DeepEarthHeatingPump.ID, 1, "DEHP", "Deep Earth Heating Pump") + .getStackForm(1L); + ItemRegistry.megaMachines[0] = new MTEMegaBlastFurnace( + MegaBlastFurnace.ID, + "MegaBlastFurnace", + StatCollector.translateToLocal("tile.bw.mbf.name")).getStackForm(1L); + ItemRegistry.megaMachines[1] = new MTEMegaVacuumFreezer( + MegaVacuumFreezer.ID, + "MegaVacuumFreezer", + StatCollector.translateToLocal("tile.bw.mvf.name")).getStackForm(1L); + ItemRegistry.cal = new MTECircuitAssemblyLine( + CircuitAssemblyLine.ID, + "CircuitAssemblyLine", + "Circuit Assembly Line").getStackForm(1L); + ItemRegistry.compressedHatch = new MTECompressedFluidHatch( + CompressedFluidHatch.ID, + "CompressedFluidHatch", + "Liquid Air Fluid Hatch").getStackForm(1L); + ItemRegistry.giantOutputHatch = new MTEGiantOutputHatch( + GiantOutputHatch.ID, + "GiantOutputHatch", + "Giant Output Hatch").getStackForm(1L); + ItemRegistry.humongousInputHatch = new MTEHumongousInputHatch( + HumongousInputHatch.ID, + "HumongousInputHatch", + "Humongous Input Hatch").getStackForm(1L); + ItemRegistry.megaMachines[2] = new MTEMegaDistillTower( + MegaDistillationTower.ID, + "MegaDistillationTower", + "Mega Distillation Tower").getStackForm(1L); + ItemRegistry.megaMachines[3] = new MTEMegaChemicalReactor( + MegaChemicalReactor.ID, + "MegaChemicalReactor", + "Mega Chemical Reactor").getStackForm(1L); + ItemRegistry.megaMachines[4] = new MTEMegaOilCracker(MegaOilCracker.ID, "MegaOilCracker", "Mega Oil Cracker") + .getStackForm(1L); + + ItemRegistry.voidminer[2] = new MTEVoidMiners.VMUV(VoidMinerIII.ID, "VoidMiner3", "Void Miner III") + .getStackForm(1L); + ItemRegistry.voidminer[1] = new MTEVoidMiners.VMZPM(VoidMinerII.ID, "VoidMiner2", "Void Miner II") + .getStackForm(1L); + ItemRegistry.voidminer[0] = new MTEVoidMiners.VMLUV(VoidMinerI.ID, "VoidMiner1", "Void Miner I") + .getStackForm(1L); + + TecTechPipeEnergyLowPower = new MTELowPowerLaserPipe( + LowPowerLaserPipe.ID, + "pipe.lowpowerlaser", + "Low Power Laser Pipe").getStackForm(1L); + + int[] LowPowerLaserConverter32A = new int[] { LowPowerLaserConverter32A_EV.ID, LowPowerLaserConverter32A_IV.ID, + LowPowerLaserConverter32A_LuV.ID, LowPowerLaserConverter32A_ZPM.ID }; + int[] LowPowerLaserConverter64A = new int[] { LowPowerLaserConverter64A_EV.ID, LowPowerLaserConverter64A_IV.ID, + LowPowerLaserConverter64A_LuV.ID, LowPowerLaserConverter64A_ZPM.ID }; + int[] LowPowerLaserConverter96A = new int[] { LowPowerLaserConverter96A_EV.ID, LowPowerLaserConverter96A_IV.ID, + LowPowerLaserConverter96A_LuV.ID, LowPowerLaserConverter96A_ZPM.ID }; + int[] LowPowerLaserConverter128A = new int[] { LowPowerLaserConverter128A_EV.ID, + LowPowerLaserConverter128A_IV.ID, LowPowerLaserConverter128A_LuV.ID, LowPowerLaserConverter128A_ZPM.ID }; + int[][] LowPowerLaserConverter = new int[][] { LowPowerLaserConverter32A, LowPowerLaserConverter64A, + LowPowerLaserConverter96A, LowPowerLaserConverter128A }; + + for (int amps = 32; amps <= 128; amps += 32) { + for (int tier = 4; tier < 8; tier++) { + TecTechLaserAdditions[0][amps / 32 - 1][tier - 4] = new MTELowPowerLaserBox( + LowPowerLaserConverter[amps / 32 - 1][tier - 4], + GTValues.VN[tier] + "_LPLaser_Converter_" + amps, + GTValues.VN[tier] + " " + amps + "A" + " Low Power Laser Converter", + tier, + amps).getStackForm(1L); + } + } + + int[] LowPowerLaserTargetHatch32A = new int[] { LowPowerLaserTargetHatch32A_EV.ID, + LowPowerLaserTargetHatch32A_IV.ID, LowPowerLaserTargetHatch32A_LuV.ID, LowPowerLaserTargetHatch32A_ZPM.ID }; + int[] LowPowerLaserTargetHatch64A = new int[] { LowPowerLaserTargetHatch64A_EV.ID, + LowPowerLaserTargetHatch64A_IV.ID, LowPowerLaserTargetHatch64A_LuV.ID, LowPowerLaserTargetHatch64A_ZPM.ID }; + int[] LowPowerLaserTargetHatch96A = new int[] { LowPowerLaserTargetHatch96A_EV.ID, + LowPowerLaserTargetHatch96A_IV.ID, LowPowerLaserTargetHatch96A_LuV.ID, LowPowerLaserTargetHatch96A_ZPM.ID }; + int[] LowPowerLaserTargetHatch128A = new int[] { LowPowerLaserTargetHatch128A_EV.ID, + LowPowerLaserTargetHatch128A_IV.ID, LowPowerLaserTargetHatch128A_LuV.ID, + LowPowerLaserTargetHatch128A_ZPM.ID }; + int[][] LowPowerLaserTargetHatch = new int[][] { LowPowerLaserTargetHatch32A, LowPowerLaserTargetHatch64A, + LowPowerLaserTargetHatch96A, LowPowerLaserTargetHatch128A }; + for (int amps = 32; amps <= 128; amps += 32) { + for (int tier = 4; tier < 8; tier++) { + TecTechLaserAdditions[1][amps / 32 - 1][tier - 4] = new MTELowPowerLaserHatch( + LowPowerLaserTargetHatch[amps / 32 - 1][tier - 4], + GTValues.VN[tier] + "_LPLaser_Hatch_" + amps, + GTValues.VN[tier] + " " + amps + "A" + " Low Power Laser Target Hatch", + tier, + amps).getStackForm(1L); + } + } + + int[] LowPowerLaserSourceHatch32A = new int[] { LowPowerLaserSourceHatch32A_EV.ID, + LowPowerLaserSourceHatch32A_IV.ID, LowPowerLaserSourceHatch32A_LuV.ID, LowPowerLaserSourceHatch32A_ZPM.ID }; + int[] LowPowerLaserSourceHatch64A = new int[] { LowPowerLaserSourceHatch64A_EV.ID, + LowPowerLaserSourceHatch64A_IV.ID, LowPowerLaserSourceHatch64A_LuV.ID, LowPowerLaserSourceHatch64A_ZPM.ID }; + int[] LowPowerLaserSourceHatch96A = new int[] { LowPowerLaserSourceHatch96A_EV.ID, + LowPowerLaserSourceHatch96A_IV.ID, LowPowerLaserSourceHatch96A_LuV.ID, LowPowerLaserSourceHatch96A_ZPM.ID }; + int[] LowPowerLaserSourceHatch128A = new int[] { LowPowerLaserSourceHatch128A_EV.ID, + LowPowerLaserSourceHatch128A_IV.ID, LowPowerLaserSourceHatch128A_LuV.ID, + LowPowerLaserSourceHatch128A_ZPM.ID }; + int[][] LowPowerLaserSourceHatch = new int[][] { LowPowerLaserSourceHatch32A, LowPowerLaserSourceHatch64A, + LowPowerLaserSourceHatch96A, LowPowerLaserSourceHatch128A }; + for (int amps = 32; amps <= 128; amps += 32) { + for (int tier = 4; tier < 8; tier++) { + TecTechLaserAdditions[2][amps / 32 - 1][tier - 4] = new MTELowPowerLaserDynamo( + LowPowerLaserSourceHatch[amps / 32 - 1][tier - 4], + GTValues.VN[tier] + "_LPLaser_Dynamo_" + amps, + GTValues.VN[tier] + " " + amps + "A" + " Low Power Laser Source Hatch", + tier, + amps).getStackForm(1L); + } + } + } +} diff --git a/src/main/java/bartworks/common/loaders/LocalisationLoader.java b/src/main/java/bartworks/common/loaders/LocalisationLoader.java new file mode 100644 index 0000000000..1015b5ff18 --- /dev/null +++ b/src/main/java/bartworks/common/loaders/LocalisationLoader.java @@ -0,0 +1,62 @@ +/* + * 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.common.loaders; + +import gregtech.api.util.GTLanguageManager; + +public class LocalisationLoader { + + private LocalisationLoader() {} + + private static void localiseTooltips() { + GTLanguageManager + .addStringLocalization("metaitem.01.tooltip.purify.2", "Throw into Cauldron to get clean crushed Ore"); + GTLanguageManager + .addStringLocalization("metaitem.01.tooltip.nqgen", "Can be used as Enriched Naquadah Fuel Substitute"); + } + + private static void localiseAchivements() { + GTLanguageManager + .addStringLocalization("achievement.gt.blockmachines.electricimplosioncompressor", "Electric Implosions?"); + GTLanguageManager.addStringLocalization( + "achievement.gt.blockmachines.electricimplosioncompressor.desc", + "Basically a giant Hammer that presses Stuff - No more TNT!"); + GTLanguageManager.addStringLocalization("achievement.gt.blockmachines.dehp", "Heat from below!"); + GTLanguageManager + .addStringLocalization("achievement.gt.blockmachines.dehp.desc", "Get ALL the thermal energy!"); + GTLanguageManager + .addStringLocalization("achievement.gt.blockmachines.circuitassemblyline", "Cheaper Circuits?"); + GTLanguageManager.addStringLocalization( + "achievement.gt.blockmachines.circuitassemblyline.desc", + "Well, yes, but actually no..."); + GTLanguageManager.addStringLocalization("achievement.gt.blockmachines.voidminer1", "Ores from deep below!"); + GTLanguageManager + .addStringLocalization("achievement.gt.blockmachines.voidminer1.desc", "Is this some kind of Ex-Nihilo?"); + GTLanguageManager.addStringLocalization( + "achievement.gt.blockmachines.voidminer2", + "Ores from deep below 2! Electric Boogaloo!"); + GTLanguageManager + .addStringLocalization("achievement.gt.blockmachines.voidminer2.desc", "Ex-Nihilo, but faster!"); + GTLanguageManager.addStringLocalization( + "achievement.gt.blockmachines.voidminer3", + "Ores from deep below 3! Trinity Ex-Nihilo"); + GTLanguageManager + .addStringLocalization("achievement.gt.blockmachines.voidminer3.desc", "3x the trouble, 3x the fun!"); + } + + public static void localiseAll() { + localiseAchivements(); + localiseTooltips(); + } +} diff --git a/src/main/java/bartworks/common/loaders/RadioHatchMaterialLoader.java b/src/main/java/bartworks/common/loaders/RadioHatchMaterialLoader.java new file mode 100644 index 0000000000..79419c5649 --- /dev/null +++ b/src/main/java/bartworks/common/loaders/RadioHatchMaterialLoader.java @@ -0,0 +1,365 @@ +package bartworks.common.loaders; + +import static bartworks.API.recipe.BartWorksRecipeMaps.radioHatchRecipes; +import static bartworks.util.BWRecipes.calcDecayTicks; +import static gregtech.api.enums.Mods.IndustrialCraft2; +import static gregtech.api.util.GTRecipeConstants.DECAY_TICKS; + +import bartworks.system.material.BWNonMetaMaterialItems; +import bartworks.system.material.Werkstoff; +import bartworks.system.material.WerkstoffLoader; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTOreDictUnificator; + +// cursed way of using a recipe map... +public class RadioHatchMaterialLoader { + + public static void run() { + + for (Werkstoff material : Werkstoff.werkstoffHashSet) { + if (material == null || !material.getStats() + .isRadioactive()) { + continue; + } + + int level = (int) material.getStats() + .getProtons(); + if (material.hasItemType(OrePrefixes.stick)) GTValues.RA.stdBuilder() + .itemInputs(material.get(OrePrefixes.stick)) + .duration(1) + .eut(level) + .metadata(DECAY_TICKS, (int) calcDecayTicks(level)) + .noOptimize() + .addTo(radioHatchRecipes); + if (material.hasItemType(OrePrefixes.stickLong)) GTValues.RA.stdBuilder() + .itemInputs(material.get(OrePrefixes.stickLong)) + .duration(2) + .eut(level) + .metadata(DECAY_TICKS, (int) calcDecayTicks(level)) + .noOptimize() + .addTo(radioHatchRecipes); + } + + for (Materials material : Materials.getAll()) { + if (material == null || material.mElement == null) continue; + boolean validProton = material.getProtons() >= 83 && !material.equals(Materials.Tritanium) // No Tritanium + && !material.equals(Materials.Naquadah); // Naquadah needs spacial value + if (validProton) { + int level = (int) material.getProtons(); + if (GTOreDictUnificator.get(OrePrefixes.stick, material, 1) != null) { + GTValues.RA.stdBuilder() + .itemInputs(GTOreDictUnificator.get(OrePrefixes.stick, material, 1)) + .duration(1) + .eut(level) + .metadata(DECAY_TICKS, (int) calcDecayTicks(level)) + .noOptimize() + .addTo(radioHatchRecipes); + } + if (GTOreDictUnificator.get(OrePrefixes.stickLong, material, 1) != null) { + GTValues.RA.stdBuilder() + .itemInputs(GTOreDictUnificator.get(OrePrefixes.stickLong, material, 1)) + .duration(2) + .eut(level) + .metadata(DECAY_TICKS, (int) calcDecayTicks(level)) + .noOptimize() + .addTo(radioHatchRecipes); + } + } + } + + Materials[] spacialMaterial = { Materials.Naquadah, Materials.NaquadahEnriched, Materials.Naquadria }; + int[] spacialValue = { 130, 140, 150 }; + + for (int i = 0; i < spacialMaterial.length; i++) { + if (GTOreDictUnificator.get(OrePrefixes.stick, spacialMaterial[i], 1) != null) { + GTValues.RA.stdBuilder() + .itemInputs(GTOreDictUnificator.get(OrePrefixes.stick, spacialMaterial[i], 1)) + .duration(1) + .eut(spacialValue[i]) + .metadata(DECAY_TICKS, (int) calcDecayTicks(spacialValue[i])) + .noOptimize() + .addTo(radioHatchRecipes); + } + + if (GTOreDictUnificator.get(OrePrefixes.stickLong, spacialMaterial[i], 1) != null) { + GTValues.RA.stdBuilder() + .itemInputs(GTOreDictUnificator.get(OrePrefixes.stickLong, spacialMaterial[i], 1)) + .duration(2) + .eut(spacialValue[i]) + .metadata(DECAY_TICKS, (int) calcDecayTicks(spacialValue[i])) + .noOptimize() + .addTo(radioHatchRecipes); + } + } + + GTValues.RA.stdBuilder() + .itemInputs(ItemList.ThoriumCell_1.get(1)) + .duration(3) + .eut((int) Materials.Thorium.getProtons()) + .metadata(DECAY_TICKS, (int) calcDecayTicks((int) Materials.Thorium.getProtons())) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ItemList.ThoriumCell_2.get(1)) + .duration(6) + .eut((int) Materials.Thorium.getProtons()) + .metadata(DECAY_TICKS, (int) calcDecayTicks((int) Materials.Thorium.getProtons())) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ItemList.ThoriumCell_4.get(1)) + .duration(12) + .eut((int) Materials.Thorium.getProtons()) + .metadata(DECAY_TICKS, (int) calcDecayTicks((int) Materials.Thorium.getProtons())) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ItemList.NaquadahCell_1.get(1)) + .duration(3) + .eut(140) + .metadata(DECAY_TICKS, (int) calcDecayTicks(140)) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ItemList.NaquadahCell_2.get(1)) + .duration(6) + .eut(140) + .metadata(DECAY_TICKS, (int) calcDecayTicks(140)) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ItemList.NaquadahCell_4.get(1)) + .duration(12) + .eut(140) + .metadata(DECAY_TICKS, (int) calcDecayTicks(140)) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Moxcell_1.get(1)) + .duration(3) + .eut((int) Materials.Plutonium.getProtons()) + .metadata(DECAY_TICKS, (int) calcDecayTicks((int) Materials.Plutonium.getProtons())) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Moxcell_2.get(1)) + .duration(6) + .eut((int) Materials.Plutonium.getProtons()) + .metadata(DECAY_TICKS, (int) calcDecayTicks((int) Materials.Plutonium.getProtons())) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Moxcell_4.get(1)) + .duration(12) + .eut((int) Materials.Plutonium.getProtons()) + .metadata(DECAY_TICKS, (int) calcDecayTicks((int) Materials.Plutonium.getProtons())) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Uraniumcell_1.get(1)) + .duration(3) + .eut((int) Materials.Uranium.getProtons()) + .metadata(DECAY_TICKS, (int) calcDecayTicks((int) Materials.Uranium.getProtons())) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Uraniumcell_2.get(1)) + .duration(6) + .eut((int) Materials.Uranium.getProtons()) + .metadata(DECAY_TICKS, (int) calcDecayTicks((int) Materials.Uranium.getProtons())) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Uraniumcell_4.get(1)) + .duration(12) + .eut((int) Materials.Uranium.getProtons()) + .metadata(DECAY_TICKS, (int) calcDecayTicks((int) Materials.Uranium.getProtons())) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(BWNonMetaMaterialItems.TiberiumCell_1.get(1)) + .duration(3) + .eut( + (int) WerkstoffLoader.Tiberium.getBridgeMaterial() + .getProtons()) + .metadata( + DECAY_TICKS, + (int) calcDecayTicks( + (int) WerkstoffLoader.Tiberium.getBridgeMaterial() + .getProtons())) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(BWNonMetaMaterialItems.TiberiumCell_2.get(1)) + .duration(6) + .eut( + (int) WerkstoffLoader.Tiberium.getBridgeMaterial() + .getProtons()) + .metadata( + DECAY_TICKS, + (int) calcDecayTicks( + (int) WerkstoffLoader.Tiberium.getBridgeMaterial() + .getProtons())) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(BWNonMetaMaterialItems.TiberiumCell_4.get(1)) + .duration(12) + .eut( + (int) WerkstoffLoader.Tiberium.getBridgeMaterial() + .getProtons()) + .metadata( + DECAY_TICKS, + (int) calcDecayTicks( + (int) WerkstoffLoader.Tiberium.getBridgeMaterial() + .getProtons())) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(BWNonMetaMaterialItems.TheCoreCell.get(1)) + .duration(96) + .eut(140) + .metadata(DECAY_TICKS, (int) calcDecayTicks(140)) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Depleted_Thorium_1.get(1)) + .duration(3) + .eut((int) Materials.Thorium.getProtons() / 10) + .metadata(DECAY_TICKS, (int) calcDecayTicks((int) Materials.Thorium.getProtons() / 10)) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Depleted_Thorium_2.get(1)) + .duration(6) + .eut((int) Materials.Thorium.getProtons() / 10) + .metadata(DECAY_TICKS, (int) calcDecayTicks((int) Materials.Thorium.getProtons() / 10)) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Depleted_Thorium_4.get(1)) + .duration(12) + .eut((int) Materials.Thorium.getProtons() / 10) + .metadata(DECAY_TICKS, (int) calcDecayTicks((int) Materials.Thorium.getProtons() / 10)) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Depleted_Naquadah_1.get(1)) + .duration(3) + .eut(14) + .metadata(DECAY_TICKS, (int) calcDecayTicks(14)) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Depleted_Naquadah_2.get(1)) + .duration(6) + .eut(14) + .metadata(DECAY_TICKS, (int) calcDecayTicks(14)) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Depleted_Naquadah_4.get(1)) + .duration(12) + .eut(14) + .metadata(DECAY_TICKS, (int) calcDecayTicks(14)) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(GTModHandler.getModItem(IndustrialCraft2.ID, "reactorMOXSimpledepleted", 1)) + .duration(3) + .eut((int) Materials.Plutonium.getProtons() / 10) + .metadata(DECAY_TICKS, (int) calcDecayTicks((int) Materials.Plutonium.getProtons() / 10)) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(GTModHandler.getModItem(IndustrialCraft2.ID, "reactorMOXDualdepleted", 1)) + .duration(6) + .eut((int) Materials.Plutonium.getProtons() / 10) + .metadata(DECAY_TICKS, (int) calcDecayTicks((int) Materials.Plutonium.getProtons() / 10)) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(GTModHandler.getModItem(IndustrialCraft2.ID, "reactorMOXQuaddepleted", 1)) + .duration(12) + .eut((int) Materials.Plutonium.getProtons() / 10) + .metadata(DECAY_TICKS, (int) calcDecayTicks((int) Materials.Plutonium.getProtons() / 10)) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(GTModHandler.getModItem(IndustrialCraft2.ID, "reactorUraniumSimpledepleted", 1)) + .duration(3) + .eut((int) Materials.Uranium.getProtons() / 10) + .metadata(DECAY_TICKS, (int) calcDecayTicks((int) Materials.Uranium.getProtons() / 10)) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(GTModHandler.getModItem(IndustrialCraft2.ID, "reactorUraniumDualdepleted", 1)) + .duration(6) + .eut((int) Materials.Uranium.getProtons() / 10) + .metadata(DECAY_TICKS, (int) calcDecayTicks((int) Materials.Uranium.getProtons() / 10)) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(GTModHandler.getModItem(IndustrialCraft2.ID, "reactorUraniumQuaddepleted", 1)) + .duration(12) + .eut((int) Materials.Uranium.getProtons() / 10) + .metadata(DECAY_TICKS, (int) calcDecayTicks((int) Materials.Uranium.getProtons() / 10)) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(BWNonMetaMaterialItems.Depleted_Tiberium_1.get(1)) + .duration(3) + .eut( + (int) WerkstoffLoader.Tiberium.getBridgeMaterial() + .getProtons() / 10) + .metadata( + DECAY_TICKS, + (int) calcDecayTicks( + (int) WerkstoffLoader.Tiberium.getBridgeMaterial() + .getProtons() / 10)) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(BWNonMetaMaterialItems.Depleted_Tiberium_2.get(1)) + .duration(6) + .eut( + (int) WerkstoffLoader.Tiberium.getBridgeMaterial() + .getProtons() / 10) + .metadata( + DECAY_TICKS, + (int) calcDecayTicks( + (int) WerkstoffLoader.Tiberium.getBridgeMaterial() + .getProtons() / 10)) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(BWNonMetaMaterialItems.Depleted_Tiberium_4.get(1)) + .duration(12) + .eut( + (int) WerkstoffLoader.Tiberium.getBridgeMaterial() + .getProtons() / 10) + .metadata( + DECAY_TICKS, + (int) calcDecayTicks( + (int) WerkstoffLoader.Tiberium.getBridgeMaterial() + .getProtons() / 10)) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(BWNonMetaMaterialItems.Depleted_TheCoreCell.get(1)) + .duration(96) + .eut(13) + .metadata(DECAY_TICKS, (int) calcDecayTicks(13)) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ItemList.MNqCell_1.get(1)) + .duration(3) + .eut(150) + .metadata(DECAY_TICKS, (int) calcDecayTicks(150)) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ItemList.MNqCell_2.get(1)) + .duration(6) + .eut(150) + .metadata(DECAY_TICKS, (int) calcDecayTicks(150)) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ItemList.MNqCell_4.get(1)) + .duration(12) + .eut(150) + .metadata(DECAY_TICKS, (int) calcDecayTicks(150)) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Depleted_MNq_1.get(1)) + .duration(3) + .eut(15) + .metadata(DECAY_TICKS, (int) calcDecayTicks(15)) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Depleted_MNq_2.get(1)) + .duration(6) + .eut(15) + .metadata(DECAY_TICKS, (int) calcDecayTicks(15)) + .addTo(radioHatchRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Depleted_MNq_4.get(1)) + .duration(12) + .eut(15) + .metadata(DECAY_TICKS, (int) calcDecayTicks(15)) + .addTo(radioHatchRecipes); + + } +} diff --git a/src/main/java/bartworks/common/loaders/RecipeLoader.java b/src/main/java/bartworks/common/loaders/RecipeLoader.java new file mode 100644 index 0000000000..b6f0992c64 --- /dev/null +++ b/src/main/java/bartworks/common/loaders/RecipeLoader.java @@ -0,0 +1,59 @@ +/* + * 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.common.loaders; + +import bartworks.common.loaders.recipes.Assembler; +import bartworks.common.loaders.recipes.AssemblyLine; +import bartworks.common.loaders.recipes.Autoclave; +import bartworks.common.loaders.recipes.Centrifuge; +import bartworks.common.loaders.recipes.ChemicalBath; +import bartworks.common.loaders.recipes.ChemicalReactor; +import bartworks.common.loaders.recipes.CraftingRecipes; +import bartworks.common.loaders.recipes.Electrolyzer; +import bartworks.common.loaders.recipes.Extractor; +import bartworks.common.loaders.recipes.FakeRecipes; +import bartworks.common.loaders.recipes.FluidHeater; +import bartworks.common.loaders.recipes.FluidSolidifier; +import bartworks.common.loaders.recipes.FormingPress; +import bartworks.common.loaders.recipes.LaserEngraver; +import bartworks.common.loaders.recipes.Mixer; +import bartworks.common.loaders.recipes.Pulverizer; +import bartworks.common.loaders.recipes.PyrolyseOven; +import gregtech.api.util.GTModHandler; + +public class RecipeLoader { + + public static final long BITSD = GTModHandler.RecipeBits.DISMANTLEABLE | GTModHandler.RecipeBits.NOT_REMOVABLE + | GTModHandler.RecipeBits.REVERSIBLE; + + public static void run() { + new Assembler().run(); + new AssemblyLine().run(); + new Autoclave().run(); + new Centrifuge().run(); + new ChemicalBath().run(); + new ChemicalReactor().run(); + new CraftingRecipes().run(); + new Electrolyzer().run(); + new Extractor().run(); + new FakeRecipes().run(); + new FluidHeater().run(); + new FluidSolidifier().run(); + new FormingPress().run(); + new LaserEngraver().run(); + new Mixer().run(); + new Pulverizer().run(); + new PyrolyseOven().run(); + } +} diff --git a/src/main/java/bartworks/common/loaders/RegisterGlassTiers.java b/src/main/java/bartworks/common/loaders/RegisterGlassTiers.java new file mode 100644 index 0000000000..fec9077e62 --- /dev/null +++ b/src/main/java/bartworks/common/loaders/RegisterGlassTiers.java @@ -0,0 +1,118 @@ +/* + * 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.common.loaders; + +import static gregtech.api.enums.GTValues.VN; +import static gregtech.api.enums.Mods.BloodArsenal; +import static gregtech.api.enums.Mods.Botania; +import static gregtech.api.enums.Mods.EnderIO; +import static gregtech.api.enums.Mods.IndustrialCraft2; +import static gregtech.api.enums.Mods.Railcraft; +import static gregtech.api.enums.Mods.Thaumcraft; + +import java.util.Map; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +import bartworks.API.BorosilicateGlass; +import bartworks.API.GlassTier; +import tectech.thing.block.BlockQuantumGlass; + +// Register all your glasses here. +public class RegisterGlassTiers { + + public static void run() { + registerGlassAsTiered(); + registerGlassOreDicts(); + } + + private static void registerGlassAsTiered() { + + // --------------------------------------------------------------------- + // Register glass. + // --------------------------------------------------------------------- + + GlassTier.addCustomGlass(BorosilicateGlass.getGlassBlock(), 0, 3); + GlassTier.addCustomGlass(BorosilicateGlass.getGlassBlock(), 1, 4); + GlassTier.addCustomGlass(BorosilicateGlass.getGlassBlock(), 2, 5); + GlassTier.addCustomGlass(BorosilicateGlass.getGlassBlock(), 3, 6); + GlassTier.addCustomGlass(BorosilicateGlass.getGlassBlock(), 4, 7); + GlassTier.addCustomGlass(BorosilicateGlass.getGlassBlock(), 5, 8); + + // Stained boro glass + GlassTier.addCustomGlass(BorosilicateGlass.getGlassBlock(), 6, 3); + GlassTier.addCustomGlass(BorosilicateGlass.getGlassBlock(), 7, 3); + GlassTier.addCustomGlass(BorosilicateGlass.getGlassBlock(), 8, 3); + GlassTier.addCustomGlass(BorosilicateGlass.getGlassBlock(), 9, 3); + GlassTier.addCustomGlass(BorosilicateGlass.getGlassBlock(), 10, 3); + GlassTier.addCustomGlass(BorosilicateGlass.getGlassBlock(), 11, 3); + + // Incrementing tiers + GlassTier.addCustomGlass(BorosilicateGlass.getGlassBlock(), 12, 5); + GlassTier.addCustomGlass(BorosilicateGlass.getGlassBlock(), 13, 9); + GlassTier.addCustomGlass(BorosilicateGlass.getGlassBlock(), 14, 10); + GlassTier.addCustomGlass(BorosilicateGlass.getGlassBlock(), 15, 11); + + // Glass block 2 for transcendent (Really?) + GlassTier.addCustomGlass(BorosilicateGlass.getGlassBlock2(), 0, 12); + + // Other mods. + GlassTier.addCustomGlass(IndustrialCraft2.ID, "blockAlloyGlass", 0, 4); + GlassTier.addCustomGlass(BlockQuantumGlass.INSTANCE, 0, 8); + + if (EnderIO.isModLoaded()) { + for (int i = 0; i < 6; ++i) { + GlassTier.addCustomGlass(EnderIO.ID, "blockFusedQuartz", i, 3); + } + } + + if (Railcraft.isModLoaded()) { + for (int i = 0; i < 16; i++) { + GlassTier.addCustomGlass(Railcraft.ID, "glass", i, 3); + } + } + + // Magic alternatives. + if (BloodArsenal.isModLoaded()) { + GlassTier.addCustomGlass(BloodArsenal.ID, "blood_stained_glass", 0, 4); + } + + if (Botania.isModLoaded()) { + GlassTier.addCustomGlass(Botania.ID, "manaGlass", 0, 4); + GlassTier.addCustomGlass(Botania.ID, "elfGlass", 0, 5); + } + + if (Thaumcraft.isModLoaded()) { + // Warded glass + GlassTier.addCustomGlass(Thaumcraft.ID, "blockCosmeticOpaque", 2, 3); + } + } + + private static void registerGlassOreDicts() { + + // Register glass ore dict entries. + for (Map.Entry<GlassTier.BlockMetaPair, Integer> pair : GlassTier.getGlassMap() + .entrySet()) { + String oreName = "blockGlass" + VN[pair.getValue()]; + ItemStack itemStack = new ItemStack( + pair.getKey() + .getBlock(), + 1, + pair.getKey() + .getMeta()); + OreDictionary.registerOre(oreName, itemStack); + } + } +} diff --git a/src/main/java/bartworks/common/loaders/RegisterServerCommands.java b/src/main/java/bartworks/common/loaders/RegisterServerCommands.java new file mode 100644 index 0000000000..f0bc69491a --- /dev/null +++ b/src/main/java/bartworks/common/loaders/RegisterServerCommands.java @@ -0,0 +1,34 @@ +/* + * 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.common.loaders; + +import bartworks.common.commands.ChangeConfig; +import bartworks.common.commands.ClearCraftingCache; +import bartworks.common.commands.GetWorkingDirectory; +import bartworks.common.commands.PrintRecipeListToFile; +import bartworks.common.commands.RunGC; +import bartworks.common.commands.SummonRuin; +import cpw.mods.fml.common.event.FMLServerStartingEvent; + +public class RegisterServerCommands { + + public static void registerAll(FMLServerStartingEvent event) { + event.registerServerCommand(new SummonRuin()); + event.registerServerCommand(new ChangeConfig()); + event.registerServerCommand(new PrintRecipeListToFile()); + event.registerServerCommand(new ClearCraftingCache()); + event.registerServerCommand(new GetWorkingDirectory()); + event.registerServerCommand(new RunGC()); + } +} diff --git a/src/main/java/bartworks/common/loaders/StaticRecipeChangeLoaders.java b/src/main/java/bartworks/common/loaders/StaticRecipeChangeLoaders.java new file mode 100644 index 0000000000..1baa5ac7f5 --- /dev/null +++ b/src/main/java/bartworks/common/loaders/StaticRecipeChangeLoaders.java @@ -0,0 +1,562 @@ +/* + * 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.common.loaders; + +import static bartworks.API.recipe.BartWorksRecipeMaps.electricImplosionCompressorRecipes; +import static gregtech.api.enums.Mods.TinkerConstruct; +import static gregtech.api.enums.TickTime.TICK; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +import org.apache.commons.lang3.StringUtils; + +import com.google.common.collect.ArrayListMultimap; + +import bartworks.API.recipe.DynamicGTRecipe; +import bartworks.MainMod; +import bartworks.system.material.Werkstoff; +import bartworks.system.material.WerkstoffLoader; +import bartworks.util.BWUtil; +import bartworks.util.log.DebugLog; +import bwcrossmod.BartWorksCrossmod; +import cpw.mods.fml.common.registry.GameRegistry; +import gnu.trove.map.hash.TObjectDoubleHashMap; +import gregtech.api.enums.Element; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SubTag; +import gregtech.api.enums.TierEU; +import gregtech.api.objects.GTItemStack; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; + +public class StaticRecipeChangeLoaders { + + private static TObjectDoubleHashMap<Materials> gtEbfGasRecipeTimeMultipliers = null; + private static TObjectDoubleHashMap<Materials> gtEbfGasRecipeConsumptionMultipliers = null; + + public static final List<ItemStack> whitelistForEBFNoGasRecipeDontCheckItemData = Arrays + .asList(GTModHandler.getModItem(TinkerConstruct.ID, "materials", 1L, 12) // Raw Aluminum -> Aluminium Ingot + // (coremod) + ); + + private StaticRecipeChangeLoaders() {} + + public static void addEBFGasRecipes() { + if (gtEbfGasRecipeTimeMultipliers == null) { + // For Werkstoff gases, use Werkstoff.Stats.setEbfGasRecipeTimeMultiplier + gtEbfGasRecipeTimeMultipliers = new TObjectDoubleHashMap<>(10, 0.5F, -1.0D); // keep default value as -1 + // Example to make Argon cut recipe times into a third of the original: + // gtEbfGasRecipeTimeMultipliers.put(Materials.Argon, 1.0D / 3.0D); + + gtEbfGasRecipeTimeMultipliers.put(Materials.Nitrogen, 1.0D); + gtEbfGasRecipeTimeMultipliers.put(Materials.Helium, 0.9D); + gtEbfGasRecipeTimeMultipliers.put(Materials.Argon, 0.8D); + gtEbfGasRecipeTimeMultipliers.put(Materials.Radon, 0.7D); + } + if (gtEbfGasRecipeConsumptionMultipliers == null) { + // For Werkstoff gases, use Werkstoff.Stats.setEbfGasRecipeConsumedAmountMultiplier + gtEbfGasRecipeConsumptionMultipliers = new TObjectDoubleHashMap<>(10, 0.5F, 1.0D); // keep default value as + // 1 + // Example to make Argon recipes use half the gas amount of the primary recipe (1000L->500L, 2000L->1000L + // etc.): + // gtEbfGasRecipeConsumptionMultipliers.put(Materials.Argon, 1.0D / 2.0D); + gtEbfGasRecipeConsumptionMultipliers.put(Materials.Nitrogen, 1.0D); + gtEbfGasRecipeConsumptionMultipliers.put(Materials.Helium, 1.0D); + gtEbfGasRecipeConsumptionMultipliers.put(Materials.Argon, 0.85D); + gtEbfGasRecipeConsumptionMultipliers.put(Materials.Radon, 0.7D); + } + ArrayListMultimap<SubTag, GTRecipe> toChange = getRecipesToChange( + WerkstoffLoader.NOBLE_GAS, + WerkstoffLoader.ANAEROBE_GAS); + editRecipes(toChange, getNoGasItems(toChange)); + } + + public static void unificationRecipeEnforcer() { + List<GTRecipe> toRemove = new ArrayList<>(); + for (Werkstoff werkstoff : Werkstoff.werkstoffHashSet) { + StaticRecipeChangeLoaders.runMaterialLinker(werkstoff); + if (werkstoff.getGenerationFeatures().enforceUnification) { + HashSet<String> oreDictNames = new HashSet<>(werkstoff.getADDITIONAL_OREDICT()); + oreDictNames.add(werkstoff.getVarName()); + StaticRecipeChangeLoaders.runMoltenUnificationEnfocement(werkstoff); + StaticRecipeChangeLoaders.runUnficationDeleter(werkstoff); + for (String s : oreDictNames) for (OrePrefixes prefixes : OrePrefixes.values()) { + if (!werkstoff.hasItemType(prefixes)) continue; + String fullOreName = prefixes + s; + List<ItemStack> ores = OreDictionary.getOres(fullOreName, false); + if (ores.size() <= 1) // empty or one entry, i.e. no unification needed + continue; + for (ItemStack toReplace : ores) { + ItemStack replacement = werkstoff.get(prefixes); + if (toReplace == null || GTUtility.areStacksEqual(toReplace, replacement) + || replacement == null + || replacement.getItem() == null) continue; + for (RecipeMap<?> map : RecipeMap.ALL_RECIPE_MAPS.values()) { + toRemove.clear(); + nextRecipe: for (GTRecipe recipe : map.getAllRecipes()) { + boolean removal = map.equals(RecipeMaps.fluidExtractionRecipes) + || map.equals(RecipeMaps.fluidSolidifierRecipes); + for (int i = 0; i < recipe.mInputs.length; i++) { + if (!GTUtility.areStacksEqual(recipe.mInputs[i], toReplace)) continue; + if (removal) { + toRemove.add(recipe); + continue nextRecipe; + } + recipe.mInputs[i] = GTUtility.copyAmount(recipe.mInputs[i].stackSize, replacement); + } + for (int i = 0; i < recipe.mOutputs.length; i++) { + if (!GTUtility.areStacksEqual(recipe.mOutputs[i], toReplace)) continue; + if (removal) { + toRemove.add(recipe); + continue nextRecipe; + } + recipe.mOutputs[i] = GTUtility + .copyAmount(recipe.mOutputs[i].stackSize, replacement); + } + if (recipe.mSpecialItems instanceof ItemStack specialItemStack) { + if (!GTUtility.areStacksEqual(specialItemStack, toReplace)) continue; + if (removal) { + toRemove.add(recipe); + continue nextRecipe; + } + recipe.mSpecialItems = GTUtility + .copyAmount(specialItemStack.stackSize, replacement); + } + } + map.getBackend() + .removeRecipes(toRemove); + } + } + } + } + } + } + + private static void runMoltenUnificationEnfocement(Werkstoff werkstoff) { + if (werkstoff.getGenerationFeatures().enforceUnification && werkstoff.hasItemType(OrePrefixes.cellMolten)) { + try { + FluidContainerRegistry.FluidContainerData data = new FluidContainerRegistry.FluidContainerData( + new FluidStack(Objects.requireNonNull(WerkstoffLoader.molten.get(werkstoff)), 144), + werkstoff.get(OrePrefixes.cellMolten), + Materials.Empty.getCells(1)); + Field f = GTUtility.class.getDeclaredField("sFilledContainerToData"); + f.setAccessible(true); + @SuppressWarnings("unchecked") + Map<GTItemStack, FluidContainerRegistry.FluidContainerData> sFilledContainerToData = (Map<GTItemStack, FluidContainerRegistry.FluidContainerData>) f + .get(null); + Set<Map.Entry<GTItemStack, FluidContainerRegistry.FluidContainerData>> toremFilledContainerToData = new HashSet<>(); + ItemStack toReplace = null; + for (Map.Entry<GTItemStack, FluidContainerRegistry.FluidContainerData> entry : sFilledContainerToData + .entrySet()) { + final String MODID = GameRegistry.findUniqueIdentifierFor(data.filledContainer.getItem()).modId; + if (MainMod.MOD_ID.equals(MODID) || BartWorksCrossmod.MOD_ID.equals(MODID)) continue; + if (entry.getValue().fluid.equals(data.fluid) + && !entry.getValue().filledContainer.equals(data.filledContainer)) { + toReplace = entry.getValue().filledContainer; + toremFilledContainerToData.add(entry); + } + } + sFilledContainerToData.entrySet() + .removeAll(toremFilledContainerToData); + Set<GTRecipe> toremRecipeList = new HashSet<>(); + if (toReplace != null) { + for (RecipeMap<?> map : RecipeMap.ALL_RECIPE_MAPS.values()) { + toremRecipeList.clear(); + for (GTRecipe recipe : map.getAllRecipes()) { + for (ItemStack mInput : recipe.mInputs) { + if (GTUtility.areStacksEqual(mInput, toReplace)) { + toremRecipeList.add(recipe); + // recipe.mInputs[i] = data.filledContainer; + } + } + for (ItemStack mOutput : recipe.mOutputs) { + if (GTUtility.areStacksEqual(mOutput, toReplace)) { + toremRecipeList.add(recipe); + // recipe.mOutputs[i] = data.filledContainer; + if (map == RecipeMaps.fluidCannerRecipes + && GTUtility.areStacksEqual(mOutput, data.filledContainer) + && !recipe.mFluidInputs[0].equals(data.fluid)) { + toremRecipeList.add(recipe); + // recipe.mOutputs[i] = data.filledContainer; + } + } + } + if (recipe.mSpecialItems instanceof ItemStack + && GTUtility.areStacksEqual((ItemStack) recipe.mSpecialItems, toReplace)) { + toremRecipeList.add(recipe); + // recipe.mSpecialItems = data.filledContainer; + } + } + map.getBackend() + .removeRecipes(toremRecipeList); + } + } + GTUtility.addFluidContainerData(data); + } catch (NoSuchFieldException | IllegalAccessException | ClassCastException e) { + e.printStackTrace(); + } + } + } + + private static void runUnficationDeleter(Werkstoff werkstoff) { + if (werkstoff.getType() == Werkstoff.Types.ELEMENT && werkstoff.getBridgeMaterial() != null + && Element.get(werkstoff.getToolTip()) != Element._NULL) { + werkstoff.getBridgeMaterial().mElement = Element.get(werkstoff.getToolTip()); + Element.get(werkstoff.getToolTip()).mLinkedMaterials = new ArrayList<>(); + Element.get(werkstoff.getToolTip()).mLinkedMaterials.add(werkstoff.getBridgeMaterial()); + } + + for (OrePrefixes prefixes : OrePrefixes.values()) if (werkstoff.hasItemType(prefixes)) { + GTOreDictUnificator.set(prefixes, werkstoff.getBridgeMaterial(), werkstoff.get(prefixes), true, true); + for (ItemStack stack : OreDictionary.getOres(prefixes + werkstoff.getVarName())) { + GTOreDictUnificator.addAssociation(prefixes, werkstoff.getBridgeMaterial(), stack, false); + GTOreDictUnificator.getAssociation(stack).mUnificationTarget = werkstoff.get(prefixes); + } + } + } + + private static void runMaterialLinker(Werkstoff werkstoff) { + if (werkstoff.getType() == Werkstoff.Types.ELEMENT && werkstoff.getBridgeMaterial() != null + && Element.get(werkstoff.getToolTip()) != Element._NULL) { + werkstoff.getBridgeMaterial().mElement = Element.get(werkstoff.getToolTip()); + Element.get(werkstoff.getToolTip()).mLinkedMaterials = new ArrayList<>(); + Element.get(werkstoff.getToolTip()).mLinkedMaterials.add(werkstoff.getBridgeMaterial()); + } + + for (OrePrefixes prefixes : OrePrefixes.values()) + if (werkstoff.hasItemType(prefixes) && werkstoff.getBridgeMaterial() != null) { + GTOreDictUnificator.set(prefixes, werkstoff.getBridgeMaterial(), werkstoff.get(prefixes), true, true); + for (ItemStack stack : OreDictionary.getOres(prefixes + werkstoff.getVarName())) { + GTOreDictUnificator.addAssociation(prefixes, werkstoff.getBridgeMaterial(), stack, false); + } + } + } + + /** + * Constructs a list of recipes to change by scanning all EBF recipes for uses of noble gases. + * + * @param GasTags list of gas tags to look out for in EBF recipes + * @return A multimap from the gas tag (noble and/or anaerobic) to all the recipes containing a gas with that tag + */ + private static ArrayListMultimap<SubTag, GTRecipe> getRecipesToChange(SubTag... GasTags) { + ArrayListMultimap<SubTag, GTRecipe> toAdd = ArrayListMultimap.create(); + for (GTRecipe recipe : RecipeMaps.blastFurnaceRecipes.getAllRecipes()) { + if (recipe.mFluidInputs != null && recipe.mFluidInputs.length > 0) { + Materials mat = getMaterialFromInputFluid(recipe); + if (mat != Materials._NULL) { + for (SubTag tag : GasTags) { + if (mat.contains(tag)) { + DebugLog.log( + "Found EBF Recipe to change, Output:" + + BWUtil.translateGTItemStack(recipe.mOutputs[0])); + toAdd.put(tag, recipe); + } + } + } + } + } + return toAdd; + } + + /** + * Scans EBF recipes for no-gas variants of the recipes present in base. Adds these recipes to the base multimap. + * + * @param base The recipe multimap to scan and modify + * @return Set of item outputs (recipe.mOutputs[0]) of the no-gas recipes + */ + private static HashSet<ItemStack> getNoGasItems(ArrayListMultimap<SubTag, GTRecipe> base) { + HashSet<ItemStack> toAdd = new HashSet<>(); + ArrayListMultimap<SubTag, GTRecipe> repToAdd = ArrayListMultimap.create(); + for (GTRecipe recipe : RecipeMaps.blastFurnaceRecipes.getAllRecipes()) { + for (SubTag tag : base.keySet()) recipeLoop: for (GTRecipe baseRe : base.get(tag)) { + if (recipe.mInputs.length == baseRe.mInputs.length && recipe.mOutputs.length == baseRe.mOutputs.length) + for (int i = 0; i < recipe.mInputs.length; i++) { + ItemStack tmpInput = recipe.mInputs[i]; + if ((recipe.mFluidInputs == null || recipe.mFluidInputs.length == 0) + && (whitelistForEBFNoGasRecipeDontCheckItemData.stream() + .anyMatch(s -> GTUtility.areStacksEqual(s, tmpInput)) + || BWUtil.checkStackAndPrefix(recipe.mInputs[i]) + && BWUtil.checkStackAndPrefix(baseRe.mInputs[i]) + && GTOreDictUnificator.getAssociation(recipe.mInputs[i]).mMaterial.mMaterial.equals( + GTOreDictUnificator.getAssociation(baseRe.mInputs[i]).mMaterial.mMaterial) + && GTUtility.areStacksEqual(recipe.mOutputs[0], baseRe.mOutputs[0]))) { + toAdd.add(recipe.mOutputs[0]); + repToAdd.put(tag, recipe); + continue recipeLoop; + } + } + } + } + base.putAll(repToAdd); + return toAdd; + } + + private static int transformEBFGasRecipeTime(int originalDuration, long originalGasProtons, long newGasProtons) { + double protonTerm = originalGasProtons * (newGasProtons >= originalGasProtons ? 1.0D : 2.75D) - newGasProtons; + return Math.max(1, (int) (originalDuration / 200D * Math.max(200D + protonTerm, 1D))); + } + + private static int transformEBFGasRecipeTime(GTRecipe recipe, Materials originalGas, Materials newGas) { + double newEbfMul = gtEbfGasRecipeTimeMultipliers.get(newGas); + double originalEbfMul = gtEbfGasRecipeTimeMultipliers.get(originalGas); + if (newEbfMul < 0.0D || originalEbfMul < 0.0D) { + return transformEBFGasRecipeTime(recipe.mDuration, originalGas.getProtons(), newGas.getProtons()); + } + return Math.max(1, (int) (recipe.mDuration * newEbfMul / originalEbfMul)); + } + + private static int transformEBFGasRecipeTime(GTRecipe recipe, Materials originalGas, Werkstoff newGas) { + double newEbfMul = newGas.getStats() + .getEbfGasRecipeTimeMultiplier(); + double originalEbfMul = gtEbfGasRecipeTimeMultipliers.get(originalGas); + if (newEbfMul < 0.0D || originalEbfMul < 0.0D) { + return transformEBFGasRecipeTime( + recipe.mDuration, + originalGas.getProtons(), + newGas.getStats() + .getProtons()); + } + return Math.max(1, (int) (recipe.mDuration * newEbfMul / originalEbfMul)); + } + + private static int transformEBFNoGasRecipeTime(GTRecipe recipe, Materials originalGas) { + return transformEBFGasRecipeTime(recipe.mDuration, originalGas.getProtons(), 0); + } + + private static void editEBFMaterialRecipes(SubTag GasTag, GTRecipe recipe, Materials originalGas, + HashSet<GTRecipe> toAdd) { + for (Materials newGas : Materials.values()) { + if (newGas.contains(GasTag)) { + int time = transformEBFGasRecipeTime(recipe, originalGas, newGas); + int gasAmount = Math.max( + 1, + (int) Math.round(recipe.mFluidInputs[0].amount * gtEbfGasRecipeConsumptionMultipliers.get(newGas))); + if (recipe.mFluidInputs != null && recipe.mFluidInputs.length == 1 + && recipe.mFluidInputs[0].isFluidEqual(newGas.getGas(0))) { + // preserve original recipe owner + toAdd.add( + new DynamicGTRecipe( + false, + recipe.mInputs, + recipe.mOutputs, + recipe.mSpecialItems, + recipe.mChances, + new FluidStack[] { newGas.getGas(gasAmount) }, + recipe.mFluidOutputs, + time, + recipe.mEUt, + recipe.mSpecialValue, + recipe)); + } else { + // new recipe + toAdd.add( + new GTRecipe( + false, + recipe.mInputs, + recipe.mOutputs, + recipe.mSpecialItems, + recipe.mChances, + new FluidStack[] { newGas.getGas(gasAmount) }, + recipe.mFluidOutputs, + time, + recipe.mEUt, + recipe.mSpecialValue)); + } + } + } + } + + private static void editEBFWerkstoffRecipes(SubTag GasTag, GTRecipe recipe, Materials originalGas, + HashSet<GTRecipe> toAdd) { + for (Werkstoff newGas : Werkstoff.werkstoffHashMap.values()) { + if (newGas.contains(GasTag)) { + int time = transformEBFGasRecipeTime(recipe, originalGas, newGas); + int gasAmount = Math.max( + 1, + (int) Math.round( + recipe.mFluidInputs[0].amount * newGas.getStats() + .getEbfGasRecipeConsumedAmountMultiplier())); + if (recipe.mFluidInputs != null && recipe.mFluidInputs.length == 1 + && recipe.mFluidInputs[0] + .isFluidEqual(new FluidStack(Objects.requireNonNull(WerkstoffLoader.fluids.get(newGas)), 0))) { + // preserve original recipe owner + toAdd.add( + new DynamicGTRecipe( + false, + recipe.mInputs, + recipe.mOutputs, + recipe.mSpecialItems, + recipe.mChances, + new FluidStack[] { + new FluidStack(Objects.requireNonNull(WerkstoffLoader.fluids.get(newGas)), gasAmount) }, + recipe.mFluidOutputs, + time, + recipe.mEUt, + recipe.mSpecialValue, + recipe)); + } else { + // new recipe + toAdd.add( + new GTRecipe( + false, + recipe.mInputs, + recipe.mOutputs, + recipe.mSpecialItems, + recipe.mChances, + new FluidStack[] { + new FluidStack(Objects.requireNonNull(WerkstoffLoader.fluids.get(newGas)), gasAmount) }, + recipe.mFluidOutputs, + time, + recipe.mEUt, + recipe.mSpecialValue)); + } + } + } + } + + private static void editEBFNoGasRecipes(GTRecipe recipe, Materials originalGas, HashSet<GTRecipe> toAdd, + HashSet<ItemStack> noGas) { + for (ItemStack is : noGas) { + byte circuitConfiguration = 1; + if (GTUtility.areStacksEqual(is, recipe.mOutputs[0])) { + ArrayList<ItemStack> inputs = new ArrayList<>(recipe.mInputs.length); + for (ItemStack stack : recipe.mInputs) + if (!GTUtility.areStacksEqual(GTUtility.getIntegratedCircuit(11), stack) + && !GTUtility.areStacksEqual(GTUtility.getIntegratedCircuit(14), stack) + && !GTUtility.areStacksEqual(GTUtility.getIntegratedCircuit(19), stack)) { + if (BWUtil.checkStackAndPrefix(stack)) circuitConfiguration = (byte) (OrePrefixes.dustSmall + .equals(GTOreDictUnificator.getAssociation(stack).mPrefix) ? 4 + : OrePrefixes.dustTiny.equals(GTOreDictUnificator.getAssociation(stack).mPrefix) ? 9 + : 1); + inputs.add(stack); + } + inputs.add(GTUtility.getIntegratedCircuit(circuitConfiguration)); + toAdd.add( + new DynamicGTRecipe( + false, + inputs.toArray(new ItemStack[0]), + recipe.mOutputs, + recipe.mSpecialItems, + recipe.mChances, + null, + recipe.mFluidOutputs, + transformEBFNoGasRecipeTime(recipe, originalGas), + recipe.mEUt, + recipe.mSpecialValue, + recipe)); + break; + } + } + } + + private static void removeDuplicateGasRecipes(HashSet<GTRecipe> toAdd) { + HashSet<GTRecipe> duplicates = new HashSet<>(); + for (GTRecipe recipe : toAdd) { + for (GTRecipe recipe2 : toAdd) { + if (recipe.mEUt != recipe2.mEUt || recipe.mDuration != recipe2.mDuration + || recipe.mSpecialValue != recipe2.mSpecialValue + || recipe == recipe2 + || recipe.mInputs.length != recipe2.mInputs.length + || recipe.mFluidInputs.length != recipe2.mFluidInputs.length) continue; + boolean isSame = true; + for (int i = 0; i < recipe.mInputs.length; i++) { + if (!GTUtility.areStacksEqual(recipe.mInputs[i], recipe2.mInputs[i])) isSame = false; + } + for (int i = 0; i < recipe.mFluidInputs.length; i++) { + if (!GTUtility.areFluidsEqual(recipe.mFluidInputs[i], recipe2.mFluidInputs[i])) isSame = false; + } + if (isSame) duplicates.add(recipe2); + } + } + toAdd.removeAll(duplicates); + } + + private static Materials getMaterialFromInputFluid(GTRecipe recipe) { + String materialString = recipe.mFluidInputs[0].getFluid() + .getName(); + materialString = StringUtils.removeStart(materialString, "molten"); + materialString = StringUtils.removeStart(materialString, "fluid"); + materialString = StringUtils.capitalize(materialString); + return Materials.get(materialString); + } + + private static void editRecipes(ArrayListMultimap<SubTag, GTRecipe> base, HashSet<ItemStack> noGas) { + HashSet<GTRecipe> toAdd = new HashSet<>(); + + for (SubTag gasTag : base.keySet()) { + for (GTRecipe recipe : base.get(gasTag)) { + if (recipe.mFluidInputs != null && recipe.mFluidInputs.length > 0) { + Materials originalGas = getMaterialFromInputFluid(recipe); + if (originalGas != Materials._NULL) { + editEBFWerkstoffRecipes(gasTag, recipe, originalGas, toAdd); + editEBFMaterialRecipes(gasTag, recipe, originalGas, toAdd); + editEBFNoGasRecipes(recipe, originalGas, toAdd, noGas); + } + } + } + RecipeMaps.blastFurnaceRecipes.getBackend() + .removeRecipes(base.get(gasTag)); + } + + removeDuplicateGasRecipes(toAdd); + toAdd.forEach(RecipeMaps.blastFurnaceRecipes::add); + } + + public static void addElectricImplosionCompressorRecipes() { + RecipeMaps.implosionRecipes.getAllRecipes() + .stream() + .filter(e -> e.mInputs != null) + .forEach( + recipe -> GTValues.RA.stdBuilder() + .itemInputs( + Arrays.stream(recipe.mInputs) + .filter(e -> !StaticRecipeChangeLoaders.checkForExplosives(e)) + .distinct() + .toArray(ItemStack[]::new)) + .itemOutputs(recipe.mOutputs) + .duration(1 * TICK) + .eut(TierEU.RECIPE_UEV) + .addTo(electricImplosionCompressorRecipes)); + + // Custom EIC recipes. + new ElectricImplosionCompressorRecipes().run(); + } + + private static boolean checkForExplosives(ItemStack input) { + return GTUtility.areStacksEqual(input, new ItemStack(Blocks.tnt)) + || GTUtility.areStacksEqual(input, GTModHandler.getIC2Item("industrialTnt", 1L)) + || GTUtility.areStacksEqual(input, GTModHandler.getIC2Item("dynamite", 1L)) + || GTUtility.areStacksEqual(input, ItemList.Block_Powderbarrel.get(1L)); + } +} diff --git a/src/main/java/bartworks/common/loaders/recipes/Assembler.java b/src/main/java/bartworks/common/loaders/recipes/Assembler.java new file mode 100644 index 0000000000..912b0f8c9a --- /dev/null +++ b/src/main/java/bartworks/common/loaders/recipes/Assembler.java @@ -0,0 +1,270 @@ +package bartworks.common.loaders.recipes; + +import static gregtech.api.recipe.RecipeMaps.assemblerRecipes; +import static gregtech.api.util.GTRecipeBuilder.HOURS; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; +import static gregtech.api.util.GTRecipeBuilder.TICKS; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; + +import bartworks.common.loaders.ItemRegistry; +import bartworks.system.material.WerkstoffLoader; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.GTUtility; + +public class Assembler implements Runnable { + + @Override + public void run() { + Materials[] cables = { // Cable material used in the acid gen, diode and energy distributor below + Materials.Lead, // ULV + Materials.Tin, // LV + Materials.AnnealedCopper, // MV + Materials.Gold, // HV + Materials.Aluminium, // EV + Materials.Tungsten, // IV + Materials.VanadiumGallium, // LuV + Materials.Naquadah, // ZPM + Materials.NaquadahAlloy, // UV + Materials.SuperconductorUV // UHV + }; + + GTValues.RA.stdBuilder() + .itemInputs( + new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 0), + Materials.Lapis.getPlates(9), + GTOreDictUnificator.get(OrePrefixes.circuit, Materials.HV, 2L), + GTUtility.getIntegratedCircuit(17)) + .itemOutputs(new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 1)) + .fluidInputs(FluidRegistry.getFluidStack("ic2coolant", 1000)) + .duration(5 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs( + new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 1), + Materials.Lapis.getBlocks(8), + GTUtility.getIntegratedCircuit(17)) + .itemOutputs(new ItemStack(ItemRegistry.BW_BLOCKS[1])) + .duration(5 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Machine_Multi_BlastFurnace.get(64), GTUtility.getIntegratedCircuit(17)) + .itemOutputs(ItemRegistry.megaMachines[0]) + .fluidInputs(Materials.SolderingAlloy.getMolten(9216)) + .duration(1 * HOURS) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Machine_Multi_VacuumFreezer.get(64), GTUtility.getIntegratedCircuit(17)) + .itemOutputs(ItemRegistry.megaMachines[1]) + .fluidInputs(Materials.SolderingAlloy.getMolten(9216)) + .duration(1 * HOURS) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Distillation_Tower.get(64), GTUtility.getIntegratedCircuit(17)) + .itemOutputs(ItemRegistry.megaMachines[2]) + .fluidInputs(Materials.SolderingAlloy.getMolten(9216)) + .duration(1 * HOURS) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Machine_Multi_LargeChemicalReactor.get(64), GTUtility.getIntegratedCircuit(17)) + .itemOutputs(ItemRegistry.megaMachines[3]) + .fluidInputs(Materials.SolderingAlloy.getMolten(9216)) + .duration(1 * HOURS) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(ItemList.OilCracker.get(64), GTUtility.getIntegratedCircuit(17)) + .itemOutputs(ItemRegistry.megaMachines[4]) + .fluidInputs(Materials.SolderingAlloy.getMolten(9216)) + .duration(1 * HOURS) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs( + GTOreDictUnificator.get(OrePrefixes.wireFine, Materials.AnnealedCopper, 64L), + GTUtility.getIntegratedCircuit(17)) + .itemOutputs(new ItemStack(ItemRegistry.BW_BLOCKS[2], 1, 1)) + .fluidInputs(Materials.Plastic.getMolten(1152L)) + .duration(1 * TICKS) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs( + GTOreDictUnificator.get(OrePrefixes.circuit, Materials.MV, 1L), + Materials.Aluminium.getPlates(1), + ItemList.Circuit_Board_Plastic.get(1L), + ItemList.Battery_RE_LV_Lithium.get(1L)) + .itemOutputs(new ItemStack(ItemRegistry.CIRCUIT_PROGRAMMER)) + .fluidInputs(Materials.SolderingAlloy.getMolten(288L)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(assemblerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs( + ItemList.Circuit_Parts_GlassFiber.get(32), + GTOreDictUnificator.get(OrePrefixes.foil, Materials.Electrum, 8), + WerkstoffLoader.CubicZirconia.get(OrePrefixes.gemExquisite, 2)) + .itemOutputs( + new ItemStack( + ItemRegistry.TecTechPipeEnergyLowPower.getItem(), + 1, + ItemRegistry.TecTechPipeEnergyLowPower.getItemDamage())) + .fluidInputs(Materials.Polytetrafluoroethylene.getMolten(72)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_EV) + .addTo(assemblerRecipes); + + ItemStack[][] converters = ItemRegistry.TecTechLaserAdditions[0]; + ItemStack[][] input = ItemRegistry.TecTechLaserAdditions[1]; + ItemStack[][] dynamo = ItemRegistry.TecTechLaserAdditions[2]; + + ItemList[] emitters = { ItemList.Emitter_EV, ItemList.Emitter_IV, ItemList.Emitter_LuV, ItemList.Emitter_ZPM }; + + ItemList[] sensors = { ItemList.Sensor_EV, ItemList.Sensor_IV, ItemList.Sensor_LuV, ItemList.Sensor_ZPM }; + + OrePrefixes[] prefixes = { OrePrefixes.cableGt04, OrePrefixes.cableGt08, OrePrefixes.cableGt12, + OrePrefixes.cableGt16 }; + + for (int j = 0; j < 4; j++) { + for (int i = 0; i < 4; i++) { + ItemStack converter = converters[j][i]; + ItemStack eInput = input[j][i]; + ItemStack eDynamo = dynamo[j][i]; + long recipeConsumption = switch (i) { + case 0 -> TierEU.RECIPE_EV; + case 1 -> TierEU.RECIPE_IV; + case 2 -> TierEU.RECIPE_LuV; + case 3 -> TierEU.RECIPE_ZPM; + default -> TierEU.RECIPE_EV; + }; + + int solderingAmount = Math.max(144 * i, 72) * (j + 1); + + GTValues.RA.stdBuilder() + .itemInputs( + + new ItemStack( + ItemRegistry.TecTechPipeEnergyLowPower.getItem(), + ((j + 1) * 16), + ItemRegistry.TecTechPipeEnergyLowPower.getItemDamage()), + WerkstoffLoader.CubicZirconia.get(OrePrefixes.lens), + GTOreDictUnificator.get(prefixes[j], cables[i + 4], 8), + emitters[i].get(2 * (j + 1)), + sensors[i].get(2 * (j + 1)), + ItemList.TRANSFORMERS[4 + i].get(2 * (j + 1))) + .itemOutputs(converter) + .fluidInputs(Materials.SolderingAlloy.getMolten(solderingAmount)) + .duration((10 * (j + 1)) * SECONDS) + .eut(recipeConsumption) + .addTo(assemblerRecipes); + GTValues.RA.stdBuilder() + .itemInputs( + new ItemStack( + ItemRegistry.TecTechPipeEnergyLowPower.getItem(), + ((j + 1) * 16), + ItemRegistry.TecTechPipeEnergyLowPower.getItemDamage()), + WerkstoffLoader.CubicZirconia.get(OrePrefixes.lens), + GTOreDictUnificator.get(prefixes[j], cables[i + 4], 8), + emitters[i].get(2 * (j + 1)), + sensors[i].get(2 * (j + 1)), + ItemList.TRANSFORMERS[4 + i].get(2 * (j + 1))) + .itemOutputs(converter) + .fluidInputs(Materials.SolderingAlloy.getMolten(solderingAmount)) + .duration((10 * (j + 1)) * SECONDS) + .eut(recipeConsumption) + .addTo(assemblerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs( + new ItemStack( + ItemRegistry.TecTechPipeEnergyLowPower.getItem(), + (j + 1) * 16, + ItemRegistry.TecTechPipeEnergyLowPower.getItemDamage()), + WerkstoffLoader.CubicZirconia.get(OrePrefixes.lens), + GTOreDictUnificator.get(prefixes[j], cables[i + 4], 8), + sensors[i].get(2 * (j + 1)), + ItemList.HATCHES_ENERGY[4 + i].get(2 * (j + 1))) + .itemOutputs(eInput) + .fluidInputs(Materials.SolderingAlloy.getMolten(solderingAmount)) + .duration((10 * (j + 1)) * SECONDS) + .eut(recipeConsumption) + .addTo(assemblerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs( + new ItemStack( + ItemRegistry.TecTechPipeEnergyLowPower.getItem(), + (j + 1) * 16, + ItemRegistry.TecTechPipeEnergyLowPower.getItemDamage()), + WerkstoffLoader.CubicZirconia.get(OrePrefixes.lens), + GTOreDictUnificator.get(prefixes[j], cables[i + 4], 8), + emitters[i].get(2 * (j + 1)), + ItemList.HATCHES_DYNAMO[4 + i].get(2 * (j + 1))) + .itemOutputs(eDynamo) + .fluidInputs(Materials.SolderingAlloy.getMolten(solderingAmount)) + .duration((10 * (j + 1) * SECONDS)) + .eut(recipeConsumption) + .addTo(assemblerRecipes); + } + } + + GTValues.RA.stdBuilder() + .itemInputs( + ItemList.Hatch_Input_HV.get(64), + Materials.LiquidAir.getCells(1), + GTUtility.getIntegratedCircuit(17)) + .itemOutputs(ItemRegistry.compressedHatch.copy()) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Hatch_Output_HV.get(64), GTUtility.getIntegratedCircuit(17)) + .itemOutputs(ItemRegistry.giantOutputHatch.copy()) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(assemblerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs( + GTOreDictUnificator.get(OrePrefixes.plateDense, Materials.Lead, 6), + GTOreDictUnificator.get(OrePrefixes.frameGt, Materials.TungstenSteel, 1)) + .itemOutputs(new ItemStack(GregTechAPI.sBlockCasings3, 1, 12)) + .fluidInputs(Materials.Concrete.getMolten(1296)) + .duration(2 * SECONDS) + .eut(TierEU.RECIPE_IV) + .addTo(assemblerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs( + new ItemStack(GregTechAPI.sBlockCasings3, 1, 12), + GTOreDictUnificator.get(OrePrefixes.foil, Materials.Europium, 6), + GTOreDictUnificator.get(OrePrefixes.screw, Materials.Europium, 24)) + .itemOutputs(new ItemStack(GregTechAPI.sBlockCasings8, 1, 5)) + .fluidInputs(Materials.Lead.getMolten(864)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_LuV) + .addTo(assemblerRecipes); + } +} diff --git a/src/main/java/bartworks/common/loaders/recipes/AssemblyLine.java b/src/main/java/bartworks/common/loaders/recipes/AssemblyLine.java new file mode 100644 index 0000000000..650bb02918 --- /dev/null +++ b/src/main/java/bartworks/common/loaders/recipes/AssemblyLine.java @@ -0,0 +1,81 @@ +package bartworks.common.loaders.recipes; + +import static gregtech.api.util.GTRecipeBuilder.HOURS; +import static gregtech.api.util.GTRecipeBuilder.MINUTES; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; +import static gregtech.api.util.GTRecipeConstants.AssemblyLine; +import static gregtech.api.util.GTRecipeConstants.RESEARCH_ITEM; +import static gregtech.api.util.GTRecipeConstants.RESEARCH_TIME; + +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import bartworks.common.loaders.ItemRegistry; +import bartworks.system.material.WerkstoffLoader; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GTOreDictUnificator; + +public class AssemblyLine implements Runnable { + + @Override + public void run() { + Fluid solderIndalloy = FluidRegistry.getFluid("molten.indalloy140") != null + ? FluidRegistry.getFluid("molten.indalloy140") + : FluidRegistry.getFluid("molten.solderingalloy"); + GTValues.RA.stdBuilder() + .metadata(RESEARCH_ITEM, ItemList.Pump_IV.get(1L)) + .metadata(RESEARCH_TIME, 1 * HOURS) + .itemInputs( + ItemList.Pump_IV.get(16), + GTOreDictUnificator.get(OrePrefixes.pipeLarge, Materials.Ultimate, 32L), + GTOreDictUnificator.get(OrePrefixes.gearGt, Materials.HSSE, 16L), + GTOreDictUnificator.get(OrePrefixes.gearGt, Materials.HSSE, 16L), + ItemList.Field_Generator_LuV.get(8)) + .fluidInputs( + new FluidStack(solderIndalloy, 32 * 144), + Materials.Polytetrafluoroethylene.getMolten(32 * 144)) + .itemOutputs(ItemRegistry.dehp) + .eut(TierEU.RECIPE_LuV) + .duration(4 * MINUTES + 10 * SECONDS) + .addTo(AssemblyLine); + + GTValues.RA.stdBuilder() + .metadata(RESEARCH_ITEM, ItemList.OreDrill4.get(1L)) + .metadata(RESEARCH_TIME, 25 * MINUTES + 36 * SECONDS) + .itemInputs( + ItemList.OreDrill4.get(1L), + GTOreDictUnificator.get(OrePrefixes.frameGt, Materials.Tritanium, 9L), + Materials.Europium.getPlates(3), + ItemList.Electric_Motor_LuV.get(9L), + ItemList.Sensor_LuV.get(9L), + ItemList.Field_Generator_LuV.get(9L), + GTOreDictUnificator.get(OrePrefixes.screw, Materials.Europium, 36L)) + .fluidInputs(new FluidStack(solderIndalloy, 1440), WerkstoffLoader.Neon.getFluidOrGas(20000)) + .itemOutputs(ItemRegistry.voidminer[0].copy()) + .eut(TierEU.RECIPE_LuV) + .duration(5 * MINUTES) + .addTo(AssemblyLine); + + GTValues.RA.stdBuilder() + .metadata(RESEARCH_ITEM, ItemList.Machine_LuV_CircuitAssembler.get(1L)) + .metadata(RESEARCH_TIME, 20 * MINUTES) + .itemInputs( + ItemList.Machine_LuV_CircuitAssembler.get(1L), + ItemList.Robot_Arm_LuV.get(4L), + ItemList.Electric_Motor_LuV.get(4L), + ItemList.Field_Generator_LuV.get(1L), + ItemList.Emitter_LuV.get(1L), + ItemList.Sensor_LuV.get(1L), + WerkstoffLoader.LuVTierMaterial.get(OrePrefixes.plate, 8)) + .fluidInputs(new FluidStack(solderIndalloy, 1440)) + .itemOutputs(ItemRegistry.cal.copy()) + .eut(TierEU.RECIPE_LuV) + .duration(20 * MINUTES) + .addTo(AssemblyLine); + } +} diff --git a/src/main/java/bartworks/common/loaders/recipes/Autoclave.java b/src/main/java/bartworks/common/loaders/recipes/Autoclave.java new file mode 100644 index 0000000000..12140611f7 --- /dev/null +++ b/src/main/java/bartworks/common/loaders/recipes/Autoclave.java @@ -0,0 +1,40 @@ +package bartworks.common.loaders.recipes; + +import static gregtech.api.recipe.RecipeMaps.autoclaveRecipes; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; + +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +import bartworks.common.loaders.BioItemList; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TierEU; + +public class Autoclave implements Runnable { + + @Override + public void run() { + Materials[] sterilizers = { Materials.Ammonia, Materials.Chlorine, Materials.Ethanol, Materials.Methanol }; + for (Materials used : sterilizers) { + + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Circuit_Parts_PetriDish.get(1L)) + .itemOutputs(BioItemList.getPetriDish(null)) + .fluidInputs(used.getGas(10L) != null ? used.getGas(8L) : used.getFluid(16L)) + .duration(5 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(autoclaveRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(Items.glass_bottle)) + .itemOutputs(BioItemList.getDNASampleFlask(null)) + .fluidInputs(used.getGas(10L) != null ? used.getGas(8L) : used.getFluid(16L)) + .duration(5 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(autoclaveRecipes); + + } + } +} diff --git a/src/main/java/bartworks/common/loaders/recipes/Centrifuge.java b/src/main/java/bartworks/common/loaders/recipes/Centrifuge.java new file mode 100644 index 0000000000..a689d39ce8 --- /dev/null +++ b/src/main/java/bartworks/common/loaders/recipes/Centrifuge.java @@ -0,0 +1,141 @@ +package bartworks.common.loaders.recipes; + +import static gregtech.api.recipe.RecipeMaps.centrifugeRecipes; +import static gregtech.api.util.GTRecipeBuilder.MINUTES; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; + +import java.util.Arrays; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import bartworks.common.loaders.BioCultureLoader; +import bartworks.common.loaders.BioItemList; +import bartworks.common.loaders.FluidLoader; +import bartworks.common.tileentities.multis.MTEHighTempGasCooledReactor; +import bartworks.common.tileentities.multis.MTEThoriumHighTempReactor; +import bartworks.system.material.WerkstoffLoader; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GTRecipeBuilder; +import gregtech.api.util.GTUtility; + +public class Centrifuge implements Runnable { + + @Override + public void run() { + GTValues.RA.stdBuilder() + .itemInputs(Materials.Thorium.getDust(1)) + .itemOutputs( + Materials.Thorium.getDust(1), + Materials.Thorium.getDust(1), + WerkstoffLoader.Thorium232.get(OrePrefixes.dust, 1), + WerkstoffLoader.Thorium232.get(OrePrefixes.dust, 1), + WerkstoffLoader.Thorium232.get(OrePrefixes.dust, 1)) + .outputChances(800, 375, 22, 22, 5) + .duration(8 * MINUTES + 20 * SECONDS) + .eut(TierEU.RECIPE_EV) + .addTo(centrifugeRecipes); + + ItemStack[] pellets = new ItemStack[6]; + Arrays.fill(pellets, new ItemStack(MTEThoriumHighTempReactor.THTRMaterials.aTHTR_Materials, 64, 4)); + + GTValues.RA.stdBuilder() + .itemInputs( + new ItemStack(MTEThoriumHighTempReactor.THTRMaterials.aTHTR_Materials, 1, 3), + GTUtility.getIntegratedCircuit(17)) + .itemOutputs(pellets) + .duration(40 * MINUTES) + .eut(TierEU.RECIPE_LV) + .addTo(centrifugeRecipes); + + GTValues.RA.stdBuilder() + .itemInputs( + new ItemStack(MTEThoriumHighTempReactor.THTRMaterials.aTHTR_Materials, 1, 5), + GTUtility.getIntegratedCircuit(17)) + .itemOutputs(new ItemStack(MTEThoriumHighTempReactor.THTRMaterials.aTHTR_Materials, 64, 6)) + .duration(40 * MINUTES) + .eut(TierEU.RECIPE_LV) + .addTo(centrifugeRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(MTEThoriumHighTempReactor.THTRMaterials.aTHTR_Materials, 1, 6)) + .itemOutputs(Materials.Lead.getDust(1)) + .outputChances(300) + .duration(60 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(centrifugeRecipes); + + int i = 0; + for (MTEHighTempGasCooledReactor.HTGRMaterials.Fuel_ fuel : MTEHighTempGasCooledReactor.HTGRMaterials.sHTGR_Fuel) { + + GTValues.RA.stdBuilder() + .itemInputs( + new ItemStack(MTEHighTempGasCooledReactor.HTGRMaterials.aHTGR_Materials, 1, i + 3), + GTUtility.getIntegratedCircuit(17)) + .itemOutputs( + new ItemStack(MTEHighTempGasCooledReactor.HTGRMaterials.aHTGR_Materials, 64, i + 4), + new ItemStack(MTEHighTempGasCooledReactor.HTGRMaterials.aHTGR_Materials, 64, i + 4), + new ItemStack(MTEHighTempGasCooledReactor.HTGRMaterials.aHTGR_Materials, 64, i + 4), + new ItemStack(MTEHighTempGasCooledReactor.HTGRMaterials.aHTGR_Materials, 64, i + 4)) + .duration(10 * MINUTES) + .eut(TierEU.RECIPE_LV) + .addTo(centrifugeRecipes); + + GTValues.RA.stdBuilder() + .itemInputs( + new ItemStack(MTEHighTempGasCooledReactor.HTGRMaterials.aHTGR_Materials, 1, i + 5), + GTUtility.getIntegratedCircuit(17)) + .itemOutputs(new ItemStack(MTEHighTempGasCooledReactor.HTGRMaterials.aHTGR_Materials, 64, i + 6)) + .duration(2 * MINUTES + 30 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(centrifugeRecipes); + + GTRecipeBuilder recipeBuilder = GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(MTEHighTempGasCooledReactor.HTGRMaterials.aHTGR_Materials, 1, i + 6)) + .itemOutputs( + fuel.recycledItems[0], + fuel.recycledItems[1], + fuel.recycledItems[2], + fuel.recycledItems[3], + fuel.recycledItems[4]) + .outputChances(fuel.recycleChances); + if (fuel.recycledFluid != null) { + recipeBuilder.fluidOutputs(fuel.recycledFluid); + } + recipeBuilder.duration(1 * MINUTES) + .eut(TierEU.RECIPE_LV) + .addTo(centrifugeRecipes); + + i += MTEHighTempGasCooledReactor.HTGRMaterials.MATERIALS_PER_FUEL; + } + + GTValues.RA.stdBuilder() + .itemInputs(GTUtility.getIntegratedCircuit(17)) + .itemOutputs(BioItemList.getOther(4)) + .fluidInputs(new FluidStack(BioCultureLoader.eColi.getFluid(), 1000)) + .fluidOutputs(new FluidStack(FluidLoader.BioLabFluidMaterials[1], 10)) + .duration(60 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(centrifugeRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(GTUtility.getIntegratedCircuit(17)) + .fluidInputs(new FluidStack(FluidLoader.BioLabFluidMaterials[1], 1000)) + .fluidOutputs(new FluidStack(FluidLoader.BioLabFluidMaterials[3], 250)) + .duration(60 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(centrifugeRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(GTUtility.getIntegratedCircuit(17)) + .fluidInputs(new FluidStack(BioCultureLoader.CommonYeast.getFluid(), 1000)) + .fluidOutputs(new FluidStack(FluidLoader.BioLabFluidMaterials[2], 10)) + .duration(60 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(centrifugeRecipes); + + } +} diff --git a/src/main/java/bartworks/common/loaders/recipes/ChemicalBath.java b/src/main/java/bartworks/common/loaders/recipes/ChemicalBath.java new file mode 100644 index 0000000000..478acdb81f --- /dev/null +++ b/src/main/java/bartworks/common/loaders/recipes/ChemicalBath.java @@ -0,0 +1,83 @@ +package bartworks.common.loaders.recipes; + +import static gregtech.api.recipe.RecipeMaps.chemicalBathRecipes; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; +import static gregtech.api.util.GTRecipeBuilder.TICKS; + +import net.minecraft.item.ItemStack; + +import bartworks.common.loaders.ItemRegistry; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.Materials; + +public class ChemicalBath implements Runnable { + + @Override + public void run() { + + for (int i = 0; i < Dyes.dyeBrown.getSizeOfFluidList(); ++i) { + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 6)) + .fluidInputs(Dyes.dyeRed.getFluidDye(i, 36)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(2) + .addTo(chemicalBathRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 7)) + .fluidInputs(Dyes.dyeGreen.getFluidDye(i, 36)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(2) + .addTo(chemicalBathRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 8)) + .fluidInputs(Dyes.dyePurple.getFluidDye(i, 36)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(2) + .addTo(chemicalBathRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 9)) + .fluidInputs(Dyes.dyeYellow.getFluidDye(i, 36)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(2) + .addTo(chemicalBathRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 10)) + .fluidInputs(Dyes.dyeLime.getFluidDye(i, 36)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(2) + .addTo(chemicalBathRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 11)) + .fluidInputs(Dyes.dyeBrown.getFluidDye(i, 36)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(2) + .addTo(chemicalBathRecipes); + + } + + for (int i = 6; i < 11; i++) { + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, i)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .fluidInputs(Materials.Chlorine.getGas(50)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(2) + .addTo(chemicalBathRecipes); + + } + } +} diff --git a/src/main/java/bartworks/common/loaders/recipes/ChemicalReactor.java b/src/main/java/bartworks/common/loaders/recipes/ChemicalReactor.java new file mode 100644 index 0000000000..0270a31355 --- /dev/null +++ b/src/main/java/bartworks/common/loaders/recipes/ChemicalReactor.java @@ -0,0 +1,28 @@ +package bartworks.common.loaders.recipes; + +import static gregtech.api.util.GTRecipeBuilder.SECONDS; +import static gregtech.api.util.GTRecipeBuilder.TICKS; +import static gregtech.api.util.GTRecipeConstants.UniversalChemical; + +import net.minecraftforge.fluids.FluidStack; + +import bartworks.common.loaders.FluidLoader; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GTUtility; + +public class ChemicalReactor implements Runnable { + + @Override + public void run() { + + GTValues.RA.stdBuilder() + .itemInputs(GTUtility.getIntegratedCircuit(10)) + .fluidInputs(new FluidStack(FluidLoader.heatedfulvicAcid, 1000)) + .fluidOutputs(new FluidStack(FluidLoader.Kerogen, 1000)) + .duration(3 * SECONDS + 15 * TICKS) + .eut(TierEU.RECIPE_MV) + .addTo(UniversalChemical); + + } +} diff --git a/src/main/java/bartworks/common/loaders/recipes/CraftingRecipes.java b/src/main/java/bartworks/common/loaders/recipes/CraftingRecipes.java new file mode 100644 index 0000000000..2cb768ec70 --- /dev/null +++ b/src/main/java/bartworks/common/loaders/recipes/CraftingRecipes.java @@ -0,0 +1,468 @@ +package bartworks.common.loaders.recipes; + +import static gregtech.api.enums.MetaTileEntityIDs.BioLab_EV; +import static gregtech.api.enums.MetaTileEntityIDs.BioLab_HV; +import static gregtech.api.enums.MetaTileEntityIDs.BioLab_IV; +import static gregtech.api.enums.MetaTileEntityIDs.BioLab_LuV; +import static gregtech.api.enums.MetaTileEntityIDs.BioLab_MAX; +import static gregtech.api.enums.MetaTileEntityIDs.BioLab_UEV; +import static gregtech.api.enums.MetaTileEntityIDs.BioLab_UHV; +import static gregtech.api.enums.MetaTileEntityIDs.BioLab_UIV; +import static gregtech.api.enums.MetaTileEntityIDs.BioLab_UMV; +import static gregtech.api.enums.MetaTileEntityIDs.BioLab_UV; +import static gregtech.api.enums.MetaTileEntityIDs.BioLab_UXV; +import static gregtech.api.enums.MetaTileEntityIDs.BioLab_ZPM; +import static gregtech.api.enums.MetaTileEntityIDs.BioVat; +import static gregtech.api.enums.MetaTileEntityIDs.LESU; +import static gregtech.api.enums.MetaTileEntityIDs.ManualTrafo; +import static gregtech.api.enums.MetaTileEntityIDs.RadioHatch_EV; +import static gregtech.api.enums.MetaTileEntityIDs.RadioHatch_HV; +import static gregtech.api.enums.MetaTileEntityIDs.RadioHatch_IV; +import static gregtech.api.enums.MetaTileEntityIDs.RadioHatch_LuV; +import static gregtech.api.enums.MetaTileEntityIDs.RadioHatch_MAX; +import static gregtech.api.enums.MetaTileEntityIDs.RadioHatch_UEV; +import static gregtech.api.enums.MetaTileEntityIDs.RadioHatch_UHV; +import static gregtech.api.enums.MetaTileEntityIDs.RadioHatch_UIV; +import static gregtech.api.enums.MetaTileEntityIDs.RadioHatch_UMV; +import static gregtech.api.enums.MetaTileEntityIDs.RadioHatch_UV; +import static gregtech.api.enums.MetaTileEntityIDs.RadioHatch_UXV; +import static gregtech.api.enums.MetaTileEntityIDs.RadioHatch_ZPM; +import static gregtech.api.enums.MetaTileEntityIDs.Windmill; +import static gregtech.api.enums.Mods.IndustrialCraft2; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; +import net.minecraftforge.oredict.OreDictionary; + +import bartworks.common.configs.ConfigHandler; +import bartworks.common.loaders.BioItemList; +import bartworks.common.loaders.ItemRegistry; +import bartworks.common.loaders.RecipeLoader; +import bartworks.common.tileentities.multis.MTEBioVat; +import bartworks.common.tileentities.multis.MTELESU; +import bartworks.common.tileentities.multis.MTEManualTrafo; +import bartworks.common.tileentities.multis.MTEWindmill; +import bartworks.common.tileentities.tiered.GT_MetaTileEntity_RadioHatch; +import bartworks.common.tileentities.tiered.MTEBioLab; +import bartworks.system.material.Werkstoff; +import bartworks.system.material.WerkstoffLoader; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.ISubTagContainer; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTOreDictUnificator; +import ic2.core.Ic2Items; + +public class CraftingRecipes implements Runnable { + + @Override + public void run() { + + Materials[] cables = { // Cable material used in the acid gen, diode and energy distributor below + Materials.Lead, // ULV + Materials.Tin, // LV + Materials.AnnealedCopper, // MV + Materials.Gold, // HV + Materials.Aluminium, // EV + Materials.Tungsten, // IV + Materials.VanadiumGallium, // LuV + Materials.Naquadah, // ZPM + Materials.NaquadahAlloy, // UV + Materials.SuperconductorUV // UHV + }; + + ISubTagContainer[] hulls = { // Plate material used in the acid gen, diode and energy distributor below + Materials.WroughtIron, // ULV + Materials.Steel, // LV + Materials.Aluminium, // MV + Materials.StainlessSteel, // HV + Materials.Titanium, // EV + Materials.TungstenSteel, // IV + WerkstoffLoader.LuVTierMaterial, // LuV + Materials.Iridium, // ZPM + Materials.Osmium, // UV + Materials.Naquadah // UHV + }; + + ItemStack[] bats = { ItemList.Battery_Hull_LV.get(1L), ItemList.Battery_Hull_MV.get(1L), + ItemList.Battery_Hull_HV.get(1L) }; + ItemStack[] chreac = { ItemList.Machine_MV_ChemicalReactor.get(1L), ItemList.Machine_HV_ChemicalReactor.get(1L), + ItemList.Machine_EV_ChemicalReactor.get(1L) }; + + GTModHandler.addCraftingRecipe( + new MTELESU(LESU.ID, "LESU", "L.E.S.U.").getStackForm(1L), + RecipeLoader.BITSD, + new Object[] { "CDC", "SBS", "CFC", 'C', "circuitAdvanced", 'D', ItemList.Cover_Screen.get(1L), 'S', + GTOreDictUnificator.get(OrePrefixes.cableGt12, Materials.Platinum, 1L), 'B', + new ItemStack(ItemRegistry.BW_BLOCKS[1]), 'F', ItemList.Field_Generator_HV.get(1L) }); + + GTModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.ROCKCUTTER_MV), + RecipeLoader.BITSD, + new Object[] { "DS ", "DP ", "DCB", 'D', GTOreDictUnificator.get(OrePrefixes.dust, Materials.Diamond, 1L), + 'S', GTOreDictUnificator.get(OrePrefixes.stick, Materials.TungstenSteel, 1L), 'P', + GTOreDictUnificator.get(OrePrefixes.plate, Materials.TungstenSteel, 1L), 'C', "circuitGood", 'B', + ItemList.IC2_AdvBattery.get(1L) }); + + GTModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.ROCKCUTTER_LV), + RecipeLoader.BITSD, + new Object[] { "DS ", "DP ", "DCB", 'D', GTOreDictUnificator.get(OrePrefixes.dust, Materials.Diamond, 1L), + 'S', GTOreDictUnificator.get(OrePrefixes.stick, Materials.Titanium, 1L), 'P', + GTOreDictUnificator.get(OrePrefixes.plate, Materials.Titanium, 1L), 'C', "circuitBasic", 'B', + ItemList.IC2_ReBattery.get(1L) }); + + GTModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.ROCKCUTTER_HV), + RecipeLoader.BITSD, + new Object[] { "DS ", "DP ", "DCB", 'D', GTOreDictUnificator.get(OrePrefixes.dust, Materials.Diamond, 1L), + 'S', GTOreDictUnificator.get(OrePrefixes.stick, Materials.Iridium, 1L), 'P', + GTOreDictUnificator.get(OrePrefixes.plate, Materials.Iridium, 1L), 'C', "circuitAdvanced", 'B', + ItemList.IC2_EnergyCrystal.get(1L) }); + + if (ConfigHandler.teslastaff) { + GTModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.TESLASTAFF), + RecipeLoader.BITSD, + new Object[] { "BO ", "OP ", " P", 'O', + GTOreDictUnificator.get(OrePrefixes.wireGt16, Materials.SuperconductorUHV, 1L), 'B', + ItemList.Energy_LapotronicOrb.get(1L), 'P', "plateAlloyIridium", }); + } + + GTModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.PUMPPARTS, 1, 0), // tube + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { " fG", " G ", "G ", 'G', ItemList.Circuit_Parts_Glass_Tube.get(1L) }); + GTModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.PUMPPARTS, 1, 1), // motor + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "GLP", "LSd", "PfT", 'G', + GTOreDictUnificator.get(OrePrefixes.gearGtSmall, Materials.Steel, 1L), 'L', + GTOreDictUnificator.get(OrePrefixes.stickLong, Materials.Steel, 1L), 'S', + GTOreDictUnificator.get(OrePrefixes.screw, Materials.Steel, 1L), 'P', new ItemStack(Blocks.piston), 'T', + new ItemStack(ItemRegistry.PUMPPARTS, 1, 0) }); + GTModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.PUMPBLOCK, 1, 0), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "IPI", "PMP", "ISI", 'I', GTOreDictUnificator.get(OrePrefixes.plate, Materials.Iron, 1L), + 'P', GTOreDictUnificator.get(OrePrefixes.pipeLarge, Materials.Wood, 1L), 'M', + new ItemStack(ItemRegistry.PUMPPARTS, 1, 1), 'S', Ic2Items.ironFurnace }); + + GTModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.WINDMETER), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "SWF", "Sf ", "Ss ", 'S', "stickWood", 'W', new ItemStack(Blocks.wool, 1, Short.MAX_VALUE), + 'F', new ItemStack(Items.string), }); + + for (int i = 0; i < 3; i++) { + Materials cable = cables[i + 2]; + ItemStack machinehull = ItemList.MACHINE_HULLS[i + 2].get(1L); + GTModHandler.addCraftingRecipe( + ItemRegistry.acidGens[i], + RecipeLoader.BITSD, + new Object[] { "HRH", "HCH", "HKH", 'H', bats[i], 'K', + GTOreDictUnificator.get(OrePrefixes.cableGt01, cable, 1L), 'C', machinehull, 'R', chreac[i] }); + } + + GTModHandler.addCraftingRecipe( + ItemRegistry.acidGensLV, + RecipeLoader.BITSD, + new Object[] { "HRH", "KCK", "HKH", 'H', ItemList.Battery_Hull_LV.get(1L), 'K', + GTOreDictUnificator.get(OrePrefixes.cableGt01, Materials.Tin, 1L), 'C', ItemList.Hull_LV.get(1L), 'R', + ItemList.Machine_LV_ChemicalReactor.get(1L), }); + + for (int i = 0; i < 9; i++) { + try { + Materials cable = cables[i]; + ItemStack hull = hulls[i] instanceof Materials + ? GTOreDictUnificator.get(OrePrefixes.plate, hulls[i], 1L) + : ((Werkstoff) hulls[i]).get(OrePrefixes.plate); + ItemStack machinehull = ItemList.MACHINE_HULLS[i].get(1L); + + GTModHandler.addCraftingRecipe( + ItemRegistry.energyDistributor[i], + RecipeLoader.BITSD, + new Object[] { "PWP", "WCW", "PWP", 'W', GTOreDictUnificator.get(OrePrefixes.wireGt16, cable, 1L), + 'P', hull, 'C', machinehull }); + GTModHandler.addCraftingRecipe( + ItemRegistry.diode12A[i], + RecipeLoader.BITSD, + new Object[] { "WDW", "DCD", "PDP", 'D', OrePrefixes.componentCircuit.get(Materials.Diode), 'W', + GTOreDictUnificator.get(OrePrefixes.cableGt12, cable, 1L), 'P', hull, 'C', machinehull }); + GTModHandler.addCraftingRecipe( + ItemRegistry.diode8A[i], + RecipeLoader.BITSD, + new Object[] { "WDW", "DCD", "PDP", 'D', OrePrefixes.componentCircuit.get(Materials.Diode), 'W', + GTOreDictUnificator.get(OrePrefixes.cableGt08, cable, 1L), 'P', hull, 'C', machinehull }); + GTModHandler.addCraftingRecipe( + ItemRegistry.diode4A[i], + RecipeLoader.BITSD, + new Object[] { "WDW", "DCD", "PDP", 'D', OrePrefixes.componentCircuit.get(Materials.Diode), 'W', + GTOreDictUnificator.get(OrePrefixes.cableGt04, cable, 1L), 'P', hull, 'C', machinehull }); + GTModHandler.addCraftingRecipe( + ItemRegistry.diode2A[i], + RecipeLoader.BITSD, + new Object[] { "WDW", "DCD", "PDP", 'D', OrePrefixes.componentCircuit.get(Materials.Diode), 'W', + GTOreDictUnificator.get(OrePrefixes.cableGt02, cable, 1L), 'P', hull, 'C', machinehull }); + GTModHandler.addCraftingRecipe( + ItemRegistry.diode16A[i], + RecipeLoader.BITSD, + new Object[] { "WHW", "DCD", "PDP", 'H', OrePrefixes.componentCircuit.get(Materials.Inductor), 'D', + OrePrefixes.componentCircuit.get(Materials.Diode), 'W', + GTOreDictUnificator.get(OrePrefixes.wireGt16, cable, 1L), 'P', hull, 'C', machinehull }); + + } catch (ArrayIndexOutOfBoundsException ignored) { + + } + + } + + String[] stones = { "stone", "stoneSmooth" }; + String[] granites = { "blockGranite", "stoneGranite", "Granite", "granite" }; + for (String granite : granites) { + for (String stone : stones) { + GTModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 0), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "SSS", "DfD", " h ", 'S', stone, 'D', + new ItemStack(GregTechAPI.sBlockGranites, 1, OreDictionary.WILDCARD_VALUE), }); + GTModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 1), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "hDf", "SSS", 'S', stone, 'D', + new ItemStack(GregTechAPI.sBlockGranites, 1, OreDictionary.WILDCARD_VALUE), }); + GTModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 0), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "SSS", "DfD", " h ", 'S', stone, 'D', granite, }); + GTModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 1), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "hDf", "SSS", 'S', stone, 'D', granite, }); + } + GTModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 2), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "STS", "h f", "SBS", 'S', granite, 'T', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 0), + 'B', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 1), }); + } + + GTModHandler.addCraftingRecipe( + new MTEManualTrafo(ManualTrafo.ID, "bw.manualtrafo", StatCollector.translateToLocal("tile.manutrafo.name")) + .getStackForm(1L), + RecipeLoader.BITSD, + new Object[] { "SCS", "CHC", "ZCZ", 'S', GTOreDictUnificator.get(OrePrefixes.screw, Materials.Titanium, 1L), + 'C', new ItemStack(ItemRegistry.BW_BLOCKS[2]), 'H', ItemList.Hull_HV.get(1L), 'Z', "circuitAdvanced" }); + + GTModHandler.addCraftingRecipe( + new MTEWindmill(Windmill.ID, "bw.windmill", StatCollector.translateToLocal("tile.bw.windmill.name")) + .getStackForm(1L), + RecipeLoader.BITSD, + new Object[] { "BHB", "WGW", "BWB", 'B', new ItemStack(Blocks.brick_block), 'W', + GTOreDictUnificator.get(OrePrefixes.gearGt, Materials.Iron, 1L), 'H', new ItemStack(Blocks.hopper), 'G', + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 2), }); + + GTModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 2), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "STS", "h f", "SBS", 'S', + new ItemStack(GregTechAPI.sBlockGranites, 1, OreDictionary.WILDCARD_VALUE), 'T', + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 0), 'B', + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 1), }); + GTModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 3), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "WLs", "WLh", "WLf", 'L', new ItemStack(Items.leather), 'W', "logWood", }); + GTModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 4), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "WLs", "WLh", "WLf", 'L', new ItemStack(Blocks.carpet), 'W', "logWood", }); + GTModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 5), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "WLs", "WLh", "WLf", 'L', new ItemStack(Items.paper), 'W', "logWood", }); + + GTModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 6), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "WEs", "WZh", "WDf", 'E', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 3), 'Z', + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 4), 'D', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 5), + 'W', "logWood", }); + + GTModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 6), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "WEs", "WZh", "WDf", 'Z', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 3), 'E', + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 4), 'D', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 5), + 'W', "logWood", }); + + GTModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 6), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "WEs", "WZh", "WDf", 'D', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 3), 'Z', + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 4), 'E', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 5), + 'W', "logWood", }); + + GTModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 6), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "WEs", "WZh", "WDf", 'E', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 3), 'D', + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 4), 'Z', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 5), + 'W', "logWood", }); + + GTModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 6), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "WEs", "WZh", "WDf", 'Z', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 3), 'D', + new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 4), 'E', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 5), + 'W', "logWood", }); + + GTModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.LEATHER_ROTOR), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "hPf", "PWP", "sPr", 'P', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 3), 'W', + GTOreDictUnificator.get(OrePrefixes.gearGt, Materials.Iron, 1L), }); + GTModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.WOOL_ROTOR), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "hPf", "PWP", "sPr", 'P', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 4), 'W', + GTOreDictUnificator.get(OrePrefixes.gearGt, Materials.Iron, 1L), }); + GTModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.PAPER_ROTOR), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "hPf", "PWP", "sPr", 'P', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 5), 'W', + GTOreDictUnificator.get(OrePrefixes.gearGt, Materials.Iron, 1L), }); + GTModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.COMBINED_ROTOR), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "hPf", "PWP", "sPr", 'P', new ItemStack(ItemRegistry.CRAFTING_PARTS, 1, 6), 'W', + GTOreDictUnificator.get(OrePrefixes.gearGt, Materials.Iron, 1L), }); + GTModHandler.addCraftingRecipe( + new ItemStack(ItemRegistry.ROTORBLOCK), + RecipeLoader.BITSD, + new Object[] { "WRW", "RGR", "WRW", 'R', GTOreDictUnificator.get(OrePrefixes.ring, Materials.Iron, 1L), 'W', + "plankWood", 'G', GTOreDictUnificator.get(OrePrefixes.gearGt, Materials.Iron, 1L), }); + + GTModHandler.addCraftingRecipe( + ItemRegistry.THTR, + RecipeLoader.BITSD, + new Object[] { "BZB", "BRB", "BZB", 'B', new ItemStack(GregTechAPI.sBlockCasings3, 1, 12), 'R', + GTModHandler.getModItem(IndustrialCraft2.ID, "blockGenerator", 1, 5), 'Z', "circuitUltimate" }); + + GTModHandler.addCraftingRecipe( + ItemRegistry.HTGR, + RecipeLoader.BITSD, + new Object[] { "BZB", "BRB", "BZB", 'B', new ItemStack(GregTechAPI.sBlockCasings8, 1, 5), 'R', + GTModHandler.getModItem(IndustrialCraft2.ID, "blockGenerator", 1, 5), 'Z', "circuitSuperconductor" }); + + // DNAExtractionModule + GTModHandler.addCraftingRecipe( + BioItemList.mBioLabParts[0], + RecipeLoader.BITSD, + new Object[] { "TET", "CFC", "TST", 'T', GTOreDictUnificator.get(OrePrefixes.plate, Materials.Titanium, 1L), + 'E', ItemList.Emitter_EV.get(1L), 'C', + GTOreDictUnificator.get(OrePrefixes.cableGt04, Materials.Aluminium, 1L), 'S', + ItemList.Sensor_EV.get(1L), 'F', ItemList.Field_Generator_EV.get(1L) }); + + // PCRThermoclyclingModule + GTModHandler.addCraftingRecipe( + BioItemList.mBioLabParts[1], + RecipeLoader.BITSD, + new Object[] { "NEN", "CFC", "NSN", 'N', + GTOreDictUnificator.get(OrePrefixes.wireGt04, Materials.Nichrome, 1L), 'E', ItemList.Emitter_EV.get(1L), + 'C', GTOreDictUnificator.get(OrePrefixes.cableGt04, Materials.Aluminium, 1L), 'S', + ItemList.Sensor_EV.get(1L), 'F', ItemList.Field_Generator_EV.get(1L) }); + + // PlasmidSynthesisModule + GTModHandler.addCraftingRecipe( + BioItemList.mBioLabParts[2], + RecipeLoader.BITSD, + new Object[] { "SFE", "CPC", "NFN", 'N', + GTOreDictUnificator.get(OrePrefixes.wireGt04, Materials.Nichrome, 1L), 'C', "circuit" + Materials.EV, + 'F', ItemList.Field_Generator_EV.get(1L), 'E', ItemList.Emitter_EV.get(1L), 'S', + ItemList.Sensor_EV.get(1L), 'P', GTOreDictUnificator.get(OrePrefixes.plate, Materials.Titanium, 1L), }); + // TransformationModule + GTModHandler.addCraftingRecipe( + BioItemList.mBioLabParts[3], + RecipeLoader.BITSD, + new Object[] { "SFE", "CPC", "NFN", 'N', + GTOreDictUnificator.get(OrePrefixes.wireGt04, Materials.Naquadah, 1L), 'C', "circuit" + Materials.LuV, + 'F', ItemList.Field_Generator_LuV.get(1L), 'E', ItemList.Emitter_LuV.get(1L), 'S', + ItemList.Sensor_LuV.get(1L), 'P', WerkstoffLoader.LuVTierMaterial.get(OrePrefixes.plate, 1), }); + + // ClonalCellularSynthesisModule + GTModHandler.addCraftingRecipe( + BioItemList.mBioLabParts[4], + RecipeLoader.BITSD, + new Object[] { "FEF", "CPC", "FSF", 'N', + GTOreDictUnificator.get(OrePrefixes.wireGt04, Materials.Naquadah, 1L), 'C', "circuit" + Materials.LuV, + 'F', ItemList.Field_Generator_LuV.get(1L), 'E', ItemList.Emitter_LuV.get(1L), 'S', + ItemList.Sensor_LuV.get(1L), 'P', WerkstoffLoader.LuVTierMaterial.get(OrePrefixes.plate, 1), }); + + GTModHandler.addCraftingRecipe( + new MTEBioVat(BioVat.ID, "bw.biovat", StatCollector.translateToLocal("tile.biovat.name")).getStackForm(1L), + RecipeLoader.BITSD, + new Object[] { "GCG", "KHK", "GCG", 'G', new ItemStack(ItemRegistry.bw_glasses[0], 1, 1), 'C', + "circuit" + Materials.EV, 'K', GTOreDictUnificator.get(OrePrefixes.wireGt08, Materials.Silver, 1L), 'H', + ItemList.MACHINE_HULLS[3].get(1L) }); + + ItemStack[] Pistons2 = { ItemList.Electric_Piston_HV.get(1L), ItemList.Electric_Piston_EV.get(1L), + ItemList.Electric_Piston_IV.get(1L), ItemList.Electric_Piston_LuV.get(1L), + ItemList.Electric_Piston_ZPM.get(1L), ItemList.Electric_Piston_UV.get(1L) }; + ItemStack[] BioLab2 = new ItemStack[GTValues.VN.length - 3]; + ItemStack[] RadioHatch2 = new ItemStack[GTValues.VN.length - 3]; + Materials[] cables2 = { Materials.Gold, Materials.Aluminium, Materials.Tungsten, Materials.VanadiumGallium, + Materials.Naquadah, Materials.NaquadahAlloy, Materials.SuperconductorUHV }; + Materials[] hulls2 = { Materials.StainlessSteel, Materials.Titanium, Materials.TungstenSteel, Materials.Chrome, + Materials.Iridium, Materials.Osmium, Materials.Naquadah }; + Materials[] wireMat2 = { Materials.Kanthal, Materials.Nichrome, Materials.TungstenSteel, Materials.Naquadah, + Materials.NaquadahAlloy, Materials.SuperconductorUHV }; + Materials[] circuits2 = { Materials.HV, Materials.EV, Materials.IV, Materials.LuV, Materials.ZPM, + Materials.UV }; + + int[] BioLab = new int[] { BioLab_HV.ID, BioLab_EV.ID, BioLab_IV.ID, BioLab_LuV.ID, BioLab_ZPM.ID, BioLab_UV.ID, + BioLab_UHV.ID, BioLab_UEV.ID, BioLab_UIV.ID, BioLab_UMV.ID, BioLab_UXV.ID, BioLab_MAX.ID }; + int[] RadioHatch = new int[] { RadioHatch_HV.ID, RadioHatch_EV.ID, RadioHatch_IV.ID, RadioHatch_LuV.ID, + RadioHatch_ZPM.ID, RadioHatch_UV.ID, RadioHatch_UHV.ID, RadioHatch_UEV.ID, RadioHatch_UIV.ID, + RadioHatch_UMV.ID, RadioHatch_UXV.ID, RadioHatch_MAX.ID }; + + for (int i = 3; i < GTValues.VN.length - 1; i++) { + BioLab2[i - 3] = new MTEBioLab( + BioLab[i - 3], + "bw.biolab" + GTValues.VN[i], + GTValues.VN[i] + " " + StatCollector.translateToLocal("tile.biolab.name"), + i).getStackForm(1L); + RadioHatch2[i - 3] = new GT_MetaTileEntity_RadioHatch( + RadioHatch[i - 3], + "bw.radiohatch" + GTValues.VN[i], + GTValues.VN[i] + " " + StatCollector.translateToLocal("tile.radiohatch.name"), + i).getStackForm(1L); + try { + ItemStack machinehull = ItemList.MACHINE_HULLS[i].get(1L); + GTModHandler.addCraftingRecipe( + BioLab2[i - 3], + RecipeLoader.BITSD, + new Object[] { "PFP", "WCW", "OGO", 'F', + GTOreDictUnificator.get(OrePrefixes.frameGt, hulls2[i - 3], 1L), 'W', + GTOreDictUnificator.get(OrePrefixes.wireGt01, wireMat2[i - 3], 1L), 'P', + GTOreDictUnificator.get(OrePrefixes.plate, Materials.Polytetrafluoroethylene, 1L), 'O', + GTOreDictUnificator.get(OrePrefixes.plate, Materials.Polystyrene, 1L), 'G', + "circuit" + circuits2[i - 3], 'C', machinehull }); + GTModHandler.addCraftingRecipe( + RadioHatch2[i - 3], + RecipeLoader.BITSD, + new Object[] { "DPD", "DCD", "DKD", 'D', + GTOreDictUnificator.get(OrePrefixes.plateDense, Materials.Lead, 1L), 'C', machinehull, 'K', + GTOreDictUnificator.get(OrePrefixes.cableGt08, cables2[i - 3], 1L), 'P', Pistons2[i - 3] }); + } catch (ArrayIndexOutOfBoundsException ignored) { + + } + } + + } +} diff --git a/src/main/java/bartworks/common/loaders/recipes/Electrolyzer.java b/src/main/java/bartworks/common/loaders/recipes/Electrolyzer.java new file mode 100644 index 0000000000..26653743fc --- /dev/null +++ b/src/main/java/bartworks/common/loaders/recipes/Electrolyzer.java @@ -0,0 +1,151 @@ +package bartworks.common.loaders.recipes; + +import static gregtech.api.recipe.RecipeMaps.electrolyzerRecipes; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; +import static gregtech.api.util.GTRecipeBuilder.TICKS; + +import bartworks.system.material.WerkstoffLoader; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GTOreDictUnificator; + +public class Electrolyzer implements Runnable { + + // TODO: fix the chemical balance issues there are below + @Override + public void run() { + + GTValues.RA.stdBuilder() + .itemInputs(WerkstoffLoader.Forsterit.get(OrePrefixes.dust, 7)) + .itemOutputs( + GTOreDictUnificator.get(OrePrefixes.dust, Materials.Magnesium, 2L), + GTOreDictUnificator.get(OrePrefixes.dust, Materials.SiliconDioxide, 1L)) + .fluidOutputs(Materials.Oxygen.getGas(2000L)) + .duration(10 * SECONDS) + .eut(90) + .addTo(electrolyzerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(WerkstoffLoader.RedZircon.get(OrePrefixes.dust, 6)) + .itemOutputs( + WerkstoffLoader.Zirconium.get(OrePrefixes.dust, 1), + GTOreDictUnificator.get(OrePrefixes.dust, Materials.SiliconDioxide, 1L)) + .fluidOutputs(Materials.Oxygen.getGas(2000L)) + .duration(12 * SECONDS + 10 * TICKS) + .eut(90) + .addTo(electrolyzerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(WerkstoffLoader.Fayalit.get(OrePrefixes.dust, 7)) + .itemOutputs( + GTOreDictUnificator.get(OrePrefixes.dust, Materials.Iron, 2L), + GTOreDictUnificator.get(OrePrefixes.dust, Materials.SiliconDioxide, 1L)) + .fluidOutputs(Materials.Oxygen.getGas(2000L)) + .duration(16 * SECONDS) + .eut(90) + .addTo(electrolyzerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(WerkstoffLoader.Prasiolite.get(OrePrefixes.dust, 16)) + .itemOutputs( + GTOreDictUnificator.get(OrePrefixes.dust, Materials.SiliconDioxide, 5L), + GTOreDictUnificator.get(OrePrefixes.dust, Materials.Iron, 1L)) + .duration(29 * SECONDS) + .eut(90) + .addTo(electrolyzerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(WerkstoffLoader.Hedenbergit.get(OrePrefixes.dust, 10)) + .itemOutputs( + GTOreDictUnificator.get(OrePrefixes.dust, Materials.Calcium, 1L), + GTOreDictUnificator.get(OrePrefixes.dust, Materials.Iron, 1L), + GTOreDictUnificator.get(OrePrefixes.dust, Materials.SiliconDioxide, 2L)) + .fluidOutputs(Materials.Oxygen.getGas(2000L)) + .duration(15 * SECONDS) + .eut(90) + .addTo(electrolyzerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(WerkstoffLoader.FuchsitAL.get(OrePrefixes.dust, 21), ItemList.Cell_Empty.get(2)) + .itemOutputs( + GTOreDictUnificator.get(OrePrefixes.dust, Materials.Potassium, 1L), + GTOreDictUnificator.get(OrePrefixes.dust, Materials.Aluminiumoxide, 3L), + GTOreDictUnificator.get(OrePrefixes.dust, Materials.SiliconDioxide, 3L), + GTOreDictUnificator.get(OrePrefixes.cell, Materials.Hydrogen, 2)) + .fluidOutputs(Materials.Oxygen.getGas(2000L)) + .duration(19 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_MV) + .addTo(electrolyzerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(WerkstoffLoader.FuchsitCR.get(OrePrefixes.dust, 21), ItemList.Cell_Empty.get(2)) + .itemOutputs( + GTOreDictUnificator.get(OrePrefixes.dust, Materials.Potassium, 1L), + GTOreDictUnificator.get(OrePrefixes.dust, Materials.Chrome, 3L), + GTOreDictUnificator.get(OrePrefixes.dust, Materials.SiliconDioxide, 3L), + GTOreDictUnificator.get(OrePrefixes.cell, Materials.Hydrogen, 2)) + .fluidOutputs(Materials.Oxygen.getGas(2000L)) + .duration(23 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(electrolyzerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(WerkstoffLoader.VanadioOxyDravit.get(OrePrefixes.dust, 53), ItemList.Cell_Empty.get(3)) + .itemOutputs( + GTOreDictUnificator.get(OrePrefixes.dust, Materials.Sodium, 1L), + GTOreDictUnificator.get(OrePrefixes.dust, Materials.Vanadium, 3L), + GTOreDictUnificator.get(OrePrefixes.dust, Materials.Magnalium, 6L), + GTOreDictUnificator.get(OrePrefixes.dust, Materials.SiliconDioxide, 6), + GTOreDictUnificator.get(OrePrefixes.dust, Materials.Boron, 3), + GTOreDictUnificator.get(OrePrefixes.cell, Materials.Hydrogen, 3)) + .fluidOutputs(Materials.Oxygen.getGas(19000L)) + .duration(35 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_MV) + .addTo(electrolyzerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(WerkstoffLoader.ChromoAluminoPovondrait.get(OrePrefixes.dust, 53), ItemList.Cell_Empty.get(3)) + .itemOutputs( + GTOreDictUnificator.get(OrePrefixes.dust, Materials.Sodium, 1L), + GTOreDictUnificator.get(OrePrefixes.dust, Materials.Chrome, 3L), + GTOreDictUnificator.get(OrePrefixes.dust, Materials.Magnalium, 6L), + GTOreDictUnificator.get(OrePrefixes.dust, Materials.SiliconDioxide, 6), + GTOreDictUnificator.get(OrePrefixes.dust, Materials.Boron, 3), + GTOreDictUnificator.get(OrePrefixes.cell, Materials.Hydrogen, 3)) + .fluidOutputs(Materials.Oxygen.getGas(19000L)) + .duration(36 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(electrolyzerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(WerkstoffLoader.FluorBuergerit.get(OrePrefixes.dust, 50), ItemList.Cell_Empty.get(3)) + .itemOutputs( + GTOreDictUnificator.get(OrePrefixes.dust, Materials.Sodium, 1L), + GTOreDictUnificator.get(OrePrefixes.dust, Materials.Iron, 3L), + GTOreDictUnificator.get(OrePrefixes.dust, Materials.Aluminiumoxide, 6L), + GTOreDictUnificator.get(OrePrefixes.dust, Materials.SiliconDioxide, 6), + GTOreDictUnificator.get(OrePrefixes.dust, Materials.Boron, 3), + GTOreDictUnificator.get(OrePrefixes.cell, Materials.Fluorine, 3)) + .fluidOutputs(Materials.Oxygen.getGas(6000L)) + .duration(36 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_MV) + .addTo(electrolyzerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(WerkstoffLoader.Olenit.get(OrePrefixes.dust, 51), ItemList.Cell_Empty.get(1)) + .itemOutputs( + GTOreDictUnificator.get(OrePrefixes.dust, Materials.Sodium, 1L), + GTOreDictUnificator.get(OrePrefixes.dust, Materials.Aluminiumoxide, 9L), + GTOreDictUnificator.get(OrePrefixes.dust, Materials.SiliconDioxide, 6L), + GTOreDictUnificator.get(OrePrefixes.dust, Materials.Boron, 3), + GTOreDictUnificator.get(OrePrefixes.cell, Materials.Hydrogen, 1)) + .fluidOutputs(Materials.Oxygen.getGas(1000L)) + .duration(39 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_MV) + .addTo(electrolyzerRecipes); + + } +} diff --git a/src/main/java/bartworks/common/loaders/recipes/Extractor.java b/src/main/java/bartworks/common/loaders/recipes/Extractor.java new file mode 100644 index 0000000000..1e99259b3f --- /dev/null +++ b/src/main/java/bartworks/common/loaders/recipes/Extractor.java @@ -0,0 +1,44 @@ +package bartworks.common.loaders.recipes; + +import static gregtech.api.enums.Mods.CropLoadCore; +import static gregtech.api.recipe.RecipeMaps.extractorRecipes; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; + +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +import bartworks.common.loaders.BioItemList; +import bartworks.util.BWUtil; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.TierEU; + +public class Extractor implements Runnable { + + @Override + public void run() { + List<ItemStack> oreCropVine = OreDictionary.getOres("cropVine", false); + if (CropLoadCore.isModLoaded() && !oreCropVine.isEmpty()) { + for (ItemStack stack : oreCropVine) { + + GTValues.RA.stdBuilder() + .itemInputs(BWUtil.setStackSize(stack, 12)) + .itemOutputs(BioItemList.getOther(1)) + .duration(25 * SECONDS) + .eut((int) TierEU.RECIPE_HV) + .addTo(extractorRecipes); + + } + } + + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Circuit_Chip_Stemcell.get(1L)) + .itemOutputs(BioItemList.getOther(4)) + .duration(25 * SECONDS) + .eut((int) TierEU.RECIPE_LuV) + .addTo(extractorRecipes); + + } +} diff --git a/src/main/java/bartworks/common/loaders/recipes/FakeRecipes.java b/src/main/java/bartworks/common/loaders/recipes/FakeRecipes.java new file mode 100644 index 0000000000..372100c187 --- /dev/null +++ b/src/main/java/bartworks/common/loaders/recipes/FakeRecipes.java @@ -0,0 +1,11 @@ +package bartworks.common.loaders.recipes; + +import bartworks.common.tileentities.multis.MTEHighTempGasCooledReactor; + +public class FakeRecipes implements Runnable { + + @Override + public void run() { + MTEHighTempGasCooledReactor.HTGRMaterials.register_fake_THR_Recipes(); + } +} diff --git a/src/main/java/bartworks/common/loaders/recipes/FluidHeater.java b/src/main/java/bartworks/common/loaders/recipes/FluidHeater.java new file mode 100644 index 0000000000..cc8e3cb64a --- /dev/null +++ b/src/main/java/bartworks/common/loaders/recipes/FluidHeater.java @@ -0,0 +1,26 @@ +package bartworks.common.loaders.recipes; + +import static gregtech.api.recipe.RecipeMaps.fluidHeaterRecipes; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; +import static gregtech.api.util.GTRecipeBuilder.TICKS; + +import net.minecraftforge.fluids.FluidStack; + +import bartworks.common.loaders.FluidLoader; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GTUtility; + +public class FluidHeater implements Runnable { + + @Override + public void run() { + GTValues.RA.stdBuilder() + .itemInputs(GTUtility.getIntegratedCircuit(10)) + .fluidInputs(new FluidStack(FluidLoader.fulvicAcid, 1000)) + .fluidOutputs(new FluidStack(FluidLoader.heatedfulvicAcid, 1000)) + .duration(4 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_MV) + .addTo(fluidHeaterRecipes); + } +} diff --git a/src/main/java/bartworks/common/loaders/recipes/FluidSolidifier.java b/src/main/java/bartworks/common/loaders/recipes/FluidSolidifier.java new file mode 100644 index 0000000000..22ed73dae2 --- /dev/null +++ b/src/main/java/bartworks/common/loaders/recipes/FluidSolidifier.java @@ -0,0 +1,102 @@ +package bartworks.common.loaders.recipes; + +import static gregtech.api.recipe.RecipeMaps.fluidSolidifierRecipes; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; + +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; + +import bartworks.common.loaders.ItemRegistry; +import bartworks.system.material.WerkstoffLoader; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.Materials; +import gregtech.api.enums.MaterialsUEVplus; +import gregtech.api.enums.TierEU; + +public class FluidSolidifier implements Runnable { + + @Override + public void run() { + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(Blocks.lapis_block)) + .itemOutputs(new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 0)) + .fluidInputs(Materials.Iron.getMolten(1296L)) + .duration(5 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(fluidSolidifierRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 1)) + .fluidInputs(Materials.Titanium.getMolten(1152)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(fluidSolidifierRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 2)) + .fluidInputs(Materials.TungstenSteel.getMolten(1152)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_EV) + .addTo(fluidSolidifierRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 3)) + .fluidInputs(WerkstoffLoader.LuVTierMaterial.getMolten(1152)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_IV) + .addTo(fluidSolidifierRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 4)) + .fluidInputs(Materials.Iridium.getMolten(1152)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_LuV) + .addTo(fluidSolidifierRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 5)) + .fluidInputs(Materials.Osmium.getMolten(1152)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_ZPM) + .addTo(fluidSolidifierRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 13)) + .fluidInputs(Materials.Neutronium.getMolten(1152)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_UV) + .addTo(fluidSolidifierRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 14)) + .fluidInputs(Materials.CosmicNeutronium.getMolten(1152)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_UHV) + .addTo(fluidSolidifierRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 15)) + .fluidInputs(Materials.Infinity.getMolten(1152)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_UEV) + .addTo(fluidSolidifierRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[1], 1, 0)) + .fluidInputs(MaterialsUEVplus.TranscendentMetal.getMolten(1152)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_UIV) + .addTo(fluidSolidifierRecipes); + + } +} diff --git a/src/main/java/bartworks/common/loaders/recipes/FormingPress.java b/src/main/java/bartworks/common/loaders/recipes/FormingPress.java new file mode 100644 index 0000000000..447f77e7df --- /dev/null +++ b/src/main/java/bartworks/common/loaders/recipes/FormingPress.java @@ -0,0 +1,76 @@ +package bartworks.common.loaders.recipes; + +import static gregtech.api.recipe.RecipeMaps.formingPressRecipes; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; + +import net.minecraft.item.ItemStack; + +import bartworks.common.tileentities.multis.MTEHighTempGasCooledReactor; +import bartworks.common.tileentities.multis.MTEThoriumHighTempReactor; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TierEU; + +public class FormingPress implements Runnable { + + @Override + public void run() { + GTValues.RA.stdBuilder() + .itemInputs( + new ItemStack(MTEThoriumHighTempReactor.THTRMaterials.aTHTR_Materials), + Materials.Graphite.getDust(64)) + .itemOutputs(new ItemStack(MTEThoriumHighTempReactor.THTRMaterials.aTHTR_Materials, 1, 1)) + .duration(2 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(formingPressRecipes); + + GTValues.RA.stdBuilder() + .itemInputs( + new ItemStack(MTEThoriumHighTempReactor.THTRMaterials.aTHTR_Materials, 1, 1), + Materials.Silicon.getDust(64)) + .itemOutputs(new ItemStack(MTEThoriumHighTempReactor.THTRMaterials.aTHTR_Materials, 1, 2)) + .duration(2 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(formingPressRecipes); + + GTValues.RA.stdBuilder() + .itemInputs( + new ItemStack(MTEThoriumHighTempReactor.THTRMaterials.aTHTR_Materials, 1, 2), + Materials.Graphite.getDust(64)) + .itemOutputs(new ItemStack(MTEThoriumHighTempReactor.THTRMaterials.aTHTR_Materials, 1, 3)) + .duration(2 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(formingPressRecipes); + + int i = 0; + for (MTEHighTempGasCooledReactor.HTGRMaterials.Fuel_ fuel : MTEHighTempGasCooledReactor.HTGRMaterials.sHTGR_Fuel) { + GTValues.RA.stdBuilder() + .itemInputs( + new ItemStack(MTEHighTempGasCooledReactor.HTGRMaterials.aHTGR_Materials, 1, i), + Materials.Carbon.getDust(64)) + .itemOutputs(new ItemStack(MTEHighTempGasCooledReactor.HTGRMaterials.aHTGR_Materials, 1, i + 1)) + .duration(2 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(formingPressRecipes); + + GTValues.RA.stdBuilder() + .itemInputs( + new ItemStack(MTEHighTempGasCooledReactor.HTGRMaterials.aHTGR_Materials, 1, i + 1), + Materials.Silicon.getDust(64)) + .itemOutputs(new ItemStack(MTEHighTempGasCooledReactor.HTGRMaterials.aHTGR_Materials, 1, i + 2)) + .duration(2 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(formingPressRecipes); + + GTValues.RA.stdBuilder() + .itemInputs( + new ItemStack(MTEHighTempGasCooledReactor.HTGRMaterials.aHTGR_Materials, 1, i + 2), + Materials.Graphite.getDust(64)) + .itemOutputs(new ItemStack(MTEHighTempGasCooledReactor.HTGRMaterials.aHTGR_Materials, 1, i + 3)) + .duration(2 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(formingPressRecipes); + i += MTEHighTempGasCooledReactor.HTGRMaterials.MATERIALS_PER_FUEL; + } + } +} diff --git a/src/main/java/bartworks/common/loaders/recipes/LaserEngraver.java b/src/main/java/bartworks/common/loaders/recipes/LaserEngraver.java new file mode 100644 index 0000000000..1983232704 --- /dev/null +++ b/src/main/java/bartworks/common/loaders/recipes/LaserEngraver.java @@ -0,0 +1,27 @@ +package bartworks.common.loaders.recipes; + +import static gregtech.api.recipe.RecipeMaps.laserEngraverRecipes; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; + +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +import bartworks.common.loaders.BioItemList; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GTUtility; + +public class LaserEngraver implements Runnable { + + @Override + public void run() { + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(Items.emerald), GTUtility.getIntegratedCircuit(17)) + .itemOutputs(BioItemList.getPlasmidCell(null)) + .duration(5 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(laserEngraverRecipes); + + } +} diff --git a/src/main/java/bartworks/common/loaders/recipes/Mixer.java b/src/main/java/bartworks/common/loaders/recipes/Mixer.java new file mode 100644 index 0000000000..6f15c3773f --- /dev/null +++ b/src/main/java/bartworks/common/loaders/recipes/Mixer.java @@ -0,0 +1,62 @@ +package bartworks.common.loaders.recipes; + +import static gregtech.api.enums.Mods.Gendustry; +import static gregtech.api.recipe.RecipeMaps.mixerRecipes; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import bartworks.common.loaders.FluidLoader; +import bartworks.common.tileentities.multis.MTEHighTempGasCooledReactor; +import bartworks.common.tileentities.multis.MTEThoriumHighTempReactor; +import bartworks.system.material.WerkstoffLoader; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.GTUtility; + +public class Mixer implements Runnable { + + @Override + public void run() { + GTValues.RA.stdBuilder() + .itemInputs( + WerkstoffLoader.Thorium232.get(OrePrefixes.dust, 10), + Materials.Uranium235.getDust(1), + GTUtility.getIntegratedCircuit(2)) + .itemOutputs(new ItemStack(MTEThoriumHighTempReactor.THTRMaterials.aTHTR_Materials)) + .duration(20 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(mixerRecipes); + + int i = 0; + for (MTEHighTempGasCooledReactor.HTGRMaterials.Fuel_ fuel : MTEHighTempGasCooledReactor.HTGRMaterials.sHTGR_Fuel) { + GTValues.RA.stdBuilder() + .itemInputs(fuel.mainItem, fuel.secondaryItem, GTUtility.getIntegratedCircuit(1)) + .itemOutputs(new ItemStack(MTEHighTempGasCooledReactor.HTGRMaterials.aHTGR_Materials, 1, i)) + .duration(20 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(mixerRecipes); + + i += MTEHighTempGasCooledReactor.HTGRMaterials.MATERIALS_PER_FUEL; + } + + if (Gendustry.isModLoaded()) { + GTValues.RA.stdBuilder() + .itemInputs( + GTUtility.getIntegratedCircuit(17), + GTOreDictUnificator.get(OrePrefixes.cell, Materials.Radon, 1L)) + .itemOutputs(Materials.Empty.getCells(1)) + .fluidInputs(FluidRegistry.getFluidStack("liquiddna", 1000)) + .fluidOutputs(new FluidStack(FluidLoader.BioLabFluidMaterials[0], 2000)) + .duration(25 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(mixerRecipes); + } + + } +} diff --git a/src/main/java/bartworks/common/loaders/recipes/Pulverizer.java b/src/main/java/bartworks/common/loaders/recipes/Pulverizer.java new file mode 100644 index 0000000000..0d0bf316a6 --- /dev/null +++ b/src/main/java/bartworks/common/loaders/recipes/Pulverizer.java @@ -0,0 +1,97 @@ +package bartworks.common.loaders.recipes; + +import static gregtech.api.recipe.RecipeMaps.maceratorRecipes; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; + +import net.minecraft.item.ItemStack; + +import bartworks.common.loaders.ItemRegistry; +import bartworks.system.material.WerkstoffLoader; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.Materials; +import gregtech.api.enums.MaterialsUEVplus; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; + +public class Pulverizer implements Runnable { + + @Override + public void run() { + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 1)) + .itemOutputs(Materials.BorosilicateGlass.getDust(9), Materials.Titanium.getDust(8)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_EV) + .addTo(maceratorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 2)) + .itemOutputs(Materials.BorosilicateGlass.getDust(9), Materials.TungstenSteel.getDust(8)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_IV) + .addTo(maceratorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 3)) + .itemOutputs( + Materials.BorosilicateGlass.getDust(9), + WerkstoffLoader.LuVTierMaterial.get(OrePrefixes.dust, 8)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_LuV) + .addTo(maceratorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 4)) + .itemOutputs(Materials.BorosilicateGlass.getDust(9), Materials.Iridium.getDust(8)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_ZPM) + .addTo(maceratorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 5)) + .itemOutputs(Materials.BorosilicateGlass.getDust(9), Materials.Osmium.getDust(8)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_UV) + .addTo(maceratorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 13)) + .itemOutputs(Materials.BorosilicateGlass.getDust(9), Materials.Neutronium.getDust(8)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_UHV) + .addTo(maceratorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 14)) + .itemOutputs(Materials.BorosilicateGlass.getDust(9), Materials.CosmicNeutronium.getDust(8)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_UEV) + .addTo(maceratorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 15)) + .itemOutputs(Materials.BorosilicateGlass.getDust(9), Materials.Infinity.getDust(8)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_UIV) + .addTo(maceratorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[1], 1, 0)) + .itemOutputs(Materials.BorosilicateGlass.getDust(9), MaterialsUEVplus.TranscendentMetal.getDust(8)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_UMV) + .addTo(maceratorRecipes); + + for (int i = 6; i < 11; i++) { + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, i)) + .itemOutputs(Materials.BorosilicateGlass.getDust(9)) + .duration(20 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(maceratorRecipes); + + } + } +} diff --git a/src/main/java/bartworks/common/loaders/recipes/PyrolyseOven.java b/src/main/java/bartworks/common/loaders/recipes/PyrolyseOven.java new file mode 100644 index 0000000000..4e457ab021 --- /dev/null +++ b/src/main/java/bartworks/common/loaders/recipes/PyrolyseOven.java @@ -0,0 +1,27 @@ +package bartworks.common.loaders.recipes; + +import static gregtech.api.recipe.RecipeMaps.pyrolyseRecipes; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; +import static gregtech.api.util.GTRecipeBuilder.TICKS; + +import net.minecraftforge.fluids.FluidStack; + +import bartworks.common.loaders.FluidLoader; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GTUtility; + +public class PyrolyseOven implements Runnable { + + @Override + public void run() { + GTValues.RA.stdBuilder() + .itemInputs(GTUtility.getIntegratedCircuit(10), Materials.Wood.getDust(10)) + .fluidInputs(new FluidStack(FluidLoader.Kerogen, 1000)) + .fluidOutputs(Materials.Oil.getFluid(1000)) + .duration(5 * SECONDS + 5 * TICKS) + .eut(TierEU.RECIPE_HV) + .addTo(pyrolyseRecipes); + } +} diff --git a/src/main/java/bartworks/common/net/BWNetwork.java b/src/main/java/bartworks/common/net/BWNetwork.java new file mode 100644 index 0000000000..78ab09e367 --- /dev/null +++ b/src/main/java/bartworks/common/net/BWNetwork.java @@ -0,0 +1,170 @@ +/* + * 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.common.net; + +import java.util.EnumMap; +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; + +import com.google.common.io.ByteArrayDataInput; +import com.google.common.io.ByteStreams; + +import cpw.mods.fml.common.network.FMLEmbeddedChannel; +import cpw.mods.fml.common.network.FMLOutboundHandler; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.server.FMLServerHandler; +import gregtech.api.enums.GTValues; +import gregtech.api.net.GTPacket; +import gregtech.api.net.GTPacketNew; +import gregtech.api.net.IGT_NetworkHandler; +import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.SimpleChannelInboundHandler; +import io.netty.handler.codec.MessageToMessageCodec; + +/* + * Original GT File slightly Modified + */ +@SuppressWarnings("deprecation") +@ChannelHandler.Sharable +public class BWNetwork extends MessageToMessageCodec<FMLProxyPacket, GTPacketNew> implements IGT_NetworkHandler { + + private final EnumMap<Side, FMLEmbeddedChannel> mChannel; + private final GTPacketNew[] mSubChannels; + + public BWNetwork() { + this.mChannel = NetworkRegistry.INSTANCE.newChannel("BartWorks", this, new BWNetwork.HandlerShared()); + this.mSubChannels = new GTPacketNew[] { new RendererPacket(), new CircuitProgrammerPacket(), + new MetaBlockPacket(), new OreDictCachePacket(), new ServerJoinedPacket(), new EICPacket() }; + } + + @Override + protected void encode(ChannelHandlerContext aContext, GTPacketNew aPacket, List<Object> aOutput) throws Exception { + aOutput.add( + new FMLProxyPacket( + Unpooled.buffer() + .writeByte(aPacket.getPacketID()) + .writeBytes(aPacket.encode()) + .copy(), + aContext.channel() + .attr(NetworkRegistry.FML_CHANNEL) + .get())); + } + + @Override + protected void decode(ChannelHandlerContext aContext, FMLProxyPacket aPacket, List<Object> aOutput) + throws Exception { + ByteArrayDataInput aData = ByteStreams.newDataInput( + aPacket.payload() + .array()); + aOutput.add(this.mSubChannels[aData.readByte()].decode(aData)); + } + + @Override + public void sendToPlayer(@Nonnull GTPacket aPacket, @Nonnull EntityPlayerMP aPlayer) { + this.mChannel.get(Side.SERVER) + .attr(FMLOutboundHandler.FML_MESSAGETARGET) + .set(FMLOutboundHandler.OutboundTarget.PLAYER); + this.mChannel.get(Side.SERVER) + .attr(FMLOutboundHandler.FML_MESSAGETARGETARGS) + .set(aPlayer); + this.mChannel.get(Side.SERVER) + .writeAndFlush(aPacket); + } + + public void sendToAllPlayersinWorld(@Nonnull GTPacket aPacket, World world) { + for (String name : FMLServerHandler.instance() + .getServer() + .getAllUsernames()) { + this.mChannel.get(Side.SERVER) + .attr(FMLOutboundHandler.FML_MESSAGETARGET) + .set(FMLOutboundHandler.OutboundTarget.PLAYER); + this.mChannel.get(Side.SERVER) + .attr(FMLOutboundHandler.FML_MESSAGETARGETARGS) + .set(world.getPlayerEntityByName(name)); + this.mChannel.get(Side.SERVER) + .writeAndFlush(aPacket); + } + } + + @Override + public void sendToAllAround(@Nonnull GTPacket aPacket, NetworkRegistry.TargetPoint aPosition) { + this.mChannel.get(Side.SERVER) + .attr(FMLOutboundHandler.FML_MESSAGETARGET) + .set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT); + this.mChannel.get(Side.SERVER) + .attr(FMLOutboundHandler.FML_MESSAGETARGETARGS) + .set(aPosition); + this.mChannel.get(Side.SERVER) + .writeAndFlush(aPacket); + } + + @Override + public void sendToAll(@Nonnull GTPacket aPacket) { + this.mChannel.get(Side.SERVER) + .attr(FMLOutboundHandler.FML_MESSAGETARGET) + .set(FMLOutboundHandler.OutboundTarget.ALL); + this.mChannel.get(Side.SERVER) + .writeAndFlush(aPacket); + } + + @Override + public void sendToServer(@Nonnull GTPacket aPacket) { + this.mChannel.get(Side.CLIENT) + .attr(FMLOutboundHandler.FML_MESSAGETARGET) + .set(FMLOutboundHandler.OutboundTarget.TOSERVER); + this.mChannel.get(Side.CLIENT) + .writeAndFlush(aPacket); + } + + @Override + public void sendPacketToAllPlayersInRange(World aWorld, @Nonnull GTPacket aPacket, int aX, int aZ) { + if (!aWorld.isRemote) { + + for (Object tObject : aWorld.playerEntities) { + if (!(tObject instanceof EntityPlayerMP tPlayer)) { + break; + } + + Chunk tChunk = aWorld.getChunkFromBlockCoords(aX, aZ); + if (tPlayer.getServerForPlayer() + .getPlayerManager() + .isPlayerWatchingChunk(tPlayer, tChunk.xPosition, tChunk.zPosition)) { + this.sendToPlayer(aPacket, tPlayer); + } + } + } + } + + @Sharable + static final class HandlerShared extends SimpleChannelInboundHandler<GTPacketNew> { + + HandlerShared() {} + + @Override + protected void channelRead0(ChannelHandlerContext ctx, GTPacketNew aPacket) throws Exception { + EntityPlayer aPlayer = GTValues.GT.getThePlayer(); + aPacket.process(aPlayer == null ? null : GTValues.GT.getThePlayer().worldObj); + } + } +} diff --git a/src/main/java/bartworks/common/net/CircuitProgrammerPacket.java b/src/main/java/bartworks/common/net/CircuitProgrammerPacket.java new file mode 100644 index 0000000000..998d10cbfa --- /dev/null +++ b/src/main/java/bartworks/common/net/CircuitProgrammerPacket.java @@ -0,0 +1,88 @@ +/* + * 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.common.net; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.DimensionManager; + +import com.google.common.io.ByteArrayDataInput; + +import bartworks.common.items.ItemCircuitProgrammer; +import gregtech.api.net.GTPacketNew; +import io.netty.buffer.ByteBuf; + +public class CircuitProgrammerPacket extends GTPacketNew { + + private int dimID, playerID; + private byte chipCfg; + private boolean hasChip; + + public CircuitProgrammerPacket() { + super(true); + } + + public CircuitProgrammerPacket(int dimID, int playerID, boolean hasChip, byte chipCfg) { + super(false); + this.dimID = dimID; + this.playerID = playerID; + this.hasChip = hasChip; + this.chipCfg = chipCfg; + } + + @Override + public byte getPacketID() { + return 1; + } + + @Override + public void encode(ByteBuf aOut) { + aOut.writeInt(this.dimID) + .writeInt(this.playerID) + .writeByte(this.hasChip ? this.chipCfg : -1); + } + + @Override + public GTPacketNew decode(ByteArrayDataInput byteArrayDataInput) { + return new CircuitProgrammerPacket( + byteArrayDataInput.readInt(), + byteArrayDataInput.readInt(), + byteArrayDataInput.readByte() > -1, + byteArrayDataInput.readByte()); + } + + @Override + public void process(IBlockAccess iBlockAccess) { + World w = DimensionManager.getWorld(this.dimID); + if (w != null && w.getEntityByID(this.playerID) instanceof EntityPlayer) { + ItemStack stack = ((EntityPlayer) w.getEntityByID(this.playerID)).getHeldItem(); + if (stack != null && stack.stackSize > 0) { + Item item = stack.getItem(); + if (item instanceof ItemCircuitProgrammer) { + NBTTagCompound nbt = stack.getTagCompound(); + nbt.setBoolean("HasChip", this.hasChip); + if (this.hasChip) nbt.setByte("ChipConfig", this.chipCfg); + stack.setTagCompound(nbt); + ((EntityPlayer) w.getEntityByID(this.playerID)).inventory.setInventorySlotContents( + ((EntityPlayer) w.getEntityByID(this.playerID)).inventory.currentItem, + stack); + } + } + } + } +} diff --git a/src/main/java/bartworks/common/net/EICPacket.java b/src/main/java/bartworks/common/net/EICPacket.java new file mode 100644 index 0000000000..9d2414a0e0 --- /dev/null +++ b/src/main/java/bartworks/common/net/EICPacket.java @@ -0,0 +1,60 @@ +package bartworks.common.net; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; + +import com.google.common.io.ByteArrayDataInput; + +import bartworks.API.SideReference; +import bartworks.common.tileentities.multis.MTEElectricImplosionCompressor; +import bartworks.util.Coords; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.net.GTPacketNew; +import io.netty.buffer.ByteBuf; + +public class EICPacket extends GTPacketNew { + + private Coords coords; + private boolean bool; + + public EICPacket() { + super(true); + } + + public EICPacket(Coords coords, boolean bool) { + super(false); + this.coords = coords; + this.bool = bool; + } + + @Override + public byte getPacketID() { + return 5; + } + + @Override + public void encode(ByteBuf aOut) { + aOut.writeInt(this.coords.x); + aOut.writeInt(this.coords.y); + aOut.writeInt(this.coords.z); + aOut.writeBoolean(this.bool); + } + + @Override + public GTPacketNew decode(ByteArrayDataInput aData) { + return new EICPacket(new Coords(aData.readInt(), aData.readInt(), aData.readInt()), aData.readBoolean()); + } + + @Override + public void process(IBlockAccess aWorld) { + if (SideReference.Side.Client) { + TileEntity te = aWorld.getTileEntity(this.coords.x, this.coords.y, this.coords.z); + if (!(te instanceof IGregTechTileEntity)) return; + IMetaTileEntity mte = ((IGregTechTileEntity) te).getMetaTileEntity(); + if (!(mte instanceof MTEElectricImplosionCompressor)) return; + if (this.bool && !((IGregTechTileEntity) te).hasMufflerUpgrade()) + ((IGregTechTileEntity) te).addMufflerUpgrade(); + } + } +} diff --git a/src/main/java/bartworks/common/net/MetaBlockPacket.java b/src/main/java/bartworks/common/net/MetaBlockPacket.java new file mode 100644 index 0000000000..ee8ab8231a --- /dev/null +++ b/src/main/java/bartworks/common/net/MetaBlockPacket.java @@ -0,0 +1,108 @@ +/* + * 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.common.net; + +import java.nio.ByteBuffer; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import com.google.common.io.ByteArrayDataInput; + +import bartworks.MainMod; +import bartworks.system.material.TileEntityMetaGeneratedBlock; +import bartworks.util.MurmurHash3; +import gregtech.api.net.GTPacketNew; +import io.netty.buffer.ByteBuf; + +public class MetaBlockPacket extends GTPacketNew { + + int x; + short y; + int z; + short meta; + + public MetaBlockPacket(int x, int y, int z, int meta) { + super(false); + this.x = x; + this.y = (short) y; + this.z = z; + this.meta = (short) meta; + } + + public MetaBlockPacket() { + super(true); + } + + @Override + public byte getPacketID() { + return 2; + } + + @Override + public void encode(ByteBuf aOut) { + int hash = MurmurHash3.murmurhash3_x86_32( + ByteBuffer.allocate(12) + .putInt(this.x) + .putInt(this.z) + .putShort(this.y) + .putShort(this.meta) + .array(), + 0, + 12, + 31); + aOut.writeInt(this.x) + .writeInt(this.z) + .writeShort(this.y) + .writeShort(this.meta) + .writeInt(hash); + } + + @Override + public GTPacketNew decode(ByteArrayDataInput byteArrayDataInput) { + this.x = byteArrayDataInput.readInt(); + this.z = byteArrayDataInput.readInt(); + this.y = byteArrayDataInput.readShort(); + this.meta = byteArrayDataInput.readShort(); + MetaBlockPacket todecode = new MetaBlockPacket(this.x, this.y, this.z, this.meta); + if (byteArrayDataInput.readInt() != MurmurHash3.murmurhash3_x86_32( + ByteBuffer.allocate(12) + .putInt(this.x) + .putInt(this.z) + .putShort(this.y) + .putShort(this.meta) + .array(), + 0, + 12, + 31)) { + MainMod.LOGGER.error("PACKET HASH DOES NOT MATCH!"); + return null; + } + return todecode; + } + + @Override + public void process(IBlockAccess iBlockAccess) { + if (iBlockAccess != null) { + TileEntity tTileEntity = iBlockAccess.getTileEntity(this.x, this.y, this.z); + if (tTileEntity instanceof TileEntityMetaGeneratedBlock) { + ((TileEntityMetaGeneratedBlock) tTileEntity).mMetaData = this.meta; + } + if (iBlockAccess instanceof World && ((World) iBlockAccess).isRemote) { + ((World) iBlockAccess).markBlockForUpdate(this.x, this.y, this.z); + } + } + } +} diff --git a/src/main/java/bartworks/common/net/OreDictCachePacket.java b/src/main/java/bartworks/common/net/OreDictCachePacket.java new file mode 100644 index 0000000000..b8cda117ac --- /dev/null +++ b/src/main/java/bartworks/common/net/OreDictCachePacket.java @@ -0,0 +1,71 @@ +/* + * 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.common.net; + +import java.util.HashSet; + +import net.minecraft.world.IBlockAccess; + +import com.google.common.io.ByteArrayDataInput; + +import bartworks.system.oredict.OreDictHandler; +import bartworks.util.Pair; +import gregtech.api.net.GTPacketNew; +import io.netty.buffer.ByteBuf; + +public class OreDictCachePacket extends GTPacketNew { + + private HashSet<Pair<Integer, Short>> hashSet = new HashSet<>(); + + public OreDictCachePacket() { + super(true); + } + + public OreDictCachePacket(HashSet<Pair<Integer, Short>> set) { + super(false); + this.hashSet = set; + } + + @Override + public byte getPacketID() { + return 3; + } + + @Override + public void encode(ByteBuf aOut) { + int size = this.hashSet.size(); + aOut.writeInt(size); + for (Pair<Integer, Short> p : this.hashSet) { + aOut.writeInt(p.getKey()) + .writeShort(p.getValue()); + } + } + + @Override + public GTPacketNew decode(ByteArrayDataInput byteArrayDataInput) { + int size = byteArrayDataInput.readInt(); + for (int i = 0; i < size; i++) { + this.hashSet.add(new Pair<>(byteArrayDataInput.readInt(), byteArrayDataInput.readShort())); + } + return new OreDictCachePacket(this.hashSet); + } + + @Override + public void process(IBlockAccess iBlockAccess) { + OreDictHandler.getNonBWCache() + .clear(); + OreDictHandler.getNonBWCache() + .addAll(this.hashSet); + } +} diff --git a/src/main/java/bartworks/common/net/RendererPacket.java b/src/main/java/bartworks/common/net/RendererPacket.java new file mode 100644 index 0000000000..f4f03c3584 --- /dev/null +++ b/src/main/java/bartworks/common/net/RendererPacket.java @@ -0,0 +1,99 @@ +/* + * 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.common.net; + +import net.minecraft.world.IBlockAccess; + +import com.google.common.io.ByteArrayDataInput; + +import bartworks.API.SideReference; +import bartworks.MainMod; +import bartworks.common.tileentities.multis.MTEBioVat; +import bartworks.util.BWColorUtil; +import bartworks.util.Coords; +import gregtech.api.net.GTPacketNew; +import io.netty.buffer.ByteBuf; + +public class RendererPacket extends GTPacketNew { + + private Coords coords; + private int integer; + private byte removal; + + public RendererPacket() { + super(true); + } + + public RendererPacket(Coords coords, int integer, boolean removal) { + super(false); + this.coords = coords; + this.integer = integer; + this.removal = (byte) (removal ? 1 : 0); + } + + @Override + public byte getPacketID() { + return 0; + } + + @Override + public void encode(ByteBuf aOut) { + byte r = (byte) (this.integer >> 16 & 0xFF); + byte g = (byte) (this.integer >> 8 & 0xFF); + byte b = (byte) (this.integer & 0xFF); + byte checksum = (byte) (this.coords.x % 25 + this.coords.y % 25 + + this.coords.z % 25 + + this.coords.wID % 25 + + this.integer % 25 + + this.removal); + aOut.writeInt(this.coords.x) + .writeShort(this.coords.y) + .writeInt(this.coords.z) + .writeInt(this.coords.wID) + .writeByte(r) + .writeByte(g) + .writeByte(b) + .writeByte(this.removal) + .writeByte(checksum); + } + + @Override + public GTPacketNew decode(ByteArrayDataInput dataInput) { + this.coords = new Coords(dataInput.readInt(), dataInput.readShort(), dataInput.readInt(), dataInput.readInt()); + this.integer = BWColorUtil + .getColorFromRGBArray(new int[] { dataInput.readByte(), dataInput.readByte(), dataInput.readByte() }); + this.removal = dataInput.readByte(); + + byte checksum = (byte) (this.coords.x % 25 + this.coords.y % 25 + + this.coords.z % 25 + + this.coords.wID % 25 + + this.integer % 25 + + this.removal); + + if (checksum != dataInput.readByte()) { + MainMod.LOGGER.error("BW Packet was corrupted or modified!"); + return null; + } + + return new RendererPacket(this.coords, this.integer, this.removal == 1); + } + + @Override + public void process(IBlockAccess iBlockAccess) { + if (SideReference.Side.Client) { + if (this.removal == 0) MTEBioVat.staticColorMap.put(this.coords, this.integer); + else MTEBioVat.staticColorMap.remove(this.coords); + } + } +} diff --git a/src/main/java/bartworks/common/net/ServerJoinedPacket.java b/src/main/java/bartworks/common/net/ServerJoinedPacket.java new file mode 100644 index 0000000000..e686d56182 --- /dev/null +++ b/src/main/java/bartworks/common/net/ServerJoinedPacket.java @@ -0,0 +1,61 @@ +/* + * 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.common.net; + +import net.minecraft.world.IBlockAccess; + +import com.google.common.io.ByteArrayDataInput; + +import bartworks.MainMod; +import bartworks.common.configs.ConfigHandler; +import gregtech.api.net.GTPacketNew; +import io.netty.buffer.ByteBuf; + +public class ServerJoinedPacket extends GTPacketNew { + + private byte config; + + ServerJoinedPacket() { + super(true); + } + + public ServerJoinedPacket(Object obj) { + super(false); + this.config = (byte) (ConfigHandler.classicMode && ConfigHandler.disableExtraGassesForEBF ? 3 + : ConfigHandler.classicMode ? 2 : ConfigHandler.disableExtraGassesForEBF ? 1 : 0); + } + + @Override + public byte getPacketID() { + return 4; + } + + @Override + public void encode(ByteBuf aOut) { + aOut.writeByte(this.config); + } + + @Override + public GTPacketNew decode(ByteArrayDataInput byteArrayDataInput) { + this.config = byteArrayDataInput.readByte(); + return this; + } + + @Override + public void process(IBlockAccess iBlockAccess) { + boolean gas = (this.config & 1) != 0; + boolean classic = (this.config & 0b10) != 0; + MainMod.runOnPlayerJoined(classic, gas); + } +} diff --git a/src/main/java/bartworks/common/tileentities/classic/TileEntityDimIDBridge.java b/src/main/java/bartworks/common/tileentities/classic/TileEntityDimIDBridge.java new file mode 100644 index 0000000000..6b00b65054 --- /dev/null +++ b/src/main/java/bartworks/common/tileentities/classic/TileEntityDimIDBridge.java @@ -0,0 +1,24 @@ +/* + * 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.common.tileentities.classic; + +import net.minecraft.tileentity.TileEntity; + +public class TileEntityDimIDBridge extends TileEntity { + + @Override + public boolean canUpdate() { + return false; + } +} diff --git a/src/main/java/bartworks/common/tileentities/classic/TileEntityHeatedWaterPump.java b/src/main/java/bartworks/common/tileentities/classic/TileEntityHeatedWaterPump.java new file mode 100644 index 0000000000..3f973e8eea --- /dev/null +++ b/src/main/java/bartworks/common/tileentities/classic/TileEntityHeatedWaterPump.java @@ -0,0 +1,375 @@ +/* + * 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.common.tileentities.classic; + +import java.util.Arrays; +import java.util.Optional; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidEvent; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import net.minecraftforge.fluids.IFluidTank; + +import com.gtnewhorizons.modularui.api.ModularUITextures; +import com.gtnewhorizons.modularui.api.forge.IItemHandlerModifiable; +import com.gtnewhorizons.modularui.api.forge.InvWrapper; +import com.gtnewhorizons.modularui.api.screen.ITileWithModularUI; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.ProgressBar; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; + +import bartworks.API.ITileAddsInformation; +import bartworks.API.ITileDropsContent; +import bartworks.API.ITileHasDifferentTextureSides; +import bartworks.API.modularUI.BWUITextures; +import bartworks.MainMod; +import bartworks.common.configs.ConfigHandler; +import gregtech.api.util.GTUtility; +import gregtech.common.Pollution; + +public class TileEntityHeatedWaterPump extends TileEntity implements ITileDropsContent, IFluidHandler, IFluidTank, + ITileWithModularUI, ITileAddsInformation, ITileHasDifferentTextureSides { + + public static final int FUELSLOT = 0; + public static final Fluid WATER = FluidRegistry.WATER; + public ItemStack fuelstack; + public FluidStack outputstack = new FluidStack(FluidRegistry.WATER, 0); + public int fuel; + public byte tick; + public int maxfuel; + public ItemStack fakestack = new ItemStack(Blocks.water); + + @Override + public void writeToNBT(NBTTagCompound compound) { + NBTTagCompound subItemStack = new NBTTagCompound(); + if (this.fuelstack != null) { + this.fuelstack.writeToNBT(subItemStack); + } + compound.setTag("ItemStack", subItemStack); + NBTTagCompound subFluidStack = new NBTTagCompound(); + this.outputstack.writeToNBT(subFluidStack); + compound.setTag("FluidStack", subFluidStack); + compound.setInteger("fuel", this.fuel); + compound.setInteger("maxfuel", this.maxfuel); + compound.setByte("tick", this.tick); + super.writeToNBT(compound); + } + + @Override + public void readFromNBT(NBTTagCompound compound) { + this.tick = compound.getByte("tick"); + this.fuel = compound.getInteger("fuel"); + this.maxfuel = compound.getInteger("maxfuel"); + this.outputstack = FluidStack.loadFluidStackFromNBT(compound.getCompoundTag("FluidStack")); + if (!compound.getCompoundTag("ItemStack") + .equals(new NBTTagCompound())) + this.fuelstack = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("ItemStack")); + super.readFromNBT(compound); + } + + private boolean checkPreUpdate() { + return (this.fuelstack == null || this.fuelstack.stackSize <= 0) && this.fuel <= 0; + } + + private void fixUnderlflow() { + if (this.fuel < 0) this.fuel = 0; + } + + private void handleRefuel() { + if (this.fuelstack != null && this.fuel == 0) { + this.fuel = this.maxfuel = TileEntityFurnace.getItemBurnTime(this.fuelstack); + --this.fuelstack.stackSize; + if (this.fuelstack.stackSize <= 0) this.fuelstack = fuelstack.getItem() + .getContainerItem(fuelstack); + } + } + + private void handleWaterGeneration() { + if (this.fuel > 0) { + ++this.tick; + --this.fuel; + if (this.tick % 20 == 0) { + if (this.outputstack.amount <= 8000 - ConfigHandler.mbWaterperSec) + this.outputstack.amount += ConfigHandler.mbWaterperSec; + this.tick = 0; + } + } + } + + @Override + public void updateEntity() { + if (this.worldObj.isRemote) return; + + this.pushWaterToAdjacentTiles(); + this.fakestack.setStackDisplayName(this.outputstack.amount + "L Water"); + if (this.checkPreUpdate()) return; + + this.fixUnderlflow(); + this.handleRefuel(); + this.handleWaterGeneration(); + this.causePollution(); + } + + private void pushWaterToAdjacentTiles() { + Arrays.stream(ForgeDirection.values(), 0, 6) // All but Unknown + .forEach( + direction -> Optional + .ofNullable( + this.worldObj.getTileEntity( + this.xCoord + direction.offsetX, + this.yCoord + direction.offsetY, + this.zCoord + direction.offsetZ)) + .ifPresent(te -> { + if (te instanceof IFluidHandler tank) { + if (tank.canFill(direction.getOpposite(), this.outputstack.getFluid())) { + int drainage = tank.fill(direction.getOpposite(), this.outputstack, false); + if (drainage > 0) { + tank.fill(direction.getOpposite(), this.outputstack, true); + this.drain(drainage, true); + } + } + } else if (te instanceof IFluidTank tank) { + int drainage = tank.fill(this.outputstack, false); + if (drainage > 0) { + tank.fill(this.outputstack, true); + this.drain(drainage, true); + } + } + })); + } + + private void causePollution() { + Optional.ofNullable(this.worldObj) + .ifPresent(e -> { + if (e.getTotalWorldTime() % 20 == 0) { + Optional.ofNullable(e.getChunkFromBlockCoords(this.xCoord, this.zCoord)) + .ifPresent(c -> Pollution.addPollution(c, ConfigHandler.pollutionHeatedWaterPumpSecond)); + } + }); + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return new int[] { 0 }; + } + + @Override + public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { + return TileEntityFurnace.getItemBurnTime(p_102007_2_) > 0; + } + + @Override + public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { + return false; + } + + @Override + public int getSizeInventory() { + return 2; + } + + @Override + public ItemStack getStackInSlot(int slotIn) { + if (slotIn == 0) return this.fuelstack; + return this.fakestack; + } + + @Override + public ItemStack decrStackSize(int slot, int ammount) { + if (slot != TileEntityHeatedWaterPump.FUELSLOT || this.fuelstack == null || ammount > this.fuelstack.stackSize) + return null; + + return this.fuelstack.splitStack(ammount); + } + + @Override + public ItemStack getStackInSlotOnClosing(int index) { + return null; + } + + @Override + public void setInventorySlotContents(int slot, ItemStack stack) { + if (slot == TileEntityHeatedWaterPump.FUELSLOT) this.fuelstack = stack; + else this.fakestack = stack; + } + + @Override + public String getInventoryName() { + return null; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return true; + } + + @Override + public void openInventory() {} + + @Override + public void closeInventory() {} + + @Override + public boolean isItemValidForSlot(int index, ItemStack stack) { + return TileEntityFurnace.getItemBurnTime(stack) > 0 && index == TileEntityHeatedWaterPump.FUELSLOT; + } + + @Override + public FluidStack getFluid() { + return this.outputstack.amount > 0 ? this.outputstack : null; + } + + @Override + public int getFluidAmount() { + return this.outputstack.amount; + } + + @Override + public int getCapacity() { + return 8000; + } + + @Override + public FluidTankInfo getInfo() { + return new FluidTankInfo(this); + } + + @Override + public int fill(FluidStack resource, boolean doFill) { + return 0; + } + + @Override + public FluidStack drain(int maxDrain, boolean doDrain) { + int actualdrain = maxDrain; + if (actualdrain > this.outputstack.amount) actualdrain = this.outputstack.amount; + FluidStack ret = new FluidStack(TileEntityHeatedWaterPump.WATER, actualdrain); + if (ret.amount == 0) ret = null; + if (doDrain) { + this.outputstack.amount -= actualdrain; + FluidEvent.fireEvent( + new FluidEvent.FluidDrainingEvent( + this.outputstack, + this.getWorldObj(), + this.xCoord, + this.yCoord, + this.zCoord, + this, + actualdrain)); + } + return ret; + } + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + return 0; + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + if (resource != null && resource.getFluid() == TileEntityHeatedWaterPump.WATER + && this.drain(resource.amount, false) != null) return this.drain(resource.amount, doDrain); + return null; + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + return this.drain(maxDrain, doDrain); + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return false; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return fluid == null || fluid == TileEntityHeatedWaterPump.WATER; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) { + return new FluidTankInfo[] { this.getInfo() }; + } + + @Override + public String[] getInfoData() { + return new String[] { + StatCollector.translateToLocal("tooltip.tile.waterpump.0.name") + " " + + GTUtility.formatNumbers(ConfigHandler.mbWaterperSec) + + String.format( + StatCollector.translateToLocal("tooltip.tile.waterpump.1.name"), + ConfigHandler.pollutionHeatedWaterPumpSecond), + StatCollector.translateToLocal("tooltip.tile.waterpump.2.name") }; + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + ITileHasDifferentTextureSides.texture[ForgeDirection.UP.ordinal()] = par1IconRegister + .registerIcon(MainMod.MOD_ID + ":heatedWaterPumpTop"); + ITileHasDifferentTextureSides.texture[ForgeDirection.DOWN.ordinal()] = par1IconRegister + .registerIcon(MainMod.MOD_ID + ":heatedWaterPumpDown"); + for (int i = 2; i < 7; i++) { + ITileHasDifferentTextureSides.texture[i] = par1IconRegister + .registerIcon(MainMod.MOD_ID + ":heatedWaterPumpSide"); + } + } + + @Override + public ModularWindow createWindow(UIBuildContext buildContext) { + ModularWindow.Builder builder = ModularWindow.builder(176, 166); + builder.setBackground(ModularUITextures.VANILLA_BACKGROUND); + builder.bindPlayerInventory(buildContext.getPlayer()); + final IItemHandlerModifiable invWrapper = new InvWrapper(this); + + builder.widget( + new SlotWidget(invWrapper, 0).setFilter(stack -> TileEntityFurnace.getItemBurnTime(stack) > 0) + .setPos(55, 52)) + .widget( + SlotWidget.phantom(invWrapper, 1) + .disableInteraction() + .setPos(85, 32)) + .widget( + new ProgressBar().setProgress(() -> (float) this.fuel / this.maxfuel) + .setTexture(BWUITextures.PROGRESSBAR_FUEL, 14) + .setDirection(ProgressBar.Direction.UP) + .setPos(56, 36) + .setSize(14, 14)); + + return builder.build(); + } +} diff --git a/src/main/java/bartworks/common/tileentities/classic/TileEntityRotorBlock.java b/src/main/java/bartworks/common/tileentities/classic/TileEntityRotorBlock.java new file mode 100644 index 0000000000..78c7f34710 --- /dev/null +++ b/src/main/java/bartworks/common/tileentities/classic/TileEntityRotorBlock.java @@ -0,0 +1,41 @@ +/* + * 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.common.tileentities.classic; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; + +import bartworks.client.gui.GuiContainerRotorBlock; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.core.block.kineticgenerator.container.ContainerWindKineticGenerator; +import ic2.core.block.kineticgenerator.tileentity.TileEntityWindKineticGenerator; + +public class TileEntityRotorBlock extends TileEntityWindKineticGenerator { + + public int getGrindPower() { + return super.getKuOutput(); + } + + @Override + public int getKuOutput() { + return 0; + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer entityPlayer, boolean isAdmin) { + return new GuiContainerRotorBlock(new ContainerWindKineticGenerator(entityPlayer, this)); + } +} diff --git a/src/main/java/bartworks/common/tileentities/debug/MTECreativeScanner.java b/src/main/java/bartworks/common/tileentities/debug/MTECreativeScanner.java new file mode 100644 index 0000000000..a1ccd7d4e3 --- /dev/null +++ b/src/main/java/bartworks/common/tileentities/debug/MTECreativeScanner.java @@ -0,0 +1,70 @@ +/* + * 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.common.tileentities.debug; + +import net.minecraft.util.StatCollector; + +import org.apache.commons.lang3.ArrayUtils; + +import bartworks.util.BWTooltipReference; +import gregtech.api.enums.MachineType; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.common.tileentities.machines.basic.MTEScanner; + +public class MTECreativeScanner extends MTEScanner { + + public MTECreativeScanner(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public MTECreativeScanner(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTECreativeScanner(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public String[] getDescription() { + return ArrayUtils.addAll( + MachineType.SCANNER.tooltipDescription(), + StatCollector.translateToLocal("gt.blockmachines.creativeScanner.desc.1"), + BWTooltipReference.ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS.get()); + } + + @Override + public long maxEUStore() { + return 0; + } + + @Override + protected boolean hasEnoughEnergyToCheckRecipe() { + return true; + } + + @Override + protected boolean drainEnergyForProcess(long aEUt) { + return true; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + this.mProgresstime = this.mMaxProgresstime; + super.onPostTick(aBaseMetaTileEntity, aTick); + } +} diff --git a/src/main/java/bartworks/common/tileentities/multis/MTEBioVat.java b/src/main/java/bartworks/common/tileentities/multis/MTEBioVat.java new file mode 100644 index 0000000000..b982c0d886 --- /dev/null +++ b/src/main/java/bartworks/common/tileentities/multis/MTEBioVat.java @@ -0,0 +1,834 @@ +/* + * 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.common.tileentities.multis; + +import static bartworks.util.BWTooltipReference.MULTIBLOCK_ADDED_BY_BARTWORKS; +import static bartworks.util.BWUtil.ofGlassTiered; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.isAir; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockAnyMeta; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_GLOW; +import static gregtech.api.util.GTStructureUtility.ofHatchAdder; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; + +import javax.annotation.Nullable; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; + +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import bartworks.API.SideReference; +import bartworks.API.recipe.BartWorksRecipeMaps; +import bartworks.MainMod; +import bartworks.common.configs.ConfigHandler; +import bartworks.common.items.ItemLabParts; +import bartworks.common.loaders.FluidLoader; +import bartworks.common.net.RendererPacket; +import bartworks.common.tileentities.tiered.GT_MetaTileEntity_RadioHatch; +import bartworks.util.BWUtil; +import bartworks.util.BioCulture; +import bartworks.util.Coords; +import bartworks.util.MathUtils; +import bartworks.util.ResultWrongSievert; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.implementations.MTEEnhancedMultiBlockBase; +import gregtech.api.metatileentity.implementations.MTEHatchInput; +import gregtech.api.metatileentity.implementations.MTEHatchOutput; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.ParallelHelper; + +public class MTEBioVat extends MTEEnhancedMultiBlockBase<MTEBioVat> { + + public static final HashMap<Coords, Integer> staticColorMap = new HashMap<>(); + + private static final byte TIMERDIVIDER = 20; + + private final HashSet<EntityPlayerMP> playerMPHashSet = new HashSet<>(); + private final ArrayList<GT_MetaTileEntity_RadioHatch> mRadHatches = new ArrayList<>(); + private int height = 1; + private Fluid mFluid = FluidRegistry.LAVA; + private BioCulture mCulture; + private ItemStack mStack; + private boolean needsVisualUpdate = true; + private byte mGlassTier; + private int mSievert; + private int mNeededSievert; + private int mCasing = 0; + private int mExpectedMultiplier = 0; + private int mTimes = 0; + private boolean isVisibleFluid = false; + + public MTEBioVat(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEBioVat(String aName) { + super(aName); + } + + private static final int CASING_INDEX = 49; + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition<MTEBioVat> STRUCTURE_DEFINITION = StructureDefinition.<MTEBioVat>builder() + .addShape( + STRUCTURE_PIECE_MAIN, + transpose( + new String[][] { { "ccccc", "ccccc", "ccccc", "ccccc", "ccccc" }, + { "ggggg", "gaaag", "gaaag", "gaaag", "ggggg" }, { "ggggg", "gaaag", "gaaag", "gaaag", "ggggg" }, + { "cc~cc", "ccccc", "ccccc", "ccccc", "ccccc" }, })) + .addElement( + 'c', + ofChain( + ofHatchAdder(MTEBioVat::addMaintenanceToMachineList, CASING_INDEX, 1), + ofHatchAdder(MTEBioVat::addOutputToMachineList, CASING_INDEX, 1), + ofHatchAdder(MTEBioVat::addInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(MTEBioVat::addRadiationInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(MTEBioVat::addEnergyInputToMachineList, CASING_INDEX, 1), + onElementPass(e -> e.mCasing++, ofBlock(GregTechAPI.sBlockCasings4, 1)))) + .addElement('a', ofChain(isAir(), ofBlockAnyMeta(FluidLoader.bioFluidBlock))) + .addElement( + 'g', + ofGlassTiered((byte) 1, (byte) 127, (byte) 0, (te, v) -> te.mGlassTier = v, te -> te.mGlassTier, 1)) + .build(); + + @Override + public IStructureDefinition<MTEBioVat> getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && f.isNotFlipped(); + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType("Bacterial Vat") + .addInfo("Controller block for the Bacterial Vat") + .addInfo("For maximum efficiency boost keep the Output Hatch always half filled!") + .addSeparator() + .beginStructureBlock(5, 4, 5, false) + .addController("Front bottom center") + .addCasingInfoMin("Clean Stainless Steel Casings", 19, false) + .addOtherStructurePart("Glass", "Hollow two middle layers", 2) + .addStructureInfo("The glass can be any glass, i.e. Tinkers Construct Clear Glass") + .addStructureInfo("Some Recipes need more advanced Glass Types") + .addMaintenanceHatch("Any casing", 1) + .addOtherStructurePart("Radio Hatch", "Any casing", 1) + .addInputBus("Any casing", 1) + .addOutputBus("Any casing", 1) + .addInputHatch("Any casing", 1) + .addOutputHatch("Any casing", 1) + .addEnergyHatch("Any casing", 1) + .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTWORKS); + return tt; + } + + public static int[] specialValueUnpack(int aSpecialValue) { + int[] ret = new int[4]; + ret[0] = aSpecialValue & 0xF; // = glass tier + ret[1] = aSpecialValue >>> 4 & 0b11; // = special value + ret[2] = aSpecialValue >>> 6 & 0b1; // boolean exact svt | 1 = true | 0 = false + ret[3] = aSpecialValue >>> 7 & Integer.MAX_VALUE; // = sievert + return ret; + } + + private int getInputCapacity() { + return this.mInputHatches.stream() + .mapToInt(MTEHatchInput::getCapacity) + .sum(); + } + + private int getOutputCapacity() { + return this.mOutputHatches.stream() + .mapToInt(MTEHatchOutput::getCapacity) + .sum(); + } + + @Override + public int getCapacity() { + int ret = 0; + ret += this.getInputCapacity(); + // ret += getOutputCapacity(); + return ret; + } + + @Override + public int fill(FluidStack resource, boolean doFill) { + return super.fill(resource, doFill); + } + + @Override + public boolean isCorrectMachinePart(ItemStack itemStack) { + return true; + } + + @Override + public RecipeMap<?> getRecipeMap() { + return BartWorksRecipeMaps.bacterialVatRecipes; + } + + /** + * Calculates the expected output multiplier based on the output hatch + * + * @param recipeFluidOutput the recipe fluid output + * @param needEqual if the recipeFluidOutput should be equal to the fluid in the output hatch + * @return the expected output multiplier + */ + private int getExpectedMultiplier(@Nullable FluidStack recipeFluidOutput, boolean needEqual) { + FluidStack storedFluidOutputs = this.getStoredFluidOutputs(); + if (storedFluidOutputs == null) return 1; + if (!needEqual || storedFluidOutputs.isFluidEqual(recipeFluidOutput)) { + return this.calcMod(storedFluidOutputs.amount) + 1; + } + return 1; + } + + private int calcMod(double x) { + double y = this.getOutputCapacity() / 2D, z = ConfigHandler.bioVatMaxParallelBonus; + + int ret = MathUtils.ceilInt((-1D / y * Math.pow(x - y, 2D) + y) / y * z); + return MathUtils.clamp(1, ret, ConfigHandler.bioVatMaxParallelBonus); + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@NotNull GTRecipe recipe) { + if (!BWUtil.areStacksEqualOrNull((ItemStack) recipe.mSpecialItems, MTEBioVat.this.getControllerSlot())) + return CheckRecipeResultRegistry.NO_RECIPE; + int[] conditions = MTEBioVat.specialValueUnpack(recipe.mSpecialValue); + MTEBioVat.this.mNeededSievert = conditions[3]; + + if (MTEBioVat.this.mGlassTier < conditions[0]) { + return CheckRecipeResultRegistry.insufficientMachineTier(conditions[0]); + } + + if (conditions[2] == 0) { + if (MTEBioVat.this.mSievert < MTEBioVat.this.mNeededSievert) { + return ResultWrongSievert.insufficientSievert(MTEBioVat.this.mNeededSievert); + } + } else if (MTEBioVat.this.mSievert != conditions[3]) { + return ResultWrongSievert.wrongSievert(conditions[3]); + } + + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @NotNull + @Override + protected ParallelHelper createParallelHelper(@NotNull GTRecipe recipe) { + return super.createParallelHelper(recipeWithMultiplier(recipe, inputFluids)); + } + }; + } + + protected GTRecipe recipeWithMultiplier(GTRecipe recipe, FluidStack[] fluidInputs) { + GTRecipe tRecipe = recipe.copy(); + int multiplier = getExpectedMultiplier(recipe.getFluidOutput(0), true); + mExpectedMultiplier = multiplier; + // Calculate max multiplier limited by input fluids + long fluidAmount = 0; + for (FluidStack fluid : fluidInputs) { + if (recipe.mFluidInputs[0].isFluidEqual(fluid)) { + fluidAmount += fluid.amount; + } + } + multiplier = (int) Math.min(multiplier, fluidAmount / recipe.mFluidInputs[0].amount); + // In case multiplier is 0 + multiplier = Math.max(multiplier, 1); + mTimes = multiplier; + tRecipe.mFluidInputs[0].amount *= multiplier; + tRecipe.mFluidOutputs[0].amount *= multiplier; + return tRecipe; + } + + @Override + protected void setupProcessingLogic(ProcessingLogic logic) { + super.setupProcessingLogic(logic); + logic.setSpecialSlotItem(this.getControllerSlot()); + } + + public FluidStack getStoredFluidOutputs() { + // Only one output Hatch + assert this.mOutputHatches.size() == 1; + return this.mOutputHatches.get(0) + .getFluid(); + } + + private boolean addRadiationInputToMachineList(IGregTechTileEntity aTileEntity, int CasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null || !(aMetaTileEntity instanceof GT_MetaTileEntity_RadioHatch)) { + return false; + } else { + ((GT_MetaTileEntity_RadioHatch) aMetaTileEntity).updateTexture(CasingIndex); + return this.mRadHatches.add((GT_MetaTileEntity_RadioHatch) aMetaTileEntity); + } + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) { + this.mRadHatches.clear(); + this.mGlassTier = 0; + this.mCasing = 0; + + if (!this.checkPiece(STRUCTURE_PIECE_MAIN, 2, 3, 0)) return false; + + return this.mCasing >= 19 && this.mRadHatches.size() <= 1 + && this.mOutputHatches.size() == 1 + && this.mMaintenanceHatches.size() == 1 + && this.mInputHatches.size() > 0 + && this.mEnergyHatches.size() > 0; + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack itemStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack itemStack) { + return 0; + } + + private void sendAllRequiredRendererPackets() { + int height = this.reCalculateHeight(); + if (this.mFluid != null && height > 1 && this.reCalculateFluidAmmount() > 0) { + for (int x = -1; x < 2; x++) for (int y = 1; y < height; y++) + for (int z = -1; z < 2; z++) this.sendPackagesOrRenewRenderer(x, y, z, this.mCulture); + } + } + + private void sendPackagesOrRenewRenderer(int x, int y, int z, BioCulture lCulture) { + int xDir = this.getXDir(); + int zDir = this.getZDir(); + + MTEBioVat.staticColorMap.remove( + new Coords( + xDir + x + + this.getBaseMetaTileEntity() + .getXCoord(), + y + this.getBaseMetaTileEntity() + .getYCoord(), + zDir + z + + this.getBaseMetaTileEntity() + .getZCoord(), + this.getBaseMetaTileEntity() + .getWorld().provider.dimensionId)); + MTEBioVat.staticColorMap.put( + new Coords( + xDir + x + + this.getBaseMetaTileEntity() + .getXCoord(), + y + this.getBaseMetaTileEntity() + .getYCoord(), + zDir + z + + this.getBaseMetaTileEntity() + .getZCoord(), + this.getBaseMetaTileEntity() + .getWorld().provider.dimensionId), + lCulture == null ? BioCulture.NULLCULTURE.getColorRGB() : lCulture.getColorRGB()); + + if (SideReference.Side.Server) { + MainMod.BW_Network_instance.sendPacketToAllPlayersInRange( + this.getBaseMetaTileEntity() + .getWorld(), + new RendererPacket( + new Coords( + xDir + x + + this.getBaseMetaTileEntity() + .getXCoord(), + y + this.getBaseMetaTileEntity() + .getYCoord(), + zDir + z + + this.getBaseMetaTileEntity() + .getZCoord(), + this.getBaseMetaTileEntity() + .getWorld().provider.dimensionId), + lCulture == null ? BioCulture.NULLCULTURE.getColorRGB() : lCulture.getColorRGB(), + true), + this.getBaseMetaTileEntity() + .getXCoord(), + this.getBaseMetaTileEntity() + .getZCoord()); + MainMod.BW_Network_instance.sendPacketToAllPlayersInRange( + this.getBaseMetaTileEntity() + .getWorld(), + new RendererPacket( + new Coords( + xDir + x + + this.getBaseMetaTileEntity() + .getXCoord(), + y + this.getBaseMetaTileEntity() + .getYCoord(), + zDir + z + + this.getBaseMetaTileEntity() + .getZCoord(), + this.getBaseMetaTileEntity() + .getWorld().provider.dimensionId), + lCulture == null ? BioCulture.NULLCULTURE.getColorRGB() : lCulture.getColorRGB(), + false), + this.getBaseMetaTileEntity() + .getXCoord(), + this.getBaseMetaTileEntity() + .getZCoord()); + } + this.needsVisualUpdate = true; + } + + private void check_Chunk() { + World aWorld = this.getBaseMetaTileEntity() + .getWorld(); + if (!aWorld.isRemote) { + + for (Object tObject : aWorld.playerEntities) { + if (!(tObject instanceof EntityPlayerMP tPlayer)) { + break; + } + Chunk tChunk = aWorld.getChunkFromBlockCoords( + this.getBaseMetaTileEntity() + .getXCoord(), + this.getBaseMetaTileEntity() + .getZCoord()); + if (tPlayer.getServerForPlayer() + .getPlayerManager() + .isPlayerWatchingChunk(tPlayer, tChunk.xPosition, tChunk.zPosition)) { + if (!this.playerMPHashSet.contains(tPlayer)) { + this.playerMPHashSet.add(tPlayer); + this.sendAllRequiredRendererPackets(); + } + } else { + this.playerMPHashSet.remove(tPlayer); + } + } + } + } + + private void placeFluid() { + this.isVisibleFluid = true; + int xDir = this.getXDir(); + int zDir = this.getZDir(); + this.height = this.reCalculateHeight(); + if (this.mFluid != null && this.height > 1 && this.reCalculateFluidAmmount() > 0) for (int x = -1; x < 2; x++) { + for (int y = 0; y < this.height; y++) { + for (int z = -1; z < 2; z++) { + if (this.getBaseMetaTileEntity() + .getWorld() + .getBlock( + xDir + x + + this.getBaseMetaTileEntity() + .getXCoord(), + y + this.getBaseMetaTileEntity() + .getYCoord(), + zDir + z + + this.getBaseMetaTileEntity() + .getZCoord()) + .equals(Blocks.air)) + this.getBaseMetaTileEntity() + .getWorld() + .setBlock( + xDir + x + + this.getBaseMetaTileEntity() + .getXCoord(), + y + this.getBaseMetaTileEntity() + .getYCoord(), + zDir + z + + this.getBaseMetaTileEntity() + .getZCoord(), + FluidLoader.bioFluidBlock); + } + } + } + } + + private void removeFluid(int xDir, int zDir) { + this.isVisibleFluid = false; + + for (int x = -1; x < 2; x++) { + for (int y = 1; y < 3; y++) { + for (int z = -1; z < 2; z++) { + if (this.getBaseMetaTileEntity() + .getWorld() + .getBlock( + xDir + x + + this.getBaseMetaTileEntity() + .getXCoord(), + y + this.getBaseMetaTileEntity() + .getYCoord(), + zDir + z + + this.getBaseMetaTileEntity() + .getZCoord()) + .equals(FluidLoader.bioFluidBlock)) + this.getBaseMetaTileEntity() + .getWorld() + .setBlockToAir( + xDir + x + + this.getBaseMetaTileEntity() + .getXCoord(), + y + this.getBaseMetaTileEntity() + .getYCoord(), + zDir + z + + this.getBaseMetaTileEntity() + .getZCoord()); + MTEBioVat.staticColorMap.remove( + new Coords( + xDir + x + + this.getBaseMetaTileEntity() + .getXCoord(), + y + this.getBaseMetaTileEntity() + .getYCoord(), + zDir + z + + this.getBaseMetaTileEntity() + .getZCoord()), + this.getBaseMetaTileEntity() + .getWorld().provider.dimensionId); + } + } + } + } + + private int reCalculateFluidAmmount() { + return this.getStoredFluids() + .stream() + .mapToInt(fluidStack -> fluidStack.amount) + .sum(); + } + + private int reCalculateHeight() { + return this.reCalculateFluidAmmount() > this.getCapacity() / 4 - 1 + ? this.reCalculateFluidAmmount() >= this.getCapacity() / 2 ? 3 : 2 + : 1; + } + + public void doAllVisualThings() { + if (this.getBaseMetaTileEntity() + .isServerSide()) { + if (this.mMachine) { + ItemStack aStack = this.mInventory[1]; + BioCulture lCulture = null; + int xDir = this.getXDir(); + int zDir = this.getZDir(); + + if (this.getBaseMetaTileEntity() + .getTimer() % 200 == 0) { + this.check_Chunk(); + } + + if (this.needsVisualUpdate && this.getBaseMetaTileEntity() + .getTimer() % MTEBioVat.TIMERDIVIDER == 0) { + for (int x = -1; x < 2; x++) + for (int y = 1; y < 3; y++) for (int z = -1; z < 2; z++) this.getBaseMetaTileEntity() + .getWorld() + .setBlockToAir( + xDir + x + + this.getBaseMetaTileEntity() + .getXCoord(), + y + this.getBaseMetaTileEntity() + .getYCoord(), + zDir + z + + this.getBaseMetaTileEntity() + .getZCoord()); + } + + this.height = this.reCalculateHeight(); + if (this.mFluid != null && this.height > 1 && this.reCalculateFluidAmmount() > 0) { + if (!BWUtil.areStacksEqualOrNull(aStack, this.mStack) + || this.needsVisualUpdate && this.getBaseMetaTileEntity() + .getTimer() % MTEBioVat.TIMERDIVIDER == 1) { + for (int x = -1; x < 2; x++) { + for (int y = 1; y < this.height; y++) { + for (int z = -1; z < 2; z++) { + if (aStack == null + || aStack.getItem() instanceof ItemLabParts && aStack.getItemDamage() == 0) { + if (this.mCulture == null || aStack == null + || aStack.getTagCompound() == null + || this.mCulture.getID() != aStack.getTagCompound() + .getInteger("ID")) { + lCulture = aStack == null || aStack.getTagCompound() == null ? null + : BioCulture.getBioCulture( + aStack.getTagCompound() + .getString("Name")); + this.sendPackagesOrRenewRenderer(x, y, z, lCulture); + } + } + } + } + } + this.mStack = aStack; + this.mCulture = lCulture; + } + if (this.needsVisualUpdate && this.getBaseMetaTileEntity() + .getTimer() % MTEBioVat.TIMERDIVIDER == 1) { + if (this.getBaseMetaTileEntity() + .isClientSide()) new Throwable().printStackTrace(); + this.placeFluid(); + this.needsVisualUpdate = false; + } + } + } else { + this.onRemoval(); + } + } + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (this.height != this.reCalculateHeight()) this.needsVisualUpdate = true; + this.doAllVisualThings(); + if (this.getBaseMetaTileEntity() + .isServerSide() && this.mRadHatches.size() == 1) { + this.mSievert = this.mRadHatches.get(0) + .getSievert(); + if (this.getBaseMetaTileEntity() + .isActive() && this.mNeededSievert > this.mSievert) this.mOutputFluids = null; + } + if (aBaseMetaTileEntity.isServerSide() && this.mMaxProgresstime <= 0) { + this.mTimes = 0; + this.mMaxProgresstime = 0; + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mFluidHeight", this.height); + if (this.mCulture != null && !this.mCulture.getName() + .isEmpty()) aNBT.setString("mCulture", this.mCulture.getName()); + else if ((this.mCulture == null || this.mCulture.getName() + .isEmpty()) && !aNBT.getString("mCulture") + .isEmpty()) { + aNBT.removeTag("mCulture"); + } + if (this.mFluid != null) aNBT.setString("mFluid", this.mFluid.getName()); + aNBT.setInteger("mSievert", this.mSievert); + aNBT.setInteger("mNeededSievert", this.mNeededSievert); + aNBT.setBoolean("isVisibleFluid", this.isVisibleFluid); + super.saveNBTData(aNBT); + } + + @Override + public void onRemoval() { + if (this.isVisibleFluid) { + int xDir = this.getXDir(); + int zDir = this.getZDir(); + this.removeFluid(xDir, zDir); + this.sendRenderPackets(xDir, zDir); + } else if (this.getBaseMetaTileEntity() + .getWorld() + .getWorldTime() % 20 == 7) { + this.sendRenderPackets(); + } + + super.onRemoval(); + } + + private int getXDir() { + return this.getBaseMetaTileEntity() + .getBackFacing().offsetX * 2; + } + + private int getZDir() { + return this.getBaseMetaTileEntity() + .getBackFacing().offsetZ * 2; + } + + private void sendRenderPackets() { + int xDir = this.getXDir(); + int zDir = this.getZDir(); + this.sendRenderPackets(xDir, zDir); + } + + private void sendRenderPackets(int xDir, int zDir) { + if (SideReference.Side.Server) { + for (int x = -1; x < 2; x++) { + for (int y = 1; y < 3; y++) { + for (int z = -1; z < 2; z++) { + MainMod.BW_Network_instance.sendPacketToAllPlayersInRange( + this.getBaseMetaTileEntity() + .getWorld(), + new RendererPacket( + new Coords( + xDir + x + + this.getBaseMetaTileEntity() + .getXCoord(), + y + this.getBaseMetaTileEntity() + .getYCoord(), + zDir + z + + this.getBaseMetaTileEntity() + .getZCoord(), + this.getBaseMetaTileEntity() + .getWorld().provider.dimensionId), + this.mCulture == null ? BioCulture.NULLCULTURE.getColorRGB() + : this.mCulture.getColorRGB(), + true), + this.getBaseMetaTileEntity() + .getXCoord(), + this.getBaseMetaTileEntity() + .getZCoord()); + } + } + } + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.height = aNBT.getInteger("mFluidHeight"); + this.mCulture = BioCulture.getBioCulture(aNBT.getString("mCulture")); + if (!aNBT.getString("mFluid") + .isEmpty()) this.mFluid = FluidRegistry.getFluid(aNBT.getString("mFluid")); + this.mSievert = aNBT.getInteger("mSievert"); + this.mNeededSievert = aNBT.getInteger("mNeededSievert"); + super.loadNBTData(aNBT); + this.isVisibleFluid = aNBT.getBoolean("isVisibleFluid"); + } + + @Override + public boolean explodesOnComponentBreak(ItemStack itemStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new MTEBioVat(this.mName); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + if (aActive) return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE_GLOW) + .extFacing() + .glow() + .build() }; + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX), TextureFactory.builder() + .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_GLOW) + .extFacing() + .glow() + .build() }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX) }; + } + + @Override + public void construct(ItemStack itemStack, boolean b) { + this.buildPiece(STRUCTURE_PIECE_MAIN, itemStack, b, 2, 3, 0); + } + + @Override + public String[] getInfoData() { + final String[] baseInfoData = super.getInfoData(); + final String[] infoData = new String[baseInfoData.length + 2]; + System.arraycopy(baseInfoData, 0, infoData, 0, baseInfoData.length); + // See https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/11923 + // here we must check the machine is well-formed as otherwise getExpectedMultiplier might error out! + infoData[infoData.length - 2] = StatCollector.translateToLocal("BW.infoData.BioVat.expectedProduction") + ": " + + EnumChatFormatting.GREEN + + (this.mMachine + ? (this.mMaxProgresstime <= 0 ? this.getExpectedMultiplier(null, false) : this.mExpectedMultiplier) + * 100 + : -1) + + EnumChatFormatting.RESET + + " %"; + infoData[infoData.length - 1] = StatCollector.translateToLocal("BW.infoData.BioVat.production") + ": " + + EnumChatFormatting.GREEN + + (this.mMaxProgresstime <= 0 ? 0 : this.mTimes) * 100 + + EnumChatFormatting.RESET + + " %"; + return infoData; + } + + @Override + public boolean supportsVoidProtection() { + return true; + } + + @Override + public boolean supportsBatchMode() { + return true; + } + + @Override + public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { + if (aPlayer.isSneaking()) { + batchMode = !batchMode; + if (batchMode) { + GTUtility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); + } else { + GTUtility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); + } + return true; + } + return false; + } + +} diff --git a/src/main/java/bartworks/common/tileentities/multis/MTECircuitAssemblyLine.java b/src/main/java/bartworks/common/tileentities/multis/MTECircuitAssemblyLine.java new file mode 100644 index 0000000000..80f851167d --- /dev/null +++ b/src/main/java/bartworks/common/tileentities/multis/MTECircuitAssemblyLine.java @@ -0,0 +1,672 @@ +/* + * 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.common.tileentities.multis; + +import static bartworks.util.BWTooltipReference.MULTIBLOCK_ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS; +import static bartworks.util.BWUtil.ofGlassTieredMixed; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.SoundResource.IC2_MACHINES_MAGNETIZER_LOOP; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_GLOW; +import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gregtech.api.util.GTUtility.filterValidMTEs; +import static gregtech.api.util.GTUtility.getColoredTierNameFromTier; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import org.jetbrains.annotations.NotNull; + +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.CycleButtonWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; + +import bartworks.API.modularUI.BWUITextures; +import bartworks.API.recipe.BartWorksRecipeMaps; +import bartworks.system.material.CircuitGeneration.BWMetaItems; +import bartworks.system.material.CircuitGeneration.CircuitImprintLoader; +import bartworks.util.BWTooltipReference; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.SoundResource; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.implementations.MTEEnhancedMultiBlockBase; +import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.metatileentity.implementations.MTEHatchInput; +import gregtech.api.metatileentity.implementations.MTEHatchInputBus; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import mcp.mobius.waila.api.IWailaConfigHandler; +import mcp.mobius.waila.api.IWailaDataAccessor; + +public class MTECircuitAssemblyLine extends MTEEnhancedMultiBlockBase<MTECircuitAssemblyLine> + implements ISurvivalConstructable { + + private static final int CASING_INDEX = 16; + + private static final String STRUCTURE_PIECE_FIRST = "first"; + private static final String STRUCTURE_PIECE_NEXT = "next"; + private static final String STRUCTURE_PIECE_NEXT_HINT = "next_hint"; + private static final String STRUCTURE_PIECE_LAST = "last"; + + private static final int MINIMUM_CIRCUIT_ASSEMBLER_LENGTH = 5; + protected static final String IMPRINT_KEY = "Type"; + protected static final String LENGTH_KEY = "Length"; + protected static final String RUNNING_MODE_KEY = "RunningMode"; + + private int length; + private int mode; + private String imprintedItemName; + private ItemStack imprintedStack; + + private static final IStructureDefinition<MTECircuitAssemblyLine> STRUCTURE_DEFINITION = StructureDefinition + .<MTECircuitAssemblyLine>builder() + .addShape( + STRUCTURE_PIECE_FIRST, + transpose(new String[][] { { "~", "G", "G" }, { "g", "l", "g" }, { "b", "i", "b" }, })) + .addShape( + STRUCTURE_PIECE_NEXT, + transpose(new String[][] { { "G", "G", "G" }, { "g", "l", "g" }, { "b", "I", "b" }, })) + .addShape( + STRUCTURE_PIECE_NEXT_HINT, + transpose(new String[][] { { "G", "G", "G" }, { "g", "l", "g" }, { "b", "i", "b" }, })) + .addShape( + STRUCTURE_PIECE_LAST, + transpose(new String[][] { { "G", "G", "G" }, { "g", "l", "g" }, { "b", "o", "b" }, })) + .addElement( + 'G', + buildHatchAdder(MTECircuitAssemblyLine.class).atLeast(Energy) + .casingIndex(CASING_INDEX) + .dot(1) + .buildAndChain(GregTechAPI.sBlockCasings3, 10)) + .addElement('g', ofGlassTieredMixed((byte) 4, (byte) 127, 5)) + .addElement('l', ofBlock(GregTechAPI.sBlockCasings2, 5)) // assembling line casings + .addElement( + 'b', + buildHatchAdder(MTECircuitAssemblyLine.class).atLeast(InputHatch, Maintenance) + .casingIndex(CASING_INDEX) + .dot(2) + .disallowOnly(ForgeDirection.EAST, ForgeDirection.WEST) + .buildAndChain(GregTechAPI.sBlockCasings2, 0)) + .addElement('i', InputBus.newAny(CASING_INDEX, 3, ForgeDirection.DOWN)) + .addElement( + 'I', + buildHatchAdder(MTECircuitAssemblyLine.class).atLeast(InputHatch, InputBus, OutputBus) + .casingIndex(CASING_INDEX) + .dot(2) + .disallowOnly(ForgeDirection.EAST, ForgeDirection.WEST) + .buildAndChain(GregTechAPI.sBlockCasings2, 0)) + .addElement('o', OutputBus.newAny(CASING_INDEX, 2, ForgeDirection.DOWN)) + .build(); + + @Override + public IStructureDefinition<MTECircuitAssemblyLine> getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType("Circuit Assembler/Circuit Assembly Line") + .addInfo("Controller block for the Circuit Assembly Line") + .addInfo("Change Mode with Screwdriver") + .addInfo("Does not lose efficiency when overclocked") + .addInfo( + "--------- " + EnumChatFormatting.GOLD + + StatCollector.translateToLocal("chat.cal.mode.0") + + EnumChatFormatting.GRAY + + " --------") + .addInfo("Imprint this machine with a Circuit Imprint,") + .addInfo("by putting the imprint in the controller") + .addInfo("Every Circuit Assembly Line can only be imprinted ONCE") + .addInfo( + "--------- " + EnumChatFormatting.GOLD + + StatCollector.translateToLocal("chat.cal.mode.1") + + EnumChatFormatting.GRAY + + " --------") + .addInfo( + "Does Circuit Assembler recipes, Minimum Length: " + EnumChatFormatting.RED + + MINIMUM_CIRCUIT_ASSEMBLER_LENGTH + + EnumChatFormatting.GRAY) + .addInfo("Recipe tier in Circuit Assembler mode is at most Energy Hatch tier - 1.") + .addInfo("This mode supports Crafting Input Buffer/Bus and allows bus separation") + .addInfo("") + .addSeparator() + .addInfo(BWTooltipReference.TT_BLUEPRINT) + .beginVariableStructureBlock(2, 7, 3, 3, 3, 3, false) + .addStructureInfo("From Bottom to Top, Left to Right") + .addStructureInfo( + "Layer 1 - Solid Steel Machine Casing, Input bus (Last Output bus), Solid Steel Machine Casing") + .addStructureInfo( + "Layer 2 - " + getColoredTierNameFromTier((byte) 4) + + "+ Tier Glass, Assembling Line Casing, " + + getColoredTierNameFromTier((byte) 4) + + "+ Tier Glass") + .addStructureInfo("Layer 3 - Grate Machine Casing") + .addStructureInfo("Up to 7 repeating slices, last is Output Bus") + .addController("Layer 3 first slice front") + .addOtherStructurePart( + "1x " + StatCollector.translateToLocal("GT5U.MBTT.EnergyHatch"), + "Any layer 3 casing", + 1) + .addInputHatch("Any layer 1 casing", 2) + .addInputBus("As specified on layer 1", 3, 4) + .addOutputBus("As specified in final slice on layer 1", 4) + .addOtherStructurePart(getColoredTierNameFromTier((byte) 4) + "+ Tier Glass", "As specified on layer 2", 5) + .addMaintenanceHatch("Any layer 1 casing", 2) + .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS); + return tt; + } + + public String getTypeForDisplay() { + + if (!isImprinted()) return ""; + return GTLanguageManager.getTranslation( + GTLanguageManager.getTranslateableItemStackName(CircuitImprintLoader.getStackFromTag(this.type))); + } + + private NBTTagCompound type = new NBTTagCompound(); + + public MTECircuitAssemblyLine(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + private MTECircuitAssemblyLine(String aName) { + super(aName); + } + + public boolean isImprinted() { + return !this.type.hasNoTags(); + } + + private boolean imprintMachine(ItemStack itemStack) { + if (isImprinted()) return true; + if (!GTUtility.isStackValid(itemStack)) return false; + if (itemStack.getItem() instanceof BWMetaItems.BW_GT_MetaGenCircuits && itemStack.getItemDamage() == 0 + && itemStack.getTagCompound() != null) { + this.type = itemStack.getTagCompound(); + itemStack.stackSize -= 1; + if (itemStack == getControllerSlot() && itemStack.stackSize <= 0) { + mInventory[getControllerSlotIndex()] = null; + } + this.getBaseMetaTileEntity() + .issueBlockUpdate(); + return true; + } + return false; + } + + @Override + public boolean isCorrectMachinePart(ItemStack itemStack) { + return true; + } + + @Override + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == 20) { + GTUtility.doSoundAtClient(IC2_MACHINES_MAGNETIZER_LOOP, 10, 1.0F, aX, aY, aZ); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.type = aNBT.getCompoundTag(IMPRINT_KEY); + this.imprintedItemName = this.type == null ? "" + : GTLanguageManager.getTranslateableItemStackName(ItemStack.loadItemStackFromNBT(this.type)); + mode = aNBT.getInteger(RUNNING_MODE_KEY); + if (aNBT.hasKey(LENGTH_KEY)) { + length = aNBT.getInteger(LENGTH_KEY); + } + super.loadNBTData(aNBT); + } + + @Override + public void setItemNBT(NBTTagCompound aNBT) { + if (isImprinted()) aNBT.setTag(IMPRINT_KEY, this.type); + aNBT.setInteger(RUNNING_MODE_KEY, mode); + super.saveNBTData(aNBT); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + if (isImprinted()) aNBT.setTag(IMPRINT_KEY, this.type); + aNBT.setInteger(RUNNING_MODE_KEY, mode); + aNBT.setInteger(LENGTH_KEY, length); + super.saveNBTData(aNBT); + } + + @Override + public void onLeftclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (mode == 0 && !isImprinted() && getBaseMetaTileEntity().isServerSide()) { + ItemStack heldItem = aPlayer.getHeldItem(); + if (imprintMachine(heldItem)) { + if (heldItem.stackSize <= 0) { + aPlayer.inventory.setInventorySlotContents(aPlayer.inventory.currentItem, null); + } + return; + } + } + super.onLeftclick(aBaseMetaTileEntity, aPlayer); + } + + @Override + public final void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (getBaseMetaTileEntity().isServerSide()) { + this.mode = (this.mode + 1) % 2; + GTUtility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("chat.cal.mode." + this.mode)); + } + super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); + } + + @Override + public RecipeMap<?> getRecipeMap() { + if (this.mode == 0) return BartWorksRecipeMaps.circuitAssemblyLineRecipes; + return RecipeMaps.circuitAssemblerRecipes; + } + + @Nonnull + @Override + public Collection<RecipeMap<?>> getAvailableRecipeMaps() { + return Arrays.asList(BartWorksRecipeMaps.circuitAssemblyLineRecipes, RecipeMaps.circuitAssemblerRecipes); + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @Override + @Nonnull + protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) { + // limit CA mode recipes to hatch tier - 1 + if (MTECircuitAssemblyLine.this.mode == 1 + && recipe.mEUt > MTECircuitAssemblyLine.this.getMaxInputVoltage() / 4) { + return CheckRecipeResultRegistry.NO_RECIPE; + } + return CheckRecipeResultRegistry.SUCCESSFUL; + } + }.enablePerfectOverclock(); + } + + @NotNull + @Override + public CheckRecipeResult checkProcessing() { + if (mode == 0) { + if (!isImprinted() && !this.imprintMachine(this.getControllerSlot())) + return SimpleCheckRecipeResult.ofFailure("no_imprint"); + if (this.imprintedItemName == null || this.imprintedStack == null) { + this.imprintedStack = new ItemStack(BWMetaItems.getCircuitParts(), 1, 0); + this.imprintedStack.setTagCompound(this.type); + this.imprintedItemName = GTLanguageManager.getTranslateableItemStackName(this.imprintedStack); + } + } else if (length < MINIMUM_CIRCUIT_ASSEMBLER_LENGTH) { + return SimpleCheckRecipeResult.ofFailure("not_enough_length"); + } + + return super.checkProcessing(); + } + + @Override + protected void setupProcessingLogic(ProcessingLogic logic) { + super.setupProcessingLogic(logic); + logic.setSpecialSlotItem(this.imprintedStack); + } + + @Override + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_MAGNETIZER_LOOP; + } + + @Override + public ArrayList<ItemStack> getStoredInputs() { + if (mode == 0) { + ArrayList<ItemStack> rList = new ArrayList<>(); + for (MTEHatchInputBus tHatch : filterValidMTEs(mInputBusses)) { + tHatch.mRecipeMap = this.getRecipeMap(); + for (int i = 0; i < tHatch.getBaseMetaTileEntity() + .getSizeInventory(); i++) { + if (tHatch.getBaseMetaTileEntity() + .getStackInSlot(i) != null) { + rList.add( + tHatch.getBaseMetaTileEntity() + .getStackInSlot(i)); + break; + } + } + } + return rList; + } + + return super.getStoredInputs(); + } + + @Override + public boolean addInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof MTEHatchInput) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + ((MTEHatchInput) aMetaTileEntity).mRecipeMap = this.getRecipeMap(); + return this.mInputHatches.add((MTEHatchInput) aMetaTileEntity); + } else if (aMetaTileEntity instanceof MTEHatchInputBus) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + ((MTEHatchInputBus) aMetaTileEntity).mRecipeMap = this.getRecipeMap(); + return this.mInputBusses.add((MTEHatchInputBus) aMetaTileEntity); + } else { + return false; + } + } + + @Override + public boolean addInputHatchToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null || !(aMetaTileEntity instanceof MTEHatchInput)) { + return false; + } else { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + ((MTEHatchInput) aMetaTileEntity).mRecipeMap = this.getRecipeMap(); + return this.mInputHatches.add((MTEHatchInput) aMetaTileEntity); + } + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack itemStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack itemStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack itemStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new MTECircuitAssemblyLine(this.mName); + } + + private String[] infoDataBuffer; + + @Override + public String[] getInfoData() { + if (this.infoDataBuffer != null) return this.infoDataBuffer; + + String[] oldInfo = super.getInfoData(); + this.infoDataBuffer = new String[oldInfo.length + 1]; + System.arraycopy(oldInfo, 0, this.infoDataBuffer, 0, oldInfo.length); + this.infoDataBuffer[oldInfo.length] = StatCollector.translateToLocal("tooltip.cal.imprintedWith") + " " + + EnumChatFormatting.YELLOW + + this.getTypeForDisplay(); + return this.infoDataBuffer; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + if (aActive) return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE_GLOW) + .extFacing() + .glow() + .build() }; + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX), TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ASSEMBLY_LINE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ASSEMBLY_LINE_GLOW) + .extFacing() + .glow() + .build() }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX) }; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + if (!this.checkPiece(STRUCTURE_PIECE_FIRST, 0, 0, 0)) { + return false; + } + return this.checkMachine(true) || this.checkMachine(false); + } + + private boolean checkMachine(boolean leftToRight) { + + for (int i = 1; i < 7; ++i) { + if (!this.checkPiece(STRUCTURE_PIECE_NEXT, leftToRight ? -i : i, 0, 0)) { + return false; + } + length = i + 1; + + if (!this.mOutputBusses.isEmpty()) { + return this.mEnergyHatches.size() == 1 && this.mMaintenanceHatches.size() == 1; + } + } + + return false; + } + + public void construct(ItemStack stackSize, boolean hintsOnly) { + this.buildPiece(STRUCTURE_PIECE_FIRST, stackSize, hintsOnly, 0, 0, 0); + int tLength = Math.min(stackSize.stackSize + 1, 7); + + for (int i = 1; i < tLength; ++i) { + this.buildPiece(STRUCTURE_PIECE_NEXT, stackSize, hintsOnly, -i, 0, 0); + } + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (this.mMachine) return -1; + int built; + built = survivialBuildPiece(STRUCTURE_PIECE_FIRST, stackSize, 0, 0, 0, elementBudget, env, false, true); + if (built >= 0) return built; + int tLength = Math.min(stackSize.stackSize + 1, 7); + + for (int i = 1; i < tLength - 1; ++i) { + built = survivialBuildPiece( + STRUCTURE_PIECE_NEXT_HINT, + stackSize, + -i, + 0, + 0, + elementBudget, + env, + false, + true); + if (built >= 0) return built; + } + return survivialBuildPiece( + STRUCTURE_PIECE_LAST, + stackSize, + -(tLength - 1), + 0, + 0, + elementBudget, + env, + false, + true); + } + + @Override + public void addAdditionalTooltipInformation(ItemStack stack, List<String> tooltip) { + if (stack.hasTagCompound() && stack.stackTagCompound.hasKey(IMPRINT_KEY)) { + tooltip.add( + StatCollector.translateToLocal("tooltip.cal.imprintedWith") + " " + + EnumChatFormatting.YELLOW + + StatCollector.translateToLocal( + GTLanguageManager.getTranslateableItemStackName( + ItemStack.loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("Type"))))); + } + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + super.addUIWidgets(builder, buildContext); + builder + .widget(new FakeSyncWidget.StringSyncer(() -> this.imprintedItemName, val -> this.imprintedItemName = val)); + builder.widget( + new CycleButtonWidget().setToggle(() -> mode == 1, val -> mode = val ? 1 : 0) + .setTextureGetter( + state -> state == 1 ? BWUITextures.OVERLAY_BUTTON_ASSEMBLER_MODE + : BWUITextures.OVERLAY_BUTTON_LINE_MODE) + .setBackground(GTUITextures.BUTTON_STANDARD) + .setPos(80, 91) + .setSize(16, 16) + .dynamicTooltip( + () -> Collections.singletonList(StatCollector.translateToLocal("chat.cal.mode." + mode))) + .setUpdateTooltipEveryTick(true) + .setTooltipShowUpDelay(TOOLTIP_DELAY)); + } + + @Override + public boolean supportsVoidProtection() { + return true; + } + + @Override + public boolean supportsBatchMode() { + return true; + } + + @Override + protected boolean supportsSlotAutomation(int aSlot) { + return aSlot == getControllerSlotIndex(); + } + + @Override + public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { + if (!aPlayer.isSneaking()) { + if (mode == 0) return false; + inputSeparation = !inputSeparation; + GTUtility.sendChatToPlayer( + aPlayer, + StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + inputSeparation); + return true; + } else { + batchMode = !batchMode; + if (batchMode) { + GTUtility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); + } else { + GTUtility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); + } + return true; + } + } + + @Override + public boolean supportsInputSeparation() { + return mode != 0; + } + + @Override + public boolean supportsSingleRecipeLocking() { + return true; + } + + @Override + public boolean isInputSeparationEnabled() { + return mode == 1 && super.isInputSeparationEnabled(); + } + + @Override + public void getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { + super.getWailaBody(itemStack, currenttip, accessor, config); + NBTTagCompound tag = accessor.getNBTData(); + currenttip.add( + StatCollector.translateToLocal("GT5U.machines.oreprocessor1") + " " + + EnumChatFormatting.WHITE + + StatCollector.translateToLocal("chat.cal.mode." + tag.getInteger(RUNNING_MODE_KEY))); + if (tag.hasKey("ImprintedWith") && tag.getInteger(RUNNING_MODE_KEY) == 0) currenttip.add( + StatCollector.translateToLocal("tooltip.cal.imprintedWith") + " " + + EnumChatFormatting.YELLOW + + tag.getString("ImprintedWith")); + } + + @Override + public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y, + int z) { + super.getWailaNBTData(player, tile, tag, world, x, y, z); + String imprintedWith = this.getTypeForDisplay(); + if (!imprintedWith.isEmpty()) tag.setString("ImprintedWith", imprintedWith); + tag.setInteger(RUNNING_MODE_KEY, mode); + } + + @Override + protected boolean supportsCraftingMEBuffer() { + return mode != 0; + } + +} diff --git a/src/main/java/bartworks/common/tileentities/multis/MTEDeepEarthHeatingPump.java b/src/main/java/bartworks/common/tileentities/multis/MTEDeepEarthHeatingPump.java new file mode 100644 index 0000000000..fca10c20fd --- /dev/null +++ b/src/main/java/bartworks/common/tileentities/multis/MTEDeepEarthHeatingPump.java @@ -0,0 +1,336 @@ +/* + * 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.common.tileentities.multis; + +import static bartworks.util.BWTooltipReference.MULTIBLOCK_ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS; +import static gregtech.api.enums.GTValues.VN; + +import java.lang.reflect.Field; +import java.util.Arrays; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; + +import bartworks.common.configs.ConfigHandler; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatchInput; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.common.tileentities.machines.multi.MTEDrillerBase; +import ic2.core.block.reactor.tileentity.TileEntityNuclearReactorElectric; + +public class MTEDeepEarthHeatingPump extends MTEDrillerBase { + + private static float nulearHeatMod = 2f; + private byte mMode; + private byte mTier; + + public MTEDeepEarthHeatingPump(int aID, int tier, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + this.mTier = (byte) tier; + } + + public MTEDeepEarthHeatingPump(String aName, byte mTier) { + super(aName); + this.mTier = mTier; + } + + @Override + @SuppressWarnings("rawtypes") + public void onConfigLoad() { + try { + Class c = TileEntityNuclearReactorElectric.class; + Field f = c.getDeclaredField("huOutputModifier"); + f.setAccessible(true); + MTEDeepEarthHeatingPump.nulearHeatMod = f.getFloat(f); + } catch (SecurityException | IllegalArgumentException | ExceptionInInitializerError | NullPointerException + | IllegalAccessException | NoSuchFieldException e) { + e.printStackTrace(); + } + super.onConfigLoad(); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setByte("mTier", this.mTier); + aNBT.setByte("mMode", this.mMode); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.mTier = aNBT.getByte("mTier"); + this.mMode = aNBT.getByte("mMode"); + super.loadNBTData(aNBT); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new MTEDeepEarthHeatingPump(this.mName, this.mTier); + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + String casings = this.getCasingBlockItem() + .get(0) + .getDisplayName(); + tt.addMachineType("Geothermal Heat Pump") + .addInfo("Consumes " + GTValues.V[this.mTier + 2] + "EU/t") + .addInfo("Has 4 Modes, use the Screwdriver to change them:"); + if (ConfigHandler.DEHPDirectSteam) { + tt.addInfo("0 Idle, 1 Steam, 2 Superheated Steam (requires Distilled Water), 3 Retract") + .addInfo("Explodes when it runs out of Water/Distilled Water") + .addInfo( + "Converts " + (long) (this.mTier * 1200 * 20) + + "L/s Water(minus 10% per Maintenance Problem) to Steam") + .addInfo( + "Converts " + (long) (this.mTier * 600 * 20) + + "L/s Distilled Water(minus 10% per Maintenance Problem) to SuperheatedSteam"); + + } else { + tt.addInfo("0 Idle, 1 & 2 Coolant Heating Mode (no Difference between them), 3 Retract") + .addInfo("Explodes when it runs out of Coolant") + .addInfo( + "Heats up " + (long) (this.mTier * 24 * (double) MTEDeepEarthHeatingPump.nulearHeatMod) * 20 + + "L/s Coolant(minus 10% per Maintenance Problem)"); + } + tt.addSeparator() + .beginStructureBlock(3, 7, 3, false) + .addController("Front bottom") + .addOtherStructurePart(casings, "form the 3x1x3 Base") + .addOtherStructurePart(casings, "1x3x1 pillar above the center of the base (2 minimum total)") + .addOtherStructurePart( + this.getFrameMaterial().mName + " Frame Boxes", + "Each pillar's side and 1x3x1 on top") + .addEnergyHatch(VN[this.getMinTier()] + "+, Any base casing") + .addMaintenanceHatch("Any base casing") + .addInputBus("Mining Pipes, optional, any base casing") + .addInputHatch("Any base casing") + .addOutputHatch("Any base casing") + .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS); + return tt; + } + + @Override + protected ItemList getCasingBlockItem() { + return ItemList.Casing_HeatProof; + } + + @Override + protected Materials getFrameMaterial() { + return Materials.Tungsten; + } + + @Override + protected int getCasingTextureIndex() { + return 11; + } + + @Override + protected int getMinTier() { + return 2 + this.mTier; + } + + @Override + protected boolean checkHatches() { + return !this.mMaintenanceHatches.isEmpty() && !this.mOutputHatches.isEmpty() && !this.mInputHatches.isEmpty(); + } + + private long getFluidFromHatches(Fluid f) { + long ret = 0; + for (MTEHatchInput ih : this.mInputHatches) { + if (ih.getFluid() + .getFluid() + .equals(f)) ret += ih.getFluidAmount(); + } + return ret; + } + + private long getWaterFromHatches(boolean onlyDistilled) { + Fluid toConsume1 = FluidRegistry.WATER; + Fluid toConsume2 = GTModHandler.getDistilledWater(1L) + .getFluid(); + if (onlyDistilled) toConsume1 = toConsume2; + long ret = 0; + for (MTEHatchInput ih : this.mInputHatches) { + if (ih.getFluid() + .getFluid() + .equals(toConsume1) + || ih.getFluid() + .getFluid() + .equals(toConsume2)) + ret += ih.getFluidAmount(); + } + return ret; + } + + @Override + protected boolean workingUpward(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, + int yHead, int oldYHead) { + if (this.mMode != 3) { + this.isPickingPipes = false; + try { + Field workState = this.getClass() + .getField("workState"); + workState.setInt(this, 0); + } catch (NoSuchFieldError | NoSuchFieldException | IllegalAccessException ignored) {} + return true; + } + return super.workingUpward(aStack, xDrill, yDrill, zDrill, xPipe, zPipe, yHead, oldYHead); + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (this.getBaseMetaTileEntity() + .getWorld().isRemote) return; + ++this.mMode; + if (this.mMode >= 4) this.mMode = 0; + GTUtility.sendChatToPlayer(aPlayer, "Mode: " + this.mMode); + super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); + } + + @Override + protected boolean workingDownward(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, + int yHead, int oldYHead) { + if (this.mMode == 3) { + this.isPickingPipes = true; + try { + Field workState = this.getClass() + .getSuperclass() + .getDeclaredField("workState"); + workState.setInt(this, 2); + } catch (NoSuchFieldError | NoSuchFieldException | IllegalAccessException ignored) {} + return true; + } + + if (this.tryLowerPipeState(false) == 0) { + return true; + } + if (this.waitForPipes()) { + return false; + } + if (this.mMode == 0) { + this.mMode = 1; + } + if (ConfigHandler.DEHPDirectSteam) { + if (this.mMode == 1) { + long steamProduced = this.mTier * 600 * 2L * this.mEfficiency / 10000L; + long waterConsume = (steamProduced + 160) / 160; + + if (this.getWaterFromHatches(false) - waterConsume > 0) { + this.consumeFluid(FluidRegistry.WATER, waterConsume); + this.addOutput(GTModHandler.getSteam(steamProduced)); + } else { + this.explodeMultiblock(); + return false; + } + } else if (this.mMode == 2) { + long steamProduced = this.mTier * 300 * 2L * this.mEfficiency / 10000L; + long waterConsume = (steamProduced + 160) / 160; + + if (this.getWaterFromHatches(true) - waterConsume > 0) { + this.consumeFluid( + GTModHandler.getDistilledWater(1) + .getFluid(), + waterConsume); + this.addOutput(FluidRegistry.getFluidStack("ic2superheatedsteam", (int) steamProduced)); + } else { + this.explodeMultiblock(); + return false; + } + } + } else if (this.mMode == 1 || this.mMode == 2) { + long coolantConverted = (long) (this.mTier * 24 + * (double) MTEDeepEarthHeatingPump.nulearHeatMod + * this.mEfficiency + / 10000L); + if (this.getFluidFromHatches(FluidRegistry.getFluid("ic2coolant")) - coolantConverted > 0) { + this.consumeFluid(FluidRegistry.getFluid("ic2coolant"), coolantConverted); + this.addOutput(FluidRegistry.getFluidStack("ic2hotcoolant", (int) coolantConverted)); + } else { + this.explodeMultiblock(); + return false; + } + } + return true; + } + + private boolean consumeFluid(Fluid fluid, long ammount) { + if (ammount > Integer.MAX_VALUE) { + int[] tmp = new int[(int) (ammount / Integer.MAX_VALUE)]; + Arrays.fill(tmp, (int) (ammount / Integer.MAX_VALUE)); + for (int i = 0; i < tmp.length; i++) { + for (MTEHatchInput ih : this.mInputHatches) { + if (fluid.equals(FluidRegistry.WATER) ? ih.getFluid() + .getFluid() + .equals(fluid) + || ih.getFluid() + .getFluid() + .equals( + GTModHandler.getDistilledWater(1) + .getFluid()) + : ih.getFluid() + .getFluid() + .equals(fluid)) + tmp[i] -= ih.drain((int) ammount, true).amount; + if (tmp[i] <= 0) break; + } + } + + return tmp[tmp.length - 1] <= 0; + } + + long tmp = ammount; + for (MTEHatchInput ih : this.mInputHatches) { + if (fluid.equals(FluidRegistry.WATER) ? ih.getFluid() + .getFluid() + .equals(fluid) + || ih.getFluid() + .getFluid() + .equals( + GTModHandler.getDistilledWater(1) + .getFluid()) + : ih.getFluid() + .getFluid() + .equals(fluid)) + tmp -= ih.drain((int) ammount, true).amount; + if (tmp <= 0) return true; + } + return false; + } + + @Override + protected void setElectricityStats() { + try { + this.mEUt = this.isPickingPipes ? 60 : Math.toIntExact(GTValues.V[this.getMinTier()]); + } catch (ArithmeticException e) { + e.printStackTrace(); + this.mEUt = Integer.MAX_VALUE - 7; + } + this.mProgresstime = 0; + this.mMaxProgresstime = 1; + this.mEfficiency = this.getCurrentEfficiency(null); + this.mEfficiencyIncrease = 10000; + } +} diff --git a/src/main/java/bartworks/common/tileentities/multis/MTEElectricImplosionCompressor.java b/src/main/java/bartworks/common/tileentities/multis/MTEElectricImplosionCompressor.java new file mode 100644 index 0000000000..4b99f97ec5 --- /dev/null +++ b/src/main/java/bartworks/common/tileentities/multis/MTEElectricImplosionCompressor.java @@ -0,0 +1,565 @@ +/* + * 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.common.tileentities.multis; + +import static bartworks.common.loaders.ItemRegistry.BW_BLOCKS; +import static bartworks.util.BWTooltipReference.MULTIBLOCK_ADDED_BY_BARTWORKS; +import static bartworks.util.BWTooltipReference.TT; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.isAir; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.ExoticEnergy; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_IMPLOSION_COMPRESSOR; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_IMPLOSION_COMPRESSOR_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_IMPLOSION_COMPRESSOR_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_IMPLOSION_COMPRESSOR_GLOW; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.NotNull; + +import com.gtnewhorizon.structurelib.StructureLibAPI; +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing; +import com.gtnewhorizon.structurelib.structure.AutoPlaceEnvironment; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.IStructureElement; +import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; +import com.gtnewhorizon.structurelib.structure.ITierConverter; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureUtility; + +import bartworks.API.recipe.BartWorksRecipeMaps; +import bartworks.MainMod; +import bartworks.client.renderer.EICPistonVisualizer; +import bartworks.common.configs.ConfigHandler; +import bartworks.common.net.EICPacket; +import bartworks.util.Coords; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import fox.spiteful.avaritia.blocks.LudicrousBlocks; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.Mods; +import gregtech.api.enums.SoundResource; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.implementations.MTEExtendedPowerMultiBlockBase; +import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.OverclockCalculator; + +public class MTEElectricImplosionCompressor extends MTEExtendedPowerMultiBlockBase<MTEElectricImplosionCompressor> + implements ISurvivalConstructable { + + private static final boolean pistonEnabled = !ConfigHandler.disablePistonInEIC; + private Boolean piston = true; + private static final SoundResource sound = SoundResource.RANDOM_EXPLODE; + private final ArrayList<ChunkCoordinates> chunkCoordinates = new ArrayList<>(5); + private int mBlockTier = 0; + private int mCasing; + + public MTEElectricImplosionCompressor(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEElectricImplosionCompressor(String aName) { + super(aName); + } + + private static final int CASING_INDEX = 16; + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition<MTEElectricImplosionCompressor> STRUCTURE_DEFINITION = StructureDefinition + .<MTEElectricImplosionCompressor>builder() + .addShape( + STRUCTURE_PIECE_MAIN, + transpose( + new String[][] { { "ccc", "cec", "ccc" }, { "ttt", "tft", "ttt" }, { "ttt", "tft", "ttt" }, + { "nnn", "nnn", "nnn" }, { "nNn", "NNN", "nNn" }, { "nnn", "nnn", "nnn" }, { "t~t", "tft", "ttt" }, + { "ttt", "tft", "ttt" }, { "CCC", "CeC", "CCC" }, })) + .addElement('c', ofChain(ofBlock(GregTechAPI.sBlockCasings2, 0), ofBlock(GregTechAPI.sBlockCasings3, 4))) + .addElement('t', ofBlock(BW_BLOCKS[2], 1)) + .addElement('f', ofBlock(BW_BLOCKS[2], 0)) + .addElement( + 'n', + StructureUtility.ofBlocksTiered( + tieredBlockConverter(), + getAllBlockTiers(), + 0, + MTEElectricImplosionCompressor::setBlockTier, + MTEElectricImplosionCompressor::getBlockTier)) + .addElement( + 'C', + buildHatchAdder(MTEElectricImplosionCompressor.class) + .atLeast(InputBus, OutputBus, Maintenance, InputHatch, OutputHatch) + .casingIndex(CASING_INDEX) + .dot(1) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(GregTechAPI.sBlockCasings2, 0)), + onElementPass(x -> ++x.mCasing, ofBlock(GregTechAPI.sBlockCasings3, 4)))) + .addElement( + 'e', + buildHatchAdder(MTEElectricImplosionCompressor.class).atLeast(Energy.or(ExoticEnergy)) + .casingIndex(CASING_INDEX) + .dot(2) + .buildAndChain( + onElementPass(x -> ++x.mCasing, ofBlock(GregTechAPI.sBlockCasings2, 0)), + onElementPass(x -> ++x.mCasing, ofBlock(GregTechAPI.sBlockCasings3, 4)))) + .addElement('N', new IStructureElement<>() { + + // Much of this based on StructureUtility.ofBlocksTiered + private final List<Pair<Block, Integer>> tiers = getAllBlockTiers(); + + @Override + public boolean check(MTEElectricImplosionCompressor te, World world, int x, int y, int z) { + if (!te.piston && !world.isAirBlock(x, y, z)) return false; + if (te.piston) { + Block candidate = world.getBlock(x, y, z); + int candidateMeta = world.getBlockMetadata(x, y, z); + return getTierOfBlock(candidate, candidateMeta) != -1; + } + return true; + } + + private Pair<Block, Integer> getTier(ItemStack trigger) { + return this.tiers.get(Math.min(Math.max(trigger.stackSize, 1), this.tiers.size()) - 1); + } + + @Override + public boolean spawnHint(MTEElectricImplosionCompressor te, World world, int x, int y, int z, + ItemStack itemStack) { + Pair<Block, Integer> tier = this.getTier(itemStack); + if (te.piston) StructureLibAPI.hintParticle(world, x, y, z, tier.getKey(), tier.getValue()); + return true; + } + + @Override + public boolean placeBlock(MTEElectricImplosionCompressor te, World world, int x, int y, int z, + ItemStack itemStack) { + Pair<Block, Integer> tier = this.getTier(itemStack); + if (te.piston) world.setBlock(x, y, z, tier.getKey(), tier.getValue(), 3); + else world.setBlockToAir(x, y, z); + return true; + } + + @Override + public BlocksToPlace getBlocksToPlace(MTEElectricImplosionCompressor t, World world, int x, int y, int z, + ItemStack trigger, AutoPlaceEnvironment env) { + return BlocksToPlace.createEmpty(); + } + + @Override + public PlaceResult survivalPlaceBlock(MTEElectricImplosionCompressor t, World world, int x, int y, int z, + ItemStack trigger, AutoPlaceEnvironment env) { + return isAir().survivalPlaceBlock(t, world, x, y, z, trigger, env); + } + }) + .build(); + + public static List<Pair<Block, Integer>> getAllBlockTiers() { + return new ArrayList<>() { + + private static final long serialVersionUID = 8171991663102417651L; + + { + this.add(Pair.of(GregTechAPI.sBlockMetal5, 2)); + if (Mods.Avaritia.isModLoaded()) { + this.add(Pair.of(LudicrousBlocks.resource_block, 1)); + } + this.add(Pair.of(GregTechAPI.sBlockMetal9, 4)); + this.add(Pair.of(GregTechAPI.sBlockMetal9, 3)); + this.add(Pair.of(GregTechAPI.sBlockMetal9, 8)); + } + + }; + } + + public static ITierConverter<Integer> tieredBlockConverter() { + return MTEElectricImplosionCompressor::getTierOfBlock; + } + + private static int getTierOfBlock(Block block, int meta) { + if (block == null) { + return -1; + } + if (block == GregTechAPI.sBlockMetal5 && meta == 2) { + return 1; // Neutronium + } + if (block == LudicrousBlocks.resource_block && meta == 1) { + return 2; // Infinity + } + if (block == GregTechAPI.sBlockMetal9) { + return switch (meta) { + case 4 -> 3; // Transcendent Metal + case 3 -> 4; // SpaceTime + case 8 -> 5; // Universium + default -> -1; + }; + } + return -1; + } + + private void setBlockTier(int tier) { + this.mBlockTier = tier; + } + + private int getBlockTier() { + return this.mBlockTier; + } + + @Override + public IStructureDefinition<MTEElectricImplosionCompressor> getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && f.isNotFlipped(); + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType("Implosion Compressor") + .addInfo("Explosions are fun") + .addInfo("Controller block for the Electric Implosion Compressor") + .addInfo("Uses electricity instead of Explosives") + .addInfo("Can parallel up to 4^(Tier - 1)") + .addInfo("Tier is determined by containment block") + .addInfo("Valid blocks: Neutronium, Infinity, Transcendent Metal, Spacetime, Universium") + .addInfo("Minimum allowed energy hatch tier is one below recipe tier") + .addInfo("Supports " + TT + " energy hatches") + .addSeparator() + .beginStructureBlock(3, 9, 3, false) + .addController("Front 3rd layer center") + .addCasingInfoMin("Solid Steel Machine Casing", 8, false) + .addStructureInfo("Casings can be replaced with Explosion Warning Signs") + .addOtherStructurePart("Transformer-Winding Blocks", "Outer layer 2,3,7,8") + .addOtherStructurePart("Nickel-Zinc-Ferrite Blocks", "Inner layer 2,3,7,8") + .addOtherStructurePart("Containment Blocks", "Layer 4,5,6") + .addMaintenanceHatch("Any bottom casing", 1) + .addInputBus("Any bottom casing", 1) + .addInputHatch("Any bottom casing", 1) + .addOutputBus("Any bottom casing", 1) + .addEnergyHatch("Bottom middle and/or top middle", 2) + .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTWORKS); + return tt; + } + + @Override + public RecipeMap<?> getRecipeMap() { + return BartWorksRecipeMaps.electricImplosionCompressorRecipes; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) { + long voltage = MTEElectricImplosionCompressor.this.getAverageInputVoltage(); + // Only allow a minimum of T-1 energy hatch + if (recipe.mEUt > voltage * 4) { + return CheckRecipeResultRegistry.insufficientPower(recipe.mEUt); + } + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @NotNull + @Override + protected OverclockCalculator createOverclockCalculator(@NotNull GTRecipe recipe) { + // For overclocking we'll allow all power to be used + return super.createOverclockCalculator(recipe) + .setEUt(MTEElectricImplosionCompressor.this.getMaxInputEu()) + .setAmperage(1); + } + }.setMaxParallelSupplier(() -> (int) Math.pow(4, Math.max(this.mBlockTier - 1, 0))); + } + + private void updateChunkCoordinates() { + this.chunkCoordinates.clear(); + + for (int x = -1; x <= 1; x++) for (int z = -1; z <= 1; z++) { + if (Math.abs(x) != 1 || Math.abs(z) != 1) { + int[] abc = { x, -2, z + 1 }; + int[] xyz = { 0, 0, 0 }; + this.getExtendedFacing() + .getWorldOffset(abc, xyz); + xyz[0] += this.getBaseMetaTileEntity() + .getXCoord(); + xyz[1] += this.getBaseMetaTileEntity() + .getYCoord(); + xyz[2] += this.getBaseMetaTileEntity() + .getZCoord(); + this.chunkCoordinates.add(new ChunkCoordinates(xyz[0], xyz[1], xyz[2])); + } + } + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + this.updateChunkCoordinates(); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + + if (pistonEnabled && aBaseMetaTileEntity.isActive() && aTick % 20 == 0) { + if (aBaseMetaTileEntity.isClientSide()) this.animatePiston(aBaseMetaTileEntity); + else if (aBaseMetaTileEntity.hasMufflerUpgrade()) MainMod.BW_Network_instance.sendPacketToAllPlayersInRange( + aBaseMetaTileEntity.getWorld(), + new EICPacket( + new Coords( + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord()), + true), + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getZCoord()); + } + } + + @Override + public void setExtendedFacing(ExtendedFacing newExtendedFacing) { + super.setExtendedFacing(newExtendedFacing); // Will call stopMachine + + this.updateChunkCoordinates(); + } + + @Override + public boolean isCorrectMachinePart(ItemStack itemStack) { + return true; + } + + @Override + public void stopMachine() { + this.resetPiston(this.mBlockTier); + super.stopMachine(); + } + + private void resetPiston(int tier) { + if (!pistonEnabled) return; + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + if (!aBaseMetaTileEntity.isServerSide()) return; + if (!this.piston) { + List<Pair<Block, Integer>> tiers = getAllBlockTiers(); + Pair<Block, Integer> tieredBlock = tiers.get(Math.min(tier, tiers.size()) - 1); + this.chunkCoordinates.forEach(c -> { + // Don't replace real blocks in case user has placed something (e.g. tier upgrade) + if (aBaseMetaTileEntity.getWorld() + .isAirBlock(c.posX, c.posY, c.posZ)) { + aBaseMetaTileEntity.getWorld() + .setBlock(c.posX, c.posY, c.posZ, tieredBlock.getKey(), tieredBlock.getValue(), 3); + } + }); + this.piston = !this.piston; + } + } + + private void activatePiston() { + if (!pistonEnabled) return; + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + if (!aBaseMetaTileEntity.isServerSide()) return; + if (this.piston) { + this.chunkCoordinates.forEach( + c -> aBaseMetaTileEntity.getWorld() + .setBlockToAir(c.posX, c.posY, c.posZ)); + this.piston = !this.piston; + } + } + + private void animatePiston(IGregTechTileEntity aBaseMetaTileEntity) { + if (!aBaseMetaTileEntity.getWorld().isRemote) return; + + if (!this.getBaseMetaTileEntity() + .hasMufflerUpgrade()) + GTUtility.doSoundAtClient( + sound, + 10, + 1f, + 1f, + this.chunkCoordinates.get(0).posX, + this.chunkCoordinates.get(0).posY, + this.chunkCoordinates.get(0).posZ); + this.spawnVisualPistonBlocks( + aBaseMetaTileEntity.getWorld(), + this.chunkCoordinates.get(2).posX, + this.chunkCoordinates.get(2).posY, + this.chunkCoordinates.get(2).posZ, + 10); + } + + @SideOnly(Side.CLIENT) + private void spawnVisualPistonBlocks(World world, int x, int y, int z, int age) { + EICPistonVisualizer pistonVisualizer = new EICPistonVisualizer(world, x, y, z, age); + Minecraft.getMinecraft().effectRenderer.addEffect(pistonVisualizer); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("piston", this.piston); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if (aNBT.hasKey("piston")) this.piston = aNBT.getBoolean("piston"); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) { + int pistonTier = this.mBlockTier; + this.mCasing = 0; + int mMaxHatchTier = 0; + this.setBlockTier(0); + boolean isOK = this.checkPiece(STRUCTURE_PIECE_MAIN, 1, 6, 0); + + List<MTEHatch> energyHatches = this.getExoticAndNormalEnergyHatchList(); + for (MTEHatch hatch : energyHatches) { + mMaxHatchTier = Math.max(mMaxHatchTier, hatch.mTier); + } + + isOK = isOK && this.mMaintenanceHatches.size() == 1 && energyHatches.size() >= 1; + if (isOK) { + this.activatePiston(); + return true; + } + this.resetPiston(pistonTier); + return false; + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack itemStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack itemStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack itemStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new MTEElectricImplosionCompressor(this.mName); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + if (aActive) return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_IMPLOSION_COMPRESSOR_ACTIVE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_IMPLOSION_COMPRESSOR_ACTIVE_GLOW) + .extFacing() + .glow() + .build() }; + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX), TextureFactory.builder() + .addIcon(OVERLAY_FRONT_IMPLOSION_COMPRESSOR) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_IMPLOSION_COMPRESSOR_GLOW) + .extFacing() + .glow() + .build() }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX) }; + } + + @Override + public void construct(ItemStack itemStack, boolean b) { + this.buildPiece(STRUCTURE_PIECE_MAIN, itemStack, b, 1, 6, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (this.mMachine) return -1; + return this.survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 1, 6, 0, elementBudget, env, false, true); + } + + @Override + public boolean supportsBatchMode() { + return true; + } + + @Override + public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { + if (aPlayer.isSneaking()) { + batchMode = !batchMode; + if (batchMode) { + GTUtility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); + } else { + GTUtility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); + } + return true; + } + return false; + } + + @Override + public boolean supportsVoidProtection() { + return true; + } +} diff --git a/src/main/java/bartworks/common/tileentities/multis/MTEHighTempGasCooledReactor.java b/src/main/java/bartworks/common/tileentities/multis/MTEHighTempGasCooledReactor.java new file mode 100644 index 0000000000..73f6593d4f --- /dev/null +++ b/src/main/java/bartworks/common/tileentities/multis/MTEHighTempGasCooledReactor.java @@ -0,0 +1,619 @@ +/* + * Copyright (C) 2022 kuba6000 This program is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. You should have received a copy of the GNU General Public License along with + * this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package bartworks.common.tileentities.multis; + +import static bartworks.API.recipe.BartWorksRecipeMaps.htgrFakeRecipes; +import static bartworks.util.BWTooltipReference.MULTIBLOCK_ADDED_VIA_BARTWORKS; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GTValues.AuthorKuba; +import static gregtech.api.util.GTRecipeBuilder.HOURS; +import static gregtech.api.util.GTStructureUtility.ofHatchAdder; +import static gregtech.api.util.GTUtility.filterValidMTEs; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import bartworks.common.items.SimpleSubItemClass; +import bartworks.system.material.WerkstoffLoader; +import bartworks.util.MathUtils; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; +import gregtech.api.enums.TierEU; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.MTEEnhancedMultiBlockBase; +import gregtech.api.metatileentity.implementations.MTEHatchInput; +import gregtech.api.metatileentity.implementations.MTEHatchOutputBus; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; + +public class MTEHighTempGasCooledReactor extends MTEEnhancedMultiBlockBase<MTEHighTempGasCooledReactor> { + + private static final int BASECASINGINDEX = 181; + + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition<MTEHighTempGasCooledReactor> STRUCTURE_DEFINITION = StructureDefinition + .<MTEHighTempGasCooledReactor>builder() + .addShape( + STRUCTURE_PIECE_MAIN, + transpose( + new String[][] { + { " BBBBBBB ", " BBBBBBBBB ", "BBBBBBBBBBB", "BBBBBBBBBBB", "BBBBBBBBBBB", "BBBBBBBBBBB", + "BBBBBBBBBBB", "BBBBBBBBBBB", "BBBBBBBBBBB", " BBBBBBBBB ", " BBBBBBB " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " bbb~bbb ", " bbbbbbbbb ", "bbbbbbbbbbb", "bbbbbbbbbbb", "bbbbbbbbbbb", "bbbbbbbbbbb", + "bbbbbbbbbbb", "bbbbbbbbbbb", "bbbbbbbbbbb", " bbbbbbbbb ", " bbbbbbb " }, })) + .addElement('c', onElementPass(x -> x.mCasing++, ofBlock(GregTechAPI.sBlockCasings8, 5))) + .addElement( + 'b', + ofChain( + ofHatchAdder(MTEHighTempGasCooledReactor::addOutputToMachineList, BASECASINGINDEX, 1), + ofHatchAdder(MTEHighTempGasCooledReactor::addMaintenanceToMachineList, BASECASINGINDEX, 1), + ofHatchAdder(MTEHighTempGasCooledReactor::addEnergyInputToMachineList, BASECASINGINDEX, 1), + onElementPass(x -> x.mCasing++, ofBlock(GregTechAPI.sBlockCasings8, 5)))) + .addElement( + 'B', + ofChain( + ofHatchAdder(MTEHighTempGasCooledReactor::addInputToMachineList, BASECASINGINDEX, 2), + onElementPass(x -> x.mCasing++, ofBlock(GregTechAPI.sBlockCasings8, 5)))) + // ofHatchAdderOptional(GT_TileEntity_HTGR::addInputToMachineList, BASECASINGINDEX, 2, + // GregTechAPI.sBlockCasings8, 5)) + .build(); + + private static final int HELIUM_NEEDED = 730000; + public static final int powerUsage = (int) TierEU.RECIPE_LuV; + private static final int maxcapacity = 720000; + private static final int mincapacity = maxcapacity / 10; + private int HeliumSupply; + private int fueltype = -1, fuelsupply = 0; + private boolean empty; + private int emptyticksnodiff = 0; + private int coolanttaking = 0; + private int mCasing = 0; + + public MTEHighTempGasCooledReactor(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + private MTEHighTempGasCooledReactor(String aName) { + super(aName); + } + + @Override + public boolean isCorrectMachinePart(ItemStack itemStack) { + return true; + } + + @Override + public IStructureDefinition<MTEHighTempGasCooledReactor> getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType("Breeder Reactor") + .addInfo("Controller block for the High Temperature Gas-cooled Reactor (HTGR)") + .addInfo(AuthorKuba) + .addInfo("You can clear internal buffer by changing the mode with a screwdriver") + .addInfo("Needs a constant supply of coolant while running") + .addInfo("Needs at least 72k Fuel pebbles to start operation (can hold up to 720k pebbles)") + .addInfo("Consumes up to 2.5% of total Fuel Pellets per Operation depending on efficiency") + .addInfo("Efficiency is calculated exponentially depending on the amount of pebbles in the internal buffer") + .addInfo("and affects total recipe time (at 100% eff, -50% total recipe time") + .addInfo( + "Reactor will take 4 000L/s of coolant multiplied by efficiency and by fuel coolant value (check tooltips)") + .addInfo("Uses " + GTUtility.formatNumbers(powerUsage) + " EU/t") + .addInfo("One Operation takes 1 hour") + .addSeparator() + .beginStructureBlock(11, 12, 11, true) + .addController("Front bottom center") + .addCasingInfoMin("Europium Reinforced Radiation Proof Casings", 500, false) + .addStructureInfo("Corners and the 2 touching blocks are air (cylindric)") + .addInputBus("Any top layer casing", 2) + .addInputHatch("Any top layer casing", 2) + .addOutputBus("Any bottom layer casing", 1) + .addOutputHatch("Any bottom layer casing", 1) + .addEnergyHatch("Any bottom layer casing", 1) + .addMaintenanceHatch("Any bottom layer casing", 1) + .toolTipFinisher(MULTIBLOCK_ADDED_VIA_BARTWORKS.apply(EnumChatFormatting.GOLD + "kuba6000")); + return tt; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && f.isNotFlipped(); + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + this.buildPiece("main", stackSize, hintsOnly, 5, 11, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) { + this.mCasing = 0; + return this.checkPiece("main", 5, 11, 0) && this.mCasing >= 500 + && this.mMaintenanceHatches.size() == 1 + && this.mInputHatches.size() > 0 + && this.mOutputHatches.size() > 0 + && this.mInputBusses.size() > 0 + && this.mOutputBusses.size() > 0 + && this.mEnergyHatches.size() > 0; + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.HeliumSupply = aNBT.getInteger("HeliumSupply"); + this.fueltype = aNBT.getInteger("fueltype"); + this.fuelsupply = aNBT.getInteger("fuelsupply"); + this.empty = aNBT.getBoolean("EmptyMode"); + this.coolanttaking = aNBT.getInteger("coolanttaking"); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("HeliumSupply", this.HeliumSupply); + aNBT.setInteger("fueltype", this.fueltype); + aNBT.setInteger("fuelsupply", this.fuelsupply); + aNBT.setBoolean("EmptyMode", this.empty); + aNBT.setInteger("coolanttaking", this.coolanttaking); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide() && !this.empty) { + boolean updateneeded = false; + if (this.HeliumSupply < MTEHighTempGasCooledReactor.HELIUM_NEEDED) { + for (FluidStack fluidStack : this.getStoredFluids()) { + if (fluidStack.isFluidEqual(Materials.Helium.getGas(1))) { + int toget = Math + .min(MTEHighTempGasCooledReactor.HELIUM_NEEDED - this.HeliumSupply, fluidStack.amount); + fluidStack.amount -= toget; + this.HeliumSupply += toget; + updateneeded = true; + } + } + } + if (this.fuelsupply < maxcapacity) { + this.startRecipeProcessing(); + for (ItemStack itemStack : this.getStoredInputs()) { + int type = -1; + if (itemStack == null || itemStack.getItem() != HTGRMaterials.aHTGR_Materials) continue; + int damage = HTGRMaterials.aHTGR_Materials.getDamage(itemStack); + if ((damage + 1) % HTGRMaterials.MATERIALS_PER_FUEL != HTGRMaterials.USABLE_FUEL_INDEX + 1) + continue; // is fuel + type = damage / HTGRMaterials.MATERIALS_PER_FUEL; + if (this.fueltype == -1) this.fueltype = type; + if (this.fueltype != type) continue; + int toget = Math.min(maxcapacity - this.fuelsupply, itemStack.stackSize); + this.fuelsupply += toget; + itemStack.stackSize -= toget; + updateneeded = true; + } + this.endRecipeProcessing(); + } + if (updateneeded) this.updateSlots(); + } + } + + @Override + public RecipeMap<?> getRecipeMap() { + // Only for visual + return htgrFakeRecipes; + } + + @Override + protected boolean filtersFluid() { + return false; + } + + @Override + public boolean checkRecipe(ItemStack controllerStack) { + + if (this.empty) { + if (this.HeliumSupply > 0 || this.fuelsupply > 0) { + this.mEfficiency = 10000; + this.mMaxProgresstime = 100; + return true; + } + return false; + } + if (this.HeliumSupply < MTEHighTempGasCooledReactor.HELIUM_NEEDED || this.fuelsupply < mincapacity) + return false; + + double eff = Math.min(Math.pow((double) this.fuelsupply / (double) mincapacity, 2D), 100D) / 100D + - (this.getIdealStatus() - this.getRepairStatus()) / 10D; + + if (eff <= 0) return false; + + int toReduce = MathUtils.floorInt(this.fuelsupply * 0.025D * eff); + + final int originalToReduce = toReduce; + int burnedballs = toReduce / 64; + if (burnedballs > 0) toReduce -= burnedballs * 64; + + int meta = this.fueltype * HTGRMaterials.MATERIALS_PER_FUEL + HTGRMaterials.BURNED_OUT_FUEL_INDEX; + + ItemStack[] toOutput = { new ItemStack(HTGRMaterials.aHTGR_Materials, burnedballs, meta), + new ItemStack(HTGRMaterials.aHTGR_Materials, toReduce, meta + 1) }; + if (!this.canOutputAll(toOutput)) return false; + + this.fuelsupply -= originalToReduce; + this.mOutputItems = toOutput; + + // this.updateSlots(); // not needed ? + + this.coolanttaking = (int) (4000D * (this.fueltype * 0.5D + 1) * eff); + + this.mEfficiency = (int) (eff * 10000D); + this.mEfficiencyIncrease = 0; + this.mEUt = -powerUsage; + this.mMaxProgresstime = (int) (72000 * (1d - eff / 2d)); + return true; + } + + private int runningtick = 0; + + @Override + public boolean onRunningTick(ItemStack aStack) { + this.runningtick++; + + if (this.empty) { + if (this.emptyticksnodiff > 20 && this.emptyticksnodiff % 20 != 0) { + this.emptyticksnodiff++; + return true; + } + if (this.HeliumSupply > 0) { + this.addOutput(Materials.Helium.getGas(this.HeliumSupply)); + this.HeliumSupply = 0; + } + if (this.fuelsupply > 0) { + ItemStack iStack = new ItemStack( + HTGRMaterials.aHTGR_Materials, + this.fuelsupply, + HTGRMaterials.MATERIALS_PER_FUEL * this.fueltype + HTGRMaterials.USABLE_FUEL_INDEX); + boolean storedAll = false; + for (MTEHatchOutputBus tHatch : filterValidMTEs(mOutputBusses)) { + if (tHatch.storeAll(iStack)) { + storedAll = true; + break; + } + } + if (!storedAll) { + if (this.fuelsupply == iStack.stackSize) this.emptyticksnodiff++; + else { + this.fuelsupply = iStack.stackSize; + this.emptyticksnodiff = 0; + } + } else { + this.fuelsupply = 0; + this.fueltype = -1; + this.coolanttaking = 0; + } + } + return true; + } + // USE DA POWAH + if (!this.drainEnergyInput(-this.mEUt)) { + this.criticalStopMachine(); + return false; + } + + if (this.runningtick % 20 == 0) { + int takecoolant = this.coolanttaking; + int drainedamount = 0; + + for (MTEHatchInput tHatch : filterValidMTEs(mInputHatches)) { + FluidStack tLiquid = tHatch.getFluid(); + if (tLiquid != null && tLiquid.isFluidEqual(FluidRegistry.getFluidStack("ic2coolant", 1))) { + FluidStack drained = tHatch.drain(takecoolant, true); + takecoolant -= drained.amount; + drainedamount += drained.amount; + if (takecoolant <= 0) break; + } + } + + if (drainedamount > 0) this.addOutput(FluidRegistry.getFluidStack("ic2hotcoolant", drainedamount)); + + this.updateSlots(); + + if (takecoolant > 0) this.stopMachine(); + } + + return true; + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack itemStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack itemStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack itemStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new MTEHighTempGasCooledReactor(this.mName); + } + + @Override + public String[] getInfoData() { + return new String[] { "Mode:", this.empty ? "Emptying" : "Normal", "Progress:", + GTUtility.formatNumbers(this.mProgresstime / 20) + "s / " + + GTUtility.formatNumbers(this.mMaxProgresstime / 20) + + "s", + "Fuel type:", + this.fueltype == -1 ? "NONE" : "TRISO (" + HTGRMaterials.sHTGR_Fuel[this.fueltype].sEnglish + ")", + "Fuel amount:", GTUtility.formatNumbers(this.fuelsupply) + " pcs.", "Helium-Level:", + GTUtility.formatNumbers(this.HeliumSupply) + "L / " + + GTUtility.formatNumbers(MTEHighTempGasCooledReactor.HELIUM_NEEDED) + + "L", + "Coolant:", GTUtility.formatNumbers(this.coolanttaking) + "L/s", "Problems:", + String.valueOf(this.getIdealStatus() - this.getRepairStatus()) }; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, + ForgeDirection forgeDirection, int aColorIndex, boolean aActive, boolean aRedstone) { + if (side == forgeDirection) { + if (aActive) return new ITexture[] { + Textures.BlockIcons.getCasingTextureForId(MTEHighTempGasCooledReactor.BASECASINGINDEX), + TextureFactory.builder() + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE_GLOW) + .extFacing() + .glow() + .build() }; + return new ITexture[] { + Textures.BlockIcons.getCasingTextureForId(MTEHighTempGasCooledReactor.BASECASINGINDEX), + TextureFactory.builder() + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_GLOW) + .extFacing() + .glow() + .build() }; + } + return new ITexture[] { + Textures.BlockIcons.getCasingTextureForId(MTEHighTempGasCooledReactor.BASECASINGINDEX) }; + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (this.mMaxProgresstime > 0) { + GTUtility.sendChatToPlayer(aPlayer, "HTGR mode cannot be changed while the machine is running."); + return; + } + this.empty = !this.empty; + GTUtility.sendChatToPlayer( + aPlayer, + "HTGR is now running in " + (this.empty ? "emptying mode." : "normal Operation")); + } + + @Override + public boolean supportsVoidProtection() { + return true; + } + + public static class HTGRMaterials { + + private static class CustomHTGRSimpleSubItemClass extends SimpleSubItemClass { + + HashMap<Integer, String> tooltip = null; + + public CustomHTGRSimpleSubItemClass(HashMap<Integer, String> tooltip, String... tex) { + super(tex); + this.tooltip = tooltip; + } + + @Override + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { + if (this.tooltip.containsKey(this.getDamage(p_77624_1_))) + aList.add(this.tooltip.get(this.getDamage(p_77624_1_))); + aList.add("Material for High Temperature Gas-cooled Reactor"); + super.addInformation(p_77624_1_, p_77624_2_, aList, p_77624_4_); + } + } + + private static class Base_ { + + public String sName; + public String sEnglish; + + public Base_(String a, String b) { + this.sName = a; + this.sEnglish = b; + } + } + + public static class Fuel_ { + + public String sName; + public String sEnglish; + public ItemStack mainItem; + public ItemStack secondaryItem; + public ItemStack[] recycledItems = { GTValues.NI, GTValues.NI, GTValues.NI, GTValues.NI, GTValues.NI, + GTValues.NI }; + public FluidStack recycledFluid; + public int[] recycleChances; + public String tooltip; + + public Fuel_(String sName, String sEnglish, ItemStack mainItem, ItemStack secondaryItem, + FluidStack recycledFluid, ItemStack[] recycledItems, int[] recycleChances, String tooltip) { + this.sName = sName; + this.sEnglish = sEnglish; + this.mainItem = mainItem; + this.secondaryItem = secondaryItem; + this.recycledFluid = recycledFluid; + System.arraycopy(recycledItems, 0, this.recycledItems, 0, recycledItems.length); + this.recycleChances = recycleChances; + this.tooltip = tooltip; + } + } + + private static class LangEntry_ { + + public String sName; + public String sEnglish; + + public LangEntry_(String a, String b) { + this.sName = a; + this.sEnglish = b; + } + } + + public static final Base_[] sHTGR_Bases = { new Base_("HTGRFuelMixture", "HTGR fuel mixture"), + new Base_("BISOPebbleCompound", "BISO pebble compound"), + new Base_("TRISOPebbleCompound", "TRISO pebble compound"), new Base_("TRISOBall", "TRISO ball"), + new Base_("TRISOPebble", "TRISO pebble"), new Base_("BurnedOutTRISOBall", "Burned out TRISO Ball"), + new Base_("BurnedOutTRISOPebble", "Burned out TRISO Pebble"), }; + public static final int MATERIALS_PER_FUEL = sHTGR_Bases.length; + static final int USABLE_FUEL_INDEX = 4; + static final int BURNED_OUT_FUEL_INDEX = 5; + public static final Fuel_[] sHTGR_Fuel = { new Fuel_( + "Thorium", + "Thorium", + WerkstoffLoader.Thorium232.get(OrePrefixes.dust, 64), + Materials.Uranium235.getDust(4), + GTValues.NF, + new ItemStack[] { Materials.Silicon.getDust(1), Materials.Graphite.getDust(1), Materials.Carbon.getDust(1), + Materials.Lutetium.getDust(1), WerkstoffLoader.Thorium232.get(OrePrefixes.dust, 1) }, + new int[] { 9900 / 4, 9900 / 4, 9900 / 4, 9900 / 4, 162 / 4 }, + "Multiplies coolant by 1"), + new Fuel_( + "Uranium", + "Uranium", + Materials.Uranium.getDust(64), + Materials.Uranium235.getDust(8), + FluidRegistry.getFluidStack("krypton", 4), + new ItemStack[] { Materials.Silicon.getDust(1), Materials.Graphite.getDust(1), + Materials.Carbon.getDust(1), Materials.Lead.getDust(1), Materials.Uranium.getDust(1) }, + new int[] { 9900 / 4, 9900 / 4, 9900 / 4, 5000 / 4, 5000 / 4 }, + "Multiplies coolant by 1.5"), + new Fuel_( + "Plutonium", + "Plutonium", + Materials.Plutonium.getDust(64), + Materials.Plutonium241.getDust(4), + FluidRegistry.getFluidStack("xenon", 4), + new ItemStack[] { Materials.Silicon.getDust(1), Materials.Graphite.getDust(1), + Materials.Carbon.getDust(1), Materials.Lead.getDust(1), Materials.Plutonium.getDust(1) }, + new int[] { 9900 / 4, 9900 / 4, 9900 / 4, 5000 / 4, 5000 / 4 }, + "Multiplies coolant by 2"), }; + public static final CustomHTGRSimpleSubItemClass aHTGR_Materials; + static final ArrayList<LangEntry_> aHTGR_Localizations = new ArrayList<>(); + + static { + String[] sHTGR_Materials = new String[sHTGR_Bases.length * sHTGR_Fuel.length]; + HashMap<Integer, String> tooltip = new HashMap<>(); + int i = 0; + for (Fuel_ fuel : sHTGR_Fuel) for (Base_ base : sHTGR_Bases) { + sHTGR_Materials[i] = "HTGR" + base.sName + fuel.sName; + aHTGR_Localizations.add( + new LangEntry_("item." + sHTGR_Materials[i] + ".name", base.sEnglish + " (" + fuel.sEnglish + ")")); + if ((i + 1) % MATERIALS_PER_FUEL == USABLE_FUEL_INDEX + 1 && fuel.tooltip != null + && !fuel.tooltip.isEmpty()) tooltip.put(i, fuel.tooltip); + i++; + } + aHTGR_Materials = new CustomHTGRSimpleSubItemClass(tooltip, sHTGR_Materials); + } + + public static void registeraTHR_Materials() { + for (LangEntry_ iName : aHTGR_Localizations) + GTLanguageManager.addStringLocalization(iName.sName, iName.sEnglish); + GameRegistry.registerItem(MTEHighTempGasCooledReactor.HTGRMaterials.aHTGR_Materials, "bw.HTGRMaterials"); + } + + public static void register_fake_THR_Recipes() { + + int i = 0; + for (@SuppressWarnings("unused") + Fuel_ fuel : sHTGR_Fuel) { + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(MTEHighTempGasCooledReactor.HTGRMaterials.aHTGR_Materials, 64, i + 4)) + .itemOutputs(new ItemStack(MTEHighTempGasCooledReactor.HTGRMaterials.aHTGR_Materials, 1, i + 5)) + .duration(1 * HOURS) + .eut(powerUsage) + .ignoreCollision() + .noOptimize() + .fake() + .addTo(htgrFakeRecipes); + + i += MATERIALS_PER_FUEL; + } + } + } +} diff --git a/src/main/java/bartworks/common/tileentities/multis/MTELESU.java b/src/main/java/bartworks/common/tileentities/multis/MTELESU.java new file mode 100644 index 0000000000..a039aa593c --- /dev/null +++ b/src/main/java/bartworks/common/tileentities/multis/MTELESU.java @@ -0,0 +1,590 @@ +/* + * 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.common.tileentities.multis; + +import java.awt.Color; +import java.util.ArrayList; +import java.util.Collections; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import com.gtnewhorizons.modularui.api.NumberFormatMUI; +import com.gtnewhorizons.modularui.api.drawable.Text; +import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.DynamicPositionedColumn; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.ProgressBar; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; + +import bartworks.API.modularUI.BWUITextures; +import bartworks.MainMod; +import bartworks.common.configs.ConfigHandler; +import bartworks.common.loaders.ItemRegistry; +import bartworks.util.BWTooltipReference; +import bartworks.util.ConnectedBlocksChecker; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.GTValues; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.MTEMultiBlockBase; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTUtility; + +public class MTELESU extends MTEMultiBlockBase { + + private static final byte TEXID_SIDE = 0; + private static final byte TEXID_CHARGING = 1; + private static final byte TEXID_IDLE = 2; + private static final byte TEXID_EMPTY = 3; + private static final IIcon[] iIcons = new IIcon[4]; + private static final IIconContainer[] iIconContainers = new IIconContainer[4]; + private static final ITexture[][] iTextures = new ITexture[4][1]; + public ConnectedBlocksChecker connectedcells; + public final ItemStack[] circuits = new ItemStack[5]; + private final ItemStackHandler circuitsInventoryHandler = new ItemStackHandler(this.circuits) { + + @Override + public int getSlotLimit(int slot) { + return 1; + } + }; + private long mStorage; + + protected static final NumberFormatMUI numberFormat = new NumberFormatMUI(); + + public MTELESU(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + this.mStorage = ConfigHandler.energyPerCell; + } + + public MTELESU(String aName) { + super(aName); + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public long maxEUStore() { + return this.mStorage >= Long.MAX_VALUE - 1 || this.mStorage < 0 ? Long.MAX_VALUE - 1 : this.mStorage; + } + + @Override + public long maxAmperesIn() { + int ret = 0; + for (int i = 0; i < 5; ++i) if (this.circuits[i] != null && this.circuits[i].getItem() + .equals( + GTUtility.getIntegratedCircuit(0) + .getItem())) + ret += this.circuits[i].getItemDamage(); + return ret > 0 ? ret : 1; + } + + @Override + public long maxAmperesOut() { + return this.maxAmperesIn(); + } + + @Override + public long maxEUInput() { + + for (int i = 1; i < GTValues.V.length; i++) { + if (this.maxEUOutput() <= GTValues.V[i] && this.maxEUOutput() > GTValues.V[i - 1]) + return Math.min(GTValues.V[i], 32768L); + } + + return 8; + } + + @Override + public long maxEUOutput() { + return Math.min(Math.max(this.mStorage / ConfigHandler.energyPerCell, 1L), 32768L); + } + + @Override + public int rechargerSlotStartIndex() { + return 0; + } + + @Override + public int rechargerSlotCount() { + return 1; + } + + @Override + public int dechargerSlotStartIndex() { + return 1; + } + + @Override + public int dechargerSlotCount() { + return 1; + } + + @Override + public boolean isTeleporterCompatible() { + return true; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new MTELESU(this.mName); + } + + @Override + public String[] getDescription() { + ArrayList<String> e = new ArrayList<>(); + String[] dsc = StatCollector.translateToLocal("tooltip.tile.lesu.0.name") + .split(";"); + Collections.addAll(e, dsc); + e.add( + StatCollector.translateToLocal("tooltip.tile.lesu.1.name") + " " + + GTUtility.formatNumbers(ConfigHandler.energyPerCell) + + "EU"); + dsc = StatCollector.translateToLocal("tooltip.tile.lesu.2.name") + .split(";"); + Collections.addAll(e, dsc); + e.add(EnumChatFormatting.RED + StatCollector.translateToLocal("tooltip.tile.lesu.3.name")); + e.add(BWTooltipReference.ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS.get()); + return e.toArray(new String[0]); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + + for (int i = 0; i < MTELESU.iTextures.length; i++) { + MTELESU.iIcons[i] = aBlockIconRegister.registerIcon(MainMod.MOD_ID + ":LESU_CASING_" + i); + int finalI = i; + MTELESU.iIconContainers[i] = new IIconContainer() { + + @Override + public IIcon getIcon() { + return MTELESU.iIcons[finalI]; + } + + @Override + public IIcon getOverlayIcon() { + return MTELESU.iIcons[finalI]; + } + + @Override + public ResourceLocation getTextureFile() { + return new ResourceLocation(MainMod.MOD_ID + ":LESU_CASING_" + finalI); + } + }; + } + } + + public boolean isClientSide() { + if (this.getWorld() != null) return this.getWorld().isRemote ? FMLCommonHandler.instance() + .getSide() == Side.CLIENT + : FMLCommonHandler.instance() + .getEffectiveSide() == Side.CLIENT; + return FMLCommonHandler.instance() + .getEffectiveSide() == Side.CLIENT; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + + ITexture[] ret = {}; + + if (this.isClientSide()) { + + for (int i = 0; i < MTELESU.iTextures.length; i++) { + MTELESU.iTextures[i][0] = TextureFactory + .of(MTELESU.iIconContainers[i], Dyes.getModulation(0, Dyes.MACHINE_METAL.mRGBa)); + } + + if (side == facing && this.getBaseMetaTileEntity() + .getUniversalEnergyStored() <= 0) ret = MTELESU.iTextures[MTELESU.TEXID_EMPTY]; + else if (side == facing && !aActive) ret = MTELESU.iTextures[MTELESU.TEXID_IDLE]; + else if (side == facing && aActive) ret = MTELESU.iTextures[MTELESU.TEXID_CHARGING]; + else ret = MTELESU.iTextures[MTELESU.TEXID_SIDE]; + } + + return ret; + } + + @Override + public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { + return true; + } + + @Override + public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { + return true; + } + + @Override + public int getSizeInventory() { + return 6; + } + + @Override + public ItemStack getStackInSlot(int slotIn) { + if (slotIn > 1) return this.circuits[slotIn - 2]; + return this.mInventory[slotIn]; + } + + @Override + public void setInventorySlotContents(int index, ItemStack stack) { + if (index < 2) this.mInventory[index] = stack; + else this.circuits[index - 2] = stack; + } + + @Override + public String getInventoryName() { + return "L.E.S.U."; + } + + @Override + public boolean hasCustomInventoryName() { + return true; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return true; + } + + @Override + public boolean isItemValidForSlot(int index, ItemStack stack) { + + return switch (index) { + case 0, 1 -> true; + default -> stack != null && stack.getItem() + .equals( + GTUtility.getIntegratedCircuit(0) + .getItem()); + }; + } + + @Override + public boolean isCorrectMachinePart(ItemStack itemStack) { + return true; + } + + @Override + public boolean checkRecipe(ItemStack itemStack) { + return true; + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return side != this.getBaseMetaTileEntity() + .getFrontFacing(); + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return side == this.getBaseMetaTileEntity() + .getFrontFacing(); + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + this.checkMachine(aBaseMetaTileEntity, null); + super.onFirstTick(aBaseMetaTileEntity); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + this.mMaxProgresstime = 1; + if (aTick % 20 == 0) this.checkMachine(aBaseMetaTileEntity, null); + } + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + this.mMaxProgresstime = 1; + return true; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setIntArray("customCircuitInv", GTUtility.stacksToIntArray(this.circuits)); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + int[] stacks = aNBT.getIntArray("customCircuitInv"); + for (int i = 0; i < stacks.length; i++) { + this.circuits[i] = GTUtility.intToStack(stacks[i]); + } + super.loadNBTData(aNBT); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) { + long startingTime = System.nanoTime(); + this.connectedcells = new ConnectedBlocksChecker(); + this.connectedcells.get_connected( + aBaseMetaTileEntity.getWorld(), + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord(), + ItemRegistry.BW_BLOCKS[1]); + + if (this.connectedcells.get_meta_of_sideblocks( + aBaseMetaTileEntity.getWorld(), + this.getBaseMetaTileEntity() + .getMetaTileID(), + new int[] { aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord() }, + true)) { + this.getBaseMetaTileEntity() + .disableWorking(); + this.getBaseMetaTileEntity() + .setActive(false); + this.mStorage = 0; + this.mMaxProgresstime = 0; + this.mProgresstime = 0; + return false; + } + + this.mEfficiency = this.getMaxEfficiency(null); + this.mStorage = ConfigHandler.energyPerCell * this.connectedcells.hashset.size() >= Long.MAX_VALUE - 1 + || ConfigHandler.energyPerCell * this.connectedcells.hashset.size() < 0 ? Long.MAX_VALUE - 1 + : ConfigHandler.energyPerCell * this.connectedcells.hashset.size(); + this.mMaxProgresstime = 1; + this.mProgresstime = 0; + + this.getBaseMetaTileEntity() + .enableWorking(); + this.getBaseMetaTileEntity() + .setActive(true); + + long finishedTime = System.nanoTime(); + // System.out.println("LESU LookUp: "+((finishedTime - startingTime) / 1000000)+"ms"); + if (finishedTime - startingTime > 5000000) MainMod.LOGGER.warn( + "LESU LookUp took longer than 5ms!(" + (finishedTime - startingTime) + + "ns / " + + (finishedTime - startingTime) / 1000000 + + "ms) Owner:" + + this.getBaseMetaTileEntity() + .getOwnerName() + + " Check at x:" + + this.getBaseMetaTileEntity() + .getXCoord() + + " y:" + + this.getBaseMetaTileEntity() + .getYCoord() + + " z:" + + this.getBaseMetaTileEntity() + .getZCoord() + + " DIM-ID: " + + this.getBaseMetaTileEntity() + .getWorld().provider.dimensionId); + return true; + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack itemStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack itemStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack itemStack) { + return false; + } + + public World getWorld() { + return this.getBaseMetaTileEntity() + .getWorld(); + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(GTUITextures.PICTURE_GT_LOGO_17x17_TRANSPARENT_GRAY) + .setSize(17, 17) + .setPos(105, 51)); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + new DrawableWidget().setDrawable(GTUITextures.PICTURE_SCREEN_BLACK) + .setPos(7, 4) + .setSize(118, 67)) + .widget(new SlotWidget(new BaseSlot(this.inventoryHandler, 1) { + + @Override + public int getSlotStackLimit() { + return 1; + } + }).setBackground( + this.getGUITextureSet() + .getItemSlot(), + GTUITextures.OVERLAY_SLOT_IN) + .setPos(127, 13)) + .widget(new SlotWidget(new BaseSlot(this.inventoryHandler, 0) { + + @Override + public int getSlotStackLimit() { + return 1; + } + }).setBackground( + this.getGUITextureSet() + .getItemSlot(), + GTUITextures.OVERLAY_SLOT_CHARGER) + .setPos(127, 49)); + for (int i = 0; i < 4; i++) { + builder.widget( + new SlotWidget(this.circuitsInventoryHandler, i).setBackground( + this.getGUITextureSet() + .getItemSlot(), + GTUITextures.OVERLAY_SLOT_INT_CIRCUIT) + .setPos(151, 4 + i * 18)); + } + + final DynamicPositionedColumn screenElements = new DynamicPositionedColumn(); + this.drawTexts(screenElements); + builder.widget(screenElements); + + builder.widget( + new DrawableWidget().setDrawable(BWUITextures.PICTURE_STORED_EU_FRAME) + .setPos(7, 72) + .setSize(118, 7)) + .widget( + new ProgressBar().setProgress( + () -> (float) this.getBaseMetaTileEntity() + .getStoredEU() / this.getBaseMetaTileEntity() + .getEUCapacity()) + .setDirection(ProgressBar.Direction.RIGHT) + .setTexture(BWUITextures.PROGRESSBAR_STORED_EU_116, 116) + .setPos(8, 73) + .setSize(116, 5)); + } + + private long clientEU; + private long clientMaxEU; + private long clientMaxIn; + private long clientMaxOut; + private long clientAmps; + + private void drawTexts(DynamicPositionedColumn screenElements) { + screenElements.setSpace(0) + .setPos(11, 8); + + screenElements.widget( + new TextWidget().setStringSupplier(() -> "EU: " + numberFormat.format(this.clientEU)) + .setDefaultColor(this.COLOR_TEXT_WHITE.get())) + .widget( + new FakeSyncWidget.LongSyncer( + () -> this.getBaseMetaTileEntity() + .getStoredEU(), + val -> clientEU = val)) + .widget( + new TextWidget().setStringSupplier(() -> "MAX: " + numberFormat.format(clientMaxEU)) + .setDefaultColor(this.COLOR_TEXT_WHITE.get())) + .widget( + new FakeSyncWidget.LongSyncer( + () -> this.getBaseMetaTileEntity() + .isActive() + ? this.getBaseMetaTileEntity() + .getOutputVoltage() * ConfigHandler.energyPerCell + : 0, + val -> clientMaxEU = val)) + .widget( + new TextWidget().setStringSupplier(() -> "MAX EU/t IN: " + numberFormat.format(clientMaxIn)) + .setDefaultColor(this.COLOR_TEXT_WHITE.get())) + .widget( + new FakeSyncWidget.LongSyncer( + () -> this.getBaseMetaTileEntity() + .getInputVoltage(), + val -> clientMaxIn = val)) + .widget( + new TextWidget().setStringSupplier(() -> "EU/t OUT: " + numberFormat.format(clientMaxOut)) + .setDefaultColor(this.COLOR_TEXT_WHITE.get())) + .widget( + new FakeSyncWidget.LongSyncer( + () -> this.getBaseMetaTileEntity() + .getOutputVoltage(), + val -> clientMaxOut = val)) + .widget( + new TextWidget().setStringSupplier(() -> "AMP/t IN/OUT: " + numberFormat.format(clientAmps)) + .setDefaultColor(this.COLOR_TEXT_WHITE.get())) + .widget( + new FakeSyncWidget.LongSyncer( + () -> this.getBaseMetaTileEntity() + .getInputAmperage(), + val -> clientAmps = val)) + .widget( + new TextWidget(Text.localised("tooltip.LESU.0.name")).setDefaultColor(Color.YELLOW.getRGB()) + .setEnabled(widget -> this.maxEUStore() >= Long.MAX_VALUE - 1)) + .widget( + new TextWidget(Text.localised("tooltip.LESU.1.name")).setDefaultColor(Color.RED.getRGB()) + .setEnabled( + widget -> !this.getBaseMetaTileEntity() + .isActive())); + } + + @Override + public boolean getDefaultHasMaintenanceChecks() { + return false; + } +} diff --git a/src/main/java/bartworks/common/tileentities/multis/MTEManualTrafo.java b/src/main/java/bartworks/common/tileentities/multis/MTEManualTrafo.java new file mode 100644 index 0000000000..2533fd5213 --- /dev/null +++ b/src/main/java/bartworks/common/tileentities/multis/MTEManualTrafo.java @@ -0,0 +1,363 @@ +/* + * 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.common.tileentities.multis; + +import static bartworks.common.loaders.ItemRegistry.BW_BLOCKS; +import static bartworks.util.BWTooltipReference.MULTIBLOCK_ADDED_BY_BARTWORKS; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GTValues.V; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_GLOW; +import static gregtech.api.util.GTStructureUtility.ofHatchAdder; +import static gregtech.api.util.GTStructureUtility.ofHatchAdderOptional; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import com.gtnewhorizon.structurelib.StructureLibAPI; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.IStructureElementNoPlacement; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import gregtech.api.GregTechAPI; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.MTEEnhancedMultiBlockBase; +import gregtech.api.metatileentity.implementations.MTEHatchDynamo; +import gregtech.api.metatileentity.implementations.MTEHatchEnergy; +import gregtech.api.metatileentity.implementations.MTETieredMachineBlock; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; + +public class MTEManualTrafo extends MTEEnhancedMultiBlockBase<MTEManualTrafo> { + + private byte mode; + private int mTiers; + private boolean upstep = true; + + public MTEManualTrafo(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEManualTrafo(String aName) { + super(aName); + } + + private static final int CASING_INDEX = 2; + private static final String STRUCTURE_PIECE_BASE = "base"; + private static final String STRUCTURE_PIECE_LAYER = "layer"; + private static final String STRUCTURE_PIECE_TOP = "top"; + private static final String STRUCTURE_PIECE_TAP_LAYER = "taplayer"; + private static final IStructureDefinition<MTEManualTrafo> STRUCTURE_DEFINITION = StructureDefinition + .<MTEManualTrafo>builder() + .addShape(STRUCTURE_PIECE_BASE, transpose(new String[][] { { "b~b", "bbb", "bbb" } })) + .addShape(STRUCTURE_PIECE_LAYER, transpose(new String[][] { { "ttt", "tft", "ttt" } })) + .addShape(STRUCTURE_PIECE_TOP, transpose(new String[][] { { "ooo", "ooo", "ooo" } })) + .addShape( + STRUCTURE_PIECE_TAP_LAYER, + transpose(new String[][] { { " TTT ", "TtttT", "TtftT", "TtttT", " TTT " } })) + .addElement( + 'b', + ofChain( + ofHatchAdder(MTEManualTrafo::addEnergyInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(MTEManualTrafo::addMaintenanceToMachineList, CASING_INDEX, 1), + ofBlock(GregTechAPI.sBlockCasings1, 2))) + .addElement( + 'o', + ofHatchAdderOptional( + MTEManualTrafo::addDynamoToMachineList, + CASING_INDEX, + 2, + GregTechAPI.sBlockCasings1, + 2)) + .addElement('t', ofBlock(BW_BLOCKS[2], 1)) + .addElement('f', ofBlock(BW_BLOCKS[2], 0)) + .addElement('T', new IStructureElementNoPlacement<MTEManualTrafo>() { + + @Override + public boolean check(MTEManualTrafo te, World world, int x, int y, int z) { + if (world.isAirBlock(x, y, z)) return true; + TileEntity tileEntity = world.getTileEntity(x, y, z); + if (tileEntity == null || !(tileEntity instanceof IGregTechTileEntity)) return true; + IMetaTileEntity mte = ((IGregTechTileEntity) tileEntity).getMetaTileEntity(); + if (mte instanceof MTEHatchDynamo || mte instanceof MTEHatchEnergy) { + int intier = te.mEnergyHatches.get(0).mTier; + if (((MTETieredMachineBlock) mte).mTier == intier + (te.upstep ? te.mTiers : -te.mTiers)) { + te.addToMachineList((IGregTechTileEntity) tileEntity, CASING_INDEX); + return true; + } + return false; + } + return true; + } + + @Override + public boolean spawnHint(MTEManualTrafo te, World world, int x, int y, int z, ItemStack itemStack) { + StructureLibAPI.hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), 2 /* aDots: 3 */); + return true; + } + }) + .build(); + + @Override + public IStructureDefinition<MTEManualTrafo> getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType("Transformer") + .addInfo("Controller block for the Manual Trafo") + .addInfo("Operates in 4 diffrent modes:") + .addInfo("Mode 1: Circuit 0 in controller: Direct-Upstep") + .addInfo("Mode 2: Circuit 1 in controller: Direct-Downstep") + .addInfo("Mode 3: Circuit 2 in controller: Tapped-Upstep (currently disabled)") + .addInfo("Mode 4: Circuit 2 in controller: Tapped-Downstep (currently disabled)") + .addSeparator() + .beginVariableStructureBlock(3, 3, 3, 10, 3, 3, false) + .addController("Front bottom center") + .addCasingInfoMin("MV Machine Casing", 0, false) + .addOtherStructurePart("Transformer-Winding Blocks", "1 Layer for each tier transformed") + .addOtherStructurePart("Nickel-Zinc-Ferrite Blocks", "Middle of Transformer-Winding Blocks") + .addMaintenanceHatch("Any bottom layer casing", 1) + .addEnergyHatch("Any bottom layer casing", 1) + .addDynamoHatch("Any top layer casing", 2) + .addStructureInfo("---------TAPPED MODE---------") + .addEnergyHatch("Touching Transformer-Winding Blocks", 3) + .addDynamoHatch("Touching Transformer-Winding Blocks", 3) + .addStructureInfo("Hatches touching Transformer-Winding Blocks must be tiered from bottom to top") + .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTWORKS); + return tt; + } + + @Override + public boolean isCorrectMachinePart(ItemStack itemStack) { + return true; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (!this.getBaseMetaTileEntity() + .isAllowedToWork()) this.stopMachine(); + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + if (!this.getBaseMetaTileEntity() + .isAllowedToWork()) { + this.stopMachine(); + return false; + } + + this.mProgresstime = 0; + this.mMaxProgresstime = 1; + + if (this.getBaseMetaTileEntity() + .getTimer() % 40 == 0) if (this.mEfficiency < this.getMaxEfficiency(null)) this.mEfficiency += 100; + else this.mEfficiency = this.getMaxEfficiency(null); + + if (this.mode > 1) { + return false; // this.onRunningTickTabbedMode(); Tapped mode is disable + } + + return this.drainEnergyInput(this.getInputTier() * 2 * this.mEnergyHatches.size()) && this.addEnergyOutput( + this.getInputTier() * 2 * this.mEnergyHatches.size() * this.mEfficiency / this.getMaxEfficiency(null)); + } + + public boolean onRunningTickTabbedMode() { + boolean ret = false; + for (MTEHatchDynamo E : this.mDynamoHatches) { + for (MTEHatchEnergy I : this.mEnergyHatches) { + + long vtt = I.getEUVar() >= V[E.mTier] / 2 && E.getEUVar() < E.maxEUStore() ? I.getEUVar() : 0; + + if (vtt == 0) continue; + + long vtp = E.getEUVar() + vtt; + long avt = Math.min(vtp, E.maxEUStore()); + E.setEUVar(avt); + I.setEUVar(I.getEUVar() - vtt); + ret = true; + } + } + return ret; + } + + @Override + public long getInputTier() { + if (this.mEnergyHatches.size() > 0) return GTUtility.getTier( + this.mEnergyHatches.get(0) + .getBaseMetaTileEntity() + .getInputVoltage()); + return 0L; + } + + @Override + public long getOutputTier() { + if (this.mDynamoHatches.size() > 0) return GTUtility.getTier( + this.mDynamoHatches.get(0) + .getBaseMetaTileEntity() + .getOutputVoltage()); + return 0L; + } + + @Override + public boolean checkRecipe(ItemStack itemStack) { + + if (!this.getBaseMetaTileEntity() + .isAllowedToWork()) { + this.stopMachine(); + return false; + } + if (itemStack == null || !itemStack.getUnlocalizedName() + .startsWith("gt.integrated_circuit")) this.mode = 0; + else this.mode = (byte) Math.min(3, itemStack.getItemDamage()); + this.upstep = this.mode % 2 == 0; + this.mProgresstime = 0; + this.mMaxProgresstime = 1; + this.mEfficiency = Math.max(this.mEfficiency, 100); + return this.upstep ? this.getOutputTier() - this.getInputTier() == this.mTiers + : this.getInputTier() - this.getOutputTier() == this.mTiers; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) { + + if (itemStack == null || !itemStack.getUnlocalizedName() + .startsWith("gt.integrated_circuit")) this.mode = 0; + else this.mode = (byte) Math.min(3, itemStack.getItemDamage()); + + this.upstep = this.mode % 2 == 0; + boolean tapmode = this.mode > 1; + + if (!this.checkPiece(STRUCTURE_PIECE_BASE, 1, 0, 0) || this.mEnergyHatches.size() == 0) return false; + + byte intier = this.mEnergyHatches.get(0).mTier; + for (MTEHatchEnergy in : this.mEnergyHatches) if (in.mTier != intier) return false; + + int mHeight; + for (mHeight = 1; mHeight <= 8; mHeight++) { + if (tapmode) { + this.mTiers = mHeight; + if (!this.checkPiece(STRUCTURE_PIECE_TAP_LAYER, 2, mHeight, 1)) break; + } else if (!this.checkPiece(STRUCTURE_PIECE_LAYER, 1, mHeight, 0)) break; + } + if (!this.checkPiece(STRUCTURE_PIECE_TOP, 1, mHeight, 0)) return false; + this.mTiers = mHeight - 1; + + if (this.mDynamoHatches.size() == 0 || this.mMaintenanceHatches.size() != 1 || this.mTiers == 0) return false; + + byte outtier = this.mDynamoHatches.get(0).mTier; + for (MTEHatchDynamo out : this.mDynamoHatches) { + if (out.mTier != outtier) return false; + } + + return true; + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack itemStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack itemStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack itemStack) { + return true; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new MTEManualTrafo(this.mName); + } + + @Override + public void saveNBTData(NBTTagCompound ntag) { + super.saveNBTData(ntag); + ntag.setInteger("mTiers", this.mTiers); + ntag.setByte("mMode", this.mode); + ntag.setBoolean("upstep", this.upstep); + } + + @Override + public void loadNBTData(NBTTagCompound ntag) { + super.loadNBTData(ntag); + this.mTiers = ntag.getInteger("mTiers"); + this.mode = ntag.getByte("mMode"); + this.upstep = ntag.getBoolean("upstep"); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + if (aActive) return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE_GLOW) + .extFacing() + .glow() + .build() }; + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX), TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_GLOW) + .extFacing() + .glow() + .build() }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX) }; + } + + @Override + public void construct(ItemStack itemStack, boolean b) { + if (this.mInventory[1] == null || !this.mInventory[1].getUnlocalizedName() + .startsWith("gt.integrated_circuit")) this.mode = 0; + else this.mode = (byte) Math.min(3, this.mInventory[1].getItemDamage()); + int mHeight = Math.min(itemStack.stackSize, 8); + boolean tapmode = this.mode > 1; + this.buildPiece(STRUCTURE_PIECE_BASE, itemStack, b, 1, 0, 0); + for (int i = 0; i < mHeight; i++) { + if (tapmode) this.buildPiece(STRUCTURE_PIECE_TAP_LAYER, itemStack, b, 2, i + 1, 1); + else this.buildPiece(STRUCTURE_PIECE_LAYER, itemStack, b, 1, i + 1, 0); + } + this.buildPiece(STRUCTURE_PIECE_TOP, itemStack, b, 1, mHeight + 1, 0); + } +} diff --git a/src/main/java/bartworks/common/tileentities/multis/MTEThoriumHighTempReactor.java b/src/main/java/bartworks/common/tileentities/multis/MTEThoriumHighTempReactor.java new file mode 100644 index 0000000000..064bc351fd --- /dev/null +++ b/src/main/java/bartworks/common/tileentities/multis/MTEThoriumHighTempReactor.java @@ -0,0 +1,416 @@ +/* + * 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.common.tileentities.multis; + +import static bartworks.util.BWTooltipReference.MULTIBLOCK_ADDED_BY_BARTWORKS; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.util.GTStructureUtility.ofHatchAdder; +import static gregtech.api.util.GTUtility.filterValidMTEs; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import bartworks.common.items.SimpleSubItemClass; +import bartworks.util.MathUtils; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.Materials; +import gregtech.api.enums.Textures; +import gregtech.api.enums.TierEU; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.MTEEnhancedMultiBlockBase; +import gregtech.api.metatileentity.implementations.MTEHatchInput; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; + +public class MTEThoriumHighTempReactor extends MTEEnhancedMultiBlockBase<MTEThoriumHighTempReactor> { + + private static final int BASECASINGINDEX = 44; + + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition<MTEThoriumHighTempReactor> STRUCTURE_DEFINITION = StructureDefinition + .<MTEThoriumHighTempReactor>builder() + .addShape( + STRUCTURE_PIECE_MAIN, + transpose( + new String[][] { + { " BBBBBBB ", " BBBBBBBBB ", "BBBBBBBBBBB", "BBBBBBBBBBB", "BBBBBBBBBBB", "BBBBBBBBBBB", + "BBBBBBBBBBB", "BBBBBBBBBBB", "BBBBBBBBBBB", " BBBBBBBBB ", " BBBBBBB " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " ccccccc ", " c-------c ", "c---------c", "c---------c", "c---------c", "c---------c", + "c---------c", "c---------c", "c---------c", " c-------c ", " ccccccc " }, + { " bbb~bbb ", " bbbbbbbbb ", "bbbbbbbbbbb", "bbbbbbbbbbb", "bbbbbbbbbbb", "bbbbbbbbbbb", + "bbbbbbbbbbb", "bbbbbbbbbbb", "bbbbbbbbbbb", " bbbbbbbbb ", " bbbbbbb " }, })) + .addElement('c', onElementPass(x -> x.mCasing++, ofBlock(GregTechAPI.sBlockCasings3, 12))) + .addElement( + 'b', + ofChain( + ofHatchAdder(MTEThoriumHighTempReactor::addOutputToMachineList, BASECASINGINDEX, 1), + ofHatchAdder(MTEThoriumHighTempReactor::addMaintenanceToMachineList, BASECASINGINDEX, 1), + ofHatchAdder(MTEThoriumHighTempReactor::addEnergyInputToMachineList, BASECASINGINDEX, 1), + onElementPass(x -> x.mCasing++, ofBlock(GregTechAPI.sBlockCasings3, 12)))) + .addElement( + 'B', + ofChain( + ofHatchAdder(MTEThoriumHighTempReactor::addInputToMachineList, BASECASINGINDEX, 2), + onElementPass(x -> x.mCasing++, ofBlock(GregTechAPI.sBlockCasings3, 12)))) + // ofHatchAdderOptional(GT_TileEntity_THTR::addInputToMachineList, BASECASINGINDEX, 2, + // GregTechAPI.sBlockCasings3, 12)) + .build(); + + private static final int HELIUM_NEEDED = 730000; + private static final int powerUsage = (int) TierEU.RECIPE_IV / 2; + private static final int maxcapacity = 675000; + private static final int mincapacity = 100000; + private int HeliumSupply; + private int fuelsupply; + private boolean empty; + private int coolanttaking = 0; + private int mCasing = 0; + + public MTEThoriumHighTempReactor(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + private MTEThoriumHighTempReactor(String aName) { + super(aName); + } + + @Override + public boolean isCorrectMachinePart(ItemStack itemStack) { + return true; + } + + @Override + public IStructureDefinition<MTEThoriumHighTempReactor> getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType("High Temperature Reactor") + .addInfo("Controller block for the Thorium High Temperature Reactor (THTR)") + .addInfo("Needs to be primed with " + GTUtility.formatNumbers(HELIUM_NEEDED) + " of helium") + .addInfo("Needs a constant supply of coolant while running") + .addInfo("Needs at least 100k Fuel pebbles to start operation (can hold up to 675k pebbles)") + .addInfo("Consumes up to 0.5% of total Fuel Pellets per Operation depending on efficiency") + .addInfo("Efficiency decreases exponentially if the internal buffer is not completely filled") + .addInfo("Reactor will take 4 800L/t of coolant multiplied by efficiency") + .addInfo("Uses " + GTUtility.formatNumbers(powerUsage) + " EU/t") + .addInfo("One Operation takes 9 hours") + .addSeparator() + .beginStructureBlock(11, 12, 11, true) + .addController("Front bottom center") + .addCasingInfoMin("Radiation Proof Casings", 500, false) + .addStructureInfo("Corners and the 2 touching blocks are air (cylindric)") + .addInputBus("Any top layer casing", 2) + .addInputHatch("Any top layer casing", 2) + .addOutputBus("Any bottom layer casing", 1) + .addOutputHatch("Any bottom layer casing", 1) + .addEnergyHatch("Any bottom layer casing", 1) + .addMaintenanceHatch("Any bottom layer casing", 1) + .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTWORKS); + return tt; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && f.isNotFlipped(); + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + this.buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 5, 11, 0); + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) { + this.mCasing = 0; + return this.checkPiece(STRUCTURE_PIECE_MAIN, 5, 11, 0) && this.mCasing >= 500 + && this.mMaintenanceHatches.size() == 1 + && this.mInputHatches.size() > 0 + && this.mOutputHatches.size() > 0 + && this.mInputBusses.size() > 0 + && this.mOutputBusses.size() > 0 + && this.mEnergyHatches.size() > 0; + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.HeliumSupply = aNBT.getInteger("HeliumSupply"); + this.fuelsupply = aNBT.getInteger("fuelsupply"); + this.coolanttaking = aNBT.getInteger("coolanttaking"); + this.empty = aNBT.getBoolean("EmptyMode"); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("HeliumSupply", this.HeliumSupply); + aNBT.setInteger("fuelsupply", this.fuelsupply); + aNBT.setInteger("coolanttaking", this.coolanttaking); + aNBT.setBoolean("EmptyMode", this.empty); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide() && !this.empty) { + if (this.HeliumSupply < MTEThoriumHighTempReactor.HELIUM_NEEDED) { + for (FluidStack fluidStack : this.getStoredFluids()) { + if (fluidStack.isFluidEqual(Materials.Helium.getGas(1))) { + int toget = Math + .min(MTEThoriumHighTempReactor.HELIUM_NEEDED - this.HeliumSupply, fluidStack.amount); + fluidStack.amount -= toget; + this.HeliumSupply += toget; + if (MTEThoriumHighTempReactor.HELIUM_NEEDED == this.HeliumSupply && fluidStack.amount == 0) + fluidStack = null; + } + } + } + if (this.fuelsupply < maxcapacity) { + this.startRecipeProcessing(); + for (ItemStack itemStack : this.getStoredInputs()) { + if (GTUtility.areStacksEqual( + itemStack, + new ItemStack(THTRMaterials.aTHTR_Materials, 1, THTRMaterials.MATERIAL_FUEL_INDEX))) { + int toget = Math.min(maxcapacity - this.fuelsupply, itemStack.stackSize); + if (toget == 0) continue; + itemStack.stackSize -= toget; + this.fuelsupply += toget; + } + } + this.endRecipeProcessing(); + this.updateSlots(); + } + } + } + + @Override + public boolean checkRecipe(ItemStack controllerStack) { + + if (this.empty) { + if (this.HeliumSupply > 0 || this.fuelsupply > 0) { + this.mEfficiency = 10000; + this.mMaxProgresstime = 100; + return true; + } + return false; + } + if (this.HeliumSupply < MTEThoriumHighTempReactor.HELIUM_NEEDED || this.fuelsupply < mincapacity) return false; + + double eff = Math + .min(Math.pow((this.fuelsupply - mincapacity) / ((maxcapacity - mincapacity) / 10D), 2D) + 1, 100D) / 100D + - (this.getIdealStatus() - this.getRepairStatus()) / 10D; + if (eff <= 0D) return false; + + int toReduce = MathUtils.floorInt(this.fuelsupply * 0.005D * eff); + + final int originalToReduce = toReduce; + int burnedballs = toReduce / 64; + if (burnedballs > 0) toReduce -= burnedballs * 64; + + int meta = THTRMaterials.MATERIAL_USED_FUEL_INDEX; + + ItemStack[] toOutput = { new ItemStack(THTRMaterials.aTHTR_Materials, burnedballs, meta), + new ItemStack(THTRMaterials.aTHTR_Materials, toReduce, meta + 1) }; + if (!this.canOutputAll(toOutput)) return false; + + this.fuelsupply -= originalToReduce; + this.mOutputItems = toOutput; + + // this.updateSlots(); not needed ? + + this.coolanttaking = (int) (4800D * eff); + this.mEfficiency = (int) (eff * 10000D); + this.mEUt = -powerUsage; + this.mMaxProgresstime = 648000; + return true; + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + + if (this.empty) { + this.addOutput(Materials.Helium.getGas(this.HeliumSupply)); + this.addOutput( + new ItemStack(THTRMaterials.aTHTR_Materials, this.fuelsupply, THTRMaterials.MATERIAL_FUEL_INDEX)); + this.HeliumSupply = 0; + this.fuelsupply = 0; + this.updateSlots(); + return true; + } + + if (!super.onRunningTick(aStack)) return false; + + int takecoolant = this.coolanttaking; + int drainedamount = 0; + + for (MTEHatchInput tHatch : filterValidMTEs(mInputHatches)) { + FluidStack tLiquid = tHatch.getFluid(); + if (tLiquid != null && tLiquid.isFluidEqual(FluidRegistry.getFluidStack("ic2coolant", 1))) { + FluidStack drained = tHatch.drain(takecoolant, true); + takecoolant -= drained.amount; + drainedamount += drained.amount; + if (takecoolant <= 0) break; + } + } + + if (drainedamount > 0) this.addOutput(FluidRegistry.getFluidStack("ic2hotcoolant", drainedamount)); + + this.updateSlots(); + + return true; + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack itemStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack itemStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack itemStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new MTEThoriumHighTempReactor(this.mName); + } + + @Override + public String[] getInfoData() { + return new String[] { "Progress:", + GTUtility.formatNumbers(this.mProgresstime / 20) + "secs /" + + GTUtility.formatNumbers(this.mMaxProgresstime / 20) + + "secs", + "TRISO-Pebbles:", + GTUtility.formatNumbers(this.fuelsupply) + "pcs. / " + GTUtility.formatNumbers(this.fuelsupply) + "psc.", + "Helium-Level:", + GTUtility.formatNumbers(this.HeliumSupply) + "L / " + + GTUtility.formatNumbers(MTEThoriumHighTempReactor.HELIUM_NEEDED) + + "L", + "Coolant/t:", GTUtility.formatNumbers(this.mProgresstime == 0 ? 0 : this.coolanttaking) + "L/t", + "Problems:", String.valueOf(this.getIdealStatus() - this.getRepairStatus()) }; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + if (aActive) return new ITexture[] { + Textures.BlockIcons.getCasingTextureForId(MTEThoriumHighTempReactor.BASECASINGINDEX), + TextureFactory.builder() + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE_GLOW) + .extFacing() + .glow() + .build() }; + return new ITexture[] { + Textures.BlockIcons.getCasingTextureForId(MTEThoriumHighTempReactor.BASECASINGINDEX), + TextureFactory.builder() + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_GLOW) + .extFacing() + .glow() + .build() }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(MTEThoriumHighTempReactor.BASECASINGINDEX) }; + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (this.mMaxProgresstime > 0) { + GTUtility.sendChatToPlayer(aPlayer, "THTR mode cannot be changed while the machine is running."); + return; + } + this.empty = !this.empty; + GTUtility.sendChatToPlayer( + aPlayer, + "THTR is now running in " + (this.empty ? "emptying mode." : "normal Operation")); + } + + @Override + public boolean supportsVoidProtection() { + return true; + } + + public static class THTRMaterials { + + public static final SimpleSubItemClass aTHTR_Materials = new SimpleSubItemClass( + "BISOPelletCompound", // 0 + "BISOPelletBall", // 1 + "TRISOPelletCompound", // 2 + "TRISOPelletBall", // 3 + "TRISOPellet", // 4 + "BurnedOutTRISOPelletBall", // 5 + "BurnedOutTRISOPellet" // 6 + ); + public static final int MATERIAL_FUEL_INDEX = 4; + public static final int MATERIAL_USED_FUEL_INDEX = 5; + + public static void registeraTHR_Materials() { + GameRegistry.registerItem(MTEThoriumHighTempReactor.THTRMaterials.aTHTR_Materials, "bw.THTRMaterials"); + } + } +} diff --git a/src/main/java/bartworks/common/tileentities/multis/MTEWindmill.java b/src/main/java/bartworks/common/tileentities/multis/MTEWindmill.java new file mode 100644 index 0000000000..e60c147b70 --- /dev/null +++ b/src/main/java/bartworks/common/tileentities/multis/MTEWindmill.java @@ -0,0 +1,637 @@ +/* + * 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.common.tileentities.multis; + +import static bartworks.util.BWTooltipReference.MULTIBLOCK_ADDED_BY_BARTWORKS; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockAnyMeta; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofTileAdder; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GTValues.V; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityDispenser; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import com.gtnewhorizon.structurelib.StructureLibAPI; +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.AutoPlaceEnvironment; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.IStructureElement; +import com.gtnewhorizon.structurelib.structure.IStructureElementNoPlacement; +import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import com.gtnewhorizons.modularui.api.drawable.ItemDrawable; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; + +import bartworks.API.modularUI.BWUITextures; +import bartworks.MainMod; +import bartworks.common.items.ItemStonageRotors; +import bartworks.common.loaders.ItemRegistry; +import bartworks.common.tileentities.classic.TileEntityRotorBlock; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GUITextureSet; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.modularui.IGetTitleColor; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.MTEEnhancedMultiBlockBase; +import gregtech.api.objects.ItemData; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.common.items.IDMetaTool01; +import gregtech.common.items.MetaGeneratedTool01; + +public class MTEWindmill extends MTEEnhancedMultiBlockBase<MTEWindmill> + implements ISurvivalConstructable, IGetTitleColor { + + private static final IIcon[] iIcons = new IIcon[2]; + private static final IIconContainer[] iIconContainers = new IIconContainer[2]; + private static final ITexture[] iTextures = new ITexture[3]; + + private TileEntityRotorBlock rotorBlock; + private int mDoor = 0; + private int mHardenedClay = 0; + private int mMulti = 16; + + public MTEWindmill(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + private MTEWindmill(String aName) { + super(aName); + } + + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition<MTEWindmill> STRUCTURE_DEFINITION = StructureDefinition + .<MTEWindmill>builder() + .addShape( + STRUCTURE_PIECE_MAIN, + transpose( + new String[][] { { " ", " ", " ", " p ", " ", " ", " " }, + { " ", " ", " ppp ", " p p ", " ppp ", " ", " " }, + { " ", " ppppp ", " p p ", " p p ", " p p ", " ppppp ", " " }, + { " ppppp ", "p p", "p p", "p p", "p p", "p p", " ppppp " }, + { " ppspp ", "p p", "p p", "p p", "p p", "p p", " ppppp " }, + { " ppppp ", "p p", "p p", "p p", "p p", "p p", " ppppp " }, + { " ", " ppppp ", " p p ", " p p ", " p p ", " ppppp ", " " }, + { " ", " ccc ", " c c ", " c c ", " c c ", " ccc ", " " }, + { " ", " ccc ", " c c ", " c c ", " c c ", " ccc ", " " }, + { " ", " ccc ", " c c ", " c c ", " c c ", " ccc ", " " }, + { " ", " ccc ", " c c ", " c c ", " c c ", " ccc ", " " }, + { " bb~bb ", "bbbbbbb", "bbbbbbb", "bbbbbbb", "bbbbbbb", "bbbbbbb", " bbbbb " }, })) + .addElement('p', ofBlockAnyMeta(Blocks.planks)) + .addElement( + 'c', + ofChain( + onElementPass(t -> t.mHardenedClay++, ofBlock(Blocks.hardened_clay, 0)), + ofTileAdder(MTEWindmill::addDispenserToOutputSet, Blocks.hardened_clay, 0), + onElementPass(t -> t.mDoor++, new IStructureElementNoPlacement<MTEWindmill>() { + + private final IStructureElement<MTEWindmill> delegate = ofBlock(Blocks.wooden_door, 0); + + @Override + public boolean check(MTEWindmill gt_tileEntity_windmill, World world, int x, int y, int z) { + return this.delegate.check(gt_tileEntity_windmill, world, x, y, z); + } + + @Override + public boolean spawnHint(MTEWindmill gt_tileEntity_windmill, World world, int x, int y, int z, + ItemStack trigger) { + return this.delegate.spawnHint(gt_tileEntity_windmill, world, x, y, z, trigger); + } + }))) + .addElement('b', ofBlock(Blocks.brick_block, 0)) + .addElement('s', new IStructureElement<MTEWindmill>() { + + @Override + public boolean check(MTEWindmill t, World world, int x, int y, int z) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + return t.setRotorBlock(tileEntity); + } + + @Override + public boolean spawnHint(MTEWindmill t, World world, int x, int y, int z, ItemStack trigger) { + StructureLibAPI.hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), 0); + return true; + } + + @Override + public boolean placeBlock(MTEWindmill gt_tileEntity_windmill, World world, int x, int y, int z, + ItemStack trigger) { + return false; + } + + @Override + public BlocksToPlace getBlocksToPlace(MTEWindmill gt_tileEntity_windmill, World world, int x, int y, int z, + ItemStack trigger, AutoPlaceEnvironment env) { + return BlocksToPlace.create(new ItemStack(ItemRegistry.ROTORBLOCK)); + } + }) + .build(); + + @Override + public IStructureDefinition<MTEWindmill> getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && f.isNotFlipped(); + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType("Windmill") + .addInfo("Controller block for the Windmill") + .addInfo("A primitive Grinder powered by Kinetic energy") + .addInfo("Speed and output will be affected by wind speed, recipe and rotor") + .addInfo("Please use the Primitive Rotor") + .addInfo("Macerates 16 items at a time") + .addInfo("The structure is too complex!") + .addInfo("Follow the StructureLib hologram projector to build the main structure.") + .addSeparator() + .beginStructureBlock(7, 12, 7, false) + .addController("Front bottom center") + .addCasingInfoMin("Hardened Clay block", 40, false) + .addOtherStructurePart("Dispenser", "Any Hardened Clay block") + .addOtherStructurePart("0-1 Wooden door", "Any Hardened Clay block") + .addStructureHint("Primitive Kinetic Shaftbox", 1) + .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTWORKS); + return tt; + } + + @Override + public boolean isCorrectMachinePart(ItemStack itemStack) { + return true; + } + + private final Set<TileEntityDispenser> tileEntityDispensers = new HashSet<>(); + + @Override + public boolean onRunningTick(ItemStack aStack) { + if (this.mMaxProgresstime > 0) this.mProgresstime += this.rotorBlock.getGrindPower(); + if (!this.rotorBlock.rotorSlot.isEmpty()) this.setRotorDamage(this.rotorBlock, this.rotorBlock.getGrindPower()); + return this.rotorBlock.getGrindPower() > 0; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return true; + } + + @Override + public boolean doRandomMaintenanceDamage() { + return true; + } + + private float[] multiplierRecipe(ItemStack itemStack) { + // will return max and min value of the multiplier, the average of these is used to calculate the multiplier. + final Item item = itemStack.getItem(); + if (item == Items.wheat) { + return new float[] { 1.13f, 1.5f }; + } + final Block block = Block.getBlockFromItem(item); + if (item == Items.bone || block == Blocks.glowstone || block == Blocks.pumpkin) { + return new float[] { 0.8f, 1f }; + } + if (block == Blocks.gravel || block == Blocks.cobblestone + || block == Blocks.stone + || block == Blocks.sandstone + || block == Blocks.clay + || block == Blocks.hardened_clay + || block == Blocks.stained_hardened_clay + || block == Blocks.wool + || block == Blocks.netherrack + || block == Blocks.log + || block == Blocks.log2) { + return new float[] { 1f, 1.5f }; + } + final ItemData association = GTOreDictUnificator.getAssociation(itemStack); + final OrePrefixes prefix = association == null ? null : association.mPrefix; + if (prefix == null || association.mMaterial == null + || association.mMaterial.mMaterial == null + || association.mMaterial.mMaterial.getDust(1) == null) { + return new float[] { 1f, 1f }; + } + if (OrePrefixes.ore == prefix || OrePrefixes.oreNetherrack == prefix + || OrePrefixes.oreEndstone == prefix + || OrePrefixes.oreBlackgranite == prefix + || OrePrefixes.oreRedgranite == prefix + || OrePrefixes.oreMarble == prefix + || OrePrefixes.oreBasalt == prefix) { + return new float[] { 0.5f, 1f }; + } + if (OrePrefixes.stone == prefix || OrePrefixes.stoneBricks == prefix + || OrePrefixes.stoneChiseled == prefix + || OrePrefixes.stoneCobble == prefix + || OrePrefixes.stoneCracked == prefix + || OrePrefixes.stoneMossy == prefix + || OrePrefixes.stoneMossyBricks == prefix + || OrePrefixes.stoneSmooth == prefix + || OrePrefixes.cobblestone == prefix) { + return new float[] { 1f, 1.5f }; + } + return new float[] { 1f, 1f }; + } + + @Override + public boolean checkRecipe(ItemStack itemStack) { + if (itemStack == null || itemStack.getItem() == null) return false; + + if (this.mOutputItems == null) this.mOutputItems = new ItemStack[2]; + + GTRecipe tRecipe = RecipeMaps.maceratorRecipes + .findRecipe(this.getBaseMetaTileEntity(), false, false, V[1], null, itemStack); + if (tRecipe == null) { + return false; + } + + if (tRecipe.getOutput(0) != null) { + // Decrease input stack by appropriate amount (Not always 1) + for (int i = 0; i < this.mMulti; i++) { + if (!tRecipe.isRecipeInputEqual(true, null, itemStack)) { + this.mMulti = i; + break; + } + } + this.updateSlots(); + this.mOutputItems[0] = tRecipe.getOutput(0); + float[] mRecipe = this.multiplierRecipe(itemStack); + float multiper = Math.min( + mRecipe[1], + Math.max( + mRecipe[0], + 2f * (float) Math.sqrt((float) 1 / (this.rotorBlock.getWindStrength() + 1)) + * this.OutputMultiplier(this.rotorBlock) + * (mRecipe[0] + mRecipe[1]))); + int amount = (int) Math.floor(multiper * (this.mOutputItems[0].stackSize * this.mMulti)); + + // Split ItemStack --by gtpp + List<ItemStack> splitStacks = new ArrayList<>(); + while (amount > this.mOutputItems[0].getMaxStackSize()) { + ItemStack tmp = this.mOutputItems[0].copy(); + tmp.stackSize = this.mOutputItems[0].getMaxStackSize(); + amount -= this.mOutputItems[0].getMaxStackSize(); + splitStacks.add(tmp); + } + ItemStack tmp = this.mOutputItems[0].copy(); + tmp.stackSize = amount; + splitStacks.add(tmp); + this.mOutputItems = splitStacks.toArray(new ItemStack[splitStacks.size()]); + } + this.mMaxProgresstime = tRecipe.mDuration * 2 * 100 * this.mMulti / this.getSpeed(this.rotorBlock); + this.mMulti = 16; + return true; + } + + @Override + public void stopMachine() { + this.getBaseMetaTileEntity() + .disableWorking(); + } + + public boolean addDispenserToOutputSet(TileEntity aTileEntity) { + if (aTileEntity instanceof TileEntityDispenser) { + this.tileEntityDispensers.add((TileEntityDispenser) aTileEntity); + return true; + } + return false; + } + + public boolean setRotorBlock(TileEntity aTileEntity) { + if (aTileEntity instanceof TileEntityRotorBlock) { + this.rotorBlock = (TileEntityRotorBlock) aTileEntity; + return true; + } + return false; + } + + @Override + public boolean addOutput(ItemStack aStack) { + if (GTUtility.isStackInvalid(aStack)) return false; + + for (TileEntityDispenser tHatch : this.tileEntityDispensers) { + for (int i = tHatch.getSizeInventory() - 1; i >= 0; i--) { + if (tHatch.getStackInSlot(i) == null || GTUtility.areStacksEqual(tHatch.getStackInSlot(i), aStack) + && aStack.stackSize + tHatch.getStackInSlot(i).stackSize <= 64) { + if (GTUtility.areStacksEqual(tHatch.getStackInSlot(i), aStack)) { + ItemStack merge = tHatch.getStackInSlot(i) + .copy(); + merge.stackSize = aStack.stackSize + tHatch.getStackInSlot(i).stackSize; + tHatch.setInventorySlotContents(i, merge); + } else { + tHatch.setInventorySlotContents(i, aStack.copy()); + } + + if (GTUtility.areStacksEqual(tHatch.getStackInSlot(i), aStack)) { + aStack = null; + return true; + } + tHatch.setInventorySlotContents(i, null); + aStack = null; + return false; + } + } + } + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) { + + this.tileEntityDispensers.clear(); + this.mDoor = 0; + this.mHardenedClay = 0; + + return this.checkPiece(STRUCTURE_PIECE_MAIN, 3, 11, 0) && !this.tileEntityDispensers.isEmpty() + && this.mDoor <= 2 + && this.mHardenedClay >= 40; + } + + @Override + public int getCurrentEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + public void updateSlots() { + if (this.mInventory[1] != null && this.mInventory[1].stackSize <= 0) { + this.mInventory[1] = null; + } + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack itemStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack itemStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack itemStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new MTEWindmill(this.mName); + } + + @Override + public String[] getInfoData() { + return new String[] { "Progress:", + this.mProgresstime + " Grindings of " + this.mMaxProgresstime + " needed Grindings", "GrindPower:", + this.rotorBlock.getGrindPower() + "KU/t" }; + } + + @SideOnly(Side.CLIENT) + @Override + public void registerIcons(IIconRegister aBlockIconRegister) { + MTEWindmill.iIcons[0] = Blocks.brick_block.getIcon(0, 0); + MTEWindmill.iIconContainers[0] = new IIconContainer() { + + @Override + public IIcon getIcon() { + return MTEWindmill.iIcons[0]; + } + + @Override + public IIcon getOverlayIcon() { + return null; + } + + @Override + public ResourceLocation getTextureFile() { + return new ResourceLocation("brick"); + } + }; + + MTEWindmill.iIcons[1] = aBlockIconRegister.registerIcon(MainMod.MOD_ID + ":windmill_top"); + MTEWindmill.iIconContainers[1] = new IIconContainer() { + + @Override + public IIcon getIcon() { + return MTEWindmill.iIcons[1]; + } + + @Override + public IIcon getOverlayIcon() { + return null; + } + + @Override + public ResourceLocation getTextureFile() { + return new ResourceLocation(MainMod.MOD_ID + ":windmill_top"); + } + }; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + + ITexture[] ret = new ITexture[6]; + + if (this.isClientSide()) { + + if (facing == side || side == ForgeDirection.DOWN) { + MTEWindmill.iTextures[0] = TextureFactory.of(MTEWindmill.iIconContainers[0]); + Arrays.fill(ret, MTEWindmill.iTextures[0]); + } else if (side == ForgeDirection.UP) { + MTEWindmill.iTextures[1] = TextureFactory.of(MTEWindmill.iIconContainers[1]); + Arrays.fill(ret, MTEWindmill.iTextures[1]); + } else { + MTEWindmill.iTextures[2] = TextureFactory.of(Textures.BlockIcons.COVER_WOOD_PLATE); + Arrays.fill(ret, MTEWindmill.iTextures[2]); + } + } + return ret; + } + + public boolean isClientSide() { + if (this.getBaseMetaTileEntity() + .getWorld() != null) + return this.getBaseMetaTileEntity() + .getWorld().isRemote + ? FMLCommonHandler.instance() + .getSide() == Side.CLIENT + : FMLCommonHandler.instance() + .getEffectiveSide() == Side.CLIENT; + return FMLCommonHandler.instance() + .getEffectiveSide() == Side.CLIENT; + } + + @Override + public void construct(ItemStack itemStack, boolean b) { + this.buildPiece(STRUCTURE_PIECE_MAIN, itemStack, b, 3, 11, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (this.mMachine) return -1; + return this.survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 3, 11, 0, elementBudget, env, false, true); + } + + public float OutputMultiplier(TileEntityRotorBlock rotorBlock) { + try { + return ((ItemStonageRotors) rotorBlock.rotorSlot.get() + .getItem()).getmRotor(); + } catch (Exception e) { + return 1f; + } + } + + public int getSpeed(TileEntityRotorBlock rotorBlock) { + try { + return ((ItemStonageRotors) rotorBlock.rotorSlot.get() + .getItem()).getSpeed(); + } catch (Exception e) { + return 1; + } + } + + public void setRotorDamage(TileEntityRotorBlock rotorBlock, int damage) { + try { + ((ItemStonageRotors) rotorBlock.rotorSlot.get() + .getItem()).damageItemStack(rotorBlock.rotorSlot.get(), damage); + } catch (Exception e) { + rotorBlock.rotorSlot.damage(damage, false); + } + } + + @Override + public GUITextureSet getGUITextureSet() { + return new GUITextureSet().setMainBackground(BWUITextures.BACKGROUND_BROWN) + .setItemSlot(BWUITextures.SLOT_BROWN) + .setTitleTab( + BWUITextures.TAB_TITLE_BROWN, + BWUITextures.TAB_TITLE_DARK_BROWN, + BWUITextures.TAB_TITLE_ANGULAR_BROWN); + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(BWUITextures.PICTURE_BW_LOGO_47X21) + .setSize(47, 21) + .setPos(123, 59)); + } + + @Override + public int getTitleColor() { + return this.COLOR_TITLE_WHITE.get(); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + new SlotWidget(this.inventoryHandler, 1).setBackground( + this.getGUITextureSet() + .getItemSlot()) + .setPos(59, 35)) + .widget(new DrawableWidget() { + + private static final int DIVIDER = 125; + + @Override + public void onScreenUpdate() { + super.onScreenUpdate(); + if (MTEWindmill.this.mMaxProgresstime > 0) { + if (System.currentTimeMillis() / DIVIDER % 40 == 30) + this.setDrawable(BWUITextures.PICTURE_WINDMILL_ROTATING[3]); + else if (System.currentTimeMillis() / DIVIDER % 40 == 20) + this.setDrawable(BWUITextures.PICTURE_WINDMILL_ROTATING[2]); + else if (System.currentTimeMillis() / DIVIDER % 40 == 10) + this.setDrawable(BWUITextures.PICTURE_WINDMILL_ROTATING[1]); + else if (System.currentTimeMillis() / DIVIDER % 40 == 0) + this.setDrawable(BWUITextures.PICTURE_WINDMILL_ROTATING[0]); + } else { + this.setDrawable(BWUITextures.PICTURE_WINDMILL_EMPTY); + } + } + }.setDrawable(BWUITextures.PICTURE_WINDMILL_EMPTY) + .setPos(85, 27) + .setSize(32, 32)) + .widget(new FakeSyncWidget.IntegerSyncer(() -> this.mMaxProgresstime, val -> this.mMaxProgresstime = val)) + .widget( + new ItemDrawable( + () -> this.mMachine && !this.getBaseMetaTileEntity() + .isActive() + ? MetaGeneratedTool01.INSTANCE + .getToolWithStats(IDMetaTool01.SOFTMALLET.ID, 1, null, null, null) + : null).asWidget() + .setPos(66, 66)) + .widget( + new FakeSyncWidget.BooleanSyncer( + () -> this.getBaseMetaTileEntity() + .isActive(), + val -> this.getBaseMetaTileEntity() + .setActive(val))) + .widget( + new TextWidget(GTUtility.trans("138", "Incomplete Structure.")) + .setDefaultColor(this.COLOR_TEXT_WHITE.get()) + .setMaxWidth(150) + .setEnabled(widget -> !this.mMachine) + .setPos(92, 22)) + .widget(new FakeSyncWidget.BooleanSyncer(() -> this.mMachine, val -> this.mMachine = val)); + } + + @Override + public boolean getDefaultHasMaintenanceChecks() { + return false; + } +} diff --git a/src/main/java/bartworks/common/tileentities/multis/mega/MTEMegaBlastFurnace.java b/src/main/java/bartworks/common/tileentities/multis/mega/MTEMegaBlastFurnace.java new file mode 100644 index 0000000000..8d5ea073db --- /dev/null +++ b/src/main/java/bartworks/common/tileentities/multis/mega/MTEMegaBlastFurnace.java @@ -0,0 +1,430 @@ +/* + * 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.common.tileentities.multis.mega; + +import static bartworks.util.BWTooltipReference.MULTIBLOCK_ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.withChannel; +import static gregtech.api.enums.HatchElement.*; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gregtech.api.util.GTStructureUtility.ofCoil; +import static gregtech.api.util.GTUtility.filterValidMTEs; + +import java.util.ArrayList; +import java.util.Arrays; + +import javax.annotation.Nonnull; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IItemSource; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import bartworks.API.BorosilicateGlass; +import bartworks.common.configs.ConfigHandler; +import bartworks.util.BWUtil; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.HeatingCoilLevel; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.metatileentity.implementations.MTEHatchMuffler; +import gregtech.api.metatileentity.implementations.MTEHatchOutput; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.OverclockCalculator; + +public class MTEMegaBlastFurnace extends MegaMultiBlockBase<MTEMegaBlastFurnace> implements ISurvivalConstructable { + + private static final int CASING_INDEX = 11; + private static final IStructureDefinition<MTEMegaBlastFurnace> STRUCTURE_DEFINITION = StructureDefinition + .<MTEMegaBlastFurnace>builder() + .addShape("main", createShape()) + .addElement('=', StructureElementAirNoHint.getInstance()) + .addElement( + 't', + buildHatchAdder(MTEMegaBlastFurnace.class) + .atLeast( + OutputHatch.withAdder(MTEMegaBlastFurnace::addOutputHatchToTopList) + .withCount(t -> t.mPollutionOutputHatches.size())) + .casingIndex(CASING_INDEX) + .dot(1) + .buildAndChain(GregTechAPI.sBlockCasings1, CASING_INDEX)) + .addElement('m', Muffler.newAny(CASING_INDEX, 2)) + .addElement( + 'C', + withChannel("coil", ofCoil(MTEMegaBlastFurnace::setCoilLevel, MTEMegaBlastFurnace::getCoilLevel))) + .addElement( + 'g', + withChannel( + "glass", + BorosilicateGlass + .ofBoroGlass((byte) 0, (byte) 1, Byte.MAX_VALUE, (te, t) -> te.glassTier = t, te -> te.glassTier))) + .addElement( + 'b', + buildHatchAdder(MTEMegaBlastFurnace.class) + .atLeast(InputHatch, OutputHatch, InputBus, OutputBus, Maintenance, Energy.or(ExoticEnergy)) + .casingIndex(CASING_INDEX) + .dot(1) + .buildAndChain(GregTechAPI.sBlockCasings1, CASING_INDEX)) + .build(); + + private static String[][] createShape() { + String[][] raw = new String[20][]; + + raw[0] = new String[15]; + String topCasing = "ttttttttttttttt"; + String middleTopCasing = "tttttttmttttttt"; + raw[0][0] = topCasing; + for (int i = 1; i < 15; i++) { + raw[0][i] = topCasing; + } + raw[0][7] = middleTopCasing; + + raw[1] = new String[15]; + String allGlass = "ggggggggggggggg"; + String allCoil = "gCCCCCCCCCCCCCg"; + String middleLine = "gC===========Cg"; + raw[1][0] = allGlass; + raw[1][1] = allCoil; + raw[1][13] = allCoil; + raw[1][14] = allGlass; + for (int i = 2; i < 13; i++) { + raw[1][i] = middleLine; + } + for (int i = 2; i < 19; i++) { + raw[i] = raw[1]; + } + String bottomCasing = "bbbbbbbbbbbbbbb"; + raw[19] = new String[15]; + for (int i = 0; i < 15; i++) { + raw[19][i] = bottomCasing; + } + + raw[17] = Arrays.copyOf(raw[17], raw[17].length); + raw[17][0] = "ggggggg~ggggggg"; + + return transpose(raw); + } + + private HeatingCoilLevel mCoilLevel; + protected final ArrayList<MTEHatchOutput> mPollutionOutputHatches = new ArrayList<>(); + protected final FluidStack[] pollutionFluidStacks = { Materials.CarbonDioxide.getGas(1000), + Materials.CarbonMonoxide.getGas(1000), Materials.SulfurDioxide.getGas(1000) }; + private int mHeatingCapacity; + private byte glassTier; + private final static int polPtick = ConfigHandler.basePollutionMBFSecond / 20 * ConfigHandler.megaMachinesMax; + + public MTEMegaBlastFurnace(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEMegaBlastFurnace(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new MTEMegaBlastFurnace(this.mName); + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType("Blast Furnace") + .addInfo("Controller block for the Mega Blast Furnace") + .addInfo("You can use some fluids to reduce recipe time. Place the circuit in the Input Bus") + .addInfo("Each 900K over the min. Heat required reduces power consumption by 5% (multiplicatively)") + .addInfo("Each 1800K over the min. Heat allows for an overclock to be upgraded to a perfect overclock.") + .addInfo("That means the EBF will reduce recipe time by a factor 4 instead of 2 (giving 100% efficiency).") + .addInfo("Additionally gives +100K for every tier past MV") + .addInfo( + GTValues.TIER_COLORS[8] + GTValues.VN[8] + + EnumChatFormatting.GRAY + + "-tier glass required for " + + EnumChatFormatting.BLUE + + "Tec" + + EnumChatFormatting.DARK_BLUE + + "Tech" + + EnumChatFormatting.GRAY + + " Laser Hatches.") + .addPollutionAmount(20 * this.getPollutionPerTick(null)) + .addSeparator() + .beginStructureBlock(15, 20, 15, true) + .addController("3rd layer center") + .addCasingInfoRange("Heat Proof Machine Casing", 0, 279, false) + .addOtherStructurePart("864x Heating Coils", "Inner 13x18x13 (Hollow)") + .addOtherStructurePart("1007x Borosilicate Glass", "Outer 15x18x15") + .addStructureInfo("The glass tier limits the Energy Input tier") + .addEnergyHatch("Any bottom layer casing") + .addMaintenanceHatch("Any bottom layer casing") + .addMufflerHatch("Top middle") + .addInputBus("Any bottom layer casing") + .addInputHatch("Any bottom layer casing") + .addOutputBus("Any bottom layer casing") + .addOutputHatch("Gasses, Any top layer casing") + .addStructureInfo("Recovery amount scales with Muffler Hatch tier") + .addOutputHatch("Platline fluids, Any bottom layer casing") + .addStructureHint("This Mega Multiblock is too big to have its structure hologram displayed fully.") + .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS); + return tt; + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.glassTier = aNBT.getByte("glasTier"); + if (!aNBT.hasKey(INPUT_SEPARATION_NBT_KEY)) { + this.inputSeparation = aNBT.getBoolean("isBussesSeparate"); + } + if (!aNBT.hasKey(BATCH_MODE_NBT_KEY)) { + this.batchMode = aNBT.getBoolean("mUseMultiparallelMode"); + } + } + + @Override + public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { + if (!aPlayer.isSneaking()) { + this.inputSeparation = !this.inputSeparation; + GTUtility.sendChatToPlayer( + aPlayer, + StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + this.inputSeparation); + return true; + } + this.batchMode = !this.batchMode; + if (this.batchMode) { + GTUtility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); + } else { + GTUtility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); + } + return true; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + if (aActive) return new ITexture[] { casingTexturePages[0][CASING_INDEX], TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE_GLOW) + .extFacing() + .glow() + .build() }; + return new ITexture[] { casingTexturePages[0][CASING_INDEX], TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_GLOW) + .extFacing() + .glow() + .build() }; + } + return new ITexture[] { casingTexturePages[0][CASING_INDEX] }; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setByte("glasTier", this.glassTier); + } + + @Override + public int getPollutionPerTick(ItemStack aStack) { + return polPtick; + } + + public boolean addOutputHatchToTopList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof MTEHatchOutput) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return this.mPollutionOutputHatches.add((MTEHatchOutput) aMetaTileEntity); + } + return false; + } + + @Override + protected String[] getExtendedInfoData() { + return new String[] { StatCollector.translateToLocal("GT5U.EBF.heat") + ": " + + EnumChatFormatting.GREEN + + GTUtility.formatNumbers(this.mHeatingCapacity) + + EnumChatFormatting.RESET + + " K" }; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @Nonnull + @Override + protected OverclockCalculator createOverclockCalculator(@Nonnull GTRecipe recipe) { + return super.createOverclockCalculator(recipe).setRecipeHeat(recipe.mSpecialValue) + .setMachineHeat(MTEMegaBlastFurnace.this.mHeatingCapacity) + .setHeatOC(true) + .setHeatDiscount(true); + } + + @Override + protected @Nonnull CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) { + return recipe.mSpecialValue <= MTEMegaBlastFurnace.this.mHeatingCapacity + ? CheckRecipeResultRegistry.SUCCESSFUL + : CheckRecipeResultRegistry.insufficientHeat(recipe.mSpecialValue); + } + }.setMaxParallel(ConfigHandler.megaMachinesMax); + } + + @Override + public IStructureDefinition<MTEMegaBlastFurnace> getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + this.buildPiece("main", stackSize, hintsOnly, 7, 17, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (this.mMachine) return -1; + int realBudget = elementBudget >= 200 ? elementBudget : Math.min(200, elementBudget * 5); + this.glassTier = 0; + this.setCoilLevel(HeatingCoilLevel.None); + return this.survivialBuildPiece("main", stackSize, 7, 17, 0, realBudget, source, actor, false, true); + } + + public void setCoilLevel(HeatingCoilLevel aCoilLevel) { + this.mCoilLevel = aCoilLevel; + } + + public HeatingCoilLevel getCoilLevel() { + return this.mCoilLevel; + } + + @Override + public boolean addOutput(FluidStack aLiquid) { + if (aLiquid == null) return false; + FluidStack tLiquid = aLiquid.copy(); + boolean isOutputPollution = false; + for (FluidStack pollutionFluidStack : this.pollutionFluidStacks) { + if (!tLiquid.isFluidEqual(pollutionFluidStack)) continue; + + isOutputPollution = true; + break; + } + ArrayList<MTEHatchOutput> tOutputHatches; + if (isOutputPollution) { + tOutputHatches = this.mPollutionOutputHatches; + int pollutionReduction = 0; + for (MTEHatchMuffler tHatch : filterValidMTEs(mMufflerHatches)) { + pollutionReduction = 100 - tHatch.calculatePollutionReduction(100); + break; + } + tLiquid.amount = tLiquid.amount * pollutionReduction / 100; + } else { + tOutputHatches = this.mOutputHatches; + } + return dumpFluid(tOutputHatches, tLiquid, true) || dumpFluid(tOutputHatches, tLiquid, false); + } + + @Override + public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + this.mHeatingCapacity = 0; + this.glassTier = 0; + + this.setCoilLevel(HeatingCoilLevel.None); + + this.mPollutionOutputHatches.clear(); + + if (!this.checkPiece("main", 7, 17, 0) || this.getCoilLevel() == HeatingCoilLevel.None + || this.mMaintenanceHatches.size() != 1) return false; + + if (this.glassTier < 8) { + for (int i = 0; i < this.mExoticEnergyHatches.size(); ++i) { + MTEHatch hatch = this.mExoticEnergyHatches.get(i); + if (hatch.getConnectionType() == MTEHatch.ConnectionType.LASER) { + return false; + } + if (this.glassTier < hatch.mTier) { + return false; + } + } + for (int i = 0; i < this.mEnergyHatches.size(); ++i) { + if (this.glassTier < this.mEnergyHatches.get(i).mTier) { + return false; + } + } + } + + this.mHeatingCapacity = (int) this.getCoilLevel() + .getHeat() + 100 * (BWUtil.getTier(this.getMaxInputEu()) - 2); + + return true; + } + + @Override + public RecipeMap<?> getRecipeMap() { + return RecipeMaps.blastFurnaceRecipes; + } + + @Override + public int getRecipeCatalystPriority() { + return -2; + } + + @Override + public boolean supportsInputSeparation() { + return true; + } + + @Override + public boolean supportsBatchMode() { + return true; + } + + @Override + public boolean supportsVoidProtection() { + return true; + } +} diff --git a/src/main/java/bartworks/common/tileentities/multis/mega/MTEMegaChemicalReactor.java b/src/main/java/bartworks/common/tileentities/multis/mega/MTEMegaChemicalReactor.java new file mode 100644 index 0000000000..e1366cec7d --- /dev/null +++ b/src/main/java/bartworks/common/tileentities/multis/mega/MTEMegaChemicalReactor.java @@ -0,0 +1,278 @@ +/* + * 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.common.tileentities.multis.mega; + +import static bartworks.util.BWTooltipReference.MULTIBLOCK_ADDED_BY_BARTWORKS; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.*; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; + +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IItemSource; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import bartworks.API.BorosilicateGlass; +import bartworks.common.configs.ConfigHandler; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.GTValues; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; + +public class MTEMegaChemicalReactor extends MegaMultiBlockBase<MTEMegaChemicalReactor> + implements ISurvivalConstructable { + + private byte glassTier; + + public MTEMegaChemicalReactor(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEMegaChemicalReactor(String aName) { + super(aName); + } + + @Override + public MultiblockTooltipBuilder createTooltip() { + final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType("Chemical Reactor") + .addInfo("Controller block for the Chemical Reactor") + .addInfo("What molecule do you want to synthesize") + .addInfo("Or you want to replace something in this molecule") + .addInfo( + GTValues.TIER_COLORS[8] + GTValues.VN[8] + + EnumChatFormatting.GRAY + + "-tier glass required for " + + EnumChatFormatting.BLUE + + "Tec" + + EnumChatFormatting.DARK_BLUE + + "Tech" + + EnumChatFormatting.GRAY + + " Laser Hatches.") + .addInfo("The structure is too complex!") + .addInfo("Follow the Structure Lib hologram projector to build the main structure.") + .addSeparator() + .beginStructureBlock(5, 5, 9, false) + .addController("Front center") + .addStructureInfo("46x Chemically Inert Machine Casing (minimum)") + .addStructureInfo("7x Fusion Coil Block") + .addStructureInfo("28x PTFE Pipe Casing") + .addStructureInfo("64x Borosilicate Glass Block (any tier)") + .addStructureInfo("The glass tier limits the Energy Input tier") + .addEnergyHatch("Hint block ", 3) + .addMaintenanceHatch("Hint block ", 2) + .addInputHatch("Hint block ", 1) + .addInputBus("Hint block ", 1) + .addOutputBus("Hint block ", 1) + .addOutputHatch("Hint block ", 1) + .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTWORKS); + return tt; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEMegaChemicalReactor(this.mName); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + if (aActive) return new ITexture[] { casingTexturePages[1][48], TextureFactory.builder() + .addIcon(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE_GLOW) + .extFacing() + .glow() + .build() }; + return new ITexture[] { casingTexturePages[1][48], TextureFactory.builder() + .addIcon(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_GLOW) + .extFacing() + .glow() + .build() }; + } + return new ITexture[] { casingTexturePages[1][48] }; + } + + @Override + public boolean supportsSingleRecipeLocking() { + return true; + } + + @Override + public RecipeMap<?> getRecipeMap() { + return RecipeMaps.multiblockChemicalReactorRecipes; + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if (!aNBT.hasKey(BATCH_MODE_NBT_KEY)) { + this.batchMode = aNBT.getBoolean("mUseMultiparallelMode"); + } + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + inputSeparation = !inputSeparation; + GTUtility.sendChatToPlayer( + aPlayer, + StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + inputSeparation); + } + + @Override + public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { + if (aPlayer.isSneaking()) { + this.batchMode = !this.batchMode; + if (this.batchMode) { + GTUtility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); + } else { + GTUtility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); + } + return true; + } + return false; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().enablePerfectOverclock() + .setMaxParallel(ConfigHandler.megaMachinesMax); + } + + @Override + public void construct(ItemStack aStack, boolean aHintsOnly) { + this.buildPiece(STRUCTURE_PIECE_MAIN, aStack, aHintsOnly, 2, 2, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (this.mMachine) return -1; + int realBudget = elementBudget >= 200 ? elementBudget : Math.min(200, elementBudget * 5); + return this + .survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 2, 2, 0, realBudget, source, actor, false, true); + } + // -------------- TEC TECH COMPAT ---------------- + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + this.glassTier = 0; + + if (!this.checkPiece(STRUCTURE_PIECE_MAIN, 2, 2, 0) || this.mMaintenanceHatches.size() != 1) return false; + + if (this.glassTier < 8) { + for (int i = 0; i < this.mExoticEnergyHatches.size(); ++i) { + MTEHatch hatch = this.mExoticEnergyHatches.get(i); + if (hatch.getConnectionType() == MTEHatch.ConnectionType.LASER) { + return false; + } + if (this.glassTier < hatch.mTier) { + return false; + } + } + for (int i = 0; i < this.mEnergyHatches.size(); ++i) { + if (this.glassTier < this.mEnergyHatches.get(i).mTier) { + return false; + } + } + } + + return true; + } + + private static final int CASING_INDEX = 176; + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition<MTEMegaChemicalReactor> STRUCTURE_DEFINITION = StructureDefinition + .<MTEMegaChemicalReactor>builder() + .addShape( + STRUCTURE_PIECE_MAIN, + transpose( + new String[][] { { "ttttt", "dptpd", "dptpd", "dptpd", "dptpd", "dptpd", "dptpd", "dptpd", "ttttt" }, + { "tgggt", " ggg ", " ggg ", " ggg ", " ggg ", " ggg ", " ggg ", " ggg ", "teeet" }, + { "tg~gt", " gcg ", " gcg ", " gcg ", " gcg ", " gcg ", " gcg ", " gcg ", "teret" }, + { "tgggt", " ggg ", " ggg ", " ggg ", " ggg ", " ggg ", " ggg ", " ggg ", "teeet" }, + { "ttttt", "dptpd", "dptpd", "dptpd", "dptpd", "dptpd", "dptpd", "dptpd", "ttttt" }, })) + .addElement('p', ofBlock(GregTechAPI.sBlockCasings8, 1)) + .addElement('t', ofBlock(GregTechAPI.sBlockCasings8, 0)) + .addElement( + 'd', + buildHatchAdder(MTEMegaChemicalReactor.class).atLeast(InputBus, InputHatch, OutputBus, OutputHatch) + .casingIndex(CASING_INDEX) + .dot(1) + .buildAndChain(GregTechAPI.sBlockCasings8, 0)) + .addElement('r', Maintenance.newAny(CASING_INDEX, 2)) + .addElement( + 'e', + buildHatchAdder(MTEMegaChemicalReactor.class) + .atLeast(Energy.or(ExoticEnergy), InputHatch, InputBus, OutputHatch, OutputBus) + .casingIndex(CASING_INDEX) + .dot(3) + .buildAndChain(GregTechAPI.sBlockCasings8, 0)) + .addElement('c', ofChain(ofBlock(GregTechAPI.sBlockCasings4, 7), ofBlock(GregTechAPI.sBlockCasings5, 13))) + .addElement( + 'g', + BorosilicateGlass + .ofBoroGlass((byte) 0, (byte) 1, Byte.MAX_VALUE, (te, t) -> te.glassTier = t, te -> te.glassTier)) + .build(); + + @Override + public IStructureDefinition<MTEMegaChemicalReactor> getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + public boolean supportsBatchMode() { + return true; + } + + @Override + public boolean supportsVoidProtection() { + return true; + } + + @Override + public boolean supportsInputSeparation() { + return true; + } +} diff --git a/src/main/java/bartworks/common/tileentities/multis/mega/MTEMegaDistillTower.java b/src/main/java/bartworks/common/tileentities/multis/mega/MTEMegaDistillTower.java new file mode 100644 index 0000000000..382b64fb47 --- /dev/null +++ b/src/main/java/bartworks/common/tileentities/multis/mega/MTEMegaDistillTower.java @@ -0,0 +1,446 @@ +/* + * 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.common.tileentities.multis.mega; + +import static bartworks.util.BWTooltipReference.MULTIBLOCK_ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.*; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_GLOW; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IItemSource; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.IStructureElementCheckOnly; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import bartworks.common.configs.ConfigHandler; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IHatchElement; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.fluid.IFluidStore; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.implementations.MTEHatchOutput; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.common.tileentities.machines.MTEHatchOutputME; + +public class MTEMegaDistillTower extends MegaMultiBlockBase<MTEMegaDistillTower> implements ISurvivalConstructable { + + protected static final int CASING_INDEX = 49; + protected static final String STRUCTURE_PIECE_BASE = "base"; + protected static final String STRUCTURE_PIECE_LAYER = "layer"; + protected static final String STRUCTURE_PIECE_TOP_HINT = "top"; + private static final IStructureDefinition<MTEMegaDistillTower> STRUCTURE_DEFINITION; + + static { + IHatchElement<MTEMegaDistillTower> layeredOutputHatch = OutputHatch + .withCount(MTEMegaDistillTower::getCurrentLayerOutputHatchCount) + .withAdder(MTEMegaDistillTower::addLayerOutputHatch); + STRUCTURE_DEFINITION = StructureDefinition.<MTEMegaDistillTower>builder() + .addShape( + STRUCTURE_PIECE_BASE, + transpose( + new String[][] { { "bbbbbbb~bbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", + "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", + "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbb", + "bbbbbbbbbbbbbbb" }, })) + .addShape( + STRUCTURE_PIECE_LAYER, + transpose( + new String[][] { + { "lllllllllllllll", "lcccccccccccccl", "lcccccccccccccl", "lcccccccccccccl", "lcccccccccccccl", + "lcccccccccccccl", "lcccccccccccccl", "lcccccccccccccl", "lcccccccccccccl", + "lcccccccccccccl", "lcccccccccccccl", "lcccccccccccccl", "lcccccccccccccl", + "lcccccccccccccl", "lllllllllllllll" }, + { "lllllllllllllll", "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "lllllllllllllll" }, + { "lllllllllllllll", "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "lllllllllllllll" }, + { "lllllllllllllll", "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "lllllllllllllll" }, + { "lllllllllllllll", "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "lllllllllllllll" }, })) + .addShape( + STRUCTURE_PIECE_TOP_HINT, + transpose( + new String[][] { + { "lllllllllllllll", "lllllllllllllll", "lllllllllllllll", "lllllllllllllll", "lllllllllllllll", + "lllllllllllllll", "lllllllllllllll", "lllllllllllllll", "lllllllllllllll", + "lllllllllllllll", "lllllllllllllll", "lllllllllllllll", "lllllllllllllll", + "lllllllllllllll", "lllllllllllllll" }, + { "lllllllllllllll", "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "lllllllllllllll" }, + { "lllllllllllllll", "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "lllllllllllllll" }, + { "lllllllllllllll", "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "lllllllllllllll" }, + { "lllllllllllllll", "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "l=============l", "l=============l", "l=============l", + "l=============l", "lllllllllllllll" }, })) + .addElement('=', StructureElementAirNoHint.getInstance()) + .addElement( + 'b', + buildHatchAdder(MTEMegaDistillTower.class) + .atLeast(InputHatch, OutputHatch, InputBus, OutputBus, Maintenance, Energy.or(ExoticEnergy)) + .casingIndex(CASING_INDEX) + .dot(1) + .buildAndChain( + onElementPass(MTEMegaDistillTower::onCasingFound, ofBlock(GregTechAPI.sBlockCasings4, 1)))) + .addElement( + 'l', + buildHatchAdder(MTEMegaDistillTower.class) + .atLeast(layeredOutputHatch, Maintenance, Energy.or(ExoticEnergy)) + .casingIndex(CASING_INDEX) + .dot(1) + .buildAndChain( + onElementPass(MTEMegaDistillTower::onCasingFound, ofBlock(GregTechAPI.sBlockCasings4, 1)))) + .addElement('c', (IStructureElementCheckOnly<MTEMegaDistillTower>) (t, world, x, y, z) -> { + if (world.isAirBlock(x, y, z)) { + if (t.mTopState < 1) { + t.mTopState = 0; + return true; + } + // definitely top - cannot be air + return false; + } + // from here on we must be looking at a top layer, since it's not air + if (t.mTopState == 0) + // must be air but failed, so no + return false; + t.mTopState = 1; + // hatch adder + TileEntity tileEntity = world.getTileEntity(x, y, z); + if (tileEntity instanceof IGregTechTileEntity entity && t.addLayerOutputHatch(entity, CASING_INDEX)) { + t.onTopLayerFound(false); + return true; + } + // block adder + if (world.getBlock(x, y, z) == GregTechAPI.sBlockCasings4 && world.getBlockMetadata(x, y, z) == 1) { + t.onTopLayerFound(true); + return true; + } + return false; + }) + .build(); + } + + protected final List<List<MTEHatchOutput>> mOutputHatchesByLayer = new ArrayList<>(); + protected int mHeight; + protected int mCasing; + protected boolean mTopLayerFound; + + // -1 => maybe top, maybe not, 0 => definitely not top, 1 => definitely top + private int mTopState = -1; + + public MTEMegaDistillTower(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + private MTEMegaDistillTower(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEMegaDistillTower(this.mName); + } + + protected void onCasingFound() { + this.mCasing++; + } + + protected int getCurrentLayerOutputHatchCount() { + return this.mOutputHatchesByLayer.size() < this.mHeight || this.mHeight <= 0 ? 0 + : this.mOutputHatchesByLayer.get(this.mHeight - 1) + .size(); + } + + protected boolean addLayerOutputHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null || aTileEntity.isDead() || !(aTileEntity.getMetaTileEntity() instanceof MTEHatchOutput)) + return false; + while (this.mOutputHatchesByLayer.size() < this.mHeight) this.mOutputHatchesByLayer.add(new ArrayList<>()); + MTEHatchOutput tHatch = (MTEHatchOutput) aTileEntity.getMetaTileEntity(); + tHatch.updateTexture(aBaseCasingIndex); + return this.mOutputHatchesByLayer.get(this.mHeight - 1) + .add(tHatch); + } + + protected void onTopLayerFound(boolean aIsCasing) { + this.mTopLayerFound = true; + if (aIsCasing) this.onCasingFound(); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + if (aActive) return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE_GLOW) + .extFacing() + .glow() + .build() }; + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX), TextureFactory.builder() + .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_GLOW) + .extFacing() + .glow() + .build() }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX) }; + } + + @Override + public RecipeMap<?> getRecipeMap() { + return RecipeMaps.distillationTowerRecipes; + } + + @Override + public int getRecipeCatalystPriority() { + return -1; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType("Distillery") + .addInfo("Controller block for the Distillation Tower") + .addInfo("Fluids are only put out at the correct height") + .addInfo("The correct height equals the slot number in the NEI recipe") + .addSeparator() + .beginVariableStructureBlock(15, 15, 16, 56, 15, 15, true) + .addController("Front bottom") + .addOtherStructurePart("Clean Stainless Steel Machine Casing", "15 x h - 5 (minimum)") + .addEnergyHatch("Any casing") + .addMaintenanceHatch("Any casing") + .addInputHatch("Any bottom layer casing") + .addOutputBus("Any bottom layer casing") + .addOutputHatch("2-11x Output Hatches (One per Output Layer except bottom layer)") + .addStructureInfo("An \"Output Layer\" consists of 5 layers!") + .addStructureHint("The interior of this Mega Multiblock's hologram is empty, it should be all air.") + .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS); + return tt; + } + + @Override + public IStructureDefinition<MTEMegaDistillTower> getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + // reset + this.mOutputHatchesByLayer.forEach(List::clear); + this.mHeight = 1; + this.mTopLayerFound = false; + this.mTopState = -1; + + // check base + if (!this.checkPiece(STRUCTURE_PIECE_BASE, 7, 0, 0)) return false; + + // check each layer + while (this.mHeight < 12) { + if (!checkPiece(STRUCTURE_PIECE_LAYER, 7, mHeight * 5, 0)) { + return false; + } + if (this.mOutputHatchesByLayer.size() < this.mHeight || this.mOutputHatchesByLayer.get(this.mHeight - 1) + .isEmpty()) + // layer without output hatch + return false; + if (mTopLayerFound) { + break; + } + this.mTopState = -1; + // not top + this.mHeight++; + } + + // validate final invariants... + return this.mCasing >= 75 * this.mHeight + 10 && this.mHeight >= 2 + && this.mTopLayerFound + && this.mMaintenanceHatches.size() == 1; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + this.buildPiece(STRUCTURE_PIECE_BASE, stackSize, hintsOnly, 7, 0, 0); + int tTotalHeight = Math.min(12, stackSize.stackSize + 2); // min 2 output layer, so at least 1 + 2 height + for (int i = 1; i < tTotalHeight - 1; i++) { + this.buildPiece(STRUCTURE_PIECE_LAYER, stackSize, hintsOnly, 7, 5 * i, 0); + } + this.buildPiece(STRUCTURE_PIECE_TOP_HINT, stackSize, hintsOnly, 7, 5 * (tTotalHeight - 1), 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (this.mMachine) return -1; + int realBudget = elementBudget >= 200 ? elementBudget : Math.min(200, elementBudget * 5); + this.mHeight = 0; + int built = this + .survivialBuildPiece(STRUCTURE_PIECE_BASE, stackSize, 7, 0, 0, realBudget, source, actor, false, true); + if (built >= 0) return built; + int tTotalHeight = Math.min(12, stackSize.stackSize + 2); // min 2 output layer, so at least 1 + 2 height + for (int i = 1; i < tTotalHeight - 1; i++) { + this.mHeight = i; + built = this.survivialBuildPiece( + STRUCTURE_PIECE_LAYER, + stackSize, + 7, + 5 * this.mHeight, + 0, + realBudget, + source, + actor, + false, + true); + if (built >= 0) return built; + } + this.mHeight = tTotalHeight - 1; + return this.survivialBuildPiece( + STRUCTURE_PIECE_TOP_HINT, + stackSize, + 7, + 5 * this.mHeight, + 0, + realBudget, + source, + actor, + false, + true); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if (!aNBT.hasKey(BATCH_MODE_NBT_KEY)) { + this.batchMode = aNBT.getBoolean("mUseMultiparallelMode"); + } + } + + @Override + public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { + if (aPlayer.isSneaking()) { + this.batchMode = !this.batchMode; + if (this.batchMode) { + GTUtility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); + } else { + GTUtility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); + } + return true; + } + return false; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setMaxParallel(ConfigHandler.megaMachinesMax); + } + + @Override + public boolean canDumpFluidToME() { + + // All fluids can be dumped to ME only if each layer contains a ME Output Hatch. + for (List<MTEHatchOutput> tLayerOutputHatches : this.mOutputHatchesByLayer) { + + boolean foundMEHatch = false; + + for (IFluidStore tHatch : tLayerOutputHatches) { + if (tHatch instanceof MTEHatchOutputME tMEHatch) { + if (tMEHatch.canAcceptFluid()) { + foundMEHatch = true; + break; + } + } + } + + // Exit if we didn't find a valid hatch on this layer. + if (!foundMEHatch) { + return false; + } + } + + return true; + } + + @Override + protected void addFluidOutputs(FluidStack[] mOutputFluids2) { + for (int i = 0; i < mOutputFluids2.length && i < this.mOutputHatchesByLayer.size(); i++) { + FluidStack tStack = mOutputFluids2[i].copy(); + if (!dumpFluid(this.mOutputHatchesByLayer.get(i), tStack, true)) + dumpFluid(this.mOutputHatchesByLayer.get(i), tStack, false); + } + } + + @Override + public List<? extends IFluidStore> getFluidOutputSlots(FluidStack[] toOutput) { + return this.getFluidOutputSlotsByLayer(toOutput, this.mOutputHatchesByLayer); + } + + @Override + public boolean supportsBatchMode() { + return true; + } + + @Override + public boolean supportsVoidProtection() { + return true; + } +} diff --git a/src/main/java/bartworks/common/tileentities/multis/mega/MTEMegaOilCracker.java b/src/main/java/bartworks/common/tileentities/multis/mega/MTEMegaOilCracker.java new file mode 100644 index 0000000000..4720b0b37c --- /dev/null +++ b/src/main/java/bartworks/common/tileentities/multis/mega/MTEMegaOilCracker.java @@ -0,0 +1,465 @@ +/* + * Copyright (c) 2022 SKYCATV587 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.common.tileentities.multis.mega; + +import static bartworks.util.BWTooltipReference.MULTIBLOCK_ADDED_BY_BARTWORKS; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.withChannel; +import static gregtech.api.enums.HatchElement.*; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gregtech.api.util.GTStructureUtility.ofCoil; +import static gregtech.api.util.GTUtility.filterValidMTEs; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.annotation.Nonnull; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IItemSource; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import bartworks.API.BorosilicateGlass; +import bartworks.common.configs.ConfigHandler; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.HeatingCoilLevel; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.metatileentity.implementations.MTEHatchInput; +import gregtech.api.metatileentity.implementations.MTEHatchMultiInput; +import gregtech.api.metatileentity.implementations.MTEHatchOutput; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.maps.OilCrackerBackend; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.common.tileentities.machines.IRecipeProcessingAwareHatch; +import gregtech.common.tileentities.machines.MTEHatchInputME; + +public class MTEMegaOilCracker extends MegaMultiBlockBase<MTEMegaOilCracker> implements ISurvivalConstructable { + + private static final int CASING_INDEX = 49; + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition<MTEMegaOilCracker> STRUCTURE_DEFINITION = StructureDefinition + .<MTEMegaOilCracker>builder() + .addShape( + STRUCTURE_PIECE_MAIN, + transpose( + new String[][] { + { " p p ", "ppgggggggggpp", " pgggggggggp ", " pgggpppgggp ", " pgggpMpgggp ", + " pgggpppgggp ", " pgggggggggp ", "ppgggggggggpp", " p p " }, + { " p p ", "pgggggggggggp", " g c c c c g ", " g c c c c g ", " g c c c c g ", + " g c c c c g ", " g c c c c g ", "pgggggggggggp", " p p " }, + { " p p ", "pgggggggggggp", " g c c c c g ", " p c c p ", " p c c c c p ", + " p c c p ", " g c c c c g ", "pgggggggggggp", " p p " }, + { " p p ", "pgggggggggggp", " g c c c c g ", " p c c c c p ", " l c c c c r ", + " p c c c c p ", " g c c c c g ", "pgggggggggggp", " p p " }, + { " p p ", "pgggggggggggp", " g c c c c g ", " p c c p ", " p c c c c p ", + " p c c p ", " g c c c c g ", "pgggggggggggp", " p p " }, + { " p p ", "pgggggggggggp", " g c c c c g ", " g c c c c g ", " g c c c c g ", + " g c c c c g ", " g c c c c g ", "pgggggggggggp", " p p " }, + { "ppmmmm~mmmmpp", "ppppppppppppp", "ppppppppppppp", "ppppppppppppp", "ppppppppppppp", + "ppppppppppppp", "ppppppppppppp", "ppppppppppppp", "ppmmmmmmmmmpp" }, })) + .addElement('c', withChannel("coil", ofCoil(MTEMegaOilCracker::setCoilLevel, MTEMegaOilCracker::getCoilLevel))) + + .addElement('p', ofBlock(GregTechAPI.sBlockCasings4, 1)) + .addElement( + 'l', + InputHatch.withAdder(MTEMegaOilCracker::addLeftHatchToMachineList) + .newAny(CASING_INDEX, 2)) + .addElement( + 'r', + OutputHatch.withAdder(MTEMegaOilCracker::addRightHatchToMachineList) + .newAny(CASING_INDEX, 3)) + .addElement( + 'm', + buildHatchAdder(MTEMegaOilCracker.class).atLeast(Energy.or(ExoticEnergy), Maintenance, InputBus) + .casingIndex(CASING_INDEX) + .dot(1) + .buildAndChain(GregTechAPI.sBlockCasings4, 1)) + .addElement( + 'M', + InputHatch.withAdder(MTEMegaOilCracker::addMiddleInputToMachineList) + .newAny(CASING_INDEX, 4)) + .addElement( + 'g', + withChannel( + "glass", + BorosilicateGlass + .ofBoroGlass((byte) 0, (byte) 1, Byte.MAX_VALUE, (te, t) -> te.glassTier = t, te -> te.glassTier))) + .build(); + private byte glassTier; + private HeatingCoilLevel heatLevel; + protected final List<MTEHatchInput> mMiddleInputHatches = new ArrayList<>(); + protected int mInputOnSide = -1; + protected int mOutputOnSide = -1; + + public MTEMegaOilCracker(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEMegaOilCracker(String aName) { + super(aName); + } + + @Override + public MultiblockTooltipBuilder createTooltip() { + final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType("Cracker") + .addInfo("Controller block for the Mega Oil Cracking") + .addInfo("Thermally cracks heavy hydrocarbons into lighter fractions") + .addInfo("More efficient than the Chemical Reactor") + .addInfo("Gives different benefits whether it hydro or steam-cracks:") + .addInfo("Hydro - Consumes 20% less Hydrogen and outputs 25% more cracked fluid") + .addInfo("Steam - Outputs 50% more cracked fluid") + .addInfo("(Values compared to cracking in the Chemical Reactor)") + .addInfo("Place the appropriate circuit in the controller or an input bus") + .addInfo( + GTValues.TIER_COLORS[8] + GTValues.VN[8] + + EnumChatFormatting.GRAY + + "-tier glass required for " + + EnumChatFormatting.BLUE + + "Tec" + + EnumChatFormatting.DARK_BLUE + + "Tech" + + EnumChatFormatting.GRAY + + " Laser Hatches.") + .addSeparator() + .beginStructureBlock(13, 7, 9, true) + .addController("Front bottom") + .addStructureInfo("The glass tier limits the Energy Input tier") + .addInfo("Gets 10% EU/t reduction per coil tier, up to a maximum of 50%") + .addEnergyHatch("Hint block", 1) + .addMaintenanceHatch("Hint block", 1) + .addInputHatch("Hint block", 2, 3) + .addOutputHatch("Hint block", 2, 3) + .addInputHatch("Steam/Hydrogen ONLY, Hint block", 4) + .addInputBus("Optional, for programmed circuit automation. Hint block", 1) + .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTWORKS); + return tt; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEMegaOilCracker(this.mName); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + if (aActive) return new ITexture[] { casingTexturePages[0][CASING_INDEX], TextureFactory.builder() + .addIcon(OVERLAY_FRONT_OIL_CRACKER_ACTIVE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_OIL_CRACKER_ACTIVE_GLOW) + .extFacing() + .glow() + .build() }; + return new ITexture[] { casingTexturePages[0][CASING_INDEX], TextureFactory.builder() + .addIcon(OVERLAY_FRONT_OIL_CRACKER) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_OIL_CRACKER_GLOW) + .extFacing() + .glow() + .build() }; + } + return new ITexture[] { casingTexturePages[0][CASING_INDEX] }; + } + + @Override + public RecipeMap<OilCrackerBackend> getRecipeMap() { + return RecipeMaps.crackingRecipes; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @Override + @Nonnull + public CheckRecipeResult process() { + this.setEuModifier(1.0F - Math.min(0.1F * (MTEMegaOilCracker.this.heatLevel.getTier() + 1), 0.5F)); + return super.process(); + } + }.setMaxParallel(ConfigHandler.megaMachinesMax); + } + + public HeatingCoilLevel getCoilLevel() { + return this.heatLevel; + } + + public void setCoilLevel(HeatingCoilLevel aCoilLevel) { + this.heatLevel = aCoilLevel; + } + + @Override + public void construct(ItemStack aStack, boolean aHintsOnly) { + this.buildPiece(STRUCTURE_PIECE_MAIN, aStack, aHintsOnly, 6, 6, 0); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (this.mMachine) return -1; + int realBudget = elementBudget >= 200 ? elementBudget : Math.min(200, elementBudget * 5); + return this + .survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 6, 6, 0, realBudget, source, actor, false, true); + } + // -------------- TEC TECH COMPAT ---------------- + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + this.glassTier = 0; + this.mInputOnSide = -1; + this.mOutputOnSide = -1; + this.mMiddleInputHatches.clear(); + + if (!this.checkPiece(STRUCTURE_PIECE_MAIN, 6, 6, 0) || this.mMaintenanceHatches.size() != 1) return false; + + if (this.glassTier < 8) { + for (int i = 0; i < this.mExoticEnergyHatches.size(); ++i) { + MTEHatch hatch = this.mExoticEnergyHatches.get(i); + if (hatch.getConnectionType() == MTEHatch.ConnectionType.LASER) { + return false; + } + if (this.glassTier < hatch.mTier) { + return false; + } + } + for (int i = 0; i < this.mEnergyHatches.size(); ++i) { + if (this.glassTier < this.mEnergyHatches.get(i).mTier) { + return false; + } + } + } + + return true; + } + + private boolean addLeftHatchToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof MTEHatchInput) { + if (this.mInputOnSide == 1) { + return false; + } + this.mInputOnSide = 0; + this.mOutputOnSide = 1; + MTEHatchInput tHatch = (MTEHatchInput) aMetaTileEntity; + tHatch.updateTexture(aBaseCasingIndex); + tHatch.mRecipeMap = this.getRecipeMap(); + return this.mInputHatches.add(tHatch); + } + if (aMetaTileEntity instanceof MTEHatchOutput) { + if (this.mOutputOnSide == 1) { + return false; + } + this.mInputOnSide = 1; + this.mOutputOnSide = 0; + MTEHatchOutput tHatch = (MTEHatchOutput) aMetaTileEntity; + tHatch.updateTexture(aBaseCasingIndex); + return this.mOutputHatches.add(tHatch); + } + return false; + } + + private boolean addRightHatchToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof MTEHatchInput) { + if (this.mInputOnSide == 0) { + return false; + } + this.mInputOnSide = 1; + this.mOutputOnSide = 0; + MTEHatchInput tHatch = (MTEHatchInput) aMetaTileEntity; + tHatch.updateTexture(aBaseCasingIndex); + tHatch.mRecipeMap = this.getRecipeMap(); + return this.mInputHatches.add(tHatch); + } + if (aMetaTileEntity instanceof MTEHatchOutput) { + if (this.mOutputOnSide == 0) { + return false; + } + this.mInputOnSide = 0; + this.mOutputOnSide = 1; + MTEHatchOutput tHatch = (MTEHatchOutput) aMetaTileEntity; + tHatch.updateTexture(aBaseCasingIndex); + return this.mOutputHatches.add(tHatch); + } + return false; + } + + private boolean addMiddleInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof MTEHatchInput tHatch) { + tHatch.updateTexture(aBaseCasingIndex); + tHatch.mRecipeMap = this.getRecipeMap(); + return this.mMiddleInputHatches.add(tHatch); + } + return false; + } + + @Override + public ArrayList<FluidStack> getStoredFluids() { + final ArrayList<FluidStack> rList = new ArrayList<>(); + Map<Fluid, FluidStack> inputsFromME = new HashMap<>(); + for (final MTEHatchInput tHatch : filterValidMTEs(mInputHatches)) { + tHatch.mRecipeMap = getRecipeMap(); + if (tHatch instanceof MTEHatchInputME meHatch) { + for (FluidStack tFluid : meHatch.getStoredFluids()) { + if (tFluid != null && !getRecipeMap().getBackend() + .isValidCatalystFluid(tFluid)) { + inputsFromME.put(tFluid.getFluid(), tFluid); + } + } + } else if (tHatch instanceof MTEHatchMultiInput) { + for (final FluidStack tFluid : ((MTEHatchMultiInput) tHatch).getStoredFluid()) { + if (tFluid != null && !getRecipeMap().getBackend() + .isValidCatalystFluid(tFluid)) { + rList.add(tFluid); + } + } + } else { + if (tHatch.getFillableStack() != null) { + if (!getRecipeMap().getBackend() + .isValidCatalystFluid(tHatch.getFillableStack())) rList.add(tHatch.getFillableStack()); + } + } + } + for (final MTEHatchInput tHatch : filterValidMTEs(mMiddleInputHatches)) { + tHatch.mRecipeMap = getRecipeMap(); + if (tHatch instanceof MTEHatchInputME meHatch) { + for (FluidStack tFluid : meHatch.getStoredFluids()) { + if (tFluid != null && getRecipeMap().getBackend() + .isValidCatalystFluid(tFluid)) { + inputsFromME.put(tFluid.getFluid(), tFluid); + } + } + } else if (tHatch instanceof MTEHatchMultiInput) { + for (final FluidStack tFluid : ((MTEHatchMultiInput) tHatch).getStoredFluid()) { + if (tFluid != null && getRecipeMap().getBackend() + .isValidCatalystFluid(tFluid)) { + rList.add(tFluid); + } + } + } else { + if (tHatch.getFillableStack() != null) { + final FluidStack tStack = tHatch.getFillableStack(); + if (getRecipeMap().getBackend() + .isValidCatalystFluid(tStack)) { + rList.add(tStack); + } + } + } + } + if (!inputsFromME.isEmpty()) { + rList.addAll(inputsFromME.values()); + } + return rList; + } + + @Override + public IStructureDefinition<MTEMegaOilCracker> getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + public boolean supportsBatchMode() { + return true; + } + + @Override + public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { + if (aPlayer.isSneaking()) { + batchMode = !batchMode; + if (batchMode) { + GTUtility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); + } else { + GTUtility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); + } + return true; + } + return false; + } + + @Override + public boolean supportsVoidProtection() { + return true; + } + + @Override + protected void startRecipeProcessing() { + for (MTEHatchInput hatch : filterValidMTEs(mMiddleInputHatches)) { + if (hatch instanceof IRecipeProcessingAwareHatch aware) { + aware.startRecipeProcessing(); + } + } + super.startRecipeProcessing(); + } + + @Override + protected void endRecipeProcessing() { + super.endRecipeProcessing(); + for (MTEHatchInput hatch : filterValidMTEs(mMiddleInputHatches)) { + if (hatch instanceof IRecipeProcessingAwareHatch aware) { + setResultIfFailure(aware.endRecipeProcessing(this)); + } + } + } +} diff --git a/src/main/java/bartworks/common/tileentities/multis/mega/MTEMegaVacuumFreezer.java b/src/main/java/bartworks/common/tileentities/multis/mega/MTEMegaVacuumFreezer.java new file mode 100644 index 0000000000..e47782d980 --- /dev/null +++ b/src/main/java/bartworks/common/tileentities/multis/mega/MTEMegaVacuumFreezer.java @@ -0,0 +1,533 @@ +/* + * 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.common.tileentities.multis.mega; + +import static bartworks.util.BWTooltipReference.MULTIBLOCK_ADDED_BY_BARTWORKS; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.HatchElement.*; +import static gregtech.api.enums.HatchElement.ExoticEnergy; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_VACUUM_FREEZER_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Optional; + +import javax.annotation.Nonnull; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IItemSource; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; + +import bartworks.common.configs.ConfigHandler; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.Materials; +import gregtech.api.enums.MaterialsUEVplus; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.implementations.MTEHatchInput; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.OverclockCalculator; +import gregtech.api.util.shutdown.ShutDownReasonRegistry; +import gregtech.common.blocks.BlockCasingsAbstract; + +public class MTEMegaVacuumFreezer extends MegaMultiBlockBase<MTEMegaVacuumFreezer> implements ISurvivalConstructable { + + public MTEMegaVacuumFreezer(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEMegaVacuumFreezer(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEMegaVacuumFreezer(this.mName); + } + + private int mCasingFrostProof = 0; + private int mTier = 1; + + private static class SubspaceCoolingFluid { + + public Materials material; + public int perfectOverclocks; + // Consumption per second of runtime + public long amount; + + public SubspaceCoolingFluid(Materials material, int perfectOverclocks, long amount) { + this.material = material; + this.perfectOverclocks = perfectOverclocks; + this.amount = amount; + } + + public FluidStack getStack() { + FluidStack stack = material.getFluid(amount); + // FUCK THIS FUCK THIS FUCK THIS + if (stack == null) { + return material.getMolten(amount); + } + return stack; + } + } + + private static final ArrayList<SubspaceCoolingFluid> SUBSPACE_COOLING_FLUIDS = new ArrayList<>( + Arrays.asList( + new SubspaceCoolingFluid(MaterialsUEVplus.SpaceTime, 1, 7500), + new SubspaceCoolingFluid(MaterialsUEVplus.Space, 2, 5000), + new SubspaceCoolingFluid(MaterialsUEVplus.Eternity, 3, 2500))); + + private SubspaceCoolingFluid currentCoolingFluid = null; + + private static final int CASING_INDEX = 17; + private static final int CASING_INDEX_T2 = ((BlockCasingsAbstract) GregTechAPI.sBlockCasings8).getTextureIndex(14); + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final String STRUCTURE_PIECE_MAIN_T2 = "main_t2"; + + private static final String[][] structure = transpose( + new String[][] { + { "AAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAA", + "AAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAA", + "AAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAAAA", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "AAAAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAAAA", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "AAAAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAAAA", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "AAAAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAAAA", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "AAAAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAAAA", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "AAAAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAAAA", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "AAAAAAAAAAAAAAA" }, + { "AAAAAAA~AAAAAAA", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "AAAAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAAAA", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "AAAAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAAAA", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "AAAAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAAAA", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "AAAAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAAAA", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "AAAAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAAAA", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "AAAAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAAAA", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "AAAAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAA", + "AAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAA", + "AAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAA" } }); + private static final String[][] structure_tier2 = new String[][] { + { "AAAAAAAAAAAAAAA", "ABBBBBBBBBBBBBA", "ABAAAAAAAAAAABA", "ABABBBBBBBBBABA", "ABABAAAAAAABABA", + "ABABABBBBBABABA", "ABABABAAABABABA", "ABABABA~ABABABA", "ABABABAAABABABA", "ABABABBBBBABABA", + "ABABAAAAAAABABA", "ABABBBBBBBBBABA", "ABAAAAAAAAAAABA", "ABBBBBBBBBBBBBA", "AAAAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAAAA", "B B", "B B", "B B", "B B", + "B B", "B B", "B B", "B B", "B B", + "B B", "B B", "B B", "B B", "AAAAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAAAA", "B B", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "B B", "AAAAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAAAA", "B B", "A A", "B B", "B B", + "B B", "B B", "B B", "B B", "B B", + "B B", "B B", "A A", "B B", "AAAAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAAAA", "B B", "A A", "B B", "A A", + "A A", "A A", "A A", "A A", "A A", + "A A", "B B", "A A", "B B", "AAAAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAAAA", "B B", "A A", "B B", "A A", + "B B", "B B", "B B", "B B", "B B", + "A A", "B B", "A A", "B B", "AAAAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAAAA", "B B", "A A", "B B", "A A", + "B B", "A A", "A A", "A A", "B B", + "A A", "B B", "A A", "B B", "AAAAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAAAA", "B B", "A A", "B B", "A A", + "B B", "A A", "A A", "A A", "B B", + "A A", "B B", "A A", "B B", "AAAAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAAAA", "B B", "A A", "B B", "A A", + "B B", "A A", "A A", "A A", "B B", + "A A", "B B", "A A", "B B", "AAAAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAAAA", "B B", "A A", "B B", "A A", + "B B", "B B", "B B", "B B", "B B", + "A A", "B B", "A A", "B B", "AAAAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAAAA", "B B", "A A", "B B", "A A", + "A A", "A A", "A A", "A A", "A A", + "A A", "B B", "A A", "B B", "AAAAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAAAA", "B B", "A A", "B B", "B B", + "B B", "B B", "B B", "B B", "B B", + "B B", "B B", "A A", "B B", "AAAAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAAAA", "B B", "A A", "A A", "A A", + "A A", "A A", "A A", "A A", "A A", + "A A", "A A", "A A", "B B", "AAAAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAAAA", "B B", "B B", "B B", "B B", + "B B", "B B", "B B", "B B", "B B", + "B B", "B B", "B B", "B B", "AAAAAAAAAAAAAAA" }, + { "AAAAAAAAAAAAAAA", "ABBBBBBBBBBBBBA", "ABAAAAAAAAAAABA", "ABABBBBBBBBBABA", "ABABAAAAAAABABA", + "ABABABBBBBABABA", "ABABABAAABABABA", "ABABABAAABABABA", "ABABABAAABABABA", "ABABABBBBBABABA", + "ABABAAAAAAABABA", "ABABBBBBBBBBABA", "ABAAAAAAAAAAABA", "ABBBBBBBBBBBBBA", "AAAAAAAAAAAAAAA" } }; + + private static final IStructureDefinition<MTEMegaVacuumFreezer> STRUCTURE_DEFINITION = StructureDefinition + .<MTEMegaVacuumFreezer>builder() + .addShape(STRUCTURE_PIECE_MAIN, structure) + .addShape(STRUCTURE_PIECE_MAIN_T2, structure_tier2) + .addElement( + 'A', + buildHatchAdder(MTEMegaVacuumFreezer.class) + .atLeast(Energy.or(ExoticEnergy), InputHatch, InputBus, OutputHatch, OutputBus, Maintenance) + .casingIndex(CASING_INDEX) + .dot(1) + .buildAndChain(onElementPass(x -> x.mCasingFrostProof++, ofBlock(GregTechAPI.sBlockCasings2, 1)))) + // Infinity Cooled Casing + .addElement('B', ofBlock(GregTechAPI.sBlockCasings8, 14)) + .build(); + + @Override + protected MultiblockTooltipBuilder createTooltip() { + MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType("Vacuum Freezer") + .addInfo("Controller Block for the Mega Vacuum Freezer") + .addInfo("Cools hot ingots and cells") + .addSeparator() + .addInfo("Upgrade to Tier 2 to unlock " + EnumChatFormatting.LIGHT_PURPLE + "Subspace Cooling.") + .addInfo( + "To activate " + EnumChatFormatting.LIGHT_PURPLE + + "Subspace Cooling " + + EnumChatFormatting.GRAY + + "supply a coolant while running recipes.") + .addInfo( + EnumChatFormatting.RED + "7500 L/s " + + EnumChatFormatting.DARK_PURPLE + + "Molten SpaceTime" + + EnumChatFormatting.GRAY + + ": " + + EnumChatFormatting.RED + + "1" + + EnumChatFormatting.GRAY + + " perfect overclock.") + .addInfo( + EnumChatFormatting.RED + "5000 L/s " + + EnumChatFormatting.DARK_PURPLE + + "Spatially Enlarged Fluid" + + EnumChatFormatting.GRAY + + ": " + + EnumChatFormatting.RED + + "2" + + EnumChatFormatting.GRAY + + " perfect overclocks.") + .addInfo( + EnumChatFormatting.RED + "2500 L/s " + + EnumChatFormatting.DARK_PURPLE + + "Molten Eternity" + + EnumChatFormatting.GRAY + + ": " + + EnumChatFormatting.RED + + "3" + + EnumChatFormatting.GRAY + + " perfect overclocks.") + .addSeparator() + .addInfo( + EnumChatFormatting.LIGHT_PURPLE + "Reinforcing the structure allows the injection of exotic coolants,") + .addInfo( + EnumChatFormatting.LIGHT_PURPLE + + "enabling the capture of heat energy in miniature tears in spacetime,") + .addInfo(EnumChatFormatting.LIGHT_PURPLE + "massively increasing the efficiency of the cooling process.") + .addSeparator() + .beginStructureBlock(15, 15, 15, true) + .addController("Front center") + .addEnergyHatch("Any Frost Proof Machine Casing", 1) + .addMaintenanceHatch("Any Frost Proof Machine Casing", 1) + .addInputHatch("Any Frost Proof Machine Casing", 1) + .addOutputHatch("Any Frost Proof Machine Casing", 1) + .addInputBus("Any Frost Proof Machine Casing", 1) + .addOutputBus("Any Frost Proof Machine Casing", 1) + .addStructureInfo( + EnumChatFormatting.BLUE + "Base Multi (Tier " + + EnumChatFormatting.DARK_PURPLE + + 1 + + EnumChatFormatting.BLUE + + "):") + .addCasingInfoMinColored( + "Frost Proof Machine Casing", + EnumChatFormatting.GRAY, + 800, + EnumChatFormatting.GOLD, + false) + .addStructureInfo( + EnumChatFormatting.BLUE + "Tier " + + EnumChatFormatting.DARK_PURPLE + + 2 + + EnumChatFormatting.BLUE + + " (Upgrades from Tier " + + EnumChatFormatting.DARK_PURPLE + + 1 + + EnumChatFormatting.BLUE + + "):") + .addCasingInfoMinColored( + "Frost Proof Machine Casing", + EnumChatFormatting.GRAY, + 700, + EnumChatFormatting.GOLD, + false) + .addCasingInfoExactlyColored( + "Infinity Cooled Casing", + EnumChatFormatting.GRAY, + 384, + EnumChatFormatting.GOLD, + false) + .toolTipFinisher(MULTIBLOCK_ADDED_BY_BARTWORKS); + return tt; + } + + @Override + public IStructureDefinition<MTEMegaVacuumFreezer> getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack aStack, boolean aHintsOnly) { + if (aStack.stackSize == 1) { + this.buildPiece(STRUCTURE_PIECE_MAIN, aStack, aHintsOnly, 7, 7, 0); + } else { + this.buildPiece(STRUCTURE_PIECE_MAIN_T2, aStack, aHintsOnly, 7, 7, 0); + } + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (this.mMachine) return -1; + int realBudget = elementBudget >= 200 ? elementBudget : Math.min(200, elementBudget * 5); + if (stackSize.stackSize == 1) { + return this + .survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 7, 7, 0, realBudget, source, actor, false, true); + } else { + return this.survivialBuildPiece( + STRUCTURE_PIECE_MAIN_T2, + stackSize, + 7, + 7, + 0, + realBudget, + source, + actor, + false, + true); + } + } + + @Override + public RecipeMap<?> getRecipeMap() { + return RecipeMaps.vacuumFreezerRecipes; + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if (!aNBT.hasKey(BATCH_MODE_NBT_KEY)) { + this.batchMode = aNBT.getBoolean("mUseMultiparallelMode"); + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + } + + @Override + public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { + if (aPlayer.isSneaking()) { + this.batchMode = !this.batchMode; + if (this.batchMode) { + GTUtility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); + } else { + GTUtility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); + } + return true; + } + return false; + } + + public SubspaceCoolingFluid findSubspaceCoolingFluid() { + // Loop over all hatches and find the first match with a valid fluid + for (MTEHatchInput hatch : mInputHatches) { + Optional<SubspaceCoolingFluid> fluid = SUBSPACE_COOLING_FLUIDS.stream() + .filter(candidate -> drain(hatch, candidate.getStack(), false)) + .findFirst(); + if (fluid.isPresent()) return fluid.get(); + } + return null; + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @Nonnull + @Override + protected OverclockCalculator createOverclockCalculator(@Nonnull GTRecipe recipe) { + // Check if the freezer is T2 + if (mTier == 1) return super.createOverclockCalculator(recipe); + + // First try to detect the current fluid used for subspace cooling. + currentCoolingFluid = findSubspaceCoolingFluid(); + + return super.createOverclockCalculator(recipe) + .setMachineHeat(currentCoolingFluid == null ? 0 : currentCoolingFluid.perfectOverclocks * 1800) + .setRecipeHeat(0) + .setHeatOC(true) + .setHeatDiscount(false); + } + }.setMaxParallel(ConfigHandler.megaMachinesMax); + } + + @Override + protected void runMachine(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.runMachine(aBaseMetaTileEntity, aTick); + // Every second while running, consume subspace coolant fluid + if (mMaxProgresstime > 0 && aTick % 20 == 0) { + // Subspace cooling only allowed for T2 freezer + if (mTier == 2) { + // Try to drain the coolant fluid if it exists. If failed, stop the machine with an error + if (this.currentCoolingFluid != null) { + FluidStack fluid = this.currentCoolingFluid.getStack(); + for (MTEHatchInput hatch : mInputHatches) { + if (drain(hatch, fluid, false)) { + drain(hatch, fluid, true); + return; + } + } + // If we exited this loop without returning from the function, no matching fluid was found, so + // stop the machine - we ran out of coolant + stopMachine(ShutDownReasonRegistry.outOfFluid(fluid)); + } + } + } + } + + // -------------- TEC TECH COMPAT ---------------- + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + this.mCasingFrostProof = 0; + this.mTier = 1; + // If check for T1 fails, also do a check for T2 structure + if (!this.checkPiece(STRUCTURE_PIECE_MAIN, 7, 7, 0)) { + // Reset mCasing in between checks, so they don't count again + this.mCasingFrostProof = 0; + if (!this.checkPiece(STRUCTURE_PIECE_MAIN_T2, 7, 7, 0)) { + return false; + } + // Structure is Tier 2 + this.mTier = 2; + } + return this.mMaintenanceHatches.size() == 1 && this.mCasingFrostProof >= 700; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int aColorIndex, boolean aActive, boolean aRedstone) { + ITexture[] rTexture; + if (side == facing) { + if (aActive) { + rTexture = new ITexture[] { casingTexturePages[0][17], TextureFactory.builder() + .addIcon(OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_VACUUM_FREEZER_ACTIVE_GLOW) + .extFacing() + .glow() + .build() }; + } else { + rTexture = new ITexture[] { casingTexturePages[0][17], TextureFactory.builder() + .addIcon(OVERLAY_FRONT_VACUUM_FREEZER) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_VACUUM_FREEZER_GLOW) + .extFacing() + .glow() + .build() }; + } + } else { + rTexture = new ITexture[] { casingTexturePages[0][17] }; + } + return rTexture; + } + + @Override + public String[] getInfoData() { + ArrayList<String> info = new ArrayList<>(Arrays.asList(super.getInfoData())); + info.add("Tier: " + mTier); + if (mTier == 2) { + if (currentCoolingFluid != null) { + info.add( + "Subspace cooling: " + EnumChatFormatting.GREEN + + "Active (" + + currentCoolingFluid.getStack() + .getLocalizedName() + + ")"); + } else { + info.add("Subspace cooling: " + EnumChatFormatting.RED + "Inactive"); + } + } + return info.toArray(new String[] {}); + } + + @Override + public boolean supportsBatchMode() { + return true; + } + + @Override + public boolean supportsVoidProtection() { + return true; + } +} diff --git a/src/main/java/bartworks/common/tileentities/multis/mega/MegaMultiBlockBase.java b/src/main/java/bartworks/common/tileentities/multis/mega/MegaMultiBlockBase.java new file mode 100644 index 0000000000..bac811ede8 --- /dev/null +++ b/src/main/java/bartworks/common/tileentities/multis/mega/MegaMultiBlockBase.java @@ -0,0 +1,212 @@ +package bartworks.common.tileentities.multis.mega; + +import static gregtech.api.util.GTUtility.filterValidMTEs; + +import java.util.Arrays; + +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import com.gtnewhorizon.structurelib.StructureLibAPI; +import com.gtnewhorizon.structurelib.structure.AutoPlaceEnvironment; +import com.gtnewhorizon.structurelib.structure.IStructureElement; + +import bartworks.util.BWTooltipReference; +import bartworks.util.BWUtil; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.metatileentity.implementations.MTEExtendedPowerMultiBlockBase; +import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.metatileentity.implementations.MTEHatchEnergy; +import gregtech.api.metatileentity.implementations.MTEHatchMuffler; +import gregtech.api.util.GTUtility; + +public abstract class MegaMultiBlockBase<T extends MegaMultiBlockBase<T>> extends MTEExtendedPowerMultiBlockBase<T> { + + protected MegaMultiBlockBase(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MegaMultiBlockBase(String aName) { + super(aName); + } + + protected String[] getExtendedInfoData() { + return new String[0]; + } + + protected long[] getCurrentInfoData() { + long storedEnergy = 0, maxEnergy = 0; + for (MTEHatch hatch : this.getExoticAndNormalEnergyHatchList()) { + storedEnergy += hatch.getBaseMetaTileEntity() + .getStoredEU(); + maxEnergy += hatch.getBaseMetaTileEntity() + .getEUCapacity(); + } + return new long[] { storedEnergy, maxEnergy }; + } + + @Override + public String[] getInfoData() { + int mPollutionReduction = 0; + + for (MTEHatchMuffler tHatch : filterValidMTEs(mMufflerHatches)) { + mPollutionReduction = Math.max(tHatch.calculatePollutionReduction(100), mPollutionReduction); + } + + long[] ttHatches = this.getCurrentInfoData(); + long storedEnergy = ttHatches[0]; + long maxEnergy = ttHatches[1]; + + for (MTEHatchEnergy tHatch : filterValidMTEs(mEnergyHatches)) { + storedEnergy += tHatch.getBaseMetaTileEntity() + .getStoredEU(); + maxEnergy += tHatch.getBaseMetaTileEntity() + .getEUCapacity(); + } + + long nominalV = this.getMaxInputEu(); + String tName = BWUtil.getTierNameFromVoltage(nominalV); + if ("MAX+".equals(tName)) tName = EnumChatFormatting.OBFUSCATED + "MAX+"; + + String[] extendedInfo = this.getExtendedInfoData(); + + String[] baseInfo = { + StatCollector.translateToLocal("GT5U.multiblock.Progress") + ": " + + EnumChatFormatting.GREEN + + GTUtility.formatNumbers(this.mProgresstime / 20) + + EnumChatFormatting.RESET + + " s / " + + EnumChatFormatting.YELLOW + + GTUtility.formatNumbers(this.mMaxProgresstime / 20) + + EnumChatFormatting.RESET + + " s", + StatCollector.translateToLocal("GT5U.multiblock.energy") + ": " + + EnumChatFormatting.GREEN + + GTUtility.formatNumbers(storedEnergy) + + EnumChatFormatting.RESET + + " EU / " + + EnumChatFormatting.YELLOW + + GTUtility.formatNumbers(maxEnergy) + + EnumChatFormatting.RESET + + " EU", + StatCollector.translateToLocal("GT5U.multiblock.usage") + ": " + + EnumChatFormatting.RED + + GTUtility.formatNumbers(-this.lEUt) + + EnumChatFormatting.RESET + + " EU/t", + StatCollector.translateToLocal("GT5U.multiblock.mei") + ": " + + EnumChatFormatting.YELLOW + + GTUtility.formatNumbers(this.getMaxInputVoltage()) + + EnumChatFormatting.RESET + + " EU/t(*" + + GTUtility.formatNumbers(this.getMaxInputAmps()) + + "A) = " + + EnumChatFormatting.YELLOW + + GTUtility.formatNumbers(nominalV) + + EnumChatFormatting.RESET, + StatCollector.translateToLocal("GT5U.machines.tier") + ": " + + EnumChatFormatting.YELLOW + + tName + + EnumChatFormatting.RESET, + StatCollector.translateToLocal("GT5U.multiblock.problems") + ": " + + EnumChatFormatting.RED + + (this.getIdealStatus() - this.getRepairStatus()) + + EnumChatFormatting.RESET + + " " + + StatCollector.translateToLocal("GT5U.multiblock.efficiency") + + ": " + + EnumChatFormatting.YELLOW + + this.mEfficiency / 100.0F + + EnumChatFormatting.RESET + + " %", + StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " + + EnumChatFormatting.GREEN + + mPollutionReduction + + EnumChatFormatting.RESET + + " %" }; + + String[] combinedInfo = Arrays.copyOf(baseInfo, baseInfo.length + extendedInfo.length + 1); + + System.arraycopy(extendedInfo, 0, combinedInfo, baseInfo.length, extendedInfo.length); + + combinedInfo[combinedInfo.length - 1] = BWTooltipReference.BW; + + return combinedInfo; + } + + @Override + public boolean isCorrectMachinePart(ItemStack itemStack) { + return true; + } + + @Override + public int getDamageToComponent(ItemStack itemStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack itemStack) { + return false; + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + protected void setProcessingLogicPower(ProcessingLogic logic) { + logic.setAvailableVoltage(this.getMaxInputEu()); + logic.setAvailableAmperage(1); + } + + protected static class StructureElementAirNoHint<T> implements IStructureElement<T> { + + private static final StructureElementAirNoHint<?> INSTANCE = new StructureElementAirNoHint<>(); + + @SuppressWarnings("unchecked") + public static <T> IStructureElement<T> getInstance() { + return (IStructureElement<T>) INSTANCE; + } + + private StructureElementAirNoHint() {} + + @Override + public boolean check(T o, World world, int x, int y, int z) { + return world.isAirBlock(x, y, z); + } + + @Override + public boolean spawnHint(T o, World world, int x, int y, int z, ItemStack trigger) { + if (world.blockExists(x, y, z) && !world.isAirBlock(x, y, z)) + // hint if this is obstructed. in case *someone* ever finish the transparent rendering + StructureLibAPI + .hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), StructureLibAPI.HINT_BLOCK_META_AIR); + return true; + } + + @Override + public boolean placeBlock(T o, World world, int x, int y, int z, ItemStack trigger) { + world.setBlockToAir(x, y, z); + return true; + } + + @Override + public BlocksToPlace getBlocksToPlace(T t, World world, int x, int y, int z, ItemStack trigger, + AutoPlaceEnvironment env) { + return BlocksToPlace.createEmpty(); + } + + @Override + public PlaceResult survivalPlaceBlock(T o, World world, int x, int y, int z, ItemStack trigger, + AutoPlaceEnvironment env) { + if (this.check(o, world, x, y, z)) return PlaceResult.SKIP; + if (!StructureLibAPI.isBlockTriviallyReplaceable(world, x, y, z, env.getActor())) return PlaceResult.REJECT; + world.setBlock(x, y, z, Blocks.air, 0, 2); + return PlaceResult.ACCEPT; + } + } +} diff --git a/src/main/java/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java b/src/main/java/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java new file mode 100644 index 0000000000..8e752711ea --- /dev/null +++ b/src/main/java/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java @@ -0,0 +1,494 @@ +/* + * 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.common.tileentities.tiered; + +import static gregtech.api.enums.GTValues.ticksBetweenSounds; + +import java.util.Collections; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; + +import com.gtnewhorizons.modularui.api.ModularUITextures; +import com.gtnewhorizons.modularui.api.drawable.ItemDrawable; +import com.gtnewhorizons.modularui.api.drawable.shapes.Rectangle; +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.math.Color; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.math.Size; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.ProgressBar; +import com.gtnewhorizons.modularui.common.widget.ProgressBar.Direction; +import com.gtnewhorizons.modularui.common.widget.TextWidget; +import com.gtnewhorizons.modularui.common.widget.textfield.NumericWidget; + +import bartworks.API.modularUI.BWUITextures; +import bartworks.API.recipe.BartWorksRecipeMaps; +import bartworks.MainMod; +import bartworks.util.BWColorUtil; +import bartworks.util.BWTooltipReference; +import bartworks.util.MathUtils; +import gregtech.api.enums.Materials; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GTUIInfos; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.gui.modularui.GUITextureSet; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.modularui.IAddGregtechLogo; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.interfaces.tileentity.RecipeMapWorkable; +import gregtech.api.metatileentity.BaseMetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.objects.ItemData; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.common.items.IDMetaTool01; +import gregtech.common.items.MetaGeneratedTool01; + +public class GT_MetaTileEntity_RadioHatch extends MTEHatch implements RecipeMapWorkable, IAddGregtechLogo { + + private final int cap; + public int sievert; + private long timer = 1; + private long decayTime = 1; + private short[] colorForGUI = { 0x02, 0x02, 0x02 }; + private byte mass; + private String material; + private byte coverage; + private ItemStack lastUsedItem = null; + private boolean lastFail = false; + private GTRecipe lastRecipe = null; + + public GT_MetaTileEntity_RadioHatch(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 1, + new String[] { StatCollector.translateToLocal("tooltip.tile.radhatch.0.name"), + StatCollector.translateToLocal("tooltip.tile.tiereddsc.3.name") + " " + + (aTier - 2) + + " " + + (aTier - 2 >= 2 ? StatCollector.translateToLocal("tooltip.bw.kg.1.name") + : StatCollector.translateToLocal("tooltip.bw.kg.0.name")), + StatCollector.translateToLocal("tooltip.tile.radhatch.1.name"), + BWTooltipReference.ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS.get() }); + this.cap = aTier - 2; + } + + public GT_MetaTileEntity_RadioHatch(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 1, aDescription, aTextures); + this.cap = aTier - 2; + } + + public int getSievert() { + return this.sievert - MathUtils.ceilInt(this.sievert / 100f * this.coverage); + } + + public short[] getColorForGUI() { + if (this.colorForGUI != null) return this.colorForGUI; + return this.colorForGUI = new short[] { 0xFA, 0xFA, 0xFF }; + } + + public byte getMass() { + return this.mass; + } + + public byte getCoverage() { + return this.coverage; + } + + public void setCoverage(short coverage) { + byte nu; + if (coverage > 100) nu = 100; + else if (coverage < 0) nu = 0; + else nu = (byte) coverage; + this.coverage = nu; + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, TextureFactory.of(Textures.BlockIcons.OVERLAY_PIPE_IN) }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, TextureFactory.of(Textures.BlockIcons.OVERLAY_PIPE_IN) }; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_MetaTileEntity_RadioHatch(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + public void updateSlots() { + if (this.mInventory[0] != null && this.mInventory[0].stackSize <= 0) this.mInventory[0] = null; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + BaseMetaTileEntity myMetaTileEntity = (BaseMetaTileEntity) this.getBaseMetaTileEntity(); + if (myMetaTileEntity.isServerSide()) { + + if (this.mass > 0) { + ++this.timer; + } + + if (this.mass > 0 && (this.decayTime == 0 || this.decayTime > 0 && this.timer % this.decayTime == 0)) { + this.mass--; + if (this.mass == 0) { + this.material = StatCollector.translateToLocal("tooltip.bw.empty.name"); + this.sievert = 0; + } + this.timer = 1; + } + + if (myMetaTileEntity.mTickTimer > myMetaTileEntity.mLastSoundTick + ticksBetweenSounds + && this.sievert > 0) { + this.sendLoopStart((byte) 1); + myMetaTileEntity.mLastSoundTick = myMetaTileEntity.mTickTimer; + } + + if (this.mass == 0) { + ItemStack lStack = this.mInventory[0]; + + if (lStack == null) { + this.colorForGUI = new short[] { 0x37, 0x37, 0x37 }; + return; + } + ItemData itemData = GTOreDictUnificator.getAssociation(lStack); + if (itemData != null) { + Materials mat = itemData.mMaterial.mMaterial; + this.colorForGUI = new short[] { mat.getRGBA()[0], mat.getRGBA()[1], mat.getRGBA()[2] }; + } else { + this.colorForGUI = new short[] { 0x37, 0x37, 0x37 }; + } + + if (this.lastFail && GTUtility.areStacksEqual(this.lastUsedItem, lStack, true)) { + return; + } + + if (!this.lastFail && this.lastUsedItem != null && this.lastRecipe != null) { + if (GTUtility.areStacksEqual(this.lastUsedItem, lStack, true)) { + this.mass = (byte) this.lastRecipe.mDuration; + this.decayTime = this.lastRecipe.mSpecialValue; + this.sievert = this.lastRecipe.mEUt; + this.material = this.lastUsedItem.getDisplayName(); + lStack.stackSize--; + this.updateSlots(); + } else { + this.lastRecipe = null; + } + } + + if (this.lastRecipe == null || this.lastFail) { + this.lastRecipe = BartWorksRecipeMaps.radioHatchRecipes.findRecipe( + this.getBaseMetaTileEntity(), + false, + Integer.MAX_VALUE - 7, + null, + this.mInventory[0]); + if (this.lastRecipe == null) { + this.lastFail = true; + this.lastUsedItem = this.mInventory[0] == null ? null : this.mInventory[0].copy(); + } else { + if (this.lastRecipe.mDuration > this.cap) { + this.lastFail = true; + this.lastUsedItem = this.mInventory[0].copy(); + return; + } + this.lastFail = false; + this.lastUsedItem = this.mInventory[0].copy(); + this.mass = (byte) this.lastRecipe.mDuration; + this.decayTime = this.lastRecipe.mSpecialValue; + this.sievert = this.lastRecipe.mEUt; + this.material = lStack.getDisplayName(); + lStack.stackSize--; + this.updateSlots(); + } + } + } + } + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + if (this.sievert != 0) return new String[] { + StatCollector.translateToLocal("tooltip.tile.radhatch.2.name") + " " + + StatCollector.translateToLocal(this.material), + StatCollector.translateToLocal("tooltip.tile.radhatch.3.name") + " " + this.sievert, + StatCollector.translateToLocal("tooltip.tile.radhatch.4.name") + " " + this.mass, + StatCollector.translateToLocal("tooltip.tile.radhatch.5.name") + " " + + (this.decayTime - this.timer % (this.decayTime * 60)) + + StatCollector.translateToLocal("tooltip.tile.radhatch.6.name") + + "/" + + (this.decayTime - this.timer % this.decayTime) / 20 + + StatCollector.translateToLocal("tooltip.tile.radhatch.7.name") + + "/" + + (this.decayTime - this.timer % this.decayTime) / 20 / 60 + + StatCollector.translateToLocal("tooltip.tile.radhatch.8.name") + + "/" + + (this.decayTime - this.timer % this.decayTime) / 20 / 60 / 60 + + StatCollector.translateToLocal("tooltip.tile.radhatch.9.name") }; + return new String[] { + StatCollector.translateToLocal("tooltip.tile.radhatch.2.name") + " " + + StatCollector.translateToLocal("tooltip.bw.empty.name"), + StatCollector.translateToLocal("tooltip.tile.radhatch.3.name") + " " + "0", + StatCollector.translateToLocal("tooltip.tile.radhatch.4.name") + " " + "0" }; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return true; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return side == this.getBaseMetaTileEntity() + .getFrontFacing() && BartWorksRecipeMaps.radioHatchRecipes.containsInput(aStack); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setByte("mMass", this.mass); + aNBT.setByte("mSv", (byte) (this.sievert - 100)); + aNBT.setByte("mCoverage", this.coverage); + aNBT.setInteger("mTextColor", BWColorUtil.getColorFromRGBArray(this.getColorForGUI())); + if (this.material != null && !this.material.isEmpty()) aNBT.setString("mMaterial", this.material); + aNBT.setLong("timer", this.timer); + aNBT.setLong("decay", this.decayTime); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.timer = aNBT.getLong("timer"); + this.mass = aNBT.getByte("mMass"); + this.sievert = aNBT.getByte("mSv") + 100; + this.coverage = aNBT.getByte("mCoverage"); + this.colorForGUI = BWColorUtil.splitColorToRBGArray(aNBT.getInteger("mTextColor")); + this.material = aNBT.getString("mMaterial"); + this.decayTime = aNBT.getLong("decay"); + super.loadNBTData(aNBT); + } + + @Override + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + ResourceLocation rl = new ResourceLocation(MainMod.MOD_ID, "hatch.RadOn"); + if (aIndex == 1) { + GTUtility.doSoundAtClient(rl, 10, 1.0F, aX, aY, aZ); + } + } + + @Override + public RecipeMap<?> getRecipeMap() { + // Only for visual + return BartWorksRecipeMaps.radioHatchRecipes; + } + + private static final int RADIATION_SHUTTER_WINDOW_ID = 999; + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + buildContext.addSyncedWindow(RADIATION_SHUTTER_WINDOW_ID, this::createShutterWindow); + + this.getBaseMetaTileEntity() + .add1by1Slot(builder); + builder.widget( + new DrawableWidget().setBackground(BWUITextures.PICTURE_SIEVERT_CONTAINER) + .setPos(61, 9) + .setSize(56, 24)) + .widget( + new ProgressBar().setProgress(() -> this.getSievert() / 148f) + .setDirection(Direction.RIGHT) + .setTexture(BWUITextures.PROGRESSBAR_SIEVERT, 24) + .setPos(65, 13) + .setSize(48, 16)) + .widget( + new DrawableWidget().setBackground(BWUITextures.PICTURE_DECAY_TIME_INSIDE) + .setPos(124, 18) + .setSize(16, 48)) + .widget(new DrawableWidget() { + + @Override + public void draw(float partialTicks) { + if (GT_MetaTileEntity_RadioHatch.this.decayTime > 0) { + int height = MathUtils.ceilInt( + 48 * ((GT_MetaTileEntity_RadioHatch.this.decayTime + - GT_MetaTileEntity_RadioHatch.this.timer % GT_MetaTileEntity_RadioHatch.this.decayTime) + / (float) GT_MetaTileEntity_RadioHatch.this.decayTime)); + new Rectangle() + .setColor( + Color.argb( + GT_MetaTileEntity_RadioHatch.this.colorForGUI[0], + GT_MetaTileEntity_RadioHatch.this.colorForGUI[1], + GT_MetaTileEntity_RadioHatch.this.colorForGUI[2], + 255)) + .draw(new Pos2d(0, 48 - height), new Size(16, height), partialTicks); + } + } + }.dynamicTooltip( + () -> Collections.singletonList( + StatCollector.translateToLocalFormatted( + "tooltip.tile.radhatch.10.name", + this.timer <= 1 ? 0 : (this.decayTime - this.timer) / 20, + this.timer <= 1 ? 0 : this.decayTime / 20))) + .setPos(124, 18) + .setSize(16, 48) + .attachSyncer( + new FakeSyncWidget.LongSyncer(() -> this.decayTime, val -> this.decayTime = val), + builder, + (widget, val) -> widget.notifyTooltipChange()) + .attachSyncer( + new FakeSyncWidget.LongSyncer(() -> this.timer, val -> this.timer = val), + builder, + (widget, val) -> widget.notifyTooltipChange())) + .widget(new FakeSyncWidget.ShortSyncer(() -> this.colorForGUI[0], val -> this.colorForGUI[0] = val)) + .widget(new FakeSyncWidget.ShortSyncer(() -> this.colorForGUI[1], val -> this.colorForGUI[1] = val)) + .widget(new FakeSyncWidget.ShortSyncer(() -> this.colorForGUI[2], val -> this.colorForGUI[2] = val)) + .widget( + new DrawableWidget().setBackground(BWUITextures.PICTURE_DECAY_TIME_CONTAINER) + .setPos(120, 14) + .setSize(24, 56)) + .widget( + new TextWidget() + .setStringSupplier( + () -> StatCollector.translateToLocalFormatted("BW.NEI.display.radhatch.1", this.mass)) + .setTextAlignment(Alignment.Center) + .setPos(65, 62)) + .widget(new FakeSyncWidget.ByteSyncer(() -> this.mass, val -> this.mass = val)) + .widget( + new TextWidget() + .setStringSupplier( + () -> StatCollector.translateToLocalFormatted("BW.NEI.display.radhatch.0", this.getSievert())) + .setTextAlignment(Alignment.Center) + .setPos(60, 72)) + .widget(new FakeSyncWidget.IntegerSyncer(() -> this.sievert, val -> this.sievert = val)) + .widget(new ButtonWidget().setOnClick((clickData, widget) -> { + if (!widget.isClient()) { + widget.getContext() + .openSyncedWindow(RADIATION_SHUTTER_WINDOW_ID); + } + }) + .addTooltip("Radiation Shutter") + .setBackground(GTUITextures.BUTTON_STANDARD) + .setPos(153, 5) + .setSize(18, 18)) + .widget( + new ItemDrawable( + MetaGeneratedTool01.INSTANCE.getToolWithStats(IDMetaTool01.SCREWDRIVER.ID, 1, null, null, null)) + .asWidget() + .setPos(154, 6)); + } + + private ModularWindow createShutterWindow(EntityPlayer player) { + ModularWindow.Builder builder = ModularWindow.builder(176, 107); + builder.setBackground(ModularUITextures.VANILLA_BACKGROUND); + builder.setGuiTint(this.getGUIColorization()); + + builder.widget( + new TextWidget("Radiation Shutter Control").setDefaultColor(this.COLOR_TITLE.get()) + .setPos(10, 9)) + .widget( + new DrawableWidget().setDrawable(BWUITextures.PICTURE_RADIATION_SHUTTER_FRAME) + .setPos(14, 27) + .setSize(55, 54)) + .widget( + new DrawableWidget() + .setDrawable(() -> this.coverage < 100 ? BWUITextures.PICTURE_RADIATION_SHUTTER_INSIDE : null) + .setPos(16, 29) + .setSize(51, 50) + .attachSyncer( + new FakeSyncWidget.ByteSyncer(this::getCoverage, this::setCoverage), + builder, + (widget, val) -> widget.setPos(16, 29 + this.coverage / 2) + .setSize(51, 50 - this.coverage / 2))) + .widget( + new NumericWidget().setSetter(val -> this.coverage = (byte) val) + .setGetter(() -> this.coverage) + .setBounds(0, 100) + .setScrollValues(1, 5, 50) + .setTextColor(Color.WHITE.dark(1)) + .setTextAlignment(Alignment.CenterLeft) + .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD.withOffset(-1, -1, 2, 2)) + .setPos(86, 27) + .setSize(30, 12)) + .widget( + ButtonWidget.closeWindowButton(true) + .setPos(176 - 15, 3)); + + return builder.build(); + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(BWUITextures.PICTURE_BW_LOGO_47X21) + .setSize(47, 21) + .setPos(10, 53)); + } + + @Override + public GUITextureSet getGUITextureSet() { + return new GUITextureSet().setMainBackground(GTUITextures.BACKGROUND_SINGLEBLOCK_DEFAULT) + .setGregTechLogo(GTUITextures.PICTURE_GT_LOGO_17x17_TRANSPARENT); + } +} diff --git a/src/main/java/bartworks/common/tileentities/tiered/MTEAcidGenerator.java b/src/main/java/bartworks/common/tileentities/tiered/MTEAcidGenerator.java new file mode 100644 index 0000000000..2713d3dee2 --- /dev/null +++ b/src/main/java/bartworks/common/tileentities/tiered/MTEAcidGenerator.java @@ -0,0 +1,155 @@ +/* + * 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.common.tileentities.tiered; + +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; + +import bartworks.API.recipe.BartWorksRecipeMaps; +import bartworks.util.BWTooltipReference; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.MTEBasicGenerator; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.render.TextureFactory; + +public class MTEAcidGenerator extends MTEBasicGenerator { + + public MTEAcidGenerator(int aID, String aName, String aNameRegional, int aTier, ITexture... aTextures) { + super(aID, aName, aNameRegional, aTier, new String[] {}, aTextures); + } + + public MTEAcidGenerator(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public int getPollution() { + return 0; + } + + @Override + public RecipeMap<?> getRecipeMap() { + return BartWorksRecipeMaps.acidGenFuels; + } + + @Override + public int getEfficiency() { + return 100 - 3 * this.mTier; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new MTEAcidGenerator(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public ITexture[] getFront(byte aColor) { + return new ITexture[] { super.getFront(aColor)[0], + TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL), + Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier] }; + } + + @Override + public ITexture[] getBack(byte aColor) { + return new ITexture[] { super.getBack(aColor)[0], + TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_ACIDHAZARD) }; + } + + @Override + public ITexture[] getBottom(byte aColor) { + return new ITexture[] { super.getBottom(aColor)[0], + TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_ACIDHAZARD) }; + } + + @Override + public ITexture[] getTop(byte aColor) { + return new ITexture[] { super.getTop(aColor)[0], + TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL), + TextureFactory.of(new Textures.BlockIcons.CustomIcon("basicmachines/chemical_reactor/OVERLAY_FRONT")), + TextureFactory.builder() + .addIcon(new Textures.BlockIcons.CustomIcon("basicmachines/chemical_reactor/OVERLAY_FRONT_GLOW")) + .glow() + .build() }; + } + + @Override + public ITexture[] getSides(byte aColor) { + return new ITexture[] { super.getSides(aColor)[0], + TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_ACIDHAZARD) }; + } + + @Override + public ITexture[] getFrontActive(byte aColor) { + return new ITexture[] { super.getFrontActive(aColor)[0], + TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL), + Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mTier] }; + } + + @Override + public ITexture[] getBackActive(byte aColor) { + return new ITexture[] { super.getBackActive(aColor)[0], + TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_ACIDHAZARD) }; + } + + @Override + public ITexture[] getBottomActive(byte aColor) { + return new ITexture[] { super.getBottomActive(aColor)[0], + TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_ACIDHAZARD) }; + } + + @Override + public ITexture[] getTopActive(byte aColor) { + return new ITexture[] { super.getTopActive(aColor)[0], + TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL), + TextureFactory + .of(new Textures.BlockIcons.CustomIcon("basicmachines/chemical_reactor/OVERLAY_FRONT_ACTIVE")), + TextureFactory.builder() + .addIcon(new Textures.BlockIcons.CustomIcon("basicmachines/chemical_reactor/OVERLAY_FRONT_ACTIVE_GLOW")) + .glow() + .build() }; + } + + @Override + public ITexture[] getSidesActive(byte aColor) { + return new ITexture[] { super.getSidesActive(aColor)[0], + TextureFactory.of(Textures.BlockIcons.MACHINE_CASING_ACIDHAZARD) }; + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return side == this.getBaseMetaTileEntity() + .getFrontFacing(); + } + + @Override + public String[] getDescription() { + return new String[] { StatCollector.translateToLocal("tooltip.tile.acidgen.0.name"), + StatCollector.translateToLocal("tooltip.tile.acidgen.1.name"), + StatCollector.translateToLocal("tooltip.tile.tiereddsc.0.name") + " " + + EnumChatFormatting.YELLOW + + GTValues.V[this.mTier], + StatCollector.translateToLocal("tooltip.rotor.2.name") + " " + + EnumChatFormatting.YELLOW + + this.getEfficiency(), + StatCollector.translateToLocal("tooltip.tile.tiereddsc.2.name") + " " + + EnumChatFormatting.YELLOW + + this.maxAmperesOut(), + BWTooltipReference.ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS.get() }; + } +} diff --git a/src/main/java/bartworks/common/tileentities/tiered/MTEBioLab.java b/src/main/java/bartworks/common/tileentities/tiered/MTEBioLab.java new file mode 100644 index 0000000000..992c7188fa --- /dev/null +++ b/src/main/java/bartworks/common/tileentities/tiered/MTEBioLab.java @@ -0,0 +1,405 @@ +/* + * 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.common.tileentities.tiered; + +import static gregtech.api.enums.Mods.Gendustry; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import bartworks.API.recipe.BartWorksRecipeMaps; +import bartworks.common.items.ItemLabModule; +import bartworks.common.items.ItemLabParts; +import bartworks.common.loaders.BioCultureLoader; +import bartworks.common.loaders.BioItemList; +import bartworks.common.loaders.FluidLoader; +import bartworks.util.BWTooltipReference; +import bartworks.util.BWUtil; +import bartworks.util.BioCulture; +import bartworks.util.BioDNA; +import bartworks.util.BioData; +import bartworks.util.BioPlasmid; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.MTEBasicMachine; +import gregtech.api.objects.XSTR; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.GTUtility; +import gregtech.common.items.behaviors.BehaviourDataOrb; + +public class MTEBioLab extends MTEBasicMachine { + + private static final int DNA_EXTRACTION_MODULE = 0; + private static final int PCR_THERMOCYCLE_MODULE = 1; + private static final int PLASMID_SYNTHESIS_MODULE = 2; + private static final int TRANSFORMATION_MODULE = 3; + private static final int CLONAL_CELLULAR_SYNTHESIS_MODULE = 4; + private static final int INCUBATION_MODULE = 5; + + public MTEBioLab(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 1, + (String) null, + 6, + 2, + TextureFactory.of( + TextureFactory + .of(new Textures.BlockIcons.CustomIcon("basicmachines/fluid_extractor/OVERLAY_SIDE_ACTIVE")), + TextureFactory.builder() + .addIcon( + new Textures.BlockIcons.CustomIcon("basicmachines/fluid_extractor/OVERLAY_SIDE_ACTIVE_GLOW")) + .glow() + .build()), + TextureFactory.of( + TextureFactory.of(new Textures.BlockIcons.CustomIcon("basicmachines/fluid_extractor/OVERLAY_SIDE")), + TextureFactory.builder() + .addIcon(new Textures.BlockIcons.CustomIcon("basicmachines/fluid_extractor/OVERLAY_SIDE_GLOW")) + .glow() + .build()), + TextureFactory.of( + TextureFactory.of(new Textures.BlockIcons.CustomIcon("basicmachines/microwave/OVERLAY_FRONT_ACTIVE")), + TextureFactory.builder() + .addIcon(new Textures.BlockIcons.CustomIcon("basicmachines/microwave/OVERLAY_FRONT_ACTIVE_GLOW")) + .glow() + .build()), + TextureFactory.of( + TextureFactory.of(new Textures.BlockIcons.CustomIcon("basicmachines/microwave/OVERLAY_FRONT")), + TextureFactory.builder() + .addIcon(new Textures.BlockIcons.CustomIcon("basicmachines/microwave/OVERLAY_FRONT_GLOW")) + .glow() + .build()), + TextureFactory.of( + TextureFactory + .of(new Textures.BlockIcons.CustomIcon("basicmachines/chemical_reactor/OVERLAY_FRONT_ACTIVE")), + TextureFactory.builder() + .addIcon( + new Textures.BlockIcons.CustomIcon("basicmachines/chemical_reactor/OVERLAY_FRONT_ACTIVE_GLOW")) + .glow() + .build() /* this is topactive */), + TextureFactory.of( + TextureFactory.of(new Textures.BlockIcons.CustomIcon("basicmachines/chemical_reactor/OVERLAY_FRONT")), + TextureFactory.builder() + .addIcon(new Textures.BlockIcons.CustomIcon("basicmachines/chemical_reactor/OVERLAY_FRONT_GLOW")) + .glow() + .build() /* this is top */), + TextureFactory.of( + TextureFactory.of(new Textures.BlockIcons.CustomIcon("basicmachines/polarizer/OVERLAY_BOTTOM_ACTIVE")), + TextureFactory.builder() + .addIcon(new Textures.BlockIcons.CustomIcon("basicmachines/polarizer/OVERLAY_BOTTOM_ACTIVE_GLOW")) + .glow() + .build()), + TextureFactory.of( + TextureFactory.of(new Textures.BlockIcons.CustomIcon("basicmachines/polarizer/OVERLAY_BOTTOM")), + TextureFactory.builder() + .addIcon(new Textures.BlockIcons.CustomIcon("basicmachines/polarizer/OVERLAY_BOTTOM_GLOW")) + .glow() + .build())); + } + + public MTEBioLab(String aName, int aTier, int aAmperage, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aAmperage, aDescription, aTextures, 6, 2); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new MTEBioLab(this.mName, this.mTier, this.mAmperage, this.mDescriptionArray, this.mTextures); + } + + @Override + public RecipeMap<?> getRecipeMap() { + return BartWorksRecipeMaps.bioLabRecipes; + } + + @Override + public int getCapacity() { + return this.mTier * 1000; + } + + @Override + public int checkRecipe(boolean skipOC) { + + int rTier = 3; + FluidStack dnaFluid = Gendustry.isModLoaded() ? FluidRegistry.getFluidStack("liquiddna", 1000) + : Materials.Biomass.getFluid(1000L); + + if (this.getSpecialSlot() != null && this.getSpecialSlot() + .getItem() instanceof ItemLabModule) { + int damage = this.getSpecialSlot() + .getItemDamage(); + switch (damage) { + case DNA_EXTRACTION_MODULE: + if (GTUtility.isStackValid(this.mInventory[this.getInputSlot()]) + && this.mInventory[this.getInputSlot()].getItem() instanceof ItemLabParts + && this.mInventory[this.getInputSlot()].getItemDamage() == 0 + && this.mInventory[this.getInputSlot()].getTagCompound() != null + && // checks if it is a Culture + GTUtility.isStackValid(this.mInventory[this.getInputSlot() + 1]) + && this.mInventory[this.getInputSlot() + 1].getItem() instanceof ItemLabParts + && this.mInventory[this.getInputSlot() + 1].getItemDamage() == 1 + && this.mInventory[this.getInputSlot() + 1].getTagCompound() == null + && GTUtility.isStackValid(this.mInventory[this.getInputSlot() + 2]) + && this.mInventory[this.getInputSlot() + 2].getItem() instanceof ItemLabParts + && this.mInventory[this.getInputSlot() + 2].getItemDamage() == 3 + && GTUtility + .areStacksEqual(this.mInventory[this.getInputSlot() + 3], Materials.Ethanol.getCells(1)) + && this.mFluid != null + && this.mFluid.isFluidEqual(FluidRegistry.getFluidStack("ic2distilledwater", 1000)) + && this.mFluid.amount >= 1000) { + + NBTTagCompound DNABioDataTag = this.mInventory[this.getInputSlot()].getTagCompound() + .getCompoundTag("DNA"); + if (DNABioDataTag == null) return super.checkRecipe(skipOC); + BioData cultureDNABioData = BioData.getBioDataFromName( + this.mInventory[this.getInputSlot()].getTagCompound() + .getCompoundTag("DNA") + .getString("Name")); + if (cultureDNABioData == null) return super.checkRecipe(skipOC); + + if (this.mTier < rTier + cultureDNABioData.getTier()) + return MTEBasicMachine.FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + + for (int i = 0; i < 4; i++) { + if (this.mInventory[this.getInputSlot() + i] != null) + this.mInventory[this.getInputSlot() + i].stackSize--; + } + + this.mFluid.amount -= 1000; + + if (cultureDNABioData.getChance() > new XSTR().nextInt(10000)) { + this.mOutputItems[0] = BioItemList + .getDNASampleFlask(BioDNA.convertDataToDNA(cultureDNABioData)); + } + this.mOutputItems[1] = GTOreDictUnificator.get(OrePrefixes.cell, Materials.Empty, 1L); + this.calculateOverclockedNess( + BWUtil.getMachineVoltageFromTier(rTier + cultureDNABioData.getTier()), + 500); + + return MTEBasicMachine.FOUND_AND_SUCCESSFULLY_USED_RECIPE; + } + break; + case PCR_THERMOCYCLE_MODULE: { + if (GTUtility.isStackValid(this.mInventory[this.getInputSlot()]) + && this.mInventory[this.getInputSlot()].getItem() instanceof ItemLabParts + && this.mInventory[this.getInputSlot()].getItemDamage() == 1 + && this.mInventory[this.getInputSlot()].getTagCompound() != null + && // checks if it is a Culture + GTUtility.isStackValid(this.mInventory[this.getInputSlot() + 3]) + && GTUtility + .areStacksEqual(this.mInventory[this.getInputSlot() + 3], ItemList.Tool_DataOrb.get(1L)) + && GTUtility.isStackValid(this.mInventory[this.getInputSlot() + 1]) + && GTUtility + .areStacksEqual(this.mInventory[this.getInputSlot() + 1], FluidLoader.BioLabFluidCells[0]) + && GTUtility.isStackValid(this.mInventory[this.getInputSlot() + 2]) + && GTUtility + .areStacksEqual(this.mInventory[this.getInputSlot() + 2], FluidLoader.BioLabFluidCells[3]) + && this.mFluid != null + && this.mFluid.isFluidEqual(dnaFluid) + && this.mFluid.amount >= 1000) { + NBTTagCompound DNABioDataTag = this.mInventory[this.getInputSlot()].getTagCompound(); + if (DNABioDataTag == null) return super.checkRecipe(skipOC); + BioData cultureDNABioData = BioData.getBioDataFromName(DNABioDataTag.getString("Name")); + if (cultureDNABioData == null) return super.checkRecipe(skipOC); + + if (this.mTier < 1 + rTier + cultureDNABioData.getTier()) + return MTEBasicMachine.FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + + for (int i = 0; i < 4; i++) { + if (this.mInventory[this.getInputSlot() + i] != null) + this.mInventory[this.getInputSlot() + i].stackSize--; + } + + this.mFluid.amount -= 1000; + + ItemStack Outp = ItemList.Tool_DataOrb.get(1L); + BehaviourDataOrb.setDataTitle(Outp, "DNA Sample"); + BehaviourDataOrb.setDataName(Outp, cultureDNABioData.getName()); + + if (cultureDNABioData.getChance() > new XSTR().nextInt(10000)) { + this.mOutputItems[0] = Outp; + } else this.mOutputItems[0] = ItemList.Tool_DataOrb.get(1L); + this.mOutputItems[1] = ItemList.Cell_Empty.get(2L); + + this.calculateOverclockedNess( + BWUtil.getMachineVoltageFromTier(1 + rTier + cultureDNABioData.getTier()), + 500); + + return MTEBasicMachine.FOUND_AND_SUCCESSFULLY_USED_RECIPE; + } + } + break; + case PLASMID_SYNTHESIS_MODULE: { + ItemStack inp2 = ItemList.Tool_DataOrb.get(1L); + BehaviourDataOrb.setDataTitle(inp2, "DNA Sample"); + BehaviourDataOrb.setDataName(inp2, BioCultureLoader.BIO_DATA_BETA_LACMATASE.getName()); + if (GTUtility.isStackValid(this.mInventory[this.getInputSlot()]) + && GTUtility + .areStacksEqual(FluidLoader.BioLabFluidCells[1], this.mInventory[this.getInputSlot()]) + && // checks + // if + // it + // is + // a + // Culture + GTUtility.isStackValid(this.mInventory[this.getInputSlot() + 1]) + && GTUtility + .areStacksEqual(this.mInventory[this.getInputSlot() + 1], BioItemList.getPlasmidCell(null)) + && GTUtility.isStackValid(this.mInventory[this.getInputSlot() + 2]) + && GTUtility.areStacksEqual( + this.mInventory[this.getInputSlot() + 2], + ItemList.Tool_DataOrb.get(1L), + true) + && "DNA Sample".equals(BehaviourDataOrb.getDataTitle(this.mInventory[this.getInputSlot() + 2])) + && !BehaviourDataOrb.getDataName(this.mInventory[this.getInputSlot() + 2]) + .isEmpty() + && GTUtility.isStackValid(this.mInventory[this.getInputSlot() + 3]) + && GTUtility.areStacksEqual(this.mInventory[this.getInputSlot() + 3], inp2) + && this.mFluid != null + && this.mFluid.isFluidEqual(dnaFluid) + && this.mFluid.amount >= 1000) { + BioData cultureDNABioData = BioData + .getBioDataFromName(BehaviourDataOrb.getDataName(this.mInventory[this.getInputSlot() + 2])); + if (cultureDNABioData == null) return super.checkRecipe(skipOC); + if (this.mTier < 1 + rTier + cultureDNABioData.getTier()) + return MTEBasicMachine.FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + for (int i = 0; i < 2; i++) { + if (this.mInventory[this.getInputSlot() + i] != null) + this.mInventory[this.getInputSlot() + i].stackSize--; + } + this.mFluid.amount -= 1000; + if (cultureDNABioData.getChance() > new XSTR().nextInt(10000)) { + this.mOutputItems[0] = BioItemList + .getPlasmidCell(BioPlasmid.convertDataToPlasmid(cultureDNABioData)); + } + this.mOutputItems[1] = ItemList.Cell_Empty.get(1L); + this.calculateOverclockedNess( + BWUtil.getMachineVoltageFromTier(1 + rTier + cultureDNABioData.getTier()), + 500); + return MTEBasicMachine.FOUND_AND_SUCCESSFULLY_USED_RECIPE; + } + } + break; + case TRANSFORMATION_MODULE: { + if (GTUtility.isStackValid(this.mInventory[this.getInputSlot()]) + && GTUtility + .areStacksEqual(this.mInventory[this.getInputSlot()], BioItemList.getPetriDish(null), true) + && this.mInventory[this.getInputSlot()].getTagCompound() != null + && GTUtility.isStackValid(this.mInventory[this.getInputSlot() + 1]) + && GTUtility.areStacksEqual( + this.mInventory[this.getInputSlot() + 1], + BioItemList.getPlasmidCell(null), + true) + && this.mInventory[this.getInputSlot() + 1].getTagCompound() != null + && GTUtility.isStackValid(this.mInventory[this.getInputSlot() + 2]) + && GTUtility + .areStacksEqual(this.mInventory[this.getInputSlot() + 2], FluidLoader.BioLabFluidCells[2]) + && this.mFluid != null + && this.mFluid.isFluidEqual(FluidRegistry.getFluidStack("ic2distilledwater", 1000)) + && this.mFluid.amount >= 1000) { + BioData cultureDNABioData = BioData + .getBioDataFromNBTTag(this.mInventory[this.getInputSlot() + 1].getTagCompound()); + BioCulture bioCulture = BioCulture + .getBioCultureFromNBTTag(this.mInventory[this.getInputSlot()].getTagCompound()); + if (cultureDNABioData == null || bioCulture == null) return super.checkRecipe(skipOC); + if (this.mTier < 3 + rTier + cultureDNABioData.getTier()) + return MTEBasicMachine.FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + for (int i = 0; i < 3; i++) { + if (this.mInventory[this.getInputSlot() + i] != null) + this.mInventory[this.getInputSlot() + i].stackSize--; + } + this.mFluid.amount -= 1000; + bioCulture = bioCulture.setPlasmid(BioPlasmid.convertDataToPlasmid(cultureDNABioData)); + if (cultureDNABioData.getChance() > new XSTR().nextInt(10000)) { + this.mOutputItems[0] = BioItemList.getPetriDish(bioCulture); + } + this.mOutputItems[1] = ItemList.Cell_Empty.get(1L); + this.calculateOverclockedNess( + BWUtil.getMachineVoltageFromTier(3 + rTier + cultureDNABioData.getTier()), + 500); + return MTEBasicMachine.FOUND_AND_SUCCESSFULLY_USED_RECIPE; + } + } + break; + case CLONAL_CELLULAR_SYNTHESIS_MODULE: { + ItemStack Outp = ItemList.Tool_DataOrb.get(1L); + BehaviourDataOrb.setDataTitle(Outp, "DNA Sample"); + + if (GTUtility.isStackValid(this.mInventory[this.getInputSlot()]) + && GTUtility + .areStacksEqual(this.mInventory[this.getInputSlot()], BioItemList.getPetriDish(null)) + && GTUtility.isStackValid(this.mInventory[this.getInputSlot() + 1]) + && GTUtility.areStacksEqual(this.mInventory[this.getInputSlot() + 1], BioItemList.getOther(4)) + && GTUtility.isStackValid(this.mInventory[this.getInputSlot() + 2]) + && GTUtility.areStacksEqual( + this.mInventory[this.getInputSlot() + 2], + ItemList.Circuit_Chip_Stemcell.get(2L)) + && GTUtility.isStackValid(this.mInventory[this.getInputSlot() + 3]) + && GTUtility.areStacksEqual( + this.mInventory[this.getInputSlot() + 3], + ItemList.Tool_DataOrb.get(1L), + true) + && "DNA Sample".equals(BehaviourDataOrb.getDataTitle(this.mInventory[this.getInputSlot() + 3])) + && this.mFluid.isFluidEqual(dnaFluid) + && this.mFluid.amount >= 8000) { + + BioData cultureDNABioData = BioData + .getBioDataFromName(BehaviourDataOrb.getDataName(this.mInventory[this.getInputSlot() + 3])); + if (cultureDNABioData == null) return super.checkRecipe(skipOC); + if (this.mTier < 3 + rTier + cultureDNABioData.getTier()) + return MTEBasicMachine.FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + for (int i = 0; i < 3; i++) { + if (this.mInventory[this.getInputSlot() + i] != null) + this.mInventory[this.getInputSlot() + i].stackSize--; + } + this.mFluid.amount -= 8000; + if (cultureDNABioData.getChance() > new XSTR().nextInt(10000)) { + BioCulture out = BioCulture.getBioCulture(BioDNA.convertDataToDNA(cultureDNABioData)); + if (out == null) return MTEBasicMachine.DID_NOT_FIND_RECIPE; + out = out.setPlasmid(BioPlasmid.convertDataToPlasmid(cultureDNABioData)); + this.mOutputItems[0] = BioItemList.getPetriDish(out); + } + this.calculateOverclockedNess( + BWUtil.getMachineVoltageFromTier(3 + rTier + cultureDNABioData.getTier()), + 500); + return MTEBasicMachine.FOUND_AND_SUCCESSFULLY_USED_RECIPE; + } + } + break; + case INCUBATION_MODULE: + default: + break; + } + } + return super.checkRecipe(skipOC); + } + + @Override + public String[] getDescription() { + return new String[] { StatCollector.translateToLocal("tooltip.tile.biolab.0.name"), + BWTooltipReference.ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS.get() }; + } +} diff --git a/src/main/java/bartworks/common/tileentities/tiered/MTECompressedFluidHatch.java b/src/main/java/bartworks/common/tileentities/tiered/MTECompressedFluidHatch.java new file mode 100644 index 0000000000..89b21ae67e --- /dev/null +++ b/src/main/java/bartworks/common/tileentities/tiered/MTECompressedFluidHatch.java @@ -0,0 +1,57 @@ +/* + * 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.common.tileentities.tiered; + +import net.minecraftforge.fluids.FluidStack; + +import com.gtnewhorizons.modularui.common.widget.FluidSlotWidget; + +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatchInput; +import gregtech.api.util.GTUtility; + +public class MTECompressedFluidHatch extends MTEHatchInput { + + public MTECompressedFluidHatch(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 0); + this.mDescriptionArray[1] = "Capacity: 100,000,000L"; + } + + public MTECompressedFluidHatch(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public int getCapacity() { + return 100_000_000; + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return GTUtility.areFluidsEqual(aFluid, Materials.LiquidAir.getFluid(1)); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTECompressedFluidHatch(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + protected FluidSlotWidget createFluidSlot() { + return super.createFluidSlot().setFilter(f -> f == Materials.LiquidAir.mFluid); + } +} diff --git a/src/main/java/bartworks/common/tileentities/tiered/MTEDiode.java b/src/main/java/bartworks/common/tileentities/tiered/MTEDiode.java new file mode 100644 index 0000000000..ad3a39320f --- /dev/null +++ b/src/main/java/bartworks/common/tileentities/tiered/MTEDiode.java @@ -0,0 +1,125 @@ +/* + * 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.common.tileentities.tiered; + +import static gregtech.api.enums.MetaTileEntityIDs.Diode12A_MAX; +import static gregtech.api.enums.MetaTileEntityIDs.Diode12A_ULV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode16A_MAX; +import static gregtech.api.enums.MetaTileEntityIDs.Diode16A_ULV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode2A_MAX; +import static gregtech.api.enums.MetaTileEntityIDs.Diode2A_ULV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode4A_MAX; +import static gregtech.api.enums.MetaTileEntityIDs.Diode4A_ULV; +import static gregtech.api.enums.MetaTileEntityIDs.Diode8A_MAX; +import static gregtech.api.enums.MetaTileEntityIDs.Diode8A_ULV; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.ArrayUtils; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.MTEBasicHull; +import gregtech.api.util.GTUtility; + +public class MTEDiode extends MTEBasicHull { + + private long maxAmps; + private long aAmps; + + public MTEDiode(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, StatCollector.translateToLocal("tooltip.tile.diode.0.name")); + this.maxAmps = this.getAmpsfromMeta(aID); + this.aAmps = this.maxAmps; + } + + public MTEDiode(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + if (this.maxAmps == 0 && !this.getBaseMetaTileEntity() + .getWorld().isRemote) { + this.maxAmps = this.getAmpsfromMeta( + this.getBaseMetaTileEntity() + .getMetaTileID()); + this.aAmps = this.maxAmps; + } + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); + + if (this.getBaseMetaTileEntity() + .getWorld().isRemote) return; + if (!aPlayer.isSneaking()) { + --this.aAmps; + if (this.aAmps < 0) this.aAmps = this.maxAmps; + } else { + ++this.aAmps; + if (this.aAmps > this.maxAmps) this.aAmps = 0; + } + GTUtility.sendChatToPlayer(aPlayer, "Max Amps: " + this.aAmps); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setLong("maxAmp", this.maxAmps); + aNBT.setLong("Amps", this.aAmps); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.maxAmps = aNBT.getLong("maxAmp"); + this.aAmps = aNBT.getLong("Amps"); + super.loadNBTData(aNBT); + } + + @Override + public long maxAmperesOut() { + return this.aAmps; + } + + @Override + public long maxAmperesIn() { + return this.aAmps; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEDiode(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + private long getAmpsfromMeta(int meta) { + if (meta >= Diode2A_ULV.ID && meta <= Diode2A_MAX.ID) return 2L; + if (meta >= Diode4A_ULV.ID && meta <= Diode4A_MAX.ID) return 4L; + if (meta >= Diode8A_ULV.ID && meta <= Diode8A_MAX.ID) return 8L; + if (meta >= Diode12A_ULV.ID && meta <= Diode12A_MAX.ID) return 12L; + if (meta >= Diode16A_ULV.ID && meta <= Diode16A_MAX.ID) return 16L; + return 0L; + } + + @Override + public String[] getDescription() { + return ArrayUtils.addAll(this.mDescriptionArray); + } +} diff --git a/src/main/java/bartworks/common/tileentities/tiered/MTEEnergyDistributor.java b/src/main/java/bartworks/common/tileentities/tiered/MTEEnergyDistributor.java new file mode 100644 index 0000000000..d361047699 --- /dev/null +++ b/src/main/java/bartworks/common/tileentities/tiered/MTEEnergyDistributor.java @@ -0,0 +1,72 @@ +/* + * 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.common.tileentities.tiered; + +import net.minecraft.util.StatCollector; + +import gregtech.api.enums.GTValues; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.MTETransformer; + +public class MTEEnergyDistributor extends MTETransformer { + + public MTEEnergyDistributor(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, null); + } + + public MTEEnergyDistributor(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + public MTEEnergyDistributor(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEEnergyDistributor(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public long maxEUInput() { + return GTValues.V[this.mTier]; + } + + @Override + public long maxEUOutput() { + return GTValues.V[this.mTier]; + } + + @Override + public long maxAmperesOut() { + return 320; + } + + @Override + public long maxAmperesIn() { + return 320; + } + + @Override + public long maxEUStore() { + return 512L + GTValues.V[this.mTier] * 320L; + } + + @Override + public String[] getDescription() { + return new String[] { StatCollector.translateToLocal("tooltip.tile.energydistributor.0.name") }; + } +} diff --git a/src/main/java/bartworks/common/tileentities/tiered/MTEGiantOutputHatch.java b/src/main/java/bartworks/common/tileentities/tiered/MTEGiantOutputHatch.java new file mode 100644 index 0000000000..dc4b031f74 --- /dev/null +++ b/src/main/java/bartworks/common/tileentities/tiered/MTEGiantOutputHatch.java @@ -0,0 +1,41 @@ +/* + * 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.common.tileentities.tiered; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatchOutput; + +public class MTEGiantOutputHatch extends MTEHatchOutput { + + public MTEGiantOutputHatch(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 0); + this.mDescriptionArray[1] = "Capacity: 100000000L"; + } + + public MTEGiantOutputHatch(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEGiantOutputHatch(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public int getCapacity() { + return 100000000; + } +} diff --git a/src/main/java/bartworks/common/tileentities/tiered/MTEHumongousInputHatch.java b/src/main/java/bartworks/common/tileentities/tiered/MTEHumongousInputHatch.java new file mode 100644 index 0000000000..efe3614250 --- /dev/null +++ b/src/main/java/bartworks/common/tileentities/tiered/MTEHumongousInputHatch.java @@ -0,0 +1,41 @@ +/* + * 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.common.tileentities.tiered; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatchInput; + +public class MTEHumongousInputHatch extends MTEHatchInput { + + public MTEHumongousInputHatch(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 13); + this.mDescriptionArray[1] = "Capacity: 2,000,000,000L"; + } + + public MTEHumongousInputHatch(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public int getCapacity() { + return 2_000_000_000; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEHumongousInputHatch(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } +} diff --git a/src/main/java/bartworks/neiHandler/BWNEIConfig.java b/src/main/java/bartworks/neiHandler/BWNEIConfig.java new file mode 100644 index 0000000000..6226613e91 --- /dev/null +++ b/src/main/java/bartworks/neiHandler/BWNEIConfig.java @@ -0,0 +1,96 @@ +/* + * 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.neiHandler; + +import net.minecraft.item.ItemStack; + +import bartworks.API.recipe.BartWorksRecipeMaps; +import bartworks.MainMod; +import bartworks.common.loaders.FluidLoader; +import bartworks.common.loaders.ItemRegistry; +import bartworks.system.material.WerkstoffLoader; +import codechicken.nei.PositionedStack; +import codechicken.nei.api.API; +import codechicken.nei.api.IConfigureNEI; +import gregtech.api.enums.OrePrefixes; + +public class BWNEIConfig implements IConfigureNEI { + + static boolean sIsAdded = true; + + static boolean checkRecipe(ItemStack labPart, Iterable<? extends PositionedStack> stacks) { + for (PositionedStack stack : stacks) { + for (ItemStack item : stack.items) { + if (labPart.getTagCompound() + .equals(item.getTagCompound())) { + return true; + } + } + } + return false; + } + + @Override + public void loadConfig() { + API.hideItem(new ItemStack(ItemRegistry.TAB)); + API.hideItem(new ItemStack(FluidLoader.bioFluidBlock)); + API.hideItem(new ItemStack(ItemRegistry.bw_fake_glasses)); + API.hideItem(new ItemStack(ItemRegistry.bw_fake_glasses2)); + ItemStack[] prefixesToHide = { + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.dustTiny, WerkstoffLoader.Bismutite) + .copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.dustSmall, WerkstoffLoader.Bismutite) + .copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.crushed, WerkstoffLoader.Bismutite) + .copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.crushedPurified, WerkstoffLoader.Bismutite) + .copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.crushedCentrifuged, WerkstoffLoader.Bismutite) + .copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.nugget, WerkstoffLoader.Bismutite) + .copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.gemChipped, WerkstoffLoader.Bismutite) + .copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.gemFlawed, WerkstoffLoader.Bismutite) + .copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.gemFlawless, WerkstoffLoader.Bismutite) + .copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.gemExquisite, WerkstoffLoader.Bismutite) + .copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.dustImpure, WerkstoffLoader.Bismutite) + .copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.dustPure, WerkstoffLoader.Bismutite) + .copy(), }; + for (ItemStack stack : prefixesToHide) { + stack.setItemDamage(Short.MAX_VALUE); + API.hideItem(stack); + } + + BWNEIConfig.sIsAdded = false; + new OreNEIHandler(); + new BioVatNEIHandler(BartWorksRecipeMaps.bacterialVatRecipes.getDefaultRecipeCategory()); + new BioLabNEIHandler(BartWorksRecipeMaps.bioLabRecipes.getDefaultRecipeCategory()); + BWNEIConfig.sIsAdded = true; + } + + @Override + public String getName() { + return "BartWorks NEI Plugin"; + } + + @Override + public String getVersion() { + return MainMod.APIVERSION; + } +} diff --git a/src/main/java/bartworks/neiHandler/BioLabNEIHandler.java b/src/main/java/bartworks/neiHandler/BioLabNEIHandler.java new file mode 100644 index 0000000000..40c20e42d3 --- /dev/null +++ b/src/main/java/bartworks/neiHandler/BioLabNEIHandler.java @@ -0,0 +1,70 @@ +/* + * 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.neiHandler; + +import net.minecraft.item.ItemStack; + +import bartworks.common.items.ItemLabParts; +import codechicken.nei.recipe.GuiCraftingRecipe; +import codechicken.nei.recipe.GuiUsageRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; +import cpw.mods.fml.common.event.FMLInterModComms; +import gregtech.api.enums.GTValues; +import gregtech.api.recipe.RecipeCategory; +import gregtech.nei.GTNEIDefaultHandler; + +public class BioLabNEIHandler extends GTNEIDefaultHandler { + + public BioLabNEIHandler(RecipeCategory recipeCategory) { + super(recipeCategory); + if (!BWNEIConfig.sIsAdded) { + FMLInterModComms.sendRuntimeMessage( + GTValues.GT, + "NEIPlugins", + "register-crafting-handler", + "gregtech@" + this.getRecipeName() + "@" + this.getOverlayIdentifier()); + GuiCraftingRecipe.craftinghandlers.add(this); + GuiUsageRecipe.usagehandlers.add(this); + } + } + + @Override + public TemplateRecipeHandler newInstance() { + return new BioLabNEIHandler(this.recipeCategory); + } + + @Override + public void loadCraftingRecipes(ItemStack aResult) { + if (aResult != null && aResult.getItem() instanceof ItemLabParts + && aResult.getItemDamage() < 3 + && aResult.getTagCompound() != null) { + for (CachedDefaultRecipe recipe : this.getCache()) + if (BWNEIConfig.checkRecipe(aResult, recipe.mOutputs)) this.arecipes.add(recipe); + } else { + super.loadCraftingRecipes(aResult); + } + } + + @Override + public void loadUsageRecipes(ItemStack aResult) { + if (aResult != null && aResult.getItem() instanceof ItemLabParts + && aResult.getItemDamage() < 3 + && aResult.getTagCompound() != null) { + for (CachedDefaultRecipe recipe : this.getCache()) + if (BWNEIConfig.checkRecipe(aResult, recipe.mInputs)) this.arecipes.add(recipe); + } else { + super.loadUsageRecipes(aResult); + } + } +} diff --git a/src/main/java/bartworks/neiHandler/BioVatNEIHandler.java b/src/main/java/bartworks/neiHandler/BioVatNEIHandler.java new file mode 100644 index 0000000000..08583a617d --- /dev/null +++ b/src/main/java/bartworks/neiHandler/BioVatNEIHandler.java @@ -0,0 +1,71 @@ +/* + * 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.neiHandler; + +import java.util.Collections; + +import net.minecraft.item.ItemStack; + +import bartworks.common.items.ItemLabParts; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.GuiCraftingRecipe; +import codechicken.nei.recipe.GuiUsageRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; +import cpw.mods.fml.common.event.FMLInterModComms; +import gregtech.api.enums.GTValues; +import gregtech.api.recipe.RecipeCategory; +import gregtech.nei.GTNEIDefaultHandler; + +public class BioVatNEIHandler extends GTNEIDefaultHandler { + + public BioVatNEIHandler(RecipeCategory recipeCategory) { + super(recipeCategory); + if (!BWNEIConfig.sIsAdded) { + FMLInterModComms.sendRuntimeMessage( + GTValues.GT, + "NEIPlugins", + "register-crafting-handler", + "gregtech@" + this.getRecipeName() + "@" + this.getOverlayIdentifier()); + GuiCraftingRecipe.craftinghandlers.add(this); + GuiUsageRecipe.usagehandlers.add(this); + } + } + + @Override + public TemplateRecipeHandler newInstance() { + return new BioVatNEIHandler(this.recipeCategory); + } + + private void loadLabPartRecipes(ItemStack aResult) { + for (CachedDefaultRecipe recipe : this.getCache()) { + // dirty way of finding the special slot item + // see constructor of CachedDefaultRecipe on why relx==120 and rely==52 means special slot + for (PositionedStack stack : recipe.mInputs) { + if (stack.relx == 120 && stack.rely == 52 + && BWNEIConfig.checkRecipe(aResult, Collections.singletonList(stack))) this.arecipes.add(recipe); + } + } + } + + @Override + public void loadUsageRecipes(ItemStack aResult) { + if (aResult != null && aResult.getItem() instanceof ItemLabParts + && aResult.getItemDamage() < 3 + && aResult.getTagCompound() != null) { + this.loadLabPartRecipes(aResult); + } else { + super.loadUsageRecipes(aResult); + } + } +} diff --git a/src/main/java/bartworks/neiHandler/OreNEIHandler.java b/src/main/java/bartworks/neiHandler/OreNEIHandler.java new file mode 100644 index 0000000000..bbb6802a61 --- /dev/null +++ b/src/main/java/bartworks/neiHandler/OreNEIHandler.java @@ -0,0 +1,249 @@ +/* + * 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.neiHandler; + +import java.awt.Rectangle; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import bartworks.MainMod; +import bartworks.system.material.BWMetaGeneratedOres; +import bartworks.system.material.BWMetaGeneratedSmallOres; +import bartworks.system.material.Werkstoff; +import bartworks.system.oregen.BWOreLayer; +import bartworks.system.oregen.BWWorldGenRoss128b; +import bartworks.system.oregen.BWWorldGenRoss128ba; +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.GuiCraftingRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; +import cpw.mods.fml.common.event.FMLInterModComms; +import gregtech.api.enums.OrePrefixes; + +public class OreNEIHandler extends TemplateRecipeHandler { + + public OreNEIHandler() { + if (!BWNEIConfig.sIsAdded) { + FMLInterModComms.sendRuntimeMessage( + MainMod.MOD_ID, + "NEIPlugins", + "register-crafting-handler", + MainMod.MOD_ID + "@" + this.getRecipeName() + "@" + this.getOverlayIdentifier()); + GuiCraftingRecipe.craftinghandlers.add(this); + } + } + + @Override + public void drawBackground(int recipe) { + GuiDraw.drawRect(0, 0, 166, 65, 0x888888); + } + + @Override + public void loadTransferRects() { + this.transferRects.add( + new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(0, 40, 40, 120), "quickanddirtyneihandler")); + } + + @Override + public int recipiesPerPage() { + return 1; + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if ("quickanddirtyneihandler".equalsIgnoreCase(outputId)) { + HashSet<ItemStack> result = new HashSet<>(); + Werkstoff.werkstoffHashSet.stream() + .filter(w -> w.hasGenerationFeature(OrePrefixes.ore)) + .forEach(w -> result.add(w.get(OrePrefixes.ore))); + result.forEach(this::loadCraftingRecipes); + result.clear(); + Werkstoff.werkstoffHashSet.stream() + .filter(w -> w.hasGenerationFeature(OrePrefixes.ore)) + .forEach(w -> result.add(w.get(OrePrefixes.oreSmall))); + result.forEach(this::loadCraftingRecipes); + result.clear(); + HashSet<TemplateRecipeHandler.CachedRecipe> hashSet = new HashSet<>(this.arecipes); + this.arecipes.clear(); + this.arecipes.addAll(hashSet); + } + if ("item".equals(outputId)) { + this.loadCraftingRecipes((ItemStack) results[0]); + HashSet<TemplateRecipeHandler.CachedRecipe> hashSet = new HashSet<>(this.arecipes); + this.arecipes.clear(); + this.arecipes.addAll(hashSet); + } + } + + @Override + public void drawExtras(int recipe) { + if (recipe < this.arecipes.size() && this.arecipes.get(recipe) instanceof CachedOreRecipe) { + CachedOreRecipe cachedOreRecipe = (CachedOreRecipe) this.arecipes.get(recipe); + + if (cachedOreRecipe == null || cachedOreRecipe.getOtherStacks() == null + || cachedOreRecipe.getOtherStacks() + .size() == 0) + return; + + if (!cachedOreRecipe.small) { + if (cachedOreRecipe.getOtherStacks() + .get(0) == null + || cachedOreRecipe.getOtherStacks() + .get(0).item == null + || cachedOreRecipe.getOtherStacks() + .get(1) == null + || cachedOreRecipe.getOtherStacks() + .get(2) == null + || cachedOreRecipe.getOtherStacks() + .get(3) == null + || cachedOreRecipe.getOtherStacks() + .get(1).item == null + || cachedOreRecipe.getOtherStacks() + .get(2).item == null + || cachedOreRecipe.getOtherStacks() + .get(3).item == null) + return; + } else if (cachedOreRecipe.getOtherStacks() + .get(0) == null + || cachedOreRecipe.getOtherStacks() + .get(0).item == null) + return; + + if (cachedOreRecipe.worldGen != null) GuiDraw.drawString( + EnumChatFormatting.BOLD + "DIM: " + EnumChatFormatting.RESET + cachedOreRecipe.worldGen.getDimName(), + 0, + 40, + 0, + false); + + GuiDraw.drawString(EnumChatFormatting.BOLD + "Primary:", 0, 50, 0, false); + GuiDraw.drawString( + cachedOreRecipe.getOtherStacks() + .get(0).item.getDisplayName(), + 0, + 60, + 0, + false); + + if (!cachedOreRecipe.small) { + GuiDraw.drawString(EnumChatFormatting.BOLD + "Secondary:", 0, 70, 0, false); + GuiDraw.drawString( + cachedOreRecipe.getOtherStacks() + .get(1).item.getDisplayName(), + 0, + 80, + 0, + false); + GuiDraw.drawString(EnumChatFormatting.BOLD + "InBetween:", 0, 90, 0, false); + GuiDraw.drawString( + cachedOreRecipe.getOtherStacks() + .get(2).item.getDisplayName(), + 0, + 100, + 0, + false); + GuiDraw.drawString(EnumChatFormatting.BOLD + "Sporadic:", 0, 110, 0, false); + GuiDraw.drawString( + cachedOreRecipe.getOtherStacks() + .get(3).item.getDisplayName(), + 0, + 120, + 0, + false); + } else if (cachedOreRecipe.worldGen != null) { + GuiDraw.drawString(EnumChatFormatting.BOLD + "Amount per Chunk:", 0, 70, 0, false); + GuiDraw.drawString(cachedOreRecipe.worldGen.mDensity + "", 0, 80, 0, false); + } + } + super.drawExtras(recipe); + } + + @Override + public void loadCraftingRecipes(ItemStack result) { + Block ore = Block.getBlockFromItem(result.getItem()); + if (ore instanceof BWMetaGeneratedOres) { + BWOreLayer.NEIMAP.get((short) result.getItemDamage()) + .stream() + .filter( + l -> !(ore instanceof BWMetaGeneratedSmallOres) || !l.getClass() + .equals(BWWorldGenRoss128b.class) + && !l.getClass() + .equals(BWWorldGenRoss128ba.class)) + .forEach( + l -> this.arecipes.add(new CachedOreRecipe(l, result, ore instanceof BWMetaGeneratedSmallOres))); + } + } + + @Override + public String getGuiTexture() { + return "textures/gui/container/brewing_stand.png"; + } + + @Override + public String getRecipeName() { + return "BartWorks Ores"; + } + + class CachedOreRecipe extends TemplateRecipeHandler.CachedRecipe { + + public CachedOreRecipe(BWOreLayer worldGen, ItemStack result, boolean smallOres) { + this.worldGen = worldGen; + this.stack = new PositionedStack(result, 0, 0); + this.small = smallOres; + } + + boolean small; + BWOreLayer worldGen; + PositionedStack stack; + + @Override + public PositionedStack getResult() { + return this.stack; + } + + @Override + public List<PositionedStack> getOtherStacks() { + List<PositionedStack> ret = new ArrayList<>(); + int x = 0; + for (int i = 0; i < (this.small ? 1 : 4); i++) { + x += 20; + ret.add( + new PositionedStack( + this.worldGen.getStacks() + .get(i), + x, + 12)); + } + return ret; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof CachedOreRecipe that)) return false; + return Objects.equals(this.worldGen, that.worldGen); + } + + @Override + public int hashCode() { + return this.worldGen.hashCode(); + } + } +} diff --git a/src/main/java/bartworks/server/EventHandler/ServerEventHandler.java b/src/main/java/bartworks/server/EventHandler/ServerEventHandler.java new file mode 100644 index 0000000000..2a1ba2b626 --- /dev/null +++ b/src/main/java/bartworks/server/EventHandler/ServerEventHandler.java @@ -0,0 +1,94 @@ +/* + * 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.server.EventHandler; + +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.oredict.OreDictionary; + +import bartworks.API.SideReference; +import bartworks.MainMod; +import bartworks.common.net.OreDictCachePacket; +import bartworks.common.net.ServerJoinedPacket; +import bartworks.system.material.Werkstoff; +import bartworks.system.oredict.OreDictHandler; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GTOreDictUnificator; + +public class ServerEventHandler { + + // MinecraftForge.EVENT_BUS + @SubscribeEvent(priority = EventPriority.LOWEST) + public void EntityJoinWorldEvent(EntityJoinWorldEvent event) { + if (event == null || !(event.entity instanceof EntityPlayerMP) || !SideReference.Side.Server) return; + MainMod.BW_Network_instance + .sendToPlayer(new OreDictCachePacket(OreDictHandler.getNonBWCache()), (EntityPlayerMP) event.entity); + MainMod.BW_Network_instance.sendToPlayer(new ServerJoinedPacket(null), (EntityPlayerMP) event.entity); + } + + // FMLCommonHandler.instance().bus() + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onPlayerTickEventServer(TickEvent.PlayerTickEvent event) { + if (event == null || !(event.player instanceof EntityPlayerMP) + || event.player.worldObj.getTotalWorldTime() % 20 != 0) return; + + boolean replace = false; + ItemStack toReplace = null; + for (int i = 0; i < event.player.inventory.mainInventory.length; i++) { + ItemStack stack = event.player.inventory.mainInventory[i]; + if (stack == null) continue; + int[] oreIDs = OreDictionary.getOreIDs(stack); + + if (oreIDs.length > 0) { + loop: for (int oreID : oreIDs) { + String oreDictName = OreDictionary.getOreName(oreID); + for (Werkstoff e : Werkstoff.werkstoffHashSet) { + replace = e.getGenerationFeatures().enforceUnification; + if (replace) { + if (oreDictName.contains(e.getVarName())) { + String prefix = oreDictName.replace(e.getVarName(), ""); + OrePrefixes prefixes = OrePrefixes.getPrefix(prefix); + if (prefixes == null) { + continue; + } + toReplace = GTOreDictUnificator.get(prefixes, e.getVarName(), stack.stackSize); + break loop; + } + for (String s : e.getADDITIONAL_OREDICT()) { + if (oreDictName.contains(s)) { + String prefix = oreDictName.replace(s, ""); + OrePrefixes prefixes = OrePrefixes.getPrefix(prefix); + if (prefixes == null) { + continue; + } + toReplace = GTOreDictUnificator.get(prefixes, e.getVarName(), stack.stackSize); + break loop; + } + } + } + replace = false; + } + } + } + if (replace && toReplace != null) { + event.player.inventory.setInventorySlotContents(i, toReplace); + replace = false; + } + } + } +} diff --git a/src/main/java/bartworks/system/material/BWGTMaterialReference.java b/src/main/java/bartworks/system/material/BWGTMaterialReference.java new file mode 100644 index 0000000000..50665464f4 --- /dev/null +++ b/src/main/java/bartworks/system/material/BWGTMaterialReference.java @@ -0,0 +1,523 @@ +/* + * 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.system.material; + +import bartworks.MainMod; +import gregtech.api.enums.Materials; + +public class BWGTMaterialReference { + + private static final Werkstoff.GenerationFeatures ADD_CASINGS_ONLY = new Werkstoff.GenerationFeatures().disable() + .addCasings(); + + public static Werkstoff Aluminium = new Werkstoff( + Materials.Aluminium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 19); + public static Werkstoff Americium = new Werkstoff( + Materials.Americium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 103); + public static Werkstoff Antimony = new Werkstoff( + Materials.Antimony, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 58); + public static Werkstoff Arsenic = new Werkstoff( + Materials.Arsenic, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 39); + public static Werkstoff Barium = new Werkstoff( + Materials.Barium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 63); + public static Werkstoff Beryllium = new Werkstoff( + Materials.Beryllium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 8); + public static Werkstoff Bismuth = new Werkstoff( + Materials.Bismuth, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 90); + public static Werkstoff Boron = new Werkstoff( + Materials.Boron, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 9); + public static Werkstoff Caesium = new Werkstoff( + Materials.Caesium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 62); + public static Werkstoff Carbon = new Werkstoff( + Materials.Carbon, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 10); + public static Werkstoff Cadmium = new Werkstoff( + Materials.Cadmium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 55); + public static Werkstoff Cerium = new Werkstoff( + Materials.Cerium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 65); + public static Werkstoff Chrome = new Werkstoff( + Materials.Chrome, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 30); + public static Werkstoff Cobalt = new Werkstoff( + Materials.Cobalt, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 33); + public static Werkstoff Copper = new Werkstoff( + Materials.Copper, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 35); + public static Werkstoff Dysprosium = new Werkstoff( + Materials.Dysprosium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 73); + public static Werkstoff Erbium = new Werkstoff( + Materials.Erbium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 75); + public static Werkstoff Europium = new Werkstoff( + Materials.Europium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 70); + public static Werkstoff Gadolinium = new Werkstoff( + Materials.Gadolinium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 71); + public static Werkstoff Gallium = new Werkstoff( + Materials.Gallium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 37); + public static Werkstoff Gold = new Werkstoff( + Materials.Gold, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 86); + public static Werkstoff Holmium = new Werkstoff( + Materials.Holmium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 74); + public static Werkstoff Indium = new Werkstoff( + Materials.Indium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 56); + public static Werkstoff Iridium = new Werkstoff( + Materials.Iridium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 84); + public static Werkstoff Iron = new Werkstoff( + Materials.Iron, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 32); + public static Werkstoff Lanthanum = new Werkstoff( + Materials.Lanthanum, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 64); + public static Werkstoff Lead = new Werkstoff( + Materials.Lead, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 89); + public static Werkstoff Lithium = new Werkstoff( + Materials.Lithium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 6); + public static Werkstoff Lutetium = new Werkstoff( + Materials.Lutetium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 78); + public static Werkstoff Magnesium = new Werkstoff( + Materials.Magnesium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 18); + public static Werkstoff Manganese = new Werkstoff( + Materials.Manganese, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 31); + public static Werkstoff Molybdenum = new Werkstoff( + Materials.Molybdenum, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 48); + public static Werkstoff Neodymium = new Werkstoff( + Materials.Neodymium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 67); + public static Werkstoff Neutronium = new Werkstoff( + Materials.Neutronium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 129); + public static Werkstoff Nickel = new Werkstoff( + Materials.Nickel, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 34); + public static Werkstoff Niobium = new Werkstoff( + Materials.Niobium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 47); + public static Werkstoff Osmium = new Werkstoff( + Materials.Osmium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 83); + public static Werkstoff Palladium = new Werkstoff( + Materials.Palladium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 52); + public static Werkstoff Phosphorus = new Werkstoff( + Materials.Phosphorus, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 21); + public static Werkstoff Platinum = new Werkstoff( + Materials.Platinum, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 85); + public static Werkstoff Plutonium241 = new Werkstoff( + Materials.Plutonium241, + ADD_CASINGS_ONLY, + Werkstoff.Types.ISOTOPE, + 31_766 + 101); + public static Werkstoff Potassium = new Werkstoff( + Materials.Potassium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 25); + public static Werkstoff Praseodymium = new Werkstoff( + Materials.Praseodymium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 66); + public static Werkstoff Promethium = new Werkstoff( + Materials.Promethium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 68); + public static Werkstoff Rubidium = new Werkstoff( + Materials.Rubidium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 43); + public static Werkstoff Samarium = new Werkstoff( + Materials.Samarium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 69); + public static Werkstoff Scandium = new Werkstoff( + Materials.Scandium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 27); + public static Werkstoff Silicon = new Werkstoff( + Materials.Silicon, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 20); + public static Werkstoff Silver = new Werkstoff( + Materials.Silver, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 54); + public static Werkstoff Sodium = new Werkstoff( + Materials.Sodium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 17); + public static Werkstoff Strontium = new Werkstoff( + Materials.Strontium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 44); + public static Werkstoff Sulfur = new Werkstoff( + Materials.Sulfur, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 22); + public static Werkstoff Tantalum = new Werkstoff( + Materials.Tantalum, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 80); + public static Werkstoff Terbium = new Werkstoff( + Materials.Terbium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 72); + public static Werkstoff Thorium = new Werkstoff( + Materials.Thorium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 96); + public static Werkstoff Thulium = new Werkstoff( + Materials.Thulium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 76); + public static Werkstoff Tin = new Werkstoff(Materials.Tin, ADD_CASINGS_ONLY, Werkstoff.Types.ELEMENT, 31_766 + 57); + public static Werkstoff Titanium = new Werkstoff( + Materials.Titanium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 28); + public static Werkstoff Tritanium = new Werkstoff( + Materials.Tritanium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 329); + public static Werkstoff Tritium = new Werkstoff( + Materials.Tritium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 3); + public static Werkstoff Tungsten = new Werkstoff( + Materials.Tungsten, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 81); + public static Werkstoff Uranium = new Werkstoff( + Materials.Uranium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 98); + public static Werkstoff Uranium235 = new Werkstoff( + Materials.Uranium235, + ADD_CASINGS_ONLY, + Werkstoff.Types.ISOTOPE, + 31_766 + 97); + public static Werkstoff Vanadium = new Werkstoff( + Materials.Vanadium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 29); + public static Werkstoff Ytterbium = new Werkstoff( + Materials.Ytterbium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 77); + public static Werkstoff Yttrium = new Werkstoff( + Materials.Yttrium, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 45); + public static Werkstoff Zinc = new Werkstoff( + Materials.Zinc, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 36); + public static Werkstoff Ardite = new Werkstoff( + Materials.Ardite, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 382); + public static Werkstoff Naquadah = new Werkstoff( + Materials.Naquadah, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 324); + public static Werkstoff NaquadahAlloy = new Werkstoff( + Materials.NaquadahAlloy, + ADD_CASINGS_ONLY, + Werkstoff.Types.COMPOUND, + 31_766 + 325); + public static Werkstoff NaquadahEnriched = new Werkstoff( + Materials.NaquadahEnriched, + ADD_CASINGS_ONLY, + Werkstoff.Types.ISOTOPE, + 31_766 + 326); + public static Werkstoff Naquadria = new Werkstoff( + Materials.Naquadria, + ADD_CASINGS_ONLY, + Werkstoff.Types.ELEMENT, + 31_766 + 327); + public static Werkstoff WroughtIron = new Werkstoff( + Materials.WroughtIron, + ADD_CASINGS_ONLY, + Werkstoff.Types.ISOTOPE, + 31_766 + 304); + public static Werkstoff AnnealedCopper = new Werkstoff( + Materials.AnnealedCopper, + ADD_CASINGS_ONLY, + Werkstoff.Types.ISOTOPE, + 31_766 + 345); + + public static Werkstoff Osmiridium = new Werkstoff( + Materials.Osmiridium, + ADD_CASINGS_ONLY, + Werkstoff.Types.MIXTURE, + 31_766 + 317); + public static Werkstoff SterlingSilver = new Werkstoff( + Materials.SterlingSilver, + ADD_CASINGS_ONLY, + Werkstoff.Types.MIXTURE, + 31_766 + 350); + public static Werkstoff RoseGold = new Werkstoff( + Materials.RoseGold, + ADD_CASINGS_ONLY, + Werkstoff.Types.MIXTURE, + 31_766 + 351); + public static Werkstoff BlackBronze = new Werkstoff( + Materials.BlackBronze, + ADD_CASINGS_ONLY, + Werkstoff.Types.MIXTURE, + 31_766 + 352); + public static Werkstoff BismuthBronze = new Werkstoff( + Materials.BismuthBronze, + ADD_CASINGS_ONLY, + Werkstoff.Types.MIXTURE, + 31_766 + 353); + public static Werkstoff BlackSteel = new Werkstoff( + Materials.BlackSteel, + ADD_CASINGS_ONLY, + Werkstoff.Types.MIXTURE, + 31_766 + 334); + public static Werkstoff RedSteel = new Werkstoff( + Materials.RedSteel, + ADD_CASINGS_ONLY, + Werkstoff.Types.MIXTURE, + 31_766 + 348); + public static Werkstoff BlueSteel = new Werkstoff( + Materials.BlueSteel, + ADD_CASINGS_ONLY, + Werkstoff.Types.MIXTURE, + 31_766 + 349); + public static Werkstoff DamascusSteel = new Werkstoff( + Materials.DamascusSteel, + ADD_CASINGS_ONLY, + Werkstoff.Types.MIXTURE, + 31_766 + 335); + public static Werkstoff TungstenSteel = new Werkstoff( + Materials.TungstenSteel, + ADD_CASINGS_ONLY, + Werkstoff.Types.MIXTURE, + 31_766 + 316); + public static Werkstoff Ultimet = new Werkstoff( + Materials.Ultimet, + ADD_CASINGS_ONLY, + Werkstoff.Types.MIXTURE, + 31_766 + 344); + public static Werkstoff TungstenCarbide = new Werkstoff( + Materials.TungstenCarbide, + ADD_CASINGS_ONLY, + Werkstoff.Types.MIXTURE, + 31_766 + 370); + public static Werkstoff VanadiumSteel = new Werkstoff( + Materials.VanadiumSteel, + ADD_CASINGS_ONLY, + Werkstoff.Types.MIXTURE, + 31_766 + 371); + public static Werkstoff HSSG = new Werkstoff( + Materials.HSSG, + ADD_CASINGS_ONLY, + Werkstoff.Types.MIXTURE, + 31_766 + 372); + public static Werkstoff HSSE = new Werkstoff( + Materials.HSSE, + ADD_CASINGS_ONLY, + Werkstoff.Types.MIXTURE, + 31_766 + 373); + public static Werkstoff HSSS = new Werkstoff( + Materials.HSSS, + ADD_CASINGS_ONLY, + Werkstoff.Types.MIXTURE, + 31_766 + 374); + public static Werkstoff StainlessSteel = new Werkstoff( + Materials.StainlessSteel, + ADD_CASINGS_ONLY, + Werkstoff.Types.MIXTURE, + 31_766 + 306); + public static Werkstoff Brass = new Werkstoff( + Materials.Brass, + ADD_CASINGS_ONLY, + Werkstoff.Types.MIXTURE, + 31_766 + 301); + public static Werkstoff Bronze = new Werkstoff( + Materials.Bronze, + ADD_CASINGS_ONLY, + Werkstoff.Types.MIXTURE, + 31_766 + 300); + + public static Werkstoff Wood = new Werkstoff( + Materials.Wood, + ADD_CASINGS_ONLY, + Werkstoff.Types.BIOLOGICAL, + 31_766 + 809); + + public static Werkstoff Steel = new Werkstoff( + Materials.Steel, + ADD_CASINGS_ONLY, + Werkstoff.Types.COMPOUND, + 31_766 + 305); + public static Werkstoff Polytetrafluoroethylene = new Werkstoff( + Materials.Polytetrafluoroethylene, + ADD_CASINGS_ONLY, + Werkstoff.Types.COMPOUND, + 31_766 + 473); + public static Werkstoff Plastic = new Werkstoff( + Materials.Plastic, + ADD_CASINGS_ONLY, + Werkstoff.Types.COMPOUND, + 31_766 + 874); + public static Werkstoff Epoxid = new Werkstoff( + Materials.Epoxid, + ADD_CASINGS_ONLY, + Werkstoff.Types.COMPOUND, + 31_766 + 470); + public static Werkstoff Magnesia = new Werkstoff( + Materials.Magnesia, + new Werkstoff.GenerationFeatures().disable() + .addMetalItems() + .addMolten(), + Werkstoff.Types.COMPOUND, + 31_766 + 471); + + public static void init() { + MainMod.LOGGER.info("Load Elements from GT"); + } +} diff --git a/src/main/java/bartworks/system/material/BWItemMetaGeneratedBlock.java b/src/main/java/bartworks/system/material/BWItemMetaGeneratedBlock.java new file mode 100644 index 0000000000..671b21e92b --- /dev/null +++ b/src/main/java/bartworks/system/material/BWItemMetaGeneratedBlock.java @@ -0,0 +1,94 @@ +/* + * 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.system.material; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +import bartworks.common.items.BWItemBlocks; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTUtility; + +public class BWItemMetaGeneratedBlock extends BWItemBlocks { + + public BWItemMetaGeneratedBlock(Block par1) { + super(par1); + } + + @Override + public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, + float hitX, float hitY, float hitZ) { + return false; + } + + @Override + public String getUnlocalizedName(ItemStack aStack) { + return this.field_150939_a.getUnlocalizedName() + "." + this.getDamage(aStack); + } + + @Override + public String getItemStackDisplayName(ItemStack aStack) { + Block block = Block.getBlockFromItem(aStack.getItem()); + if (block instanceof BWMetaGeneratedBlocks metaBlock) { + int aMetaData = aStack.getItemDamage(); + Werkstoff werkstoff = Werkstoff.werkstoffHashMap.get((short) aMetaData); + if (werkstoff == null) werkstoff = Werkstoff.default_null_Werkstoff; + return metaBlock.blockTypeLocalizedName.replace("%material", werkstoff.getLocalizedName()); + } + return GTLanguageManager.getTranslation(this.getUnlocalizedName(aStack) + ".name"); + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List<String> aList, boolean aF3_H) { + if (!GTUtility.isStackValid(aStack) || aPlayer == null || aStack.getItemDamage() <= 0) { + return; + } + if (aList == null) { + aList = new ArrayList<>(); + } + Werkstoff werkstoff = Werkstoff.werkstoffHashMap.get((short) aStack.getItemDamage()); + if (werkstoff != null) { + String tooltip = werkstoff.getLocalizedToolTip(); + if (!tooltip.isEmpty()) { + aList.add(tooltip); + } + } + } + + @Override + public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int side, + float hitX, float hitY, float hitZ, int aMeta) { + short tDamage = (short) this.getDamage(aStack); + if (tDamage > 0) { + if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, tDamage, 3)) { + return false; + } + TileEntityMetaGeneratedBlock tTileEntity = (TileEntityMetaGeneratedBlock) aWorld.getTileEntity(aX, aY, aZ); + tTileEntity.mMetaData = tDamage; + } else if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, 0, 3)) return false; + if (aWorld.getBlock(aX, aY, aZ) == this.field_150939_a) { + this.field_150939_a.onBlockPlacedBy(aWorld, aX, aY, aZ, aPlayer, aStack); + this.field_150939_a.onPostBlockPlaced(aWorld, aX, aY, aZ, tDamage); + } + return true; + } +} diff --git a/src/main/java/bartworks/system/material/BWMetaGeneratedBlocks.java b/src/main/java/bartworks/system/material/BWMetaGeneratedBlocks.java new file mode 100644 index 0000000000..db838d059a --- /dev/null +++ b/src/main/java/bartworks/system/material/BWMetaGeneratedBlocks.java @@ -0,0 +1,130 @@ +/* + * 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.system.material; + +import static bartworks.system.material.BWMetaGeneratedItems.metaTab; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.material.Material; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import bartworks.client.renderer.BWBlockOreRenderer; +import bartworks.common.blocks.BWTileEntityContainer; +import bartworks.util.BWUtil; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GTLanguageManager; + +public abstract class BWMetaGeneratedBlocks extends BWTileEntityContainer { + + public static ThreadLocal<TileEntityMetaGeneratedBlock> mTemporaryTileEntity = new ThreadLocal<>(); + protected OrePrefixes _prefixes; + protected String blockTypeLocalizedName; + + public BWMetaGeneratedBlocks(Material p_i45386_1_, Class<? extends TileEntity> tileEntity, String blockName) { + this(p_i45386_1_, tileEntity, blockName, null); + } + + public BWMetaGeneratedBlocks(Material p_i45386_1_, Class<? extends TileEntity> tileEntity, String blockName, + OrePrefixes types) { + super(p_i45386_1_, tileEntity, blockName); + this.setHardness(5.0F); + this.setResistance(5.0F); + this.setBlockTextureName("stone"); + this.setCreativeTab(metaTab); + this._prefixes = types; + if (this._prefixes != null) { + this.blockTypeLocalizedName = GTLanguageManager.addStringLocalization( + "bw.blocktype." + this._prefixes, + this._prefixes.mLocalizedMaterialPre + "%material" + this._prefixes.mLocalizedMaterialPost); + } + Werkstoff.werkstoffHashSet.forEach(this::doRegistrationStuff); + } + + @Override + public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { + super.onBlockAdded(aWorld, aX, aY, aZ); + // Waste some time to allow the TE to be set, do not use thread sleep here, it doesnt allow for nanoseconds. + // This will just waste a few cpu cycles to allow the TE to be set + BWUtil.shortSleep(0); + } + + @SideOnly(Side.CLIENT) + public final TileEntityMetaGeneratedBlock getProperTileEntityForRendering() { + return (TileEntityMetaGeneratedBlock) this.createNewTileEntity(null, 0); + } + + protected abstract void doRegistrationStuff(Werkstoff w); + + @Override + public String getHarvestTool(int metadata) { + return "pickaxe"; + } + + @Override + protected boolean canSilkHarvest() { + return false; + } + + @Override + public int getRenderType() { + if (BWBlockOreRenderer.INSTANCE == null) return super.getRenderType(); + return BWBlockOreRenderer.INSTANCE.renderID; + } + + @Override + public int getDamageValue(World aWorld, int aX, int aY, int aZ) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof TileEntityMetaGeneratedBlock metaTE) { + return metaTE.mMetaData; + } + return 0; + } + + @Override + public TileEntity createTileEntity(World world, int metadata) { + return ((ITileEntityProvider) this).createNewTileEntity(world, metadata); + } + + @Override + public boolean hasTileEntity(int metadata) { + return true; + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + TileEntity tTileEntity = world.getTileEntity(x, y, z); + if (tTileEntity instanceof TileEntityMetaGeneratedBlock metaTE) { + mTemporaryTileEntity.set(metaTE); + } + super.breakBlock(world, x, y, z, block, meta); + } + + @Override + public ArrayList<ItemStack> getDrops(World aWorld, int aX, int aY, int aZ, int aMeta, int aFortune) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof TileEntityMetaGeneratedBlock metaTE) { + return metaTE.getDrops(aFortune); + } + return mTemporaryTileEntity.get() == null ? new ArrayList<>() + : mTemporaryTileEntity.get() + .getDrops(aFortune); + } +} diff --git a/src/main/java/bartworks/system/material/BWMetaGeneratedBlocksCasing.java b/src/main/java/bartworks/system/material/BWMetaGeneratedBlocksCasing.java new file mode 100644 index 0000000000..f8ed670092 --- /dev/null +++ b/src/main/java/bartworks/system/material/BWMetaGeneratedBlocksCasing.java @@ -0,0 +1,121 @@ +/* + * 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.system.material; + +import java.util.List; +import java.util.Optional; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.OrePrefixes; + +public class BWMetaGeneratedBlocksCasing extends BWMetaGeneratedBlocks + implements com.gtnewhorizon.structurelib.structure.ICustomBlockSetting { + + public BWMetaGeneratedBlocksCasing(Material p_i45386_1_, Class<? extends TileEntity> tileEntity, String blockName, + OrePrefixes prefixes) { + super(p_i45386_1_, tileEntity, blockName, prefixes); + } + + @Override + public String getHarvestTool(int aMeta) { + return "wrench"; + } + + @Override + public int getHarvestLevel(int aMeta) { + return 2; + } + + @Override + public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { + return Blocks.iron_block.getBlockHardness(aWorld, aX, aY, aZ); + } + + @Override + public float getExplosionResistance(Entity aTNT) { + return Blocks.iron_block.getExplosionResistance(aTNT); + } + + @Override + protected boolean canSilkHarvest() { + return false; + } + + @Override + public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetaData) { + GregTechAPI.causeMachineUpdate(aWorld, aX, aY, aZ); + super.breakBlock(aWorld, aX, aY, aZ, aBlock, aMetaData); + } + + @Override + public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { + super.onBlockAdded(aWorld, aX, aY, aZ); + GregTechAPI.causeMachineUpdate(aWorld, aX, aY, aZ); + } + + @Override + protected void doRegistrationStuff(Werkstoff tMaterial) { + GregTechAPI.registerMachineBlock(this, -1); + } + + @Override + public String getUnlocalizedName() { + if (this._prefixes == OrePrefixes.blockCasing) return "bw.werkstoffblockscasing.01"; + if (this._prefixes == OrePrefixes.blockCasingAdvanced) return "bw.werkstoffblockscasingadvanced.01"; + return ""; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item aItem, CreativeTabs aTab, List<ItemStack> aList) { + Werkstoff.werkstoffHashSet.stream() + .filter( + pMaterial -> Werkstoff.Types.BIOLOGICAL.equals(pMaterial.getType()) + && pMaterial.hasGenerationFeature(OrePrefixes.blockCasing) + || pMaterial.doesOreDictedItemExists(OrePrefixes.plate) + && pMaterial.doesOreDictedItemExists(OrePrefixes.screw) + && pMaterial.doesOreDictedItemExists(OrePrefixes.plateDouble) + && pMaterial.doesOreDictedItemExists(OrePrefixes.gearGt) + && pMaterial.doesOreDictedItemExists(OrePrefixes.gearGtSmall)) + .map(pMaterial -> new ItemStack(aItem, 1, pMaterial.getmID())) + .forEach(aList::add); + } + + /** + * ICustomBlockSetting setBlock override + */ + public void setBlock(World world, int x, int y, int z, int meta) { + world.setBlock(x, y, z, this, meta, 2); + try { + Thread.sleep(1); + // Fucking Minecraft TE settings. + } catch (InterruptedException ignored) {} + Optional.ofNullable(world.getTileEntity(x, y, z)) + .filter(te -> te instanceof TileEntityMetaGeneratedBlock) + .map(te -> (TileEntityMetaGeneratedBlock) te) + .ifPresent(te -> te.mMetaData = (short) meta); + } +} diff --git a/src/main/java/bartworks/system/material/BWMetaGeneratedFrames.java b/src/main/java/bartworks/system/material/BWMetaGeneratedFrames.java new file mode 100644 index 0000000000..092ccf038b --- /dev/null +++ b/src/main/java/bartworks/system/material/BWMetaGeneratedFrames.java @@ -0,0 +1,144 @@ +/* + * 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.system.material; + +import static gregtech.api.enums.GTValues.RA; +import static gregtech.api.recipe.RecipeMaps.assemblerRecipes; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; +import static gregtech.api.util.GTRecipeBuilder.TICKS; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.enums.Dyes; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaPipeEntity; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTModHandler.RecipeBits; +import gregtech.api.util.GTOreDictUnificator; + +public class BWMetaGeneratedFrames extends MetaPipeEntity { + + public final Werkstoff mMaterial; + + public BWMetaGeneratedFrames(int aID, String aName, String aNameRegional, Werkstoff aMaterial) { + super(aID, aName, aNameRegional, 0); + this.mMaterial = aMaterial; + + GTOreDictUnificator.registerOre(OrePrefixes.frameGt, aMaterial, this.getStackForm(1)); + GTModHandler.addCraftingRecipe( + this.getStackForm(2), + RecipeBits.NOT_REMOVABLE | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "SSS", "SwS", "SSS", 'S', this.mMaterial.get(OrePrefixes.stick) }); + + RA.stdBuilder() + .itemInputs( + GTOreDictUnificator.get(OrePrefixes.stick, aMaterial.getVarName(), 4), + ItemList.Circuit_Integrated.getWithDamage(0, 4)) + .itemOutputs(getStackForm(1)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(8) + .addTo(assemblerRecipes); + } + + private BWMetaGeneratedFrames(String aName, Werkstoff aMaterial) { + super(aName, 0); + this.mMaterial = aMaterial; + } + + @Override + public byte getTileEntityBaseType() { + return 4; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new BWMetaGeneratedFrames(this.mName, this.mMaterial); + } + + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, byte aConnections, + int aColorIndex, boolean aConnected, boolean aRedstone) { + return new ITexture[] { TextureFactory.of( + this.mMaterial.getTexSet().mTextures[OrePrefixes.frameGt.mTextureIndex], + Dyes.getModulation(aColorIndex, this.mMaterial.getRGBA())) }; + } + + @Override + public String[] getDescription() { + return new String[] { "Just something you can put a Cover or CFoam on." }; + } + + @Override + public final boolean isSimpleMachine() { + return true; + } + + @Override + public final boolean isFacingValid(ForgeDirection facing) { + return false; + } + + @Override + public final boolean isValidSlot(int aIndex) { + return false; + } + + @Override + public final boolean renderInside(ForgeDirection side) { + return true; + } + + @Override + public final float getThickNess() { + return 1.0F; + } + + @Override + public final void saveNBTData(NBTTagCompound aNBT) { + /* Do nothing */ + } + + @Override + public final void loadNBTData(NBTTagCompound aNBT) { + /* Do nothing */ + } + + @Override + public final boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public final boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public int connect(ForgeDirection side) { + return 0; + } + + @Override + public void disconnect(ForgeDirection side) { + /* Do nothing */ + } +} diff --git a/src/main/java/bartworks/system/material/BWMetaGeneratedItems.java b/src/main/java/bartworks/system/material/BWMetaGeneratedItems.java new file mode 100644 index 0000000000..bdeab62cfd --- /dev/null +++ b/src/main/java/bartworks/system/material/BWMetaGeneratedItems.java @@ -0,0 +1,258 @@ +/* + * 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.system.material; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +import bartworks.API.IRadMaterial; +import bartworks.API.SideReference; +import bartworks.client.textures.PrefixTextureLinker; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.items.MetaGeneratedItem; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.GTUtility; +import ic2.core.IC2Potion; + +public class BWMetaGeneratedItems extends MetaGeneratedItem implements IRadMaterial { + + public static final CreativeTabs metaTab = new CreativeTabs("bartworksMetaMaterials") { + + @Override + public Item getTabIconItem() { + return new ItemStack(Blocks.iron_ore).getItem(); + } + }; + + protected final OrePrefixes orePrefixes; + protected final String itemTypeLocalizedName; + + public BWMetaGeneratedItems(OrePrefixes orePrefixes, Object unused) { + super("bwMetaGeneratedGTEnhancement" + orePrefixes.name(), (short) 32766, (short) 0); + this.orePrefixes = orePrefixes; + this.itemTypeLocalizedName = GTLanguageManager.addStringLocalization( + "bw.itemtype." + orePrefixes, + orePrefixes.mLocalizedMaterialPre + "%material" + orePrefixes.mLocalizedMaterialPost); + } + + public BWMetaGeneratedItems(OrePrefixes orePrefixes) { + super("bwMetaGenerated" + orePrefixes.name(), (short) 32766, (short) 0); + this.orePrefixes = orePrefixes; + this.itemTypeLocalizedName = GTLanguageManager.addStringLocalization( + "bw.itemtype." + orePrefixes, + orePrefixes.mLocalizedMaterialPre + "%material" + orePrefixes.mLocalizedMaterialPost); + this.setCreativeTab(BWMetaGeneratedItems.metaTab); + for (Werkstoff w : Werkstoff.werkstoffHashSet) { + ItemStack tStack = new ItemStack(this, 1, w.getmID()); + if (!w.hasItemType(this.orePrefixes)) continue; + GTOreDictUnificator.registerOre(this.orePrefixes.name() + w.getVarName(), tStack); + } + } + + @Override + public boolean onEntityItemUpdate(EntityItem aItemEntity) { + if (this.orePrefixes == OrePrefixes.dustImpure || this.orePrefixes == OrePrefixes.dustPure + || this.orePrefixes == OrePrefixes.crushed) { + int aDamage = aItemEntity.getEntityItem() + .getItemDamage(); + if (aDamage >= 0 && !aItemEntity.worldObj.isRemote) { + Werkstoff aMaterial = Werkstoff.werkstoffHashMap.get((short) aDamage); + if (aMaterial != null && aMaterial != Werkstoff.default_null_Werkstoff) { + int tX = MathHelper.floor_double(aItemEntity.posX); + int tY = MathHelper.floor_double(aItemEntity.posY); + int tZ = MathHelper.floor_double(aItemEntity.posZ); + Block tBlock = aItemEntity.worldObj.getBlock(tX, tY, tZ); + byte tMetaData = (byte) aItemEntity.worldObj.getBlockMetadata(tX, tY, tZ); + if (tBlock == Blocks.cauldron && tMetaData > 0) { + if (this.orePrefixes == OrePrefixes.dustImpure || this.orePrefixes == OrePrefixes.dustPure) { + aItemEntity.setEntityItemStack( + WerkstoffLoader.getCorrespondingItemStack( + OrePrefixes.dust, + aMaterial, + aItemEntity.getEntityItem().stackSize)); + aItemEntity.worldObj.setBlockMetadataWithNotify(tX, tY, tZ, tMetaData - 1, 3); + return true; + } else { + aItemEntity.setEntityItemStack( + WerkstoffLoader.getCorrespondingItemStack( + OrePrefixes.crushedPurified, + aMaterial, + aItemEntity.getEntityItem().stackSize)); + aItemEntity.worldObj.setBlockMetadataWithNotify(tX, tY, tZ, tMetaData - 1, 3); + return true; + } + } + } + } + } + return false; + } + + @Override + protected void addAdditionalToolTips(List<String> aList, ItemStack aStack, EntityPlayer aPlayer) { + if (this.orePrefixes == OrePrefixes.dustImpure || this.orePrefixes == OrePrefixes.dustPure) { + aList.add(GTLanguageManager.getTranslation("metaitem.01.tooltip.purify")); + } + if (this.orePrefixes == OrePrefixes.crushed) + aList.add(GTLanguageManager.getTranslation("metaitem.01.tooltip.purify.2")); + + if (aStack != null && aStack.getItem() instanceof BWMetaGeneratedItems + && aStack.getItemDamage() == WerkstoffLoader.Tiberium.getmID()) + aList.add(GTLanguageManager.getTranslation("metaitem.01.tooltip.nqgen")); + + Werkstoff werkstoff = Werkstoff.werkstoffHashMap.get((short) this.getDamage(aStack)); + if (werkstoff != null) { + String tooltip = werkstoff.getLocalizedToolTip(); + if (!tooltip.isEmpty()) { + aList.add(tooltip); + } + } + } + + @Override + public String getItemStackDisplayName(ItemStack aStack) { + int aMetaData = aStack.getItemDamage(); + Werkstoff werkstoff = Werkstoff.werkstoffHashMap.get((short) aMetaData); + if (werkstoff == null) werkstoff = Werkstoff.default_null_Werkstoff; + return this.itemTypeLocalizedName.replace("%material", werkstoff.getLocalizedName()); + } + + @Override + public IIconContainer getIconContainer(int aMetaData) { + if (Werkstoff.werkstoffHashMap.get((short) aMetaData) == null) return null; + if (this.orePrefixes.mTextureIndex == -1) return this.getIconContainerBartWorks(aMetaData); + return Werkstoff.werkstoffHashMap.get((short) aMetaData) + .getTexSet().mTextures[this.orePrefixes.mTextureIndex]; + } + + protected IIconContainer getIconContainerBartWorks(int aMetaData) { + if (SideReference.Side.Client) return PrefixTextureLinker.texMap.get(this.orePrefixes) + .get( + Werkstoff.werkstoffHashMap.get((short) aMetaData) + .getTexSet()); + return null; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item var1, CreativeTabs aCreativeTab, List<ItemStack> aList) { + for (Werkstoff werkstoff : Werkstoff.werkstoffHashSet) { + if (werkstoff != null && werkstoff.hasItemType(this.orePrefixes)) { + ItemStack tStack = new ItemStack(this, 1, werkstoff.getmID()); + aList.add(tStack); + } + } + // super.getSubItems(var1, aCreativeTab, aList); + } + + @Override + public short[] getRGBa(ItemStack aStack) { + Werkstoff werkstoff = Werkstoff.werkstoffHashMap.get((short) this.getDamage(aStack)); + return werkstoff == null ? Materials._NULL.mRGBa : werkstoff.getRGBA(); + } + + @Override + public void onUpdate(ItemStack aStack, World aWorld, Entity aPlayer, int aTimer, boolean aIsInHand) { + super.onUpdate(aStack, aWorld, aPlayer, aTimer, aIsInHand); + if (aStack == null || aStack.getItem() == null || !(aPlayer instanceof EntityLivingBase)) return; + + EntityLivingBase bPlayer = (EntityPlayer) aPlayer; + Werkstoff w = Werkstoff.werkstoffHashMap.get((short) aStack.getItemDamage()); + if (w == null || w.getStats() == null) return; + + if (w.getStats() + .isToxic() && !GTUtility.isWearingFullBioHazmat(bPlayer)) { + bPlayer.addPotionEffect(new PotionEffect(Potion.poison.getId(), 80, 4)); + } + + if (w.getStats() + .isRadioactive() && !GTUtility.isWearingFullRadioHazmat(bPlayer)) { + bPlayer.addPotionEffect(new PotionEffect(IC2Potion.radiation.id, 80, 4)); + } + } + + @Override + public IIcon getIconFromDamage(int aMetaData) { + if (aMetaData < 0) return null; + Werkstoff tMaterial = Werkstoff.werkstoffHashMap.get((short) aMetaData); + if (tMaterial == null) return null; + IIconContainer tIcon = this.getIconContainer(aMetaData); + if (tIcon != null) return tIcon.getIcon(); + return null; + } + + @Override + public int getItemStackLimit(ItemStack aStack) { + return this.orePrefixes.mDefaultStackSize; + } + + @Override + public int getRadiationLevel(ItemStack aStack) { + Werkstoff w = Werkstoff.werkstoffHashMap.get((short) aStack.getItemDamage()); + return w.getStats() + .isRadioactive() + ? (int) w.getStats() + .getProtons() + : 0; + } + + @Override + public byte getAmountOfMaterial(ItemStack aStack) { + return (byte) (this.orePrefixes == OrePrefixes.stick ? 1 : this.orePrefixes == OrePrefixes.stickLong ? 2 : 0); + } + + @Override + public short[] getColorForGUI(ItemStack aStack) { + Werkstoff w = Werkstoff.werkstoffHashMap.get((short) aStack.getItemDamage()); + return w.getRGBA(); + } + + @Override + public String getNameForGUI(ItemStack aStack) { + Werkstoff w = Werkstoff.werkstoffHashMap.get((short) aStack.getItemDamage()); + return w.getDefaultName(); + } + + @Override + public int getCapacity(ItemStack aStack) { + return this.orePrefixes == OrePrefixes.capsule || this.orePrefixes == OrePrefixes.cell + || this.orePrefixes == OrePrefixes.cellPlasma ? 1000 + : this.orePrefixes == OrePrefixes.cellMolten || this.orePrefixes == OrePrefixes.capsuleMolten ? 144 : 0; + } + + @Override + public ItemStack getContainerItem(ItemStack aStack) { + return this.orePrefixes == OrePrefixes.cell || this.orePrefixes == OrePrefixes.cellPlasma + || this.orePrefixes == OrePrefixes.cellMolten ? Materials.Empty.getCells(1) : null; + } +} diff --git a/src/main/java/bartworks/system/material/BWMetaGeneratedOres.java b/src/main/java/bartworks/system/material/BWMetaGeneratedOres.java new file mode 100644 index 0000000000..c74c3f01cb --- /dev/null +++ b/src/main/java/bartworks/system/material/BWMetaGeneratedOres.java @@ -0,0 +1,133 @@ +/* + * 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.system.material; + +import java.util.Arrays; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.FakePlayer; + +import bartworks.util.MathUtils; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTModHandler; + +public class BWMetaGeneratedOres extends BWMetaGeneratedBlocks { + + public BWMetaGeneratedOres(Material p_i45386_1_, Class<? extends TileEntity> tileEntity, String blockName) { + super(p_i45386_1_, tileEntity, blockName); + this.blockTypeLocalizedName = GTLanguageManager.addStringLocalization( + "bw.blocktype." + OrePrefixes.ore, + OrePrefixes.ore.mLocalizedMaterialPre + "%material" + OrePrefixes.ore.mLocalizedMaterialPost); + } + + @Override + protected void doRegistrationStuff(Werkstoff w) { + if (w != null) { + if (!w.hasItemType(OrePrefixes.ore) || (w.getGenerationFeatures().blacklist & 0b1000) != 0) return; + GTModHandler.addValuableOre(this, w.getmID(), 1); + } + } + + public static boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData, boolean air, Block block, + int[] aBlockMeta) { + if (!air) { + aY = MathUtils.clamp(aY, 1, aWorld.getActualHeight()); + } + + Block tBlock = aWorld.getBlock(aX, aY, aZ); + Block tOreBlock = WerkstoffLoader.BWOres; + if (aMetaData < 0 || tBlock == Blocks.air && !air + || Block.getIdFromBlock(tBlock) != Block.getIdFromBlock(block)) { + return false; + } + final int aaY = aY; + if (Arrays.stream(aBlockMeta) + .noneMatch(e -> e == aWorld.getBlockMetadata(aX, aaY, aZ))) { + return false; + } + + aWorld.setBlock(aX, aY, aZ, tOreBlock, aMetaData, 0); + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof BWTileEntityMetaGeneratedOre metaTE) { + metaTE.mMetaData = (short) aMetaData; + metaTE.mNatural = true; + } + + return true; + } + + @Override + public IIcon getIcon(int side, int meta) { + return Blocks.stone.getIcon(0, 0); + } + + @Override + public IIcon getIcon(IBlockAccess worldIn, int x, int y, int z, int side) { + return Blocks.stone.getIcon(0, 0); + } + + @Override + public int getHarvestLevel(int metadata) { + return 3; + } + + @Override + public String getUnlocalizedName() { + return "bw.blockores.01"; + } + + @Override + public void getSubBlocks(Item aItem, CreativeTabs aTab, List<ItemStack> aList) { + for (Werkstoff tMaterial : Werkstoff.werkstoffHashSet) { + if (tMaterial != null && tMaterial.hasItemType(OrePrefixes.ore) + && (tMaterial.getGenerationFeatures().blacklist & 0x8) == 0) { + aList.add(new ItemStack(aItem, 1, tMaterial.getmID())); + } + } + } + + @Override + public void harvestBlock(World worldIn, EntityPlayer player, int x, int y, int z, int meta) { + if (EnchantmentHelper.getSilkTouchModifier(player)) { + BWTileEntityMetaGeneratedOre.shouldSilkTouch = true; + super.harvestBlock(worldIn, player, x, y, z, meta); + + if (BWTileEntityMetaGeneratedOre.shouldSilkTouch) { + BWTileEntityMetaGeneratedOre.shouldSilkTouch = false; + } + return; + } + + if (!(player instanceof FakePlayer)) { + BWTileEntityMetaGeneratedOre.shouldFortune = true; + } + super.harvestBlock(worldIn, player, x, y, z, meta); + if (BWTileEntityMetaGeneratedOre.shouldFortune) { + BWTileEntityMetaGeneratedOre.shouldFortune = false; + } + } +} diff --git a/src/main/java/bartworks/system/material/BWMetaGeneratedSmallOres.java b/src/main/java/bartworks/system/material/BWMetaGeneratedSmallOres.java new file mode 100644 index 0000000000..5025f4ac77 --- /dev/null +++ b/src/main/java/bartworks/system/material/BWMetaGeneratedSmallOres.java @@ -0,0 +1,76 @@ +/* + * 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.system.material; + +import java.util.Arrays; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTModHandler; + +public class BWMetaGeneratedSmallOres extends BWMetaGeneratedOres { + + public BWMetaGeneratedSmallOres(Material p_i45386_1_, Class<? extends TileEntity> tileEntity, String blockName) { + super(p_i45386_1_, tileEntity, blockName); + this.blockTypeLocalizedName = GTLanguageManager.addStringLocalization( + "bw.blocktype." + OrePrefixes.oreSmall, + OrePrefixes.oreSmall.mLocalizedMaterialPre + "%material" + OrePrefixes.oreSmall.mLocalizedMaterialPost); + } + + @Override + protected void doRegistrationStuff(Werkstoff w) { + if (w != null) { + if (!w.hasItemType(OrePrefixes.ore) || (w.getGenerationFeatures().blacklist & 0b1000) != 0) return; + GTModHandler.addValuableOre(this, w.getmID(), 1); + } + } + + @Override + public String getUnlocalizedName() { + return "bw.blockores.02"; + } + + public static boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData, boolean air, Block block, + int[] aBlockMeta) { + if (!air) { + aY = Math.min(aWorld.getActualHeight(), Math.max(aY, 1)); + } + + Block tBlock = aWorld.getBlock(aX, aY, aZ); + Block tOreBlock = WerkstoffLoader.BWSmallOres; + if (aMetaData < 0 || tBlock == Blocks.air && !air + || Block.getIdFromBlock(tBlock) != Block.getIdFromBlock(block)) { + return false; + } + final int aaY = aY; + if (Arrays.stream(aBlockMeta) + .noneMatch(e -> e == aWorld.getBlockMetadata(aX, aaY, aZ))) { + return false; + } + + aWorld.setBlock(aX, aY, aZ, tOreBlock, aMetaData, 0); + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof BWTileEntityMetaGeneratedOre metaTE) { + metaTE.mMetaData = (short) aMetaData; + } + + return true; + } +} diff --git a/src/main/java/bartworks/system/material/BWMetaGeneratedWerkstoffBlocks.java b/src/main/java/bartworks/system/material/BWMetaGeneratedWerkstoffBlocks.java new file mode 100644 index 0000000000..b7c1e73927 --- /dev/null +++ b/src/main/java/bartworks/system/material/BWMetaGeneratedWerkstoffBlocks.java @@ -0,0 +1,65 @@ +/* + * 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.system.material; + +import java.util.List; + +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GTLanguageManager; + +public class BWMetaGeneratedWerkstoffBlocks extends BWMetaGeneratedBlocks { + + public BWMetaGeneratedWerkstoffBlocks(Material p_i45386_1_, Class<? extends TileEntity> tileEntity, + String blockName) { + super(p_i45386_1_, tileEntity, blockName); + this.blockTypeLocalizedName = GTLanguageManager.addStringLocalization( + "bw.blocktype." + OrePrefixes.block, + OrePrefixes.block.mLocalizedMaterialPre + "%material" + OrePrefixes.block.mLocalizedMaterialPost); + } + + @Override + protected void doRegistrationStuff(Werkstoff tMaterial) {} + + @Override + public String getUnlocalizedName() { + return "bw.werkstoffblocks.01"; + } + + @Override + public IIcon getIcon(int side, int meta) { + return Blocks.iron_block.getIcon(0, 0); + } + + @Override + public IIcon getIcon(IBlockAccess worldIn, int x, int y, int z, int side) { + return Blocks.iron_block.getIcon(0, 0); + } + + @Override + public void getSubBlocks(Item aItem, CreativeTabs tab, List<ItemStack> aList) { + Werkstoff.werkstoffHashSet.stream() + .filter(tMaterial -> tMaterial.hasItemType(OrePrefixes.gem) || tMaterial.hasItemType(OrePrefixes.ingot)) + .map(tMaterial -> new ItemStack(aItem, 1, tMaterial.getmID())) + .forEach(aList::add); + } +} diff --git a/src/main/java/bartworks/system/material/BWNonMetaMaterialItems.java b/src/main/java/bartworks/system/material/BWNonMetaMaterialItems.java new file mode 100644 index 0000000000..a8ddb5a3bf --- /dev/null +++ b/src/main/java/bartworks/system/material/BWNonMetaMaterialItems.java @@ -0,0 +1,167 @@ +/* + * 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.system.material; + +import static gregtech.api.enums.GTValues.W; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import gregtech.api.interfaces.IItemContainer; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.GTUtility; + +public enum BWNonMetaMaterialItems implements IItemContainer { + + Depleted_Tiberium_1, + Depleted_Tiberium_2, + Depleted_Tiberium_4, + TiberiumCell_1, + TiberiumCell_2, + TiberiumCell_4, + TheCoreCell, + Depleted_TheCoreCell; + + private ItemStack mStack; + private boolean mHasNotBeenSet = true; + + @Override + public IItemContainer set(Item aItem) { + this.mHasNotBeenSet = false; + if (aItem == null) return this; + ItemStack aStack = new ItemStack(aItem, 1, 0); + this.mStack = GTUtility.copyAmount(1, aStack); + return this; + } + + @Override + public IItemContainer set(ItemStack aStack) { + this.mHasNotBeenSet = false; + this.mStack = GTUtility.copyAmount(1, aStack); + return this; + } + + @Override + public IItemContainer hidden() { + codechicken.nei.api.API.hideItem(get(1L)); + return this; + } + + @Override + public Item getItem() { + if (this.mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + if (GTUtility.isStackInvalid(this.mStack)) return null; + return this.mStack.getItem(); + } + + @Override + public Block getBlock() { + if (this.mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + return GTUtility.getBlockFromItem(this.getItem()); + } + + @Override + public final boolean hasBeenSet() { + return !this.mHasNotBeenSet; + } + + @Override + public boolean isStackEqual(Object aStack) { + return this.isStackEqual(aStack, false, false); + } + + @Override + public boolean isStackEqual(Object aStack, boolean aWildcard, boolean aIgnoreNBT) { + if (GTUtility.isStackInvalid(aStack)) return false; + return GTUtility + .areUnificationsEqual((ItemStack) aStack, aWildcard ? this.getWildcard(1) : this.get(1), aIgnoreNBT); + } + + @Override + public ItemStack get(long aAmount, Object... aReplacements) { + if (this.mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + if (GTUtility.isStackInvalid(this.mStack)) return GTUtility.copyAmount(aAmount, aReplacements); + return GTUtility.copyAmount(aAmount, GTOreDictUnificator.get(this.mStack)); + } + + @Override + public ItemStack getWildcard(long aAmount, Object... aReplacements) { + if (this.mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + if (GTUtility.isStackInvalid(this.mStack)) return GTUtility.copyAmount(aAmount, aReplacements); + return GTUtility.copyAmountAndMetaData(aAmount, W, GTOreDictUnificator.get(this.mStack)); + } + + @Override + public ItemStack getUndamaged(long aAmount, Object... aReplacements) { + if (this.mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + if (GTUtility.isStackInvalid(this.mStack)) return GTUtility.copyAmount(aAmount, aReplacements); + return GTUtility.copyAmountAndMetaData(aAmount, 0, GTOreDictUnificator.get(this.mStack)); + } + + @Override + public ItemStack getAlmostBroken(long aAmount, Object... aReplacements) { + if (this.mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + if (GTUtility.isStackInvalid(this.mStack)) return GTUtility.copyAmount(aAmount, aReplacements); + return GTUtility + .copyAmountAndMetaData(aAmount, this.mStack.getMaxDamage() - 1, GTOreDictUnificator.get(this.mStack)); + } + + @Override + public ItemStack getWithName(long aAmount, String aDisplayName, Object... aReplacements) { + ItemStack rStack = this.get(1, aReplacements); + if (GTUtility.isStackInvalid(rStack)) return null; + rStack.setStackDisplayName(aDisplayName); + return GTUtility.copyAmount(aAmount, rStack); + } + + @Override + public ItemStack getWithCharge(long aAmount, int aEnergy, Object... aReplacements) { + ItemStack rStack = this.get(1, aReplacements); + if (GTUtility.isStackInvalid(rStack)) return null; + GTModHandler.chargeElectricItem(rStack, aEnergy, Integer.MAX_VALUE, true, false); + return GTUtility.copyAmount(aAmount, rStack); + } + + @Override + public ItemStack getWithDamage(long aAmount, long aMetaValue, Object... aReplacements) { + if (this.mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + if (GTUtility.isStackInvalid(this.mStack)) return GTUtility.copyAmount(aAmount, aReplacements); + return GTUtility.copyAmountAndMetaData(aAmount, aMetaValue, GTOreDictUnificator.get(this.mStack)); + } + + @Override + public IItemContainer registerOre(Object... aOreNames) { + if (this.mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + for (Object tOreName : aOreNames) GTOreDictUnificator.registerOre(tOreName, this.get(1)); + return this; + } + + @Override + public IItemContainer registerWildcardAsOre(Object... aOreNames) { + if (this.mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + this.name() + "' has not been set to an Item at this time!"); + for (Object tOreName : aOreNames) GTOreDictUnificator.registerOre(tOreName, this.getWildcard(1)); + return this; + } +} diff --git a/src/main/java/bartworks/system/material/BWTileEntityMetaGeneratedBlocksCasing.java b/src/main/java/bartworks/system/material/BWTileEntityMetaGeneratedBlocksCasing.java new file mode 100644 index 0000000000..536bdccf60 --- /dev/null +++ b/src/main/java/bartworks/system/material/BWTileEntityMetaGeneratedBlocksCasing.java @@ -0,0 +1,50 @@ +/* + * 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.system.material; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraftforge.common.util.ForgeDirection; + +import bartworks.API.SideReference; +import bartworks.client.textures.PrefixTextureLinker; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TextureSet; +import gregtech.api.interfaces.ITexture; +import gregtech.api.render.TextureFactory; + +public class BWTileEntityMetaGeneratedBlocksCasing extends TileEntityMetaGeneratedBlock { + + @Override + protected Block GetProperBlock() { + return WerkstoffLoader.BWBlockCasings; + } + + @Override + public ITexture[] getTexture(Block aBlock, ForgeDirection side) { + if (SideReference.Side.Client) { + Werkstoff aMaterial = Werkstoff.werkstoffHashMap.get(this.mMetaData); + if (aMaterial != null) { + TextureSet set = aMaterial.getTexSet(); + ITexture aIconSet = TextureFactory.of( + PrefixTextureLinker.texMapBlocks.get(OrePrefixes.blockCasing) + .getOrDefault(set, TextureSet.SET_NONE.mTextures[OrePrefixes.block.mTextureIndex]), + aMaterial.getRGBA()); + return new ITexture[] { TextureFactory.of(Blocks.iron_block), aIconSet }; + } + } + return new ITexture[] { TextureFactory.of(Blocks.iron_block), + TextureFactory.of(gregtech.api.enums.TextureSet.SET_NONE.mTextures[OrePrefixes.block.mTextureIndex]) }; + } +} diff --git a/src/main/java/bartworks/system/material/BWTileEntityMetaGeneratedBlocksCasingAdvanced.java b/src/main/java/bartworks/system/material/BWTileEntityMetaGeneratedBlocksCasingAdvanced.java new file mode 100644 index 0000000000..57399a8f87 --- /dev/null +++ b/src/main/java/bartworks/system/material/BWTileEntityMetaGeneratedBlocksCasingAdvanced.java @@ -0,0 +1,50 @@ +/* + * 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.system.material; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraftforge.common.util.ForgeDirection; + +import bartworks.API.SideReference; +import bartworks.client.textures.PrefixTextureLinker; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TextureSet; +import gregtech.api.interfaces.ITexture; +import gregtech.api.render.TextureFactory; + +public class BWTileEntityMetaGeneratedBlocksCasingAdvanced extends TileEntityMetaGeneratedBlock { + + @Override + protected Block GetProperBlock() { + return WerkstoffLoader.BWBlockCasingsAdvanced; + } + + @Override + public ITexture[] getTexture(Block aBlock, ForgeDirection side) { + if (SideReference.Side.Client) { + Werkstoff aMaterial = Werkstoff.werkstoffHashMap.get(this.mMetaData); + if (aMaterial != null) { + TextureSet set = aMaterial.getTexSet(); + ITexture aIconSet = TextureFactory.of( + PrefixTextureLinker.texMapBlocks.get(OrePrefixes.blockCasingAdvanced) + .getOrDefault(set, TextureSet.SET_NONE.mTextures[OrePrefixes.block.mTextureIndex]), + aMaterial.getRGBA()); + return new ITexture[] { TextureFactory.of(Blocks.iron_block), aIconSet }; + } + } + return new ITexture[] { TextureFactory.of(Blocks.iron_block), + TextureFactory.of(gregtech.api.enums.TextureSet.SET_NONE.mTextures[OrePrefixes.block.mTextureIndex]) }; + } +} diff --git a/src/main/java/bartworks/system/material/BWTileEntityMetaGeneratedOre.java b/src/main/java/bartworks/system/material/BWTileEntityMetaGeneratedOre.java new file mode 100644 index 0000000000..7f7d0716f5 --- /dev/null +++ b/src/main/java/bartworks/system/material/BWTileEntityMetaGeneratedOre.java @@ -0,0 +1,116 @@ +/* + * 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.system.material; + +import java.util.ArrayList; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.GTMod; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.ITexture; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTOreDictUnificator; + +public class BWTileEntityMetaGeneratedOre extends TileEntityMetaGeneratedBlock { + + protected static boolean shouldFortune = false; + protected static boolean shouldSilkTouch = false; + public boolean mNatural = false; + + @Override + public void readFromNBT(NBTTagCompound aNBT) { + super.readFromNBT(aNBT); + this.mNatural = aNBT.getBoolean("n"); + } + + @Override + public void writeToNBT(NBTTagCompound aNBT) { + super.writeToNBT(aNBT); + aNBT.setBoolean("n", this.mNatural); + } + + @Override + public ITexture[] getTexture(Block aBlock, ForgeDirection side) { + Werkstoff aMaterial = Werkstoff.werkstoffHashMap.get(this.mMetaData); + if (aMaterial != null) { + ITexture aIconSet = TextureFactory + .of(aMaterial.getTexSet().mTextures[OrePrefixes.ore.mTextureIndex], aMaterial.getRGBA()); + return new ITexture[] { TextureFactory.of(Blocks.stone), aIconSet }; + } + return new ITexture[] { TextureFactory.of(Blocks.stone), + TextureFactory.of(gregtech.api.enums.TextureSet.SET_NONE.mTextures[OrePrefixes.ore.mTextureIndex]) }; + } + + @Override + protected Block GetProperBlock() { + return WerkstoffLoader.BWOres; + } + + @Override + public ArrayList<ItemStack> getDrops(int aFortune) { + ArrayList<ItemStack> rList = new ArrayList<>(); + if (this.mMetaData <= 0) { + rList.add(new ItemStack(Blocks.cobblestone, 1, 0)); + return rList; + } + Materials aOreMaterial = Werkstoff.werkstoffHashMap.get(this.mMetaData) + .getBridgeMaterial(); + if (shouldSilkTouch) { + rList.add(new ItemStack(this.GetProperBlock(), 1, this.mMetaData)); + } else { + switch (GTMod.gregtechproxy.oreDropSystem) { + case Item -> { + rList.add(GTOreDictUnificator.get(OrePrefixes.rawOre, aOreMaterial, 1)); + } + case FortuneItem -> { + // if shouldFortune and isNatural then get fortune drops + // if not shouldFortune or not isNatural then get normal drops + // if not shouldFortune and isNatural then get normal drops + // if shouldFortune and not isNatural then get normal drops + if (shouldFortune && this.mNatural && aFortune > 0) { + int aMinAmount = 1; + // Max applicable fortune + if (aFortune > 3) aFortune = 3; + long amount = (long) new Random().nextInt(aFortune) + aMinAmount; + for (int i = 0; i < amount; i++) { + rList.add(GTOreDictUnificator.get(OrePrefixes.rawOre, aOreMaterial, 1)); + } + } else { + rList.add(GTOreDictUnificator.get(OrePrefixes.rawOre, aOreMaterial, 1)); + } + } + case UnifiedBlock -> { + // Unified ore + rList.add(new ItemStack(this.GetProperBlock(), 1, this.mMetaData)); + } + case PerDimBlock -> { + // Per Dimension ore + rList.add(new ItemStack(this.GetProperBlock(), 1, this.mMetaData)); + } + case Block -> { + // Regular ore + rList.add(new ItemStack(this.GetProperBlock(), 1, this.mMetaData)); + } + } + } + return rList; + } +} diff --git a/src/main/java/bartworks/system/material/BWTileEntityMetaGeneratedSmallOre.java b/src/main/java/bartworks/system/material/BWTileEntityMetaGeneratedSmallOre.java new file mode 100644 index 0000000000..8764c7891e --- /dev/null +++ b/src/main/java/bartworks/system/material/BWTileEntityMetaGeneratedSmallOre.java @@ -0,0 +1,125 @@ +/* + * 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.system.material; + +import java.util.ArrayList; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.ITexture; +import gregtech.api.objects.XSTR; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.GTUtility; + +public class BWTileEntityMetaGeneratedSmallOre extends BWTileEntityMetaGeneratedOre { + + @Override + public ArrayList<ItemStack> getDrops(int aFortune) { + ArrayList<ItemStack> rList = new ArrayList<>(); + Materials aMaterial = Werkstoff.werkstoffHashMap.get(this.mMetaData) + .getBridgeMaterial(); + + if (aMaterial != null) { + Random tRandom = new XSTR(this.xCoord ^ this.yCoord ^ this.zCoord); + ArrayList<ItemStack> tSelector = new ArrayList<>(); + + ItemStack tStack = GTOreDictUnificator + .get(OrePrefixes.gemExquisite, aMaterial, GTOreDictUnificator.get(OrePrefixes.gem, aMaterial, 1L), 1L); + if (tStack != null) { + for (int i = 0; i < 1; i++) { + tSelector.add(tStack); + } + } + tStack = GTOreDictUnificator + .get(OrePrefixes.gemFlawless, aMaterial, GTOreDictUnificator.get(OrePrefixes.gem, aMaterial, 1L), 1L); + if (tStack != null) { + for (int i = 0; i < 2; i++) { + tSelector.add(tStack); + } + } + tStack = GTOreDictUnificator.get(OrePrefixes.gem, aMaterial, 1L); + if (tStack != null) { + for (int i = 0; i < 12; i++) { + tSelector.add(tStack); + } + } + tStack = GTOreDictUnificator + .get(OrePrefixes.gemFlawed, aMaterial, GTOreDictUnificator.get(OrePrefixes.crushed, aMaterial, 1L), 1L); + if (tStack != null) { + for (int i = 0; i < 5; i++) { + tSelector.add(tStack); + } + } + tStack = GTOreDictUnificator.get(OrePrefixes.crushed, aMaterial, 1L); + if (tStack != null) { + for (int i = 0; i < 10; i++) { + tSelector.add(tStack); + } + } + tStack = GTOreDictUnificator.get( + OrePrefixes.gemChipped, + aMaterial, + GTOreDictUnificator.get(OrePrefixes.dustImpure, aMaterial, 1L), + 1L); + if (tStack != null) { + for (int i = 0; i < 5; i++) { + tSelector.add(tStack); + } + } + tStack = GTOreDictUnificator.get(OrePrefixes.dustImpure, aMaterial, 1L); + if (tStack != null) { + for (int i = 0; i < 10; i++) { + tSelector.add(tStack); + } + } + if (tSelector.size() > 0) { + int i = 0; + + for (int j = Math.max(1, aFortune > 0 ? tRandom.nextInt(1 + aFortune) : 0); i < j; ++i) { + rList.add(GTUtility.copyAmount(1L, tSelector.get(tRandom.nextInt(tSelector.size())))); + } + } + if (tRandom.nextInt(3 + aFortune) > 1) { + rList.add( + GTOreDictUnificator + .get(tRandom.nextInt(3) > 0 ? OrePrefixes.dustImpure : OrePrefixes.dust, Materials.Stone, 1L)); + } + } + return rList; + } + + @Override + public ITexture[] getTexture(Block aBlock, ForgeDirection side) { + Werkstoff aMaterial = Werkstoff.werkstoffHashMap.get(this.mMetaData); + if (aMaterial != null) { + ITexture aIconSet = TextureFactory + .of(aMaterial.getTexSet().mTextures[OrePrefixes.oreSmall.mTextureIndex], aMaterial.getRGBA()); + return new ITexture[] { TextureFactory.of(Blocks.stone), aIconSet }; + } + return new ITexture[] { TextureFactory.of(Blocks.stone), + TextureFactory.of(gregtech.api.enums.TextureSet.SET_NONE.mTextures[OrePrefixes.oreSmall.mTextureIndex]) }; + } + + @Override + protected Block GetProperBlock() { + return WerkstoffLoader.BWSmallOres; + } +} diff --git a/src/main/java/bartworks/system/material/BWTileEntityMetaGeneratedWerkstoffBlock.java b/src/main/java/bartworks/system/material/BWTileEntityMetaGeneratedWerkstoffBlock.java new file mode 100644 index 0000000000..f1fd978909 --- /dev/null +++ b/src/main/java/bartworks/system/material/BWTileEntityMetaGeneratedWerkstoffBlock.java @@ -0,0 +1,49 @@ +/* + * 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.system.material; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraftforge.common.util.ForgeDirection; + +import bartworks.API.SideReference; +import bartworks.client.textures.PrefixTextureLinker; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TextureSet; +import gregtech.api.interfaces.ITexture; +import gregtech.api.render.TextureFactory; + +public class BWTileEntityMetaGeneratedWerkstoffBlock extends TileEntityMetaGeneratedBlock { + + @Override + public ITexture[] getTexture(Block aBlock, ForgeDirection side) { + if (SideReference.Side.Client) { + Werkstoff aMaterial = Werkstoff.werkstoffHashMap.get(this.mMetaData); + if (aMaterial != null) { + TextureSet set = aMaterial.getTexSet(); + ITexture aIconSet = TextureFactory.of( + set.mTextures[PrefixTextureLinker.blockTexMap.getOrDefault(set, OrePrefixes.block.mTextureIndex)], + aMaterial.getRGBA()); + return new ITexture[] { TextureFactory.of(Blocks.iron_block), aIconSet }; + } + } + return new ITexture[] { TextureFactory.of(Blocks.iron_block), + TextureFactory.of(gregtech.api.enums.TextureSet.SET_NONE.mTextures[OrePrefixes.block.mTextureIndex]) }; + } + + @Override + protected Block GetProperBlock() { + return WerkstoffLoader.BWBlocks; + } +} diff --git a/src/main/java/bartworks/system/material/CircuitGeneration/BWCircuitsLoader.java b/src/main/java/bartworks/system/material/CircuitGeneration/BWCircuitsLoader.java new file mode 100644 index 0000000000..55b42a662d --- /dev/null +++ b/src/main/java/bartworks/system/material/CircuitGeneration/BWCircuitsLoader.java @@ -0,0 +1,25 @@ +/* + * 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.system.material.CircuitGeneration; + +public class BWCircuitsLoader { + + private static final BWMetaItems NEW_CIRCUITS = new BWMetaItems(); + + private BWCircuitsLoader() {} + + public static void initNewCircuits() { + + } +} diff --git a/src/main/java/bartworks/system/material/CircuitGeneration/BWMetaItems.java b/src/main/java/bartworks/system/material/CircuitGeneration/BWMetaItems.java new file mode 100644 index 0000000000..bafecfa0cd --- /dev/null +++ b/src/main/java/bartworks/system/material/CircuitGeneration/BWMetaItems.java @@ -0,0 +1,327 @@ +/* + * 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.system.material.CircuitGeneration; + +import static gregtech.api.recipe.RecipeMaps.formingPressRecipes; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; + +import java.util.ArrayList; +import java.util.BitSet; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.IIcon; +import net.minecraftforge.fluids.FluidStack; + +import bartworks.MainMod; +import bartworks.common.loaders.ItemRegistry; +import bartworks.system.material.WerkstoffLoader; +import bartworks.util.BWUtil; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SubTag; +import gregtech.api.enums.TCAspects; +import gregtech.api.enums.TierEU; +import gregtech.api.interfaces.IItemBehaviour; +import gregtech.api.interfaces.IItemContainer; +import gregtech.api.items.MetaBaseItem; +import gregtech.api.objects.ItemData; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; + +public class BWMetaItems { + + public static BWMetaItems.BW_GT_MetaGenCircuits getCircuitParts() { + return BWMetaItems.NEW_CIRCUIT_PARTS; + } + + private static final BWMetaItems.BW_GT_MetaGenCircuits NEW_CIRCUIT_PARTS = new BWMetaItems.BW_GT_MetaGenCircuits(); + + static { + BWMetaItems.NEW_CIRCUIT_PARTS.addItem(0, "Circuit Imprint", "", SubTag.NO_UNIFICATION, SubTag.NO_RECYCLING); + BWMetaItems.NEW_CIRCUIT_PARTS.addItem(1, "Sliced Circuit", "", SubTag.NO_UNIFICATION, SubTag.NO_RECYCLING); + BWMetaItems.NEW_CIRCUIT_PARTS + .addItem(2, "Raw Imprint supporting Board", "A Raw Board needed for Circuit Imprints"); + BWMetaItems.NEW_CIRCUIT_PARTS.addItem(3, "Imprint supporting Board", "A Board needed for Circuit Imprints"); + + GTValues.RA.stdBuilder() + .itemInputs( + WerkstoffLoader.MagnetoResonaticDust.get(OrePrefixes.dust, 1), + WerkstoffLoader.ArInGaPhoBiBoTe.get(OrePrefixes.dust, 4)) + .itemOutputs(BWMetaItems.NEW_CIRCUIT_PARTS.getStack(2)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(formingPressRecipes); + + RecipeMaps.autoclaveRecipes.add( + new GTRecipe( + false, + new ItemStack[] { BWMetaItems.NEW_CIRCUIT_PARTS.getStack(2) }, + new ItemStack[] { BWMetaItems.NEW_CIRCUIT_PARTS.getStack(3) }, + null, + new int[] { 7500 }, + new FluidStack[] { Materials.SolderingAlloy.getMolten(576) }, + null, + 300, + (int) TierEU.RECIPE_EV, + BWUtil.CLEANROOM)); + } + + public static class BW_GT_MetaGenCircuits extends BWMetaItems.BW_GT_MetaGen_Item_Hook { + + public BW_GT_MetaGenCircuits() { + super("bwMetaGeneratedItem0"); + } + + public final ItemStack getStack(int meta) { + return getStack(meta, 1); + } + + public final ItemStack getStack(int meta, int stackSize) { + return new ItemStack(this, stackSize, meta); + } + + public final ItemStack getStackWithNBT(NBTTagCompound tag, int meta, int stackSize) { + ItemStack itemStack = getStack(meta, stackSize); + itemStack.setTagCompound(tag); + return itemStack; + } + + @Override + public void getSubItems(Item var1, CreativeTabs aCreativeTab, List<ItemStack> aList) { + if (aCreativeTab == this.getCreativeTab()) + for (NBTTagCompound tag : CircuitImprintLoader.recipeTagMap.keySet()) { + ItemStack stack = new ItemStack(BWMetaItems.NEW_CIRCUIT_PARTS, 1, 0); + stack.setTagCompound(tag); + aList.add(stack); + } + super.getSubItems(var1, aCreativeTab, aList); + } + + @Override + @SideOnly(Side.CLIENT) + public final void registerIcons(IIconRegister aIconRegister) { + + for (short i = 0; i < CircuitImprintLoader.reverseIDs; ++i) { + if (this.mEnabledItems.get(i)) { + BWUtil.set2DCoordTo1DArray( + i, + 0, + 2, + aIconRegister.registerIcon("gregtech:" + this.getUnlocalizedName() + "/" + i), + this.mIconList); + } + } + + for (short i = CircuitImprintLoader.reverseIDs; i < Short.MAX_VALUE; i++) { + if (this.mEnabledItems.get(i)) { + BWUtil.set2DCoordTo1DArray( + i, + 0, + 2, + Objects.requireNonNull(CircuitImprintLoader.circuitIIconRefs.get(i)) + .get(1) + .getIconIndex(), + this.mIconList); + BWUtil.set2DCoordTo1DArray( + i, + 1, + 2, + aIconRegister.registerIcon(MainMod.MOD_ID + ":WrapOverlay"), + this.mIconList); + } + } + } + + @Override + protected void addAdditionalToolTips(List<String> aList, ItemStack aStack, EntityPlayer aPlayer) { + if (aStack.getTagCompound() != null) { + ItemStack tagStack = CircuitImprintLoader.getStackFromTag(aStack.getTagCompound()); + String itemName = tagStack != null + ? GTLanguageManager.getTranslation(GTLanguageManager.getTranslateableItemStackName(tagStack)) + : "a circuit"; + + if (aStack.getItemDamage() == 0) { + aList.add("An imprint for: " + itemName); + } else if (aStack.getItemDamage() == 1) { + aList.add("A sliced " + itemName); + } + } else { + if (aStack.getItemDamage() == 0) { + aList.add("An imprint for a Circuit"); + } else if (aStack.getItemDamage() == 1) { + aList.add("A sliced Circuit"); + } + } + + super.addAdditionalToolTips(aList, aStack, aPlayer); + } + + } + + public static class BW_GT_MetaGen_Item_Hook extends MetaBaseItem { + + public static final HashSet<BWMetaItems.BW_GT_MetaGen_Item_Hook> sInstances = new HashSet<>(); + public final IIcon[] mIconList; + public final BitSet mEnabledItems; + + { + this.mIconList = new IIcon[Short.MAX_VALUE * 2]; + this.mEnabledItems = new BitSet(Short.MAX_VALUE); + } + + private BW_GT_MetaGen_Item_Hook(String aUnlocalized) { + super(aUnlocalized); + + this.setCreativeTab(new CreativeTabs("bw.MetaItems.0") { + + @Override + public Item getTabIconItem() { + return ItemRegistry.TAB; + } + }); + this.setHasSubtypes(true); + this.setMaxDamage(0); + BWMetaItems.BW_GT_MetaGen_Item_Hook.sInstances.add(this); + } + + @Override + public Long[] getElectricStats(ItemStack itemStack) { + return null; + } + + @Override + public Long[] getFluidContainerStats(ItemStack itemStack) { + return null; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + public final ItemStack addItem(int aID, String aEnglish, String aToolTip, Object... aRandomData) { + if (aToolTip == null) { + aToolTip = ""; + } + ItemStack rStack = new ItemStack(this, 1, aID); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName(rStack) + ".name", aEnglish); + GTLanguageManager.addStringLocalization(this.getUnlocalizedName(rStack) + ".tooltip", aToolTip); + List<TCAspects.TC_AspectStack> tAspects = new ArrayList<>(); + this.mEnabledItems.set(aID); + Object[] var7 = aRandomData; + int var8 = aRandomData.length; + + int var9; + Object tRandomData; + for (var9 = 0; var9 < var8; ++var9) { + tRandomData = var7[var9]; + if (tRandomData instanceof SubTag && tRandomData == SubTag.NO_UNIFICATION) { + GTOreDictUnificator.addToBlacklist(rStack); + } + } + + var7 = aRandomData; + var8 = aRandomData.length; + + for (var9 = 0; var9 < var8; ++var9) { + tRandomData = var7[var9]; + if (tRandomData != null) { + boolean tUseOreDict = true; + + if (tRandomData instanceof IItemBehaviour) { + this.addItemBehavior(aID, (IItemBehaviour) tRandomData); + tUseOreDict = false; + } + + if (tRandomData instanceof IItemContainer) { + ((IItemContainer) tRandomData).set(rStack); + tUseOreDict = false; + } + + if (!(tRandomData instanceof SubTag)) { + if (tRandomData instanceof TCAspects.TC_AspectStack) { + ((TCAspects.TC_AspectStack) tRandomData).addToAspectList(tAspects); + } else if (tRandomData instanceof ItemData) { + if (GTUtility.isStringValid(tRandomData)) { + GTOreDictUnificator.registerOre(tRandomData, rStack); + } else { + GTOreDictUnificator.addItemData(rStack, (ItemData) tRandomData); + } + } else if (tUseOreDict) { + GTOreDictUnificator.registerOre(tRandomData, rStack); + } + } + } + } + + if (GregTechAPI.sThaumcraftCompat != null) { + GregTechAPI.sThaumcraftCompat.registerThaumcraftAspectsToItem(rStack, tAspects, false); + } + + return rStack; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item var1, CreativeTabs aCreativeTab, List<ItemStack> aList) { + int j = this.mEnabledItems.length(); + + for (int i = 0; i < j; ++i) { + if (this.mEnabledItems.get(i)) { + ItemStack tStack = new ItemStack(this, 1, i); + this.isItemStackUsable(tStack); + aList.add(tStack); + } + } + } + + @Override + protected void addAdditionalToolTips(List<String> aList, ItemStack aStack, EntityPlayer aPlayer) { + super.addAdditionalToolTips(aList, aStack, aPlayer); + } + + @Override + public String getUnlocalizedName(ItemStack aStack) { + return this.getUnlocalizedName() + "." + aStack.getItemDamage(); + } + + @Override + public IIcon getIconFromDamage(int i) { + if (this.mEnabledItems.get(i)) return (IIcon) BWUtil.get2DCoordFrom1DArray(i, 0, 2, this.mIconList); + return null; + } + + @Override + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, + int useRemaining) { + return this.getIconFromDamage(stack.getItemDamage()); + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return this.getIconFromDamage(stack.getItemDamage()); + } + } +} diff --git a/src/main/java/bartworks/system/material/CircuitGeneration/CircuitData.java b/src/main/java/bartworks/system/material/CircuitGeneration/CircuitData.java new file mode 100644 index 0000000000..fbf8600257 --- /dev/null +++ b/src/main/java/bartworks/system/material/CircuitGeneration/CircuitData.java @@ -0,0 +1,76 @@ +/* + * 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.system.material.CircuitGeneration; + +import java.nio.ByteBuffer; + +import bartworks.util.MurmurHash3; + +public class CircuitData { + + private long aVoltage; + private int aSpecial; + private byte aTier; + + public CircuitData(long aVoltage, int aSpecial, byte aTier) { + this.aVoltage = aVoltage; + this.aSpecial = aSpecial; + this.aTier = aTier; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof CircuitData that)) return false; + if (this.getaVoltage() != that.getaVoltage() || this.getaSpecial() != that.getaSpecial()) return false; + return this.getaTier() == that.getaTier(); + } + + @Override + public int hashCode() { + return MurmurHash3.murmurhash3_x86_32( + ByteBuffer.allocate(13) + .put(this.aTier) + .putInt(this.aSpecial) + .putLong(this.aVoltage) + .array(), + 0, + 13, + 31); + } + + public long getaVoltage() { + return this.aVoltage; + } + + public void setaVoltage(long aVoltage) { + this.aVoltage = aVoltage; + } + + public int getaSpecial() { + return this.aSpecial; + } + + public void setaSpecial(int aSpecial) { + this.aSpecial = aSpecial; + } + + public byte getaTier() { + return this.aTier; + } + + public void setaTier(byte aTier) { + this.aTier = aTier; + } +} diff --git a/src/main/java/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java b/src/main/java/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java new file mode 100644 index 0000000000..c81f62e2ab --- /dev/null +++ b/src/main/java/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java @@ -0,0 +1,367 @@ +/* + * 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.system.material.CircuitGeneration; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; +import net.minecraftforge.oredict.ShapedOreRecipe; + +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; + +import bartworks.API.recipe.BWNBTDependantCraftingRecipe; +import bartworks.API.recipe.BartWorksRecipeMaps; +import bartworks.ASM.BWCoreStaticReplacementMethodes; +import bartworks.common.configs.ConfigHandler; +import bartworks.system.material.WerkstoffLoader; +import bartworks.util.BWUtil; +import bartworks.util.Pair; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; + +public class CircuitImprintLoader { + + public static short reverseIDs = Short.MAX_VALUE - 1; + + public static final ArrayListMultimap<NBTTagCompound, GTRecipe> recipeTagMap = ArrayListMultimap.create(); + public static final HashBiMap<Short, ItemList> circuitIIconRefs = HashBiMap.create(20); + public static final HashSet<ItemStack> blacklistSet = new HashSet<>(); + static final HashBiMap<CircuitData, ItemStack> bwCircuitTagMap = HashBiMap.create(20); + private static final HashSet<IRecipe> recipeWorldCache = new HashSet<>(); + private static final HashSet<GTRecipe> gtrecipeWorldCache = new HashSet<>(); + private static final HashSet<GTRecipe> ORIGINAL_CAL_RECIPES = new HashSet<>(); + private static final HashSet<GTRecipe> MODIFIED_CAL_RECIPES = new HashSet<>(); + + public static void run() { + HashSet<GTRecipe> toRem = new HashSet<>(); + HashSet<GTRecipe> toAdd = new HashSet<>(); + + deleteCALRecipesAndTags(); + rebuildCircuitAssemblerMap(toRem, toAdd); + exchangeRecipesInList(toRem, toAdd); + makeCircuitImprintRecipes(); + + toRem = null; + toAdd = null; + } + + private static void reAddOriginalRecipes() { + RecipeMaps.circuitAssemblerRecipes.getBackend() + .removeRecipes(MODIFIED_CAL_RECIPES); + ORIGINAL_CAL_RECIPES.forEach(RecipeMaps.circuitAssemblerRecipes::add); + ORIGINAL_CAL_RECIPES.clear(); + MODIFIED_CAL_RECIPES.clear(); + } + + private static void rebuildCircuitAssemblerMap(HashSet<GTRecipe> toRem, HashSet<GTRecipe> toAdd) { + reAddOriginalRecipes(); + RecipeMaps.circuitAssemblerRecipes.getAllRecipes() + .forEach(e -> CircuitImprintLoader.handleCircuitRecipeRebuilding(e, toRem, toAdd)); + } + + private static void handleCircuitRecipeRebuilding(GTRecipe circuitRecipe, HashSet<GTRecipe> toRem, + HashSet<GTRecipe> toAdd) { + ItemStack[] outputs = circuitRecipe.mOutputs; + boolean isOrePass = isCircuitOreDict(outputs[0]); + String unlocalizedName = outputs[0].getUnlocalizedName(); + if (isOrePass || unlocalizedName.contains("Circuit") || unlocalizedName.contains("circuit")) { + + CircuitImprintLoader.recipeTagMap + .put(CircuitImprintLoader.getTagFromStack(outputs[0]), circuitRecipe.copy()); + + Fluid solderIndalloy = FluidRegistry.getFluid("molten.indalloy140") != null + ? FluidRegistry.getFluid("molten.indalloy140") + : FluidRegistry.getFluid("molten.solderingalloy"); + + Fluid solderUEV = FluidRegistry.getFluid("molten.mutatedlivingsolder") != null + ? FluidRegistry.getFluid("molten.mutatedlivingsolder") + : FluidRegistry.getFluid("molten.solderingalloy"); + + if (circuitRecipe.mFluidInputs[0].isFluidEqual(Materials.SolderingAlloy.getMolten(0)) + || circuitRecipe.mFluidInputs[0].isFluidEqual(new FluidStack(solderIndalloy, 0)) + || circuitRecipe.mFluidInputs[0].isFluidEqual(new FluidStack(solderUEV, 0))) { + GTRecipe newRecipe = CircuitImprintLoader.reBuildRecipe(circuitRecipe); + if (newRecipe != null) BartWorksRecipeMaps.circuitAssemblyLineRecipes.addRecipe(newRecipe); + addCutoffRecipeToSets(toRem, toAdd, circuitRecipe); + } else if (circuitRecipe.mEUt > BWUtil.getTierVoltage(ConfigHandler.cutoffTier)) toRem.add(circuitRecipe); + } + } + + private static boolean isCircuitOreDict(ItemStack item) { + return BWUtil.isTieredCircuit(item) || BWUtil.getOreNames(item) + .stream() + .anyMatch(s -> "circuitPrimitiveArray".equals(s)); + } + + private static void exchangeRecipesInList(HashSet<GTRecipe> toRem, HashSet<GTRecipe> toAdd) { + toAdd.forEach(RecipeMaps.circuitAssemblerRecipes::add); + RecipeMaps.circuitAssemblerRecipes.getBackend() + .removeRecipes(toRem); + ORIGINAL_CAL_RECIPES.addAll(toRem); + MODIFIED_CAL_RECIPES.addAll(toAdd); + } + + private static void addCutoffRecipeToSets(HashSet<GTRecipe> toRem, HashSet<GTRecipe> toAdd, + GTRecipe circuitRecipe) { + if (circuitRecipe.mEUt > BWUtil.getTierVoltage(ConfigHandler.cutoffTier)) { + toRem.add(circuitRecipe); + toAdd.add(CircuitImprintLoader.makeMoreExpensive(circuitRecipe)); + } + } + + @SuppressWarnings("deprecation") + public static GTRecipe makeMoreExpensive(GTRecipe original) { + GTRecipe newRecipe = original.copy(); + for (ItemStack is : newRecipe.mInputs) { + if (!BWUtil.isTieredCircuit(is)) { + is.stackSize = Math.min(is.stackSize * 6, 64); + if (is.stackSize > is.getItem() + .getItemStackLimit() || is.stackSize > is.getMaxStackSize()) is.stackSize = is.getMaxStackSize(); + } + } + newRecipe.mFluidInputs[0].amount *= 4; + newRecipe.mDuration *= 4; + return newRecipe; + } + + public static GTRecipe reBuildRecipe(GTRecipe original) { + ItemStack[] in = new ItemStack[6]; + BiMap<ItemList, Short> inversed = CircuitImprintLoader.circuitIIconRefs.inverse(); + + for (int i = 0; i < 6; i++) { + try { + replaceCircuits(inversed, original, in, i); + replaceComponents(in, original, i); + } catch (ArrayIndexOutOfBoundsException e) { + break; + } catch (NullPointerException e) { + e.printStackTrace(); + } + } + + if (CircuitImprintLoader.checkForBlacklistedComponents(in)) { + return null; + } + + return new GTRecipe( + false, + in, + new ItemStack[] { getOutputMultiplied(original) }, + BWMetaItems.getCircuitParts() + .getStackWithNBT(CircuitImprintLoader.getTagFromStack(original.mOutputs[0]), 0, 0), + null, + original.mFluidInputs, + null, + original.mDuration * 12, + original.mEUt, + 0); + } + + private static ItemStack getOutputMultiplied(GTRecipe original) { + ItemStack out = original.copy() + .getOutput(0); + out.stackSize *= 16; + return out; + } + + private static void replaceCircuits(BiMap<ItemList, Short> inversed, GTRecipe original, ItemStack[] in, int index) { + for (ItemList il : inversed.keySet()) { + if (GTUtility.areStacksEqual(il.get(1), replaceCircuitParts(original.mInputs[index]))) { + in[index] = BWMetaItems.getCircuitParts() + .getStack(inversed.get(il), original.mInputs[index].stackSize); + } + } + } + + private static final List<Pair<ItemStack, ItemStack>> circuitPartsToReplace = Collections.unmodifiableList( + Arrays.asList( + new Pair<>(ItemList.Circuit_Parts_Resistor.get(1), ItemList.Circuit_Parts_ResistorSMD.get(1)), + new Pair<>(ItemList.Circuit_Parts_Diode.get(1), ItemList.Circuit_Parts_DiodeSMD.get(1)), + new Pair<>(ItemList.Circuit_Parts_Transistor.get(1), ItemList.Circuit_Parts_TransistorSMD.get(1)), + new Pair<>(ItemList.Circuit_Parts_Capacitor.get(1), ItemList.Circuit_Parts_CapacitorSMD.get(1)), + new Pair<>(ItemList.Circuit_Parts_Coil.get(1), ItemList.Circuit_Parts_InductorSMD.get(1)))); + + private static ItemStack replaceCircuitParts(ItemStack stack) { + for (Pair<ItemStack, ItemStack> pair : circuitPartsToReplace) { + if (GTUtility.areStacksEqual(pair.getKey(), stack)) { + ItemStack newStack = pair.getValue(); + newStack.stackSize = stack.stackSize; + return newStack; + } + } + return stack; + } + + @SuppressWarnings("deprecation") + private static void replaceComponents(ItemStack[] in, GTRecipe original, int index) + throws ArrayIndexOutOfBoundsException { + if (original.mInputs[index] != null && in[index] == null) { + // big wires + if (BWUtil.checkStackAndPrefix(original.mInputs[index]) + && GTOreDictUnificator.getAssociation(original.mInputs[index]).mPrefix == OrePrefixes.wireGt01) { + in[index] = GTOreDictUnificator.get( + OrePrefixes.wireGt16, + GTOreDictUnificator.getAssociation(original.mInputs[index]).mMaterial.mMaterial, + original.mInputs[index].stackSize); + // fine wires + } else if (BWUtil.checkStackAndPrefix(original.mInputs[index]) + && GTOreDictUnificator.getAssociation(original.mInputs[index]).mPrefix == OrePrefixes.wireFine) { + in[index] = GTOreDictUnificator.get( + OrePrefixes.wireGt04, + GTOreDictUnificator.getAssociation(original.mInputs[index]).mMaterial.mMaterial, + original.mInputs[index].stackSize); + if (in[index] == null) { + in[index] = GTOreDictUnificator.get( + OrePrefixes.wireFine, + GTOreDictUnificator.getAssociation(original.mInputs[index]).mMaterial.mMaterial, + original.mInputs[index].stackSize * 16); + } + // other components + } else { + in[index] = original.mInputs[index].copy(); + in[index].stackSize *= 16; + if (in[index].stackSize > in[index].getItem() + .getItemStackLimit() || in[index].stackSize > in[index].getMaxStackSize()) + in[index].stackSize = in[index].getMaxStackSize(); + } + } + } + + private static void makeCircuitImprintRecipes() { + removeOldRecipesFromRegistries(); + CircuitImprintLoader.recipeTagMap.keySet() + .forEach(e -> { + makeAndAddSlicingRecipe(e); + makeAndAddCraftingRecipes(e); + }); + } + + private static boolean checkForBlacklistedComponents(ItemStack[] itemStacks) { + for (ItemStack is : itemStacks) { + for (ItemStack is2 : CircuitImprintLoader.blacklistSet) { + if (GTUtility.areStacksEqual(is, is2)) return true; + } + } + return false; + } + + private static void removeOldRecipesFromRegistries() { + recipeWorldCache.forEach( + CraftingManager.getInstance() + .getRecipeList()::remove); + BWCoreStaticReplacementMethodes.clearRecentlyUsedRecipes(); + RecipeMaps.slicerRecipes.getBackend() + .removeRecipes(gtrecipeWorldCache); + recipeWorldCache.forEach(r -> { + try { + BWUtil.getGTBufferedRecipeList() + .remove(r); + } catch (Exception e) { + e.printStackTrace(); + } + }); + recipeWorldCache.clear(); + gtrecipeWorldCache.clear(); + } + + private static void makeAndAddSlicingRecipe(NBTTagCompound tag) { + ItemStack stack = CircuitImprintLoader.getStackFromTag(tag); + int eut = Integer.MAX_VALUE; + + for (GTRecipe recipe : CircuitImprintLoader.recipeTagMap.get(tag)) { + eut = Math.min(eut, recipe.mEUt); + } + + eut = Math.min( + eut, + BWUtil.getMachineVoltageFromTier( + BWUtil.getCircuitTierFromOreDictName( + OreDictionary.getOreName( + OreDictionary.getOreIDs(stack) != null && OreDictionary.getOreIDs(stack).length > 0 + ? OreDictionary.getOreIDs(stack)[0] + : -1)))); + GTRecipe slicingRecipe = new GTRecipe( + true, + new ItemStack[] { stack, ItemList.Shape_Slicer_Flat.get(0) }, + new ItemStack[] { BWMetaItems.getCircuitParts() + .getStackWithNBT(tag, 1, 1) }, + null, + null, + null, + null, + 300, + eut, + BWUtil.CLEANROOM); + gtrecipeWorldCache.add(slicingRecipe); + RecipeMaps.slicerRecipes.add(slicingRecipe); + } + + private static void makeAndAddCraftingRecipes(NBTTagCompound tag) { + ItemStack circuit = BWMetaItems.getCircuitParts() + .getStackWithNBT(tag, 0, 1); + Object[] imprintRecipe = { " X ", "GPG", " X ", 'P', BWMetaItems.getCircuitParts() + .getStackWithNBT(tag, 1, 1), 'G', WerkstoffLoader.Prasiolite.get(OrePrefixes.gemExquisite, 1), 'X', + BWMetaItems.getCircuitParts() + .getStack(3) }; + + IRecipe bwrecipe = new BWNBTDependantCraftingRecipe(circuit, imprintRecipe); + ShapedOreRecipe gtrecipe = BWUtil.createGTCraftingRecipe( + circuit, + GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GTModHandler.RecipeBits.KEEPNBT + | GTModHandler.RecipeBits.BUFFERED, + imprintRecipe); + + // Adds the actual recipe + recipeWorldCache.add(bwrecipe); + GameRegistry.addRecipe(bwrecipe); + // Adds the NEI visual recipe + recipeWorldCache.add(gtrecipe); + GameRegistry.addRecipe(gtrecipe); + } + + public static NBTTagCompound getTagFromStack(ItemStack stack) { + if (GTUtility.isStackValid(stack)) return BWUtil.setStackSize(stack.copy(), 1) + .writeToNBT(new NBTTagCompound()); + return new NBTTagCompound(); + } + + public static ItemStack getStackFromTag(NBTTagCompound tagCompound) { + return ItemStack.loadItemStackFromNBT(tagCompound); + } + + private static void deleteCALRecipesAndTags() { + BartWorksRecipeMaps.circuitAssemblyLineRecipes.getBackend() + .clearRecipes(); + recipeTagMap.clear(); + } +} diff --git a/src/main/java/bartworks/system/material/CircuitGeneration/CircuitPartLoader.java b/src/main/java/bartworks/system/material/CircuitGeneration/CircuitPartLoader.java new file mode 100644 index 0000000000..ea4d222cac --- /dev/null +++ b/src/main/java/bartworks/system/material/CircuitGeneration/CircuitPartLoader.java @@ -0,0 +1,265 @@ +/* + * 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.system.material.CircuitGeneration; + +import static gregtech.api.enums.ItemList.Circuit_Board_Advanced; +import static gregtech.api.enums.ItemList.Circuit_Board_Basic; +import static gregtech.api.enums.ItemList.Circuit_Board_Bio; +import static gregtech.api.enums.ItemList.Circuit_Board_Bio_Ultra; +import static gregtech.api.enums.ItemList.Circuit_Board_Coated; +import static gregtech.api.enums.ItemList.Circuit_Board_Coated_Basic; +import static gregtech.api.enums.ItemList.Circuit_Board_Elite; +import static gregtech.api.enums.ItemList.Circuit_Board_Epoxy; +import static gregtech.api.enums.ItemList.Circuit_Board_Epoxy_Advanced; +import static gregtech.api.enums.ItemList.Circuit_Board_Fiberglass; +import static gregtech.api.enums.ItemList.Circuit_Board_Fiberglass_Advanced; +import static gregtech.api.enums.ItemList.Circuit_Board_Multifiberglass; +import static gregtech.api.enums.ItemList.Circuit_Board_Multifiberglass_Elite; +import static gregtech.api.enums.ItemList.Circuit_Board_Optical; +import static gregtech.api.enums.ItemList.Circuit_Board_Phenolic; +import static gregtech.api.enums.ItemList.Circuit_Board_Phenolic_Good; +import static gregtech.api.enums.ItemList.Circuit_Board_Plastic; +import static gregtech.api.enums.ItemList.Circuit_Board_Plastic_Advanced; +import static gregtech.api.enums.ItemList.Circuit_Board_Wetware; +import static gregtech.api.enums.ItemList.Circuit_Board_Wetware_Extreme; +import static gregtech.api.enums.ItemList.Circuit_Chip_BioCPU; +import static gregtech.api.enums.ItemList.Circuit_Chip_Biocell; +import static gregtech.api.enums.ItemList.Circuit_Chip_CPU; +import static gregtech.api.enums.ItemList.Circuit_Chip_CrystalCPU; +import static gregtech.api.enums.ItemList.Circuit_Chip_CrystalSoC; +import static gregtech.api.enums.ItemList.Circuit_Chip_CrystalSoC2; +import static gregtech.api.enums.ItemList.Circuit_Chip_HPIC; +import static gregtech.api.enums.ItemList.Circuit_Chip_ILC; +import static gregtech.api.enums.ItemList.Circuit_Chip_LPIC; +import static gregtech.api.enums.ItemList.Circuit_Chip_NAND; +import static gregtech.api.enums.ItemList.Circuit_Chip_NOR; +import static gregtech.api.enums.ItemList.Circuit_Chip_NPIC; +import static gregtech.api.enums.ItemList.Circuit_Chip_NanoCPU; +import static gregtech.api.enums.ItemList.Circuit_Chip_NeuroCPU; +import static gregtech.api.enums.ItemList.Circuit_Chip_Optical; +import static gregtech.api.enums.ItemList.Circuit_Chip_PIC; +import static gregtech.api.enums.ItemList.Circuit_Chip_PPIC; +import static gregtech.api.enums.ItemList.Circuit_Chip_QPIC; +import static gregtech.api.enums.ItemList.Circuit_Chip_QuantumCPU; +import static gregtech.api.enums.ItemList.Circuit_Chip_Ram; +import static gregtech.api.enums.ItemList.Circuit_Chip_Simple_SoC; +import static gregtech.api.enums.ItemList.Circuit_Chip_SoC; +import static gregtech.api.enums.ItemList.Circuit_Chip_SoC2; +import static gregtech.api.enums.ItemList.Circuit_Chip_Stemcell; +import static gregtech.api.enums.ItemList.Circuit_Chip_UHPIC; +import static gregtech.api.enums.ItemList.Circuit_Chip_ULPIC; +import static gregtech.api.enums.ItemList.Circuit_Integrated; +import static gregtech.api.enums.ItemList.Circuit_Integrated_Good; +import static gregtech.api.enums.ItemList.Circuit_Parts_Advanced; +import static gregtech.api.enums.ItemList.Circuit_Parts_CapacitorASMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_CapacitorSMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_CapacitorXSMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_Chip_Bioware; +import static gregtech.api.enums.ItemList.Circuit_Parts_Crystal_Chip_Elite; +import static gregtech.api.enums.ItemList.Circuit_Parts_Crystal_Chip_Master; +import static gregtech.api.enums.ItemList.Circuit_Parts_Crystal_Chip_Wetware; +import static gregtech.api.enums.ItemList.Circuit_Parts_DiodeASMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_DiodeSMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_DiodeXSMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_GlassFiber; +import static gregtech.api.enums.ItemList.Circuit_Parts_InductorASMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_InductorSMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_InductorXSMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_PetriDish; +import static gregtech.api.enums.ItemList.Circuit_Parts_ResistorASMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_ResistorSMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_ResistorXSMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_TransistorASMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_TransistorSMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_TransistorXSMD; +import static gregtech.api.enums.ItemList.Circuit_Parts_Vacuum_Tube; +import static gregtech.api.enums.ItemList.Circuit_Parts_Wiring_Advanced; +import static gregtech.api.enums.ItemList.Circuit_Parts_Wiring_Basic; +import static gregtech.api.enums.ItemList.Circuit_Parts_Wiring_Elite; +import static gregtech.api.enums.ItemList.Optical_Cpu_Containment_Housing; +import static gregtech.api.enums.ItemList.Optically_Compatible_Memory; +import static gregtech.api.enums.ItemList.Optically_Perfected_CPU; +import static gregtech.api.enums.ItemList.values; +import static gregtech.api.recipe.RecipeMaps.assemblerRecipes; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import net.minecraft.item.ItemStack; + +import bartworks.client.renderer.BWItemRenderer; +import cpw.mods.fml.common.FMLCommonHandler; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTUtility; + +public class CircuitPartLoader implements Runnable { + + @Override + public void run() { + CircuitPartLoader.makeCircuitParts(); + if (FMLCommonHandler.instance() + .getEffectiveSide() + .isClient()) new BWItemRenderer(); + } + + public static void makeCircuitParts() { + ItemList[] itemLists = values(); + for (ItemList single : itemLists) { + if (!single.hasBeenSet()) continue; + if (single.toString() + .contains("Wafer") + || single.toString() + .contains("Circuit_Silicon_Ingot") + || single.toString() + .contains("Raw") + || single.toString() + .contains("raw") + || single.toString() + .contains("Glass_Tube") + || single == Circuit_Parts_GlassFiber + || single == Circuit_Parts_Advanced + || single == Circuit_Parts_Wiring_Advanced + || single == Circuit_Parts_Wiring_Elite + || single == Circuit_Parts_Wiring_Basic + || single == Circuit_Integrated + || single == Circuit_Parts_PetriDish + || single == Circuit_Parts_Vacuum_Tube + || single == Circuit_Integrated_Good) { + + CircuitImprintLoader.blacklistSet.add(single.get(1)); + } + } + + for (ItemList single : CIRCUIT_PARTS) { + if (!single.hasBeenSet()) continue; + ItemStack itemStack = single.get(1); + if (!GTUtility.isStackValid(itemStack)) continue; + ArrayList<String> toolTip = new ArrayList<>(); + if (FMLCommonHandler.instance() + .getEffectiveSide() + .isClient()) + single.getItem() + .addInformation( + single.get(1) + .copy(), + null, + toolTip, + true); + String tt = !toolTip.isEmpty() ? toolTip.get(0) : ""; + // tt += "Internal Name = "+single; + String localised = GTLanguageManager + .getTranslation(GTLanguageManager.getTranslateableItemStackName(itemStack)); + BWMetaItems.getCircuitParts() + .addItem(CircuitImprintLoader.reverseIDs, "Wrap of " + localised + "s", tt); + + GTValues.RA.stdBuilder() + .itemInputs( + single.get(16) + .copy(), + GTUtility.getIntegratedCircuit(16)) + .itemOutputs( + BWMetaItems.getCircuitParts() + .getStack(CircuitImprintLoader.reverseIDs)) + .fluidInputs(Materials.Plastic.getMolten(72)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(assemblerRecipes); + + CircuitImprintLoader.circuitIIconRefs.put(CircuitImprintLoader.reverseIDs, single); + CircuitImprintLoader.reverseIDs--; + } + } + + /** + * Contains all the circuit parts we want to generate wrapped version of. New entries MUST be placed at the END of + * this list, to prevent id shift. + */ + private static final List<ItemList> CIRCUIT_PARTS = Collections.unmodifiableList( + Arrays.asList( + Circuit_Board_Basic, + Circuit_Board_Advanced, + Circuit_Board_Elite, + Circuit_Parts_Crystal_Chip_Elite, + Circuit_Parts_Crystal_Chip_Master, + Circuit_Board_Coated, + Circuit_Board_Coated_Basic, + Circuit_Board_Phenolic, + Circuit_Board_Phenolic_Good, + Circuit_Board_Epoxy, + Circuit_Board_Epoxy_Advanced, + Circuit_Board_Fiberglass, + Circuit_Board_Fiberglass_Advanced, + Circuit_Board_Multifiberglass_Elite, + Circuit_Board_Multifiberglass, + Circuit_Board_Wetware, + Circuit_Board_Wetware_Extreme, + Circuit_Board_Plastic, + Circuit_Board_Plastic_Advanced, + Circuit_Board_Bio, + Circuit_Board_Bio_Ultra, + Circuit_Parts_ResistorSMD, + Circuit_Parts_InductorSMD, + Circuit_Parts_DiodeSMD, + Circuit_Parts_TransistorSMD, + Circuit_Parts_CapacitorSMD, + Circuit_Parts_ResistorASMD, + Circuit_Parts_DiodeASMD, + Circuit_Parts_TransistorASMD, + Circuit_Parts_CapacitorASMD, + Circuit_Chip_ILC, + Circuit_Chip_Ram, + Circuit_Chip_NAND, + Circuit_Chip_NOR, + Circuit_Chip_CPU, + Circuit_Chip_SoC, + Circuit_Chip_SoC2, + Circuit_Chip_PIC, + Circuit_Chip_Simple_SoC, + Circuit_Chip_HPIC, + Circuit_Chip_UHPIC, + Circuit_Chip_ULPIC, + Circuit_Chip_LPIC, + Circuit_Chip_NPIC, + Circuit_Chip_PPIC, + Circuit_Chip_QPIC, + Circuit_Chip_NanoCPU, + Circuit_Chip_QuantumCPU, + Circuit_Chip_CrystalCPU, + Circuit_Chip_CrystalSoC, + Circuit_Chip_CrystalSoC2, + Circuit_Chip_NeuroCPU, + Circuit_Chip_BioCPU, + Circuit_Chip_Stemcell, + Circuit_Chip_Biocell, + Circuit_Parts_ResistorXSMD, + Circuit_Parts_DiodeXSMD, + Circuit_Parts_TransistorXSMD, + Circuit_Parts_CapacitorXSMD, + Circuit_Parts_InductorASMD, + Circuit_Parts_InductorXSMD, + Circuit_Chip_Optical, + Circuit_Board_Optical, + Optically_Perfected_CPU, + Optical_Cpu_Containment_Housing, + Optically_Compatible_Memory, + Circuit_Parts_Crystal_Chip_Wetware, + Circuit_Parts_Chip_Bioware)); +} diff --git a/src/main/java/bartworks/system/material/TileEntityMetaGeneratedBlock.java b/src/main/java/bartworks/system/material/TileEntityMetaGeneratedBlock.java new file mode 100644 index 0000000000..c37613aa17 --- /dev/null +++ b/src/main/java/bartworks/system/material/TileEntityMetaGeneratedBlock.java @@ -0,0 +1,71 @@ +/* + * 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.system.material; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.Packet; +import net.minecraft.tileentity.TileEntity; + +import bartworks.MainMod; +import bartworks.common.net.MetaBlockPacket; +import gregtech.api.interfaces.tileentity.ITexturedTileEntity; + +public abstract class TileEntityMetaGeneratedBlock extends TileEntity implements ITexturedTileEntity { + + public short mMetaData; + + @Override + public boolean canUpdate() { + return false; + } + + @Override + public void readFromNBT(NBTTagCompound aNBT) { + super.readFromNBT(aNBT); + this.mMetaData = aNBT.getShort("m"); + } + + @Override + public void writeToNBT(NBTTagCompound aNBT) { + super.writeToNBT(aNBT); + aNBT.setShort("m", this.mMetaData); + } + + @Override + public Packet getDescriptionPacket() { + if (!this.worldObj.isRemote) MainMod.BW_Network_instance.sendPacketToAllPlayersInRange( + this.worldObj, + new MetaBlockPacket(this.xCoord, (short) this.yCoord, this.zCoord, this.mMetaData), + this.xCoord, + this.zCoord); + return null; + } + + protected abstract Block GetProperBlock(); + + public ArrayList<ItemStack> getDrops(int aFortune) { + ArrayList<ItemStack> rList = new ArrayList<>(); + if (this.mMetaData <= 0) { + rList.add(new ItemStack(Blocks.cobblestone, 1, 0)); + return rList; + } + rList.add(new ItemStack(this.GetProperBlock(), 1, this.mMetaData)); + return rList; + } +} diff --git a/src/main/java/bartworks/system/material/Werkstoff.java b/src/main/java/bartworks/system/material/Werkstoff.java new file mode 100644 index 0000000000..1c29d52a92 --- /dev/null +++ b/src/main/java/bartworks/system/material/Werkstoff.java @@ -0,0 +1,1263 @@ +/* + * 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.system.material; + +import static gregtech.api.enums.Mods.GalaxySpace; +import static net.minecraft.util.EnumChatFormatting.DARK_PURPLE; +import static net.minecraft.util.EnumChatFormatting.GREEN; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import bartworks.MainMod; +import bartworks.system.oredict.OreDictHandler; +import bartworks.util.BWColorUtil; +import bartworks.util.BWUtil; +import bartworks.util.MurmurHash3; +import bartworks.util.NonNullWrappedHashMap; +import bartworks.util.Pair; +import bwcrossmod.BartWorksCrossmod; +import bwcrossmod.tgregworks.MaterialsInjector; +import cpw.mods.fml.common.Loader; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.FluidState; +import gregtech.api.enums.Materials; +import gregtech.api.enums.Mods; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SubTag; +import gregtech.api.enums.TCAspects; +import gregtech.api.enums.TextureSet; +import gregtech.api.interfaces.IColorModulationContainer; +import gregtech.api.interfaces.ISubTagContainer; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTOreDictUnificator; +import thaumcraft.api.aspects.Aspect; + +public class Werkstoff implements IColorModulationContainer, ISubTagContainer { + + public static final LinkedHashSet<Werkstoff> werkstoffHashSet = new LinkedHashSet<>(); + public static final LinkedHashMap<Short, Werkstoff> werkstoffHashMap = new LinkedHashMap<>(); + public static final LinkedHashMap<String, Werkstoff> werkstoffNameHashMap = new LinkedHashMap<>(); + + public static final Map<String, String> modNameOverrides = new HashMap<>() { + + private static final long serialVersionUID = 6399917619058898648L; + + { + this.put(GalaxySpace.ID, DARK_PURPLE + "GalaxySpace"); + } + }; + + private static final List<String> BWModNames = Arrays + .asList(MainMod.NAME, BartWorksCrossmod.NAME, MaterialsInjector.NAME); + + private static final HashSet<Short> idHashSet = new HashSet<>(); + + private static final Werkstoff.Stats DEFAULT_NULL_STATS = new Werkstoff.Stats(); + private static final Werkstoff.GenerationFeatures DEFAULT_NULL_GENERATION_FEATURES = new Werkstoff.GenerationFeatures() + .disable(); + public static Werkstoff default_null_Werkstoff; + + private final HashSet<String> ADDITIONAL_OREDICT = new HashSet<>(); + private final List<ISubTagContainer> mOreByProducts = new ArrayList<>(); + private final LinkedHashSet<Pair<ISubTagContainer, Integer>> CONTENTS = new LinkedHashSet<>(); + private final HashSet<SubTag> SUBTAGS = new HashSet<>(); + private byte[] rgb = new byte[3]; + private final String defaultName; + private String toolTip; + + private Werkstoff.Stats stats; + private final Werkstoff.Types type; + private final Werkstoff.GenerationFeatures generationFeatures; + private final short mID; + private final TextureSet texSet; + private Materials bridgeMaterial; + private final String owner; + + public Materials getBridgeMaterial() { + return this.bridgeMaterial; + } + + public void setBridgeMaterial(Materials bridgeMaterial) { + this.bridgeMaterial = bridgeMaterial; + } + + public static void init() { + Werkstoff.default_null_Werkstoff = new Werkstoff( + new short[3], + "_NULL", + "Default null Werkstoff", + Werkstoff.DEFAULT_NULL_STATS, + Werkstoff.Types.UNDEFINED, + Werkstoff.DEFAULT_NULL_GENERATION_FEATURES, + -1, + TextureSet.SET_NONE); + } + + /** + * GT Materials Bridge Constructor + * + * @param materials a GT Materials + * @param generationFeatures the new Types you want to add + * @param type - self explainatory + * @param mID > 31_766 && <= 32_767 + */ + public Werkstoff(Materials materials, Werkstoff.GenerationFeatures generationFeatures, Types type, int mID) { + this( + materials.mRGBa, + materials.mDefaultLocalName, + materials.getToolTip(), + type == null ? materials.mElement != null ? Types.ELEMENT : Types.UNDEFINED : type, + generationFeatures, + mID, + materials.mIconSet, + (List) materials.mOreByProducts, + new Pair<>(materials, 1)); + if (mID <= 31_766 || mID > 32_767) throw new IllegalArgumentException(); + this.stats.mass = materials.getMass(); + this.stats.protons = materials.getProtons(); + this.stats.meltingPoint = materials.mMeltingPoint; + this.stats.neutrons = materials.getNeutrons(); + this.stats.speedOverride = materials.mToolSpeed; + this.stats.durOverride = materials.mDurability; + this.stats.qualityOverride = materials.mToolQuality; + this.stats.setGas(materials.mHasGas); + this.stats.setRadioactive(materials.isRadioactive()); + this.stats.setBlastFurnace(materials.mBlastFurnaceRequired); + this.stats.setMeltingVoltage(120); + if (type == Types.COMPOUND) { + this.stats.setElektrolysis(true); + this.generationFeatures.addChemicalRecipes(); + } else if (type == Types.MIXTURE) { + this.stats.setCentrifuge(true); + this.generationFeatures.addMixerRecipes(); + } + } + + @SafeVarargs + public Werkstoff(short[] rgba, String defaultName, Werkstoff.Types type, int meltingpoint, + Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, + Pair<ISubTagContainer, Integer>... contents) { + this( + rgba, + defaultName, + Werkstoff.Types.getDefaultStatForType(type) + .setMeltingPoint(meltingpoint), + type, + generationFeatures, + mID, + texSet, + contents); + } + + @SafeVarargs + public Werkstoff(short[] rgba, String defaultName, Werkstoff.Types type, + Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, + Pair<ISubTagContainer, Integer>... contents) { + this( + rgba, + defaultName, + Werkstoff.Types.getDefaultStatForType(type), + type, + generationFeatures, + mID, + texSet, + contents); + } + + @SafeVarargs + public Werkstoff(short[] rgba, String defaultName, Werkstoff.Types type, int meltingpoint, + Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, + List<ISubTagContainer> oreByProduct, Pair<ISubTagContainer, Integer>... contents) { + this( + rgba, + defaultName, + Werkstoff.Types.getDefaultStatForType(type) + .setMeltingPoint(meltingpoint), + type, + generationFeatures, + mID, + texSet, + oreByProduct, + contents); + } + + @SafeVarargs + public Werkstoff(short[] rgba, String defaultName, Werkstoff.Types type, + Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, + List<ISubTagContainer> oreByProduct, Pair<ISubTagContainer, Integer>... contents) { + this( + rgba, + defaultName, + Werkstoff.Types.getDefaultStatForType(type), + type, + generationFeatures, + mID, + texSet, + oreByProduct, + contents); + } + + @SafeVarargs + public Werkstoff(short[] rgba, String toolTip, String defaultName, Werkstoff.Types type, + Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, + List<ISubTagContainer> oreByProduct, Pair<ISubTagContainer, Integer>... contents) { + this( + rgba, + toolTip, + defaultName, + Werkstoff.Types.getDefaultStatForType(type), + type, + generationFeatures, + mID, + texSet, + oreByProduct, + contents); + } + + @SafeVarargs + public Werkstoff(short[] rgba, String defaultName, Werkstoff.Stats stats, Werkstoff.Types type, + Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, + List<ISubTagContainer> oreByProduct, Pair<ISubTagContainer, Integer>... contents) { + this(rgba, defaultName, "", stats, type, generationFeatures, mID, texSet, contents); + this.mOreByProducts.clear(); + this.mOreByProducts.addAll(oreByProduct); + } + + @SafeVarargs + public Werkstoff(short[] rgba, String defaultName, Werkstoff.Stats stats, Werkstoff.Types type, + Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, + Pair<ISubTagContainer, Integer>... contents) { + this(rgba, defaultName, "", stats, type, generationFeatures, mID, texSet, contents); + } + + @SafeVarargs + public Werkstoff(short[] rgba, String defaultName, String toolTip, Werkstoff.Stats stats, Werkstoff.Types type, + Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, + List<ISubTagContainer> oreByProduct, Pair<ISubTagContainer, Integer>... contents) { + this(rgba, defaultName, toolTip, stats, type, generationFeatures, mID, texSet, contents); + this.mOreByProducts.clear(); + this.mOreByProducts.addAll(oreByProduct); + } + + @SafeVarargs + public Werkstoff(short[] rgba, String defaultName, String toolTip, Werkstoff.Stats stats, Werkstoff.Types type, + Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, + Pair<ISubTagContainer, Integer>... contents) { + + if (Werkstoff.idHashSet.contains((short) mID)) + throw new UnsupportedOperationException("ID (" + mID + ") is already in use!"); + Werkstoff.idHashSet.add((short) mID); + if (type == null) type = Werkstoff.Types.UNDEFINED; + + this.mID = (short) mID; + this.defaultName = defaultName; + // Ensure that localization key are written to the lang file + GregTechAPI.sAfterGTPreload.add(() -> { this.getLocalizedName(); }); + this.stats = stats; + this.type = type; + this.generationFeatures = generationFeatures; + this.setRgb(BWColorUtil.correctCorlorArray(rgba)); + this.CONTENTS.addAll(Arrays.asList(contents)); + this.toolTip = ""; + if (toolTip.isEmpty()) { + for (Pair<ISubTagContainer, Integer> p : contents) { + if (contents.length > 1) { + if (p.getKey() instanceof Materials) { + if (((Materials) p.getKey()).mMaterialList.size() > 1 && p.getValue() > 1) + this.toolTip += "(" + getFormula((Materials) p.getKey()) + + ")" + + BWUtil.subscriptNumber(p.getValue()); + else this.toolTip += getFormula((Materials) p.getKey()) + + (p.getValue() > 1 ? BWUtil.subscriptNumber(p.getValue()) : ""); + } + if (p.getKey() instanceof Werkstoff) { + if (((Werkstoff) p.getKey()).CONTENTS.size() > 1 && p.getValue() > 1) + this.toolTip += "(" + getFormula((Werkstoff) p.getKey()) + + ")" + + BWUtil.subscriptNumber(p.getValue()); + else this.toolTip += getFormula((Werkstoff) p.getKey()) + + (p.getValue() > 1 ? BWUtil.subscriptNumber(p.getValue()) : ""); + } + } else if (p.getKey() instanceof Materials) { + this.toolTip += getFormula((Materials) p.getKey()) + + (p.getValue() > 1 ? BWUtil.subscriptNumber(p.getValue()) : ""); + } else if (p.getKey() instanceof Werkstoff) this.toolTip += getFormula((Werkstoff) p.getKey()) + + (p.getValue() > 1 ? BWUtil.subscriptNumber(p.getValue()) : ""); + } + } else this.toolTip = toolTip; + + // if (this.toolTip.length() > 25) + // this.toolTip = "The formula is to long..."; + + // Ensure that localization key are written to the lang file + GregTechAPI.sAfterGTPreload.add(() -> { this.getLocalizedToolTip(); }); + + if (this.stats.protons == 0) { + long tmpprotons = 0; + for (Pair<ISubTagContainer, Integer> p : contents) { + if (p.getKey() instanceof Materials) { + tmpprotons += ((Materials) p.getKey()).getProtons() * p.getValue(); + } else if (p.getKey() instanceof Werkstoff) { + tmpprotons += ((Werkstoff) p.getKey()).getStats().protons * p.getValue(); + } + } + this.stats = stats.setProtons(tmpprotons); + } + if (this.stats.mass == 0) { + long tmpmass = 0; + int count = 0; + for (Pair<ISubTagContainer, Integer> p : contents) { + if (p.getKey() instanceof Materials) { + tmpmass += ((Materials) p.getKey()).getMass() * p.getValue(); + count += p.getValue(); + } else if (p.getKey() instanceof Werkstoff) { + tmpmass += ((Werkstoff) p.getKey()).getStats().mass * p.getValue(); + count += p.getValue(); + } + } + if (count > 0) this.stats = stats.setMass(tmpmass / count); + } + + if (this.stats.meltingPoint == 0) this.stats.meltingPoint = 1123; + + if (this.stats.meltingVoltage == 0) this.stats.meltingVoltage = 120; + + this.texSet = texSet; + + switch (this.mOreByProducts.size()) { + case 0: + this.mOreByProducts.add(this); + this.mOreByProducts.add(this); + this.mOreByProducts.add(this); + break; + case 1: + this.mOreByProducts.add(this); + this.mOreByProducts.add(this); + break; + case 2: + this.mOreByProducts.add(this); + break; + } + + Optional<Pair<ISubTagContainer, Integer>> firstContent; + if (this.CONTENTS.size() == 1 && (firstContent = this.CONTENTS.stream() + .findFirst()).isPresent()) { + ISubTagContainer firstContentSubTagContainer = firstContent.get() + .getKey(); + if (firstContent.get() + .getValue() == 1 && firstContentSubTagContainer instanceof Materials) this.getGenerationFeatures() + .setExtension(); + } + + Werkstoff.werkstoffHashSet.add(this); + Werkstoff.werkstoffHashMap.put(this.mID, this); + Werkstoff.werkstoffNameHashMap.put(this.defaultName, this); + + this.owner = this.getMaterialOwner(); + } + + private static String getFormula(Materials material) { + return material.mChemicalFormula.isEmpty() ? "?" : material.mChemicalFormula; + } + + private static String getFormula(Werkstoff material) { + return material.toolTip.isEmpty() ? "?" : material.toolTip; + } + + public Werkstoff addAdditionalOreDict(String s) { + this.ADDITIONAL_OREDICT.add(s); + return this; + } + + public HashSet<String> getADDITIONAL_OREDICT() { + return this.ADDITIONAL_OREDICT; + } + + public void setTCAspects(Pair<Object, Integer>... pAspectsArr) { + this.stats.mTC_Aspects = pAspectsArr; + } + + @SuppressWarnings("unchecked") + public Pair<Object, Integer>[] getTCAspects(int ratio) { + if (this.stats.mTC_Aspects == null) { + HashSet<TCAspects.TC_AspectStack> tc_aspectStacks = new HashSet<>(); + HashSet<Pair<Object, Integer>> set = new HashSet<>(); + for (Pair<?, ?> p : this.getContents() + .getValue()) { + if (p.getKey() instanceof Materials) tc_aspectStacks.addAll(((Materials) p.getKey()).mAspects); + if (p.getKey() instanceof Werkstoff) set.addAll(Arrays.asList(((Werkstoff) p.getKey()).getTCAspects())); + } + tc_aspectStacks.forEach( + tc_aspectStack -> set.add(new Pair<>(tc_aspectStack.mAspect.mAspect, (int) tc_aspectStack.mAmount))); + this.stats.mTC_Aspects = set.toArray(new Pair[0]); + } + Pair<Object, Integer>[] ret = this.stats.mTC_Aspects.clone(); + for (int i = 0; i < ret.length; i++) { + ret[i] = ret[i].copyWithNewValue(ret[i].getValue() * ratio); + } + return ret; + } + + public List<TCAspects.TC_AspectStack> getGTWrappedTCAspects() { + final List<TCAspects.TC_AspectStack> ret = new ArrayList<>(); + Arrays.stream(this.getTCAspects()) + .forEach(objectIntegerPair -> { + new TCAspects.TC_AspectStack( + TCAspects.valueOf( + ((Aspect) objectIntegerPair.getKey()).getName() + .toUpperCase(Locale.US)), + objectIntegerPair.getValue()).addToAspectList(ret); + }); + return ret; + } + + public Pair<Object, Integer>[] getTCAspects() { + return this.getTCAspects(1); + } + + public Werkstoff.Types getType() { + return this.type; + } + + public boolean containsStuff(ISubTagContainer stuff) { + for (Pair<ISubTagContainer, Integer> pair : this.CONTENTS) { + if (pair.getKey() + .equals(stuff)) return true; + } + return false; + } + + public Pair<Integer, LinkedHashSet<Pair<ISubTagContainer, Integer>>> getContents() { + int ret = 0; + switch (this.type) { + case COMPOUND: + case MIXTURE: + case BIOLOGICAL: { + for (int i = 0; i < this.CONTENTS.toArray().length; i++) { + ret += (int) this.CONTENTS.toArray(new Pair[0])[i].getValue(); + } + break; + } + default: + ret = 1; + break; + } + return new Pair<>(ret, this.CONTENTS); + } + + public int getNoOfByProducts() { + return this.mOreByProducts.size(); + } + + public ISubTagContainer getOreByProductRaw(int aNumber) { + if (this.mOreByProducts.size() == 0) return null; + if (aNumber < 0) aNumber = this.mOreByProducts.size() + aNumber; + while (aNumber >= this.mOreByProducts.size()) aNumber--; + ISubTagContainer o = this.mOreByProducts.get(aNumber); + if (o == null || o.equals(Werkstoff.default_null_Werkstoff) || o.equals(Materials._NULL)) return this; + return o; + } + + public ItemStack getOreByProduct(int aNumber, OrePrefixes prefixes) { + if (this.mOreByProducts.size() == 0) return null; + if (aNumber < 0) aNumber = this.mOreByProducts.size() + aNumber; + while (aNumber >= this.mOreByProducts.size()) aNumber--; + Object o = this.mOreByProducts.get(aNumber); + if (o == null || o.equals(Werkstoff.default_null_Werkstoff) || o.equals(Materials._NULL)) + return this.get(prefixes); + if (o instanceof Werkstoff) return WerkstoffLoader.getCorrespondingItemStack(prefixes, (Werkstoff) o); + if (o instanceof Materials) return GTOreDictUnificator.get(prefixes, o, 1L); + return null; + } + + public String getDefaultName() { + return this.defaultName; + } + + public String getLocalizedName() { + return GTLanguageManager.addStringLocalization( + String.format("bw.werkstoff.%05d.name", this.mID), + this.defaultName, + !GregTechAPI.sPostloadFinished); + } + + public String getVarName() { + return this.defaultName.replace(" ", ""); + } + + public String getToolTip() { + return this.toolTip; + } + + public String getLocalizedToolTip() { + return GTLanguageManager.addStringLocalization( + String.format("bw.werkstoff.%05d.tooltip", this.mID), + this.toolTip, + !GregTechAPI.sPostloadFinished); + } + + public Werkstoff.Stats getStats() { + return this.stats; + } + + public short getmID() { + return this.mID; + } + + public short getMixCircuit() { + return this.getGenerationFeatures().mixCircuit; + } + + public Werkstoff.GenerationFeatures getGenerationFeatures() { + return this.generationFeatures; + } + + public TextureSet getTexSet() { + return this.texSet; + } + + public void setRgb(short[] rgb) { + this.rgb = new byte[] { (byte) (rgb[0] - 128), (byte) (rgb[1] - 128), (byte) (rgb[2] - 128) }; + } + + @Override + public short[] getRGBA() { + return new short[] { (short) (this.rgb[0] + 128), (short) (this.rgb[1] + 128), (short) (this.rgb[2] + 128), 0 }; + } + + @Override + public boolean contains(SubTag subTag) { + if (!subTag.equals(WerkstoffLoader.NOBLE_GAS) && !subTag.equals(WerkstoffLoader.ANAEROBE_GAS) + && !subTag.equals(WerkstoffLoader.NO_BLAST)) + for (Pair<ISubTagContainer, Integer> p : this.CONTENTS) if (p.getKey() + .contains(subTag)) return true; + return this.SUBTAGS.contains(subTag); + } + + @Override + public ISubTagContainer add(SubTag... subTags) { + this.SUBTAGS.addAll(Arrays.asList(subTags)); + return this; + } + + @Override + public boolean remove(SubTag subTag) { + return this.SUBTAGS.remove(subTag); + } + + public void getAndAddToCollection(OrePrefixes prefixes, int amount, Collection<ItemStack> stacks) { + stacks.add(this.get(prefixes, amount)); + } + + public ItemStack get(OrePrefixes prefixes) { + return WerkstoffLoader.getCorrespondingItemStack(prefixes, this); + } + + public FluidStack getFluidOrGas(int fluidAmount) { + return new FluidStack(Objects.requireNonNull(WerkstoffLoader.fluids.get(this)), fluidAmount); + } + + public FluidStack getMolten(int fluidAmount) { + return new FluidStack(Objects.requireNonNull(WerkstoffLoader.molten.get(this)), fluidAmount); + } + + public ItemStack get(OrePrefixes prefixes, int amount) { + return WerkstoffLoader.getCorrespondingItemStack(prefixes, this, amount); + } + + public byte getToolQuality() { + return this.stats.getQualityOverride() > 0 ? this.stats.getQualityOverride() + : (byte) (15f * (this.getStats() + .getProtons() / 188f + + this.getStats() + .getMeltingPoint() / 10801f) + / (float) this.getContents() + .getKey()); + } + + public float getToolSpeed() { + return this.stats.getSpeedOverride() > 0f ? this.stats.getSpeedOverride() + : Math.max( + 1f, + 2f * (-this.getStats() + .getMass() + 0.1f + * this.getStats() + .getMeltingPoint() + + this.getStats() + .getProtons()) + * 0.1f + / (float) this.getContents() + .getKey() + * 0.1f + * this.getToolQuality()); + } + + public int getDurability() { + return this.stats.getDurOverride() > 0 ? this.stats.getDurOverride() + : (int) (this.stats.durMod * (0.01f * this.getStats() + .getMeltingPoint() + * this.getStats() + .getMass() + / (float) this.getContents() + .getKey())); + } + + /** + * Checks if the generation feature is enabled and if its not in the blacklist + */ + public boolean hasItemType(OrePrefixes prefixes) { + int unpacked = Werkstoff.GenerationFeatures.getPrefixDataRaw(prefixes); + return (this.getGenerationFeatures().toGenerate & unpacked) != 0 + && (this.getGenerationFeatures().blacklist & unpacked) == 0; + } + + /** + * DOES NOT CHECK BLACKLIST! + */ + public boolean hasGenerationFeature(OrePrefixes prefixes) { + int unpacked = Werkstoff.GenerationFeatures.getPrefixDataRaw(prefixes); + return (this.getGenerationFeatures().toGenerate & unpacked) != 0; + } + + /** + * Checks if the Actual Stack exists in the OreDict + */ + public boolean doesOreDictedItemExists(OrePrefixes prefixes) { + return OreDictHandler.getItemStack(this.getDefaultName(), prefixes, 1) != null; + } + + public String getOwner() { + return this.owner; + } + + private String getMaterialOwner() { + String modName = Loader.instance() + .activeModContainer() + .getName(); + if (modNameOverrides.get(modName) != null) { + return modNameOverrides.get(modName); + } + if (BWModNames.contains(modName)) { + return null; + } + return GREEN + modName; + } + + public enum Types { + + MATERIAL, + COMPOUND, + MIXTURE, + BIOLOGICAL, + ELEMENT, + ISOTOPE, + UNDEFINED; + + public static Werkstoff.Stats getDefaultStatForType(Werkstoff.Types T) { + return switch (T) { + case COMPOUND, BIOLOGICAL -> new Werkstoff.Stats().setElektrolysis(true); + case MIXTURE -> new Werkstoff.Stats().setCentrifuge(true); + default -> new Werkstoff.Stats(); + }; + } + } + + public static class GenerationFeatures { + + public static final GenerationFeatures DISABLED = new GenerationFeatures().disable(); + long toGenerate = 0b0001001; + // logic gate shit + /* + * dust 1 metal 10 (ingot, nugget) gem 100 ore 1000 cell 10000 plasma 100000 molten 1000000 crafting metal + * 10000000 (sticks, plates) meta crafting metal 100000000 (gears, screws, bolts, springs) multiple ingotWorth + * stuff 1000000000 (double, triple, quadruple, ingot/plates) + */ + private boolean isExtension; + private static final NonNullWrappedHashMap<OrePrefixes, Integer> prefixLogic = new NonNullWrappedHashMap<>(0); + + public GenerationFeatures() {} + + public static void initPrefixLogic() { + Arrays.stream(OrePrefixes.values()) + .forEach(e -> prefixLogic.put(e, 0)); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.dust, 0b1); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.dustTiny, 0b1); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.dustSmall, 0b1); + + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.ingot, 0b10); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.ingotHot, 0b10); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.nugget, 0b10); + + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.gem, 0b100); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.gemFlawed, 0b100); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.gemExquisite, 0b100); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.gemChipped, 0b100); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.gemFlawless, 0b100); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.lens, 0b100); + + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.block, 0b110); + + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.ore, 0b1000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.dustImpure, 0b1000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.dustPure, 0b1000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.crushed, 0b1000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.crushedPurified, 0b1000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.crushedCentrifuged, 0b1000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.rawOre, 0b1000); + + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.cell, 0b10000); + if (Mods.Forestry.isModLoaded()) { + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.capsule, 0b10000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.capsuleMolten, 0b1000000); + } + // Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.bottle,0b10000); + + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.cellMolten, 0b1000000); + + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.plate, 0b10000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.foil, 0b10000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.stick, 0b10000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.stickLong, 0b10000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.toolHeadHammer, 0b10000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.toolHeadWrench, 0b10000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.toolHeadSaw, 0b10000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.turbineBlade, 0b10000000); + + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.screw, 0b100000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.gearGt, 0b100000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.gearGtSmall, 0b100000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.bolt, 0b100000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.ring, 0b100000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.spring, 0b100000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.springSmall, 0b100000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.rotor, 0b100000000); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.wireFine, 0b100000000); + + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.plateDouble, 0x200); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.plateTriple, 0x200); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.plateQuadruple, 0x200); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.plateQuintuple, 0x200); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.plateDense, 0x200); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.ingotDouble, 0x200); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.ingotTriple, 0x200); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.ingotQuadruple, 0x200); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.ingotQuintuple, 0x200); + + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.blockCasing, 0x380); + Werkstoff.GenerationFeatures.prefixLogic.put(OrePrefixes.blockCasingAdvanced, 0x380); + } + + public void setExtension() { + this.isExtension = !this.isExtension; + } + + public static int getPrefixDataRaw(OrePrefixes prefixes) { + if (prefixes == null) throw new IllegalArgumentException("OrePrefixes is NULL!"); + return GenerationFeatures.prefixLogic.get(prefixes); + } + + public boolean isExtension() { + return this.isExtension; + } + + // public byte toGenerateSecondary = 0b0000000; + public byte blacklist; + + public boolean enforceUnification; + + /* + * Auto add Chemical Recipes 1 Auto add mixer Recipes 10 Auto add Sifter Recipe 100 Auto add + * MetalWorking(sticks, plates) Recipe 1000 Auto add MetalWorking(crafting components) Recipe 10000 + */ + public byte extraRecipes; + + /* + * Here so that new recipes don't fuck with existing functionality Auto add Crafting Metal Solidifier recipes 1 + * Auto add Meta Crafting Metal Solidifier recipes 10 Auto add Multiple Ingot Metal Solidifier recipes 100 + * (Unused) + */ + public byte extraRecipes2; + + public short mixCircuit = -1; + + public Werkstoff.GenerationFeatures setBlacklist(OrePrefixes p) { + this.blacklist |= getPrefixDataRaw(p); + return this; + } + + @Deprecated + public boolean hasDusts() { + return (this.toGenerate & 0b1) != 0; + } + + @Deprecated + public boolean hasGems() { + return (this.toGenerate & 0b100) != 0; + } + + @Deprecated + public boolean hasOres() { + return (this.toGenerate & 0b1000) != 0; + } + + public Werkstoff.GenerationFeatures enforceUnification() { + this.enforceUnification = true; + return this; + } + + @Deprecated + public Werkstoff.GenerationFeatures removeGems() { + if (this.hasGems()) this.toGenerate = this.toGenerate ^ 0b100; + return this; + } + + @Deprecated + public Werkstoff.GenerationFeatures removeDusts() { + if (this.hasDusts()) this.toGenerate = this.toGenerate ^ 0b1; + return this; + } + + @Deprecated + public Werkstoff.GenerationFeatures removeOres() { + if (this.hasOres()) this.toGenerate = this.toGenerate ^ 0b1000; + return this; + } + + public Werkstoff.GenerationFeatures addChemicalRecipes() { + this.extraRecipes = (byte) (this.extraRecipes | 1); + return this; + } + + public boolean hasChemicalRecipes() { + return (this.extraRecipes & 1) != 0; + } + + public Werkstoff.GenerationFeatures addMetalCraftingSolidifierRecipes() { + this.extraRecipes2 = (byte) (this.extraRecipes2 | 1); + return this; + } + + public boolean hasMetalCraftingSolidifierRecipes() { + return (this.extraRecipes2 & 1) != 0; + } + + public Werkstoff.GenerationFeatures addMetaSolidifierRecipes() { + this.extraRecipes2 = (byte) (this.extraRecipes2 | 10); + return this; + } + + public boolean hasMetaSolidifierRecipes() { + return (this.extraRecipes2 & 10) != 0; + } + + public Werkstoff.GenerationFeatures addMultipleMetalSolidifierRecipes() { + this.extraRecipes2 = (byte) (this.extraRecipes2 | 100); + return this; + } + + public boolean hasMultipleMetalSolidifierRecipes() { + return (this.extraRecipes2 & 100) != 0; + } + + public Werkstoff.GenerationFeatures addMixerRecipes() { + this.extraRecipes = (byte) (this.extraRecipes | 10); + return this; + } + + public Werkstoff.GenerationFeatures addMixerRecipes(short aCircuit) { + this.extraRecipes = (byte) (this.extraRecipes | 10); + if (aCircuit >= 1 && aCircuit <= 24) this.mixCircuit = aCircuit; + return this; + } + + public boolean hasMixerRecipes() { + return (this.extraRecipes & 10) != 0; + } + + public Werkstoff.GenerationFeatures addSifterRecipes() { + this.extraRecipes = (byte) (this.extraRecipes | 100); + return this; + } + + public boolean hasSifterRecipes() { + return (this.extraRecipes & 100) != 0; + } + + public Werkstoff.GenerationFeatures onlyDust() { + this.toGenerate = 0b1; + return this; + } + + /** + * Automatically adds Simple Metal Working Items + */ + public Werkstoff.GenerationFeatures addMetalItems() { + this.toGenerate = this.addSimpleMetalWorkingItems().toGenerate | 0b10; + return this; + } + + public Werkstoff.GenerationFeatures disable() { + this.toGenerate = 0; + return this; + } + + public Werkstoff.GenerationFeatures addCells() { + this.toGenerate = this.toGenerate | 0b10000; + return this; + } + + @Deprecated + public boolean hasCells() { + return (this.toGenerate & 0b10000) != 0; + } + + @Deprecated + public boolean hasMolten() { + return (this.toGenerate & 0b1000000) != 0; + } + + public Werkstoff.GenerationFeatures addMolten() { + this.toGenerate = this.toGenerate | 0b1000000; + return this; + } + + /** + * Automatically adds Simple Metal Working Items + */ + public Werkstoff.GenerationFeatures addGems() { + this.toGenerate = this.addSimpleMetalWorkingItems().toGenerate | 0x4; + return this; + } + + public Werkstoff.GenerationFeatures addSimpleMetalWorkingItems() { + this.toGenerate = this.toGenerate | 0b10000000; + return this; + } + + public Werkstoff.GenerationFeatures addCasings() { + this.toGenerate = this.toGenerate | 0x382; + return this; + } + + @Deprecated + public boolean hasSimpleMetalWorkingItems() { + return (this.toGenerate & 0b10000000) != 0; + } + + public Werkstoff.GenerationFeatures addCraftingMetalWorkingItems() { + this.toGenerate = this.toGenerate | 0x100; + return this; + } + + public Werkstoff.GenerationFeatures addMultipleIngotMetalWorkingItems() { + this.toGenerate = this.toGenerate | 0x200; + return this; + } + + public Werkstoff.GenerationFeatures addPrefix(OrePrefixes prefixes) { + this.toGenerate = this.toGenerate | getPrefixDataRaw(prefixes); + return this; + } + + public Werkstoff.GenerationFeatures removePrefix(OrePrefixes prefixes) { + this.toGenerate = this.toGenerate ^ getPrefixDataRaw(prefixes); + return this; + } + } + + public static class Stats { + + public static final int NULL_KELVIN = 0; + + int boilingPoint; + + public int getBoilingPoint() { + return this.boilingPoint; + } + + public Werkstoff.Stats setBoilingPoint(int boilingPoint) { + this.boilingPoint = boilingPoint; + return this; + } + + public long getMass() { + return this.mass; + } + + public long getProtons() { + return this.protons; + } + + public int getMeltingPoint() { + return this.meltingPoint; + } + + public Werkstoff.Stats setMeltingPoint(int meltingPoint) { + this.meltingPoint = meltingPoint; + return this; + } + + public double getEbfGasRecipeTimeMultiplier() { + return this.ebfGasRecipeTimeMultiplier; + } + + /** + * The generated EBF recipes using this gas will have their duration multiplied by this number. If set to a + * negative value, the default proton count-based logic is used. See also + * {@link gregtech.api.util.BlastFurnaceGasStat} + */ + public Werkstoff.Stats setEbfGasRecipeTimeMultiplier(double timeMultiplier) { + this.ebfGasRecipeTimeMultiplier = timeMultiplier; + return this; + } + + public double getEbfGasRecipeConsumedAmountMultiplier() { + return this.ebfGasRecipeConsumedAmountMultiplier; + } + + /** + * The generated EBF recipes using this gas will have the amount of gas consumed multiplied by this number. See + * also {@link gregtech.api.util.BlastFurnaceGasStat} + */ + public Werkstoff.Stats setEbfGasRecipeConsumedAmountMultiplier(double amountMultiplier) { + this.ebfGasRecipeConsumedAmountMultiplier = amountMultiplier; + return this; + } + + public int getDurOverride() { + return this.durOverride; + } + + public Werkstoff.Stats setDurOverride(int durOverride) { + this.durOverride = durOverride; + return this; + } + + public float getSpeedOverride() { + return this.speedOverride; + } + + public Werkstoff.Stats setSpeedOverride(float speedOverride) { + this.speedOverride = speedOverride; + return this; + } + + public byte getQualityOverride() { + return this.qualityOverride; + } + + public Werkstoff.Stats setQualityOverride(byte qualityOverride) { + this.qualityOverride = qualityOverride; + return this; + } + + private byte qualityOverride; + private int durOverride; + private float speedOverride; + private int meltingPoint; + private int meltingVoltage; + private long protons; + private long neutrons; + private long electrons; + private long mass; + private double ebfGasRecipeTimeMultiplier = -1.0; + private double ebfGasRecipeConsumedAmountMultiplier = 1.0; + + float durMod = 1f; + + public float getDurMod() { + return this.durMod; + } + + public void setDurMod(float durMod) { + this.durMod = durMod; + } + + private Pair<Object, Integer>[] mTC_Aspects; + // logic gate shit + byte quality = ~0b1111111; + + public Werkstoff.Stats setmTC_AspectsArray(Pair<Object, Integer>[] mTC_Aspects) { + this.mTC_Aspects = mTC_Aspects; + return this; + } + + @SafeVarargs + public final Werkstoff.Stats setmTC_AspectsVarArg(Pair<Object, Integer>... mTC_Aspects) { + this.mTC_Aspects = mTC_Aspects; + return this; + } + + Pair<Object, Integer>[] getmTC_Aspects() { + return this.mTC_Aspects; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Werkstoff.Stats that)) return false; + + if (this.boilingPoint != that.boilingPoint || this.meltingPoint != that.meltingPoint + || this.mass != that.mass + || this.protons != that.protons) return false; + if (this.neutrons != that.neutrons) return false; + if (this.electrons != that.electrons) return false; + if (Math.abs(this.ebfGasRecipeTimeMultiplier - that.ebfGasRecipeTimeMultiplier) > 1.0e-6D) return false; + if (Math.abs(this.ebfGasRecipeConsumedAmountMultiplier - that.ebfGasRecipeConsumedAmountMultiplier) + > 1.0e-6D) return false; + return this.quality == that.quality; + } + + @Override + public int hashCode() { + return MurmurHash3.murmurhash3_x86_32( + ByteBuffer.allocate(49) + .put(this.quality) + .putInt(this.boilingPoint) + .putInt(this.meltingPoint) + .putLong(this.protons) + .putLong(this.neutrons) + .putLong(this.electrons) + .putLong(this.mass) + .putDouble(this.ebfGasRecipeTimeMultiplier) + .putDouble(this.ebfGasRecipeConsumedAmountMultiplier) + .array(), + 0, + 49, + 31); + } + + public Werkstoff.Stats setMass(long mass) { + this.mass = mass; + return this; + } + + public Werkstoff.Stats setProtons(long protons) { + this.protons = protons; + return this; + } + + public boolean isSublimation() { + return (this.quality & 0b1) != 0; + } + + public Werkstoff.Stats setSublimation(boolean sublimation) { + if (sublimation) this.quality = (byte) (this.quality | 0b000001); + else this.quality = (byte) (this.quality & 0b1111110); + return this; + } + + public boolean isToxic() { + return (this.quality & 0b10) != 0; + } + + public Werkstoff.Stats setToxic(boolean toxic) { + if (toxic) this.quality = (byte) (this.quality | 0b000010); + else this.quality = (byte) (this.quality & 0b1111101); + return this; + } + + byte enchantmentlvl = 3; + + public byte getEnchantmentlvl() { + return this.enchantmentlvl; + } + + public Werkstoff.Stats setEnchantmentlvl(byte enchantmentlvl) { + this.enchantmentlvl = enchantmentlvl; + return this; + } + + public boolean isRadioactive() { + return (this.quality & 0b100) != 0; + } + + public Werkstoff.Stats setRadioactive(boolean radioactive) { + if (radioactive) this.quality = (byte) (this.quality | 0b000100); + else this.quality = (byte) (this.quality & 0b1111011); + return this; + } + + public boolean isBlastFurnace() { + return (this.quality & 0b1000) != 0; + } + + public Werkstoff.Stats setBlastFurnace(boolean blastFurnace) { + if (blastFurnace) this.quality = (byte) (this.quality | 0b001000); + else this.quality = (byte) (this.quality & 0b1110111); + return this; + } + + public Werkstoff.Stats setMeltingVoltage(int meltingVoltage) { + this.meltingVoltage = meltingVoltage; + return this; + } + + public int getMeltingVoltage() { + return this.meltingVoltage; + } + + public boolean isElektrolysis() { + return (this.quality & 0x10) != 0; + } + + public Werkstoff.Stats setElektrolysis(boolean elektrolysis) { + if (elektrolysis) this.quality = (byte) (this.quality | 0x10); + else this.quality = (byte) (this.quality & 0b1101111); + return this; + } + + public boolean isCentrifuge() { + return (this.quality & 0x20) != 0; + } + + public Werkstoff.Stats setCentrifuge(boolean centrifuge) { + if (centrifuge) this.quality = (byte) (this.quality | 0x20); + else this.quality = (byte) (this.quality & 0b1011111); + return this; + } + + public boolean isGas() { + return (this.quality & 0x40) != 0; + } + + public FluidState getFluidState() { + if ((this.quality & 0x40) != 0) { + return FluidState.GAS; + } + return FluidState.LIQUID; + } + + public Werkstoff.Stats setGas(boolean gas) { + if (gas) this.quality = (byte) (this.quality | 0x40); + else this.quality = (byte) (this.quality & 0b0111111); + return this; + } + } +} diff --git a/src/main/java/bartworks/system/material/WerkstoffLoader.java b/src/main/java/bartworks/system/material/WerkstoffLoader.java new file mode 100644 index 0000000000..d5c9337a7c --- /dev/null +++ b/src/main/java/bartworks/system/material/WerkstoffLoader.java @@ -0,0 +1,2105 @@ +/* + * 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.system.material; + +import static bartworks.util.BWUtil.subscriptNumbers; +import static bartworks.util.BWUtil.superscriptNumbers; +import static gregtech.api.enums.Mods.BetterLoadingScreen; +import static gregtech.api.enums.Mods.Forestry; +import static gregtech.api.enums.OrePrefixes.block; +import static gregtech.api.enums.OrePrefixes.bolt; +import static gregtech.api.enums.OrePrefixes.bottle; +import static gregtech.api.enums.OrePrefixes.capsule; +import static gregtech.api.enums.OrePrefixes.cell; +import static gregtech.api.enums.OrePrefixes.cellPlasma; +import static gregtech.api.enums.OrePrefixes.crushed; +import static gregtech.api.enums.OrePrefixes.crushedCentrifuged; +import static gregtech.api.enums.OrePrefixes.crushedPurified; +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.dustImpure; +import static gregtech.api.enums.OrePrefixes.dustPure; +import static gregtech.api.enums.OrePrefixes.dustSmall; +import static gregtech.api.enums.OrePrefixes.dustTiny; +import static gregtech.api.enums.OrePrefixes.foil; +import static gregtech.api.enums.OrePrefixes.gearGt; +import static gregtech.api.enums.OrePrefixes.gearGtSmall; +import static gregtech.api.enums.OrePrefixes.gem; +import static gregtech.api.enums.OrePrefixes.gemChipped; +import static gregtech.api.enums.OrePrefixes.gemExquisite; +import static gregtech.api.enums.OrePrefixes.gemFlawed; +import static gregtech.api.enums.OrePrefixes.gemFlawless; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.enums.OrePrefixes.ingotDouble; +import static gregtech.api.enums.OrePrefixes.ingotHot; +import static gregtech.api.enums.OrePrefixes.ingotQuadruple; +import static gregtech.api.enums.OrePrefixes.ingotQuintuple; +import static gregtech.api.enums.OrePrefixes.ingotTriple; +import static gregtech.api.enums.OrePrefixes.lens; +import static gregtech.api.enums.OrePrefixes.nugget; +import static gregtech.api.enums.OrePrefixes.ore; +import static gregtech.api.enums.OrePrefixes.oreSmall; +import static gregtech.api.enums.OrePrefixes.plate; +import static gregtech.api.enums.OrePrefixes.plateDense; +import static gregtech.api.enums.OrePrefixes.plateDouble; +import static gregtech.api.enums.OrePrefixes.plateQuadruple; +import static gregtech.api.enums.OrePrefixes.plateQuintuple; +import static gregtech.api.enums.OrePrefixes.plateTriple; +import static gregtech.api.enums.OrePrefixes.rawOre; +import static gregtech.api.enums.OrePrefixes.ring; +import static gregtech.api.enums.OrePrefixes.rotor; +import static gregtech.api.enums.OrePrefixes.screw; +import static gregtech.api.enums.OrePrefixes.spring; +import static gregtech.api.enums.OrePrefixes.springSmall; +import static gregtech.api.enums.OrePrefixes.stick; +import static gregtech.api.enums.OrePrefixes.stickLong; +import static gregtech.api.enums.OrePrefixes.toolHeadHammer; +import static gregtech.api.enums.OrePrefixes.toolHeadSaw; +import static gregtech.api.enums.OrePrefixes.toolHeadWrench; +import static gregtech.api.enums.OrePrefixes.turbineBlade; +import static gregtech.api.enums.OrePrefixes.values; +import static gregtech.api.enums.OrePrefixes.wireFine; +import static gregtech.api.util.GTRecipeBuilder.WILDCARD; + +import java.lang.reflect.Field; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.oredict.OreDictionary; + +import org.apache.logging.log4j.Level; + +import com.google.common.collect.HashBiMap; + +import bartworks.API.SideReference; +import bartworks.API.WerkstoffAdderRegistry; +import bartworks.MainMod; +import bartworks.client.renderer.BWBlockOreRenderer; +import bartworks.common.configs.ConfigHandler; +import bartworks.system.material.CircuitGeneration.BWCircuitsLoader; +import bartworks.system.material.gtenhancement.GTMetaItemEnhancer; +import bartworks.system.material.processingLoaders.AdditionalRecipes; +import bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; +import bartworks.system.material.werkstoff_loaders.recipe.AspectLoader; +import bartworks.system.material.werkstoff_loaders.recipe.BlockLoader; +import bartworks.system.material.werkstoff_loaders.recipe.CasingLoader; +import bartworks.system.material.werkstoff_loaders.recipe.CellLoader; +import bartworks.system.material.werkstoff_loaders.recipe.CraftingMaterialLoader; +import bartworks.system.material.werkstoff_loaders.recipe.CrushedLoader; +import bartworks.system.material.werkstoff_loaders.recipe.DustLoader; +import bartworks.system.material.werkstoff_loaders.recipe.GemLoader; +import bartworks.system.material.werkstoff_loaders.recipe.MetalLoader; +import bartworks.system.material.werkstoff_loaders.recipe.MoltenCellLoader; +import bartworks.system.material.werkstoff_loaders.recipe.MultipleMetalLoader; +import bartworks.system.material.werkstoff_loaders.recipe.OreLoader; +import bartworks.system.material.werkstoff_loaders.recipe.RawOreLoader; +import bartworks.system.material.werkstoff_loaders.recipe.SimpleMetalLoader; +import bartworks.system.material.werkstoff_loaders.recipe.ToolLoader; +import bartworks.system.material.werkstoff_loaders.registration.AssociationLoader; +import bartworks.system.material.werkstoff_loaders.registration.BridgeMaterialsLoader; +import bartworks.system.material.werkstoff_loaders.registration.CasingRegistrator; +import bartworks.system.oredict.OreDictHandler; +import bartworks.util.BWColorUtil; +import bartworks.util.EnumUtils; +import bartworks.util.Pair; +import bartworks.util.log.DebugLog; +import bwcrossmod.cls.CLSCompat; +import codechicken.nei.api.API; +import cpw.mods.fml.common.ProgressManager; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.Element; +import gregtech.api.enums.FluidState; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SubTag; +import gregtech.api.enums.TextureSet; +import gregtech.api.fluid.GTFluidFactory; +import gregtech.api.interfaces.ISubTagContainer; +import gregtech.api.util.GTOreDictUnificator; +import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeInputOreDict; +import ic2.api.recipe.RecipeOutput; +import ic2.api.recipe.Recipes; + +@SuppressWarnings("deprecation") +public class WerkstoffLoader { + + private WerkstoffLoader() {} + + public static final SubTag NOBLE_GAS = SubTag.getNewSubTag("NobleGas"); + public static final SubTag ANAEROBE_GAS = SubTag.getNewSubTag("AnaerobeGas"); + public static final SubTag ANAEROBE_SMELTING = SubTag.getNewSubTag("AnaerobeSmelting"); + public static final SubTag NOBLE_GAS_SMELTING = SubTag.getNewSubTag("NobleGasSmelting"); + public static final SubTag NO_BLAST = SubTag.getNewSubTag("NoBlast"); + public static ItemList rotorMold; + public static ItemList rotorShape; + public static ItemList smallGearShape; + public static ItemList ringMold; + public static ItemList boltMold; + + public static void setUp() { + + OrePrefixes.cellMolten.mMaterialGenerationBits = 0b1000000; + OrePrefixes.capsuleMolten.mMaterialGenerationBits = 0b1000000; + + try { + WerkstoffLoader.rotorMold = Enum.valueOf(ItemList.class, "Shape_Mold_Rotor"); + WerkstoffLoader.rotorShape = Enum.valueOf(ItemList.class, "Shape_Extruder_Rotor"); + WerkstoffLoader.smallGearShape = Enum.valueOf(ItemList.class, "Shape_Extruder_Small_Gear"); + WerkstoffLoader.ringMold = Enum.valueOf(ItemList.class, "Shape_Mold_Ring"); + WerkstoffLoader.boltMold = Enum.valueOf(ItemList.class, "Shape_Mold_Bolt"); + } catch (NullPointerException | IllegalArgumentException ignored) {} + + // add tiberium + EnumUtils.createNewElement("Tr", 123L, 203L, 0L, -1L, null, "Tiberium", false); + + bottle.mDefaultStackSize = 1; + Werkstoff.GenerationFeatures.initPrefixLogic(); + BWGTMaterialReference.init(); + } + + // TODO: + // FREE ID RANGE: 12_000-28_998 + // bartimaeusnek reserved 0-10_000 + // GlodBlock reserved range 10_001-10_999 + // Elisis reserved range 11_000-11_499 + // glowredman reserved range 11_500-11_999 + // bot reserved range 29_899-29_999 + // Tec & basdxz reserved range 30_000-31_000 + // GT Material range reserved on 31_767-32_767 + public static final Werkstoff Bismutite = new Werkstoff( + new short[] { 255, 233, 0, 0 }, + "Bismutite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 1, + TextureSet.SET_FLINT, + Collections.singletonList(Materials.Bismuth), + new Pair<>(Materials.Bismuth, 2), + new Pair<>(Materials.Oxygen, 2), + new Pair<>(Materials.CarbonDioxide, 2)); + public static final Werkstoff Bismuthinit = new Werkstoff( + new short[] { 192, 192, 192, 0 }, + "Bismuthinite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 2, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Bismuth, Materials.Sulfur), + new Pair<>(Materials.Bismuth, 2), + new Pair<>(Materials.Sulfur, 3)); + public static final Werkstoff Zirconium = new Werkstoff( + new short[] { 175, 175, 175, 0 }, + "Zirconium", + "Zr", + new Werkstoff.Stats().setProtons(40) + .setBlastFurnace(true) + .setMeltingPoint(2130) + .setMeltingVoltage(480), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addMetalItems() + .enforceUnification(), + 3, + TextureSet.SET_METALLIC + // No Byproducts + ); + public static final Werkstoff CubicZirconia = new Werkstoff( + new short[] { 255, 255, 255, 0 }, + "Cubic Zirconia", + Werkstoff.Types.COMPOUND, + 3273, + new Werkstoff.GenerationFeatures().onlyDust() + .addGems() + .enforceUnification(), + 4, + TextureSet.SET_DIAMOND, + Collections.singletonList(WerkstoffLoader.Zirconium), + new Pair<>(WerkstoffLoader.Zirconium, 1), + new Pair<>(Materials.Oxygen, 2)); + public static final Werkstoff FluorBuergerit = new Werkstoff( + new short[] { 0x20, 0x20, 0x20, 0 }, + "Fluor-Buergerite", + subscriptNumbers("NaFe3Al6(Si6O18)(BO3)3O3F"), + new Werkstoff.Stats().setElektrolysis(false), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 5, + TextureSet.SET_RUBY, + Arrays.asList(Materials.Sodium, Materials.Boron, Materials.SiliconDioxide), + new Pair<>(Materials.Sodium, 1), + new Pair<>(Materials.Iron, 3), + new Pair<>(Materials.Aluminium, 6), + new Pair<>(Materials.Silicon, 6), + new Pair<>(Materials.Boron, 3), + new Pair<>(Materials.Oxygen, 30), + new Pair<>(Materials.Fluorine, 1)); + public static final Werkstoff YttriumOxide = new Werkstoff( + new short[] { 255, 255, 255, 0 }, + "Yttrium Oxide", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().onlyDust() + .enforceUnification(), // No autoadd here to gate this material + // by hand + 6, + TextureSet.SET_DULL, + new Pair<>(Materials.Yttrium, 2), + new Pair<>(Materials.Oxygen, 3)); + public static final Werkstoff ChromoAluminoPovondrait = new Werkstoff( + new short[] { 0, 0x79, 0x6A, 0 }, + "Chromo-Alumino-Povondraite", + subscriptNumbers("NaCr3(Al4Mg2)(Si6O18)(BO3)3(OH)3O"), + Werkstoff.Types.getDefaultStatForType(Werkstoff.Types.COMPOUND) + .setElektrolysis(false), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 7, + TextureSet.SET_RUBY, + Arrays.asList(Materials.Sodium, Materials.Boron, Materials.SiliconDioxide), + new Pair<>(Materials.Sodium, 1), + new Pair<>(Materials.Chrome, 3), + new Pair<>(Materials.Magnalium, 6), + new Pair<>(Materials.Silicon, 6), + new Pair<>(Materials.Boron, 3), + new Pair<>(Materials.Oxygen, 31), + new Pair<>(Materials.Hydrogen, 3)); + public static final Werkstoff VanadioOxyDravit = new Werkstoff( + new short[] { 0x60, 0xA0, 0xA0, 0 }, + "Vanadio-Oxy-Dravite", + subscriptNumbers("NaV3(Al4Mg2)(Si6O18)(BO3)3(OH)3O"), + Werkstoff.Types.getDefaultStatForType(Werkstoff.Types.COMPOUND) + .setElektrolysis(false), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 8, + TextureSet.SET_RUBY, + Arrays.asList(Materials.Sodium, Materials.Boron, Materials.SiliconDioxide), + new Pair<>(Materials.Sodium, 1), + new Pair<>(Materials.Vanadium, 3), + new Pair<>(Materials.Magnalium, 6), + new Pair<>(Materials.Silicon, 6), + new Pair<>(Materials.Boron, 3), + new Pair<>(Materials.Oxygen, 31), + new Pair<>(Materials.Hydrogen, 3)); + public static final Werkstoff Olenit = new Werkstoff( + new short[] { 210, 210, 210, 0 }, + "Olenite", + subscriptNumbers("NaAl3Al6(Si6O18)(BO3)3O3OH"), + Werkstoff.Types.getDefaultStatForType(Werkstoff.Types.COMPOUND) + .setElektrolysis(false), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 9, + TextureSet.SET_RUBY, + Arrays.asList(Materials.Sodium, Materials.Boron, Materials.SiliconDioxide), + new Pair<>(Materials.Sodium, 1), + new Pair<>(Materials.Aluminium, 9), + new Pair<>(Materials.Silicon, 6), + new Pair<>(Materials.Boron, 3), + new Pair<>(Materials.Oxygen, 31), + new Pair<>(Materials.Hydrogen, 1)); + public static final Werkstoff Arsenopyrite = new Werkstoff( + new short[] { 0xB0, 0xB0, 0xB0, 0 }, + "Arsenopyrite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 10, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Sulfur, Materials.Arsenic, Materials.Iron), + new Pair<>(Materials.Iron, 1), + new Pair<>(Materials.Arsenic, 1), + new Pair<>(Materials.Sulfur, 1)); + public static final Werkstoff Ferberite = new Werkstoff( + new short[] { 0xB0, 0xB0, 0xB0, 0 }, + "Ferberite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 11, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Iron, Materials.Tungsten), + new Pair<>(Materials.Iron, 1), + new Pair<>(Materials.Tungsten, 1), + new Pair<>(Materials.Oxygen, 3)); + public static final Werkstoff Loellingit = new Werkstoff( + new short[] { 0xD0, 0xD0, 0xD0, 0 }, + "Loellingite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 12, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Iron, Materials.Arsenic), + new Pair<>(Materials.Iron, 1), + new Pair<>(Materials.Arsenic, 2)); + public static final Werkstoff Roquesit = new Werkstoff( + new short[] { 0xA0, 0xA0, 0xA0, 0 }, + "Roquesite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 13, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Copper, Materials.Sulfur), + new Pair<>(Materials.Copper, 1), + new Pair<>(Materials.Indium, 1), + new Pair<>(Materials.Sulfur, 2)); + public static final Werkstoff Bornite = new Werkstoff( + new short[] { 0x97, 0x66, 0x2B, 0 }, + "Bornite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 14, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Copper, Materials.Iron, Materials.Sulfur), + new Pair<>(Materials.Copper, 5), + new Pair<>(Materials.Iron, 1), + new Pair<>(Materials.Sulfur, 4)); + public static final Werkstoff Wittichenit = new Werkstoff( + Materials.Copper.mRGBa, + "Wittichenite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 15, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Copper, Materials.Bismuth, Materials.Sulfur), + new Pair<>(Materials.Copper, 5), + new Pair<>(Materials.Bismuth, 1), + new Pair<>(Materials.Sulfur, 4)); + public static final Werkstoff Djurleit = new Werkstoff( + new short[] { 0x60, 0x60, 0x60, 0 }, + "Djurleite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 16, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Copper, Materials.Copper, Materials.Sulfur), + new Pair<>(Materials.Copper, 31), + new Pair<>(Materials.Sulfur, 16)); + public static final Werkstoff Huebnerit = new Werkstoff( + new short[] { 0x80, 0x60, 0x60, 0 }, + "Huebnerite", + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 17, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Manganese, Materials.Tungsten), + new Pair<>(Materials.Manganese, 1), + new Pair<>(Materials.Tungsten, 1), + new Pair<>(Materials.Oxygen, 3)); + public static final Werkstoff Thorianit = new Werkstoff( + new short[] { 0x30, 0x30, 0x30, 0 }, + "Thorianite", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 18, + TextureSet.SET_METALLIC, + Collections.singletonList(Materials.Thorium), + new Pair<>(Materials.Thorium, 1), + new Pair<>(Materials.Oxygen, 2)); + public static final Werkstoff RedZircon = new Werkstoff( + new short[] { 195, 19, 19, 0 }, + "Red Zircon", + new Werkstoff.Stats().setElektrolysis(false) + .setMeltingPoint(2130), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 19, + TextureSet.SET_GEM_VERTICAL, + Arrays.asList(WerkstoffLoader.Zirconium, Materials.SiliconDioxide), + new Pair<>(WerkstoffLoader.Zirconium, 1), + new Pair<>(Materials.Silicon, 1), + new Pair<>(Materials.Oxygen, 4)); + + // GT Enhancements + public static final Werkstoff Salt = new Werkstoff( + Materials.Salt.mRGBa, + "Salt", + new Werkstoff.Stats(), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .addGems() + .addSifterRecipes(), + 20, + TextureSet.SET_FLINT, + Arrays.asList(Materials.RockSalt, Materials.Borax), + new Pair<>(Materials.Salt, 1)); + public static final Werkstoff Spodumen = new Werkstoff( + Materials.Spodumene.mRGBa, + "Spodumene", + new Werkstoff.Stats(), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .addGems() + .addSifterRecipes(), + 21, + TextureSet.SET_FLINT, + Collections.singletonList(Materials.Spodumene), + new Pair<>(Materials.Spodumene, 1)); + public static final Werkstoff RockSalt = new Werkstoff( + Materials.RockSalt.mRGBa, + "Rock Salt", + new Werkstoff.Stats(), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .addGems() + .addSifterRecipes(), + 22, + TextureSet.SET_FLINT, + Arrays.asList(Materials.RockSalt, Materials.Borax), + new Pair<>(Materials.RockSalt, 1)); + + // More NonGT Stuff + public static final Werkstoff Fayalit = new Werkstoff( + new short[] { 50, 50, 50, 0 }, + "Fayalite", + new Werkstoff.Stats().setElektrolysis(false), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 23, + TextureSet.SET_QUARTZ, + Arrays.asList(Materials.Iron, Materials.SiliconDioxide), + new Pair<>(Materials.Iron, 2), + new Pair<>(Materials.Silicon, 1), + new Pair<>(Materials.Oxygen, 4)); + public static final Werkstoff Forsterit = new Werkstoff( + new short[] { 255, 255, 255, 0 }, + "Forsterite", + new Werkstoff.Stats().setElektrolysis(false), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 24, + TextureSet.SET_QUARTZ, + Arrays.asList(Materials.Magnesium, Materials.SiliconDioxide), + new Pair<>(Materials.Magnesium, 2), + new Pair<>(Materials.Silicon, 1), + new Pair<>(Materials.Oxygen, 4)); + public static final Werkstoff Hedenbergit = new Werkstoff( + new short[] { 100, 150, 100, 0 }, + "Hedenbergite", + new Werkstoff.Stats().setElektrolysis(false), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 25, + TextureSet.SET_QUARTZ, + Arrays.asList(Materials.Iron, Materials.Calcium, Materials.SiliconDioxide), + new Pair<>(Materials.Calcium, 1), + new Pair<>(Materials.Iron, 1), + new Pair<>(Materials.Silicon, 2), + new Pair<>(Materials.Oxygen, 6)); + public static final Werkstoff DescloiziteZNVO4 = new Werkstoff( + new short[] { 0xBF, 0x18, 0x0F, 0 }, + "Red Descloizite", // Pb(Zn,Cu)[OH|VO4 + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 26, + TextureSet.SET_QUARTZ, + Arrays.asList(Materials.Lead, Materials.Copper, Materials.Vanadium), + new Pair<>(Materials.Lead, 1), + new Pair<>(Materials.Zinc, 1), + new Pair<>(Materials.Vanadium, 1), + new Pair<>(Materials.Oxygen, 4)); + public static final Werkstoff DescloiziteCUVO4 = new Werkstoff( + new short[] { 0xf9, 0x6d, 0x18, 0 }, + "Orange Descloizite", // Pb(Zn,Cu)[OH|VO4 + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 27, + TextureSet.SET_QUARTZ, + Arrays.asList(Materials.Lead, Materials.Zinc, Materials.Vanadium), + new Pair<>(Materials.Lead, 1), + new Pair<>(Materials.Copper, 1), + new Pair<>(Materials.Vanadium, 1), + new Pair<>(Materials.Oxygen, 4)); + public static final Werkstoff FuchsitAL = new Werkstoff( + new short[] { 0x4D, 0x7F, 0x64, 0 }, + "Green Fuchsite", + subscriptNumbers("KAl3Si3O10(OH)2"), + new Werkstoff.Stats().setElektrolysis(false), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 28, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Potassium, Materials.Aluminiumoxide, Materials.SiliconDioxide), + new Pair<>(Materials.Potassium, 1), + new Pair<>(Materials.Aluminium, 3), + new Pair<>(Materials.Silicon, 3), + new Pair<>(Materials.Oxygen, 12), + new Pair<>(Materials.Hydrogen, 2)); + + public static final Werkstoff FuchsitCR = new Werkstoff( + new short[] { 128, 0, 0, 0 }, + "Red Fuchsite", + subscriptNumbers("KCr3Si3O10(OH)2"), + new Werkstoff.Stats().setElektrolysis(false), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 29, + TextureSet.SET_METALLIC, + Arrays.asList(Materials.Potassium, Materials.Chrome, Materials.SiliconDioxide), + new Pair<>(Materials.Potassium, 1), + new Pair<>(Materials.Chrome, 3), + new Pair<>(Materials.Silicon, 3), + new Pair<>(Materials.Oxygen, 12), + new Pair<>(Materials.Hydrogen, 2)); + + public static final Werkstoff Thorium232 = new Werkstoff( + new short[] { 0, 64, 0, 0 }, + "Thorium 232", + superscriptNumbers("Th232"), + new Werkstoff.Stats().setRadioactive(true) + .setBlastFurnace(true) + .setMass(232) + .setProtons(Element.Th.mProtons), + Werkstoff.Types.ISOTOPE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addMetalItems() + .enforceUnification(), + 30, + TextureSet.SET_METALLIC + // No Byproducts + ); + public static final Werkstoff BismuthTellurite = new Werkstoff( + new short[] { 32, 72, 32, 0 }, + // Telluride is correct, tellurite is not. + // Only the display name gets renamed to avoid problems in other mods + "Bismuth Telluride", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addChemicalRecipes(), + 31, + TextureSet.SET_METALLIC, + // No Byproducts + new Pair<>(Materials.Bismuth, 2), + new Pair<>(Materials.Tellurium, 3)); + public static final Werkstoff Tellurium = new Werkstoff( + new short[] { 0xff, 0xff, 0xff, 0 }, + "Tellurium", + new Werkstoff.Stats(), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().addMetalItems() + .removePrefix(ore), + 32, + TextureSet.SET_METALLIC, + // No Byproducts + new Pair<>(Materials.Tellurium, 1)); + public static final Werkstoff BismuthHydroBorat = new Werkstoff( + new short[] { 72, 144, 72, 0 }, + "Dibismuthhydroborat", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addChemicalRecipes(), + 33, + TextureSet.SET_METALLIC, + // No Byproducts + new Pair<>(Materials.Bismuth, 2), + new Pair<>(Materials.Boron, 1), + new Pair<>(Materials.Hydrogen, 1)); + public static final Werkstoff ArInGaPhoBiBoTe = new Werkstoff( + new short[] { 36, 36, 36, 0 }, + "Circuit Compound MK3", + new Werkstoff.Stats().setCentrifuge(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addMixerRecipes(), + 34, + TextureSet.SET_METALLIC, + // No Byproducts + new Pair<>(Materials.IndiumGalliumPhosphide, 1), + new Pair<>(WerkstoffLoader.BismuthHydroBorat, 3), + new Pair<>(WerkstoffLoader.BismuthTellurite, 2)); + + public static final Werkstoff Prasiolite = new Werkstoff( + new short[] { 0xD0, 0xDD, 0x95, 0 }, + "Prasiolite", + new Werkstoff.Stats().setElektrolysis(false) + .setMeltingPoint(1923), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 35, + TextureSet.SET_QUARTZ, + // No Byproducts + new Pair<>(Materials.Silicon, 5), + new Pair<>(Materials.Oxygen, 10), + new Pair<>(Materials.Iron, 1)); + + public static final Werkstoff MagnetoResonaticDust = new Werkstoff( + new short[] { 0xDD, 0x77, 0xDD, 0 }, + "Magneto Resonatic", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().onlyDust() + .addMixerRecipes() + .addGems(), + 36, + TextureSet.SET_MAGNETIC, + // No Byproducts + new Pair<>(WerkstoffLoader.Prasiolite, 3), + new Pair<>(WerkstoffLoader.BismuthTellurite, 4), + new Pair<>(WerkstoffLoader.CubicZirconia, 1), + new Pair<>(Materials.SteelMagnetic, 1)); + public static final Werkstoff Xenon = new Werkstoff( + new short[] { 0x14, 0x39, 0x7F, 0 }, + "Xenon", + "Xe", + new Werkstoff.Stats().setProtons(54) + .setMass(131) + .setGas(true) + .setEbfGasRecipeTimeMultiplier(0.4d) + .setEbfGasRecipeConsumedAmountMultiplier(0.25d), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().disable() + .addCells() + .enforceUnification(), + 37, + TextureSet.SET_FLUID + // No Byproducts + // No Ingredients + ); + public static final Werkstoff Oganesson = new Werkstoff( + new short[] { 0x14, 0x39, 0x7F, 0 }, + "Oganesson", + "Og", + new Werkstoff.Stats().setProtons(118) + .setMass(294) + .setGas(true) + .setEbfGasRecipeTimeMultiplier(0.3d) + .setEbfGasRecipeConsumedAmountMultiplier(0.1d), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 38, + TextureSet.SET_FLUID + // No Byproducts + // No Ingredients + ); + public static final Werkstoff Californium = new Werkstoff( + new short[] { 0xAA, 0xAA, 0xAA, 0 }, + "Californium", + "Cf", + new Werkstoff.Stats().setProtons(98) + .setMass(251) + .setBlastFurnace(true) + .setMeltingPoint(900), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addMetalItems() + .addMolten() + .enforceUnification(), + 39, + TextureSet.SET_METALLIC + // No Byproducts + // No Ingredients + ); + public static final Werkstoff Calcium = new Werkstoff( + Materials.Calcium.mRGBa, + "Calcium", + "Ca", + new Werkstoff.Stats().setProtons(Element.Ca.mProtons) + .setMass(Element.Ca.getMass()) + .setBlastFurnace(true) + .setMeltingPoint(1115) + .setBoilingPoint(1757), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addMetalItems() + .addMolten(), + 40, + Materials.Calcium.mIconSet, + // No Byproducts + new Pair<>(Materials.Calcium, 1)); + public static final Werkstoff Neon = new Werkstoff( + new short[] { 0xff, 0x07, 0x3a }, + "Neon", + "Ne", + new Werkstoff.Stats().setProtons(Element.Ne.mProtons) + .setMass(Element.Ne.getMass()) + .setGas(true) + .setEbfGasRecipeTimeMultiplier(0.6d) + .setEbfGasRecipeConsumedAmountMultiplier(0.55d), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().disable() + .addCells() + .enforceUnification(), + 41, + TextureSet.SET_FLUID + // No Byproducts + // No Ingredients + ); + public static final Werkstoff Krypton = new Werkstoff( + new short[] { 0xb1, 0xff, 0x32 }, + "Krypton", + "Kr", + new Werkstoff.Stats().setProtons(Element.Kr.mProtons) + .setMass(Element.Kr.getMass()) + .setGas(true) + .setEbfGasRecipeTimeMultiplier(0.5d) + .setEbfGasRecipeConsumedAmountMultiplier(0.4d), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().disable() + .addCells() + .enforceUnification(), + 42, + TextureSet.SET_FLUID + // No Byproducts + // No Ingredients + ); + public static final Werkstoff BArTiMaEuSNeK = new Werkstoff( + new short[] { 0x00, 0xff, 0x00 }, + "BArTiMaEuSNeK", + "Are you serious?", + new Werkstoff.Stats().setMeltingPoint(9001) + .setCentrifuge(true) + .setBlastFurnace(true) + .setMeltingVoltage(1920), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems() + .addMetalItems() + .addMolten(), + 43, + TextureSet.SET_DIAMOND, + Arrays.asList(Materials.Boron, Materials.Titanium, Materials.Europium), + new Pair<>(Materials.Boron, 1), + new Pair<>(Materials.Argon, 1), + new Pair<>(Materials.Titanium, 1), + new Pair<>(Materials.Magic, 1), + new Pair<>(Materials.Europium, 1), + new Pair<>(Materials.Sulfur, 1), + new Pair<>(WerkstoffLoader.Neon, 1), + new Pair<>(Materials.Potassium, 1)); + public static final Werkstoff PTConcentrate = new Werkstoff( + Materials.Platinum.getRGBA(), + "Platinum Concentrate", + "", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 44, + TextureSet.SET_FLUID + // No Byproducts + // No Ingredients + ); + public static final Werkstoff PTSaltCrude = new Werkstoff( + Materials.Platinum.getRGBA(), + "Platinum Salt", + "", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 45, + TextureSet.SET_DULL + // No Byproducts + // No Ingredients + ); + public static final Werkstoff PTSaltRefined = new Werkstoff( + Materials.Platinum.getRGBA(), + "Refined Platinum Salt", + "", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 46, + TextureSet.SET_METALLIC + // No Byproducts + // No Ingredients + ); + public static final Werkstoff PTMetallicPowder = new Werkstoff( + Materials.Platinum.getRGBA(), + "Platinum Metallic Powder", + "??PtPdIrOsRhRu??", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures(), + 47, + TextureSet.SET_METALLIC, + // No Byproducts + new Pair<>(Materials.Platinum, 1), + new Pair<>(Materials.Stone, 2)); + public static final Werkstoff AquaRegia = new Werkstoff( + new short[] { 0xff, 0xb1, 0x32 }, + "Aqua Regia", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 48, + TextureSet.SET_FLUID, + // No Byproducts + new Pair<>(Materials.DilutedSulfuricAcid, 1), + new Pair<>(Materials.NitricAcid, 1)); + public static final Werkstoff PTResidue = new Werkstoff( + new short[] { 0x64, 0x63, 0x2E }, + "Platinum Residue", + "??IrOsRhRu??", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 49, + TextureSet.SET_ROUGH + // No Byproducts + ); + public static final Werkstoff AmmoniumChloride = new Werkstoff( + new short[] { 0xff, 0xff, 0xff }, + "Ammonium Chloride", + subscriptNumbers("NH4Cl"), + new Werkstoff.Stats(), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 50, + TextureSet.SET_FLUID, + // No Byproducts + new Pair<>(Materials.Ammonium, 1), + new Pair<>(Materials.HydrochloricAcid, 1)); + public static final Werkstoff PTRawPowder = new Werkstoff( + Materials.Platinum.getRGBA(), + "Reprecipitated Platinum", + "PtCl", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 51, + TextureSet.SET_METALLIC + // No Byproducts + ); + public static final Werkstoff PDAmmonia = new Werkstoff( + Materials.Palladium.getRGBA(), + "Palladium Enriched Ammonia", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 52, + TextureSet.SET_FLUID, + // No Byproducts + new Pair<>(Materials.Ammonium, 1), + new Pair<>(Materials.Palladium, 1)); + public static final Werkstoff PDMetallicPowder = new Werkstoff( + Materials.Palladium.getRGBA(), + "Palladium Metallic Powder", + "??Pd??", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures(), + 53, + TextureSet.SET_METALLIC, + // No Byproducts + new Pair<>(Materials.Palladium, 1), + new Pair<>(Materials.Stone, 2)); + public static final Werkstoff PDRawPowder = new Werkstoff( + Materials.Palladium.getRGBA(), + "Reprecipitated Palladium", + subscriptNumbers("Pd2NH4"), + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 54, + TextureSet.SET_METALLIC + // No Byproducts + // No Ingredients + ); + public static final Werkstoff PDSalt = new Werkstoff( + Materials.Palladium.getRGBA(), + "Palladium Salt", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 55, + TextureSet.SET_METALLIC + // No Byproducts + // No Ingredients + ); + public static final Werkstoff Sodiumformate = new Werkstoff( + new short[] { 0xff, 0xaa, 0xaa }, + "Sodium Formate", + "HCOONa", + new Werkstoff.Stats(), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 56, + TextureSet.SET_FLUID, + // No Byproducts + new Pair<>(Materials.SodiumHydroxide, 1), + new Pair<>(Materials.CarbonMonoxide, 1)); + public static final Werkstoff Sodiumsulfate = new Werkstoff( + new short[] { 0xff, 0xff, 0xff }, + "Sodium Sulfate", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 57, + TextureSet.SET_FLUID, + // No Byproducts + new Pair<>(Materials.Sodium, 2), + new Pair<>(Materials.Sulfur, 1), + new Pair<>(Materials.Oxygen, 4)); + public static final Werkstoff FormicAcid = new Werkstoff( + new short[] { 0xff, 0xaa, 0x77 }, + "Formic Acid", + subscriptNumbers("CH2O2"), + new Werkstoff.Stats().setElektrolysis(false), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 58, + TextureSet.SET_FLUID, + // No Byproducts + new Pair<>(Materials.Carbon, 1), + new Pair<>(Materials.Hydrogen, 2), + new Pair<>(Materials.Oxygen, 2)); + public static final Werkstoff PotassiumDisulfate = new Werkstoff( + new short[] { 0xfb, 0xbb, 0x66 }, + "Potassium Disulfate", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addMolten() + .addChemicalRecipes(), + 59, + TextureSet.SET_DULL, + // No Byproducts + new Pair<>(Materials.Potassium, 2), + new Pair<>(Materials.Sulfur, 2), + new Pair<>(Materials.Oxygen, 7)); + public static final Werkstoff LeachResidue = new Werkstoff( + new short[] { 0x64, 0x46, 0x29 }, + "Leach Residue", + "??IrOsRu??", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures(), + 60, + TextureSet.SET_ROUGH + // No Byproducts + ); + public static final Werkstoff RHSulfate = new Werkstoff( + new short[] { 0xee, 0xaa, 0x55 }, + "Rhodium Sulfate", + new Werkstoff.Stats().setGas(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 61, + TextureSet.SET_FLUID + // No Byproducts + ); + public static final Werkstoff RHSulfateSolution = new Werkstoff( + new short[] { 0xff, 0xbb, 0x66 }, + "Rhodium Sulfate Solution", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 62, + TextureSet.SET_FLUID + // No Byproducts + ); + public static final Werkstoff CalciumChloride = new Werkstoff( + new short[] { 0xff, 0xff, 0xff }, + "Calcium Chloride", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addCells(), + 63, + TextureSet.SET_DULL, + new Pair<>(Materials.Calcium, 1), + new Pair<>(Materials.Chlorine, 2) + // No Byproducts + ); + public static final Werkstoff Ruthenium = new Werkstoff( + new short[] { 0x64, 0x64, 0x64 }, + "Ruthenium", + "Ru", + new Werkstoff.Stats().setBlastFurnace(true) + .setMeltingPoint(2607) + .setMass(Element.Ru.getMass()) + .setProtons(Element.Ru.mProtons), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().onlyDust() + .addMolten() + .addMetalItems() + .enforceUnification(), + 64, + TextureSet.SET_METALLIC + // No Byproducts + ); + public static final Werkstoff SodiumRuthenate = new Werkstoff( + new short[] { 0x3a, 0x40, 0xcb }, + "Sodium Ruthenate", + new Werkstoff.Stats(), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 65, + TextureSet.SET_SHINY, + new Pair<>(Materials.Sodium, 2), + new Pair<>(Ruthenium, 1), + new Pair<>(Materials.Oxygen, 3) + // No Byproducts + ); + public static final Werkstoff RutheniumTetroxide = new Werkstoff( + new short[] { 0xc7, 0xc7, 0xc7 }, + "Ruthenium Tetroxide", + new Werkstoff.Stats().setMeltingPoint(313), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addCells(), + 66, + TextureSet.SET_DULL, + new Pair<>(WerkstoffLoader.Ruthenium, 1), + new Pair<>(Materials.Oxygen, 4) + // No Byproducts + ); + public static final Werkstoff HotRutheniumTetroxideSollution = new Werkstoff( + new short[] { 0xc7, 0xc7, 0xc7 }, + "Hot Ruthenium Tetroxide Solution", + "???", + new Werkstoff.Stats().setGas(true) + .setMeltingPoint(700), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 67, + TextureSet.SET_FLUID, + new Pair<>(WerkstoffLoader.Ruthenium, 1), + new Pair<>(Materials.Oxygen, 4), + new Pair<>(Materials.Chlorine, 2), + new Pair<>(Materials.Sodium, 2), + new Pair<>(Materials.Water, 2) + // No Byproducts + ); + public static final Werkstoff RutheniumTetroxideSollution = new Werkstoff( + new short[] { 0xc7, 0xc7, 0xc7 }, + "Ruthenium Tetroxide Solution", + "???", + new Werkstoff.Stats().setMeltingPoint(313), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 68, + TextureSet.SET_FLUID, + new Pair<>(Ruthenium, 1), + new Pair<>(Materials.Oxygen, 4), + new Pair<>(Materials.Chlorine, 2), + new Pair<>(Materials.Sodium, 2), + new Pair<>(Materials.Water, 2) + // No Byproducts + ); + public static final Werkstoff IrOsLeachResidue = new Werkstoff( + new short[] { 0x64, 0x46, 0x29 }, + "Rarest Metal Residue", + "??OsIr??", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures(), + 69, + TextureSet.SET_ROUGH, + // No Byproducts + new Pair<>(Materials.Osmiridium, 1), + new Pair<>(Materials.Stone, 2)); + public static final Werkstoff IrLeachResidue = new Werkstoff( + new short[] { 0x84, 0x66, 0x49 }, + "Iridium Metal Residue", + "??Ir??", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures(), + 70, + TextureSet.SET_ROUGH, + new Pair<>(Materials.Iridium, 1), + new Pair<>(Materials.Stone, 2) + // No Byproducts + ); + public static final Werkstoff PGSDResidue = new Werkstoff( + new short[] { 0x84, 0x66, 0x49 }, + "Sludge Dust Residue", + new Werkstoff.Stats().setCentrifuge(true), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 71, + TextureSet.SET_DULL, + new Pair<>(Materials.SiliconDioxide, 3), + new Pair<>(Materials.Gold, 2)); + public static final Werkstoff AcidicOsmiumSolution = new Werkstoff( + new short[] { 0x84, 0x66, 0x49 }, + "Acidic Osmium Solution", + "???", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 72, + TextureSet.SET_FLUID, + new Pair<>(Materials.Osmium, 1), + new Pair<>(Materials.HydrochloricAcid, 1)); + public static final Werkstoff IridiumDioxide = new Werkstoff( + new short[] { 0x84, 0x66, 0x49 }, + "Iridium Dioxide", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 73, + TextureSet.SET_FLUID, + new Pair<>(Materials.Iridium, 1), + new Pair<>(Materials.Oxygen, 2)); + public static final Werkstoff OsmiumSolution = new Werkstoff( + new short[] { 0x84, 0x66, 0x49 }, + "Osmium Solution", + "???", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 74, + TextureSet.SET_FLUID, + new Pair<>(Materials.Osmium, 1), + new Pair<>(Materials.Hydrogen, 1)); + public static final Werkstoff AcidicIridiumSolution = new Werkstoff( + new short[] { 0x84, 0x66, 0x49 }, + "Acidic Iridium Solution", + "???", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 75, + TextureSet.SET_FLUID, + new Pair<>(Materials.Iridium, 1), + new Pair<>(Materials.Hydrogen, 1)); + public static final Werkstoff IridiumChloride = new Werkstoff( + new short[] { 0x84, 0x66, 0x49 }, + "Iridium Chloride", + subscriptNumbers("IrCl3"), + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 76, + TextureSet.SET_LAPIS, + new Pair<>(Materials.Iridium, 1), + new Pair<>(Materials.Chlorine, 3)); + public static final Werkstoff PGSDResidue2 = new Werkstoff( + new short[] { 0x84, 0x66, 0x49 }, + "Metallic Sludge Dust Residue", + new Werkstoff.Stats().setCentrifuge(true), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 77, + TextureSet.SET_DULL, + new Pair<>(Materials.Nickel, 1), + new Pair<>(Materials.Copper, 1)); + public static final Werkstoff Rhodium = new Werkstoff( + new short[] { 0xF4, 0xF4, 0xF4 }, + "Rhodium", + "Rh", + new Werkstoff.Stats().setProtons(Element.Rh.mProtons) + .setMass(Element.Rh.getMass()) + .setBlastFurnace(true) + .setMeltingPoint(2237), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addMetalItems() + .addMolten() + .enforceUnification(), + 78, + TextureSet.SET_METALLIC); + public static final Werkstoff CrudeRhMetall = new Werkstoff( + new short[] { 0x66, 0x66, 0x66 }, + "Crude Rhodium Metal", + "??Rh??", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures(), + 79, + TextureSet.SET_DULL, + new Pair<>(Rhodium, 1), + new Pair<>(Materials.Stone, 1)); + public static final Werkstoff RHSalt = new Werkstoff( + new short[] { 0x84, 0x84, 0x84 }, + "Rhodium Salt", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 80, + TextureSet.SET_GEM_VERTICAL); + public static final Werkstoff RHSaltSolution = new Werkstoff( + new short[] { 0x66, 0x77, 0x88 }, + "Rhodium Salt Solution", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 81, + TextureSet.SET_FLUID); + public static final Werkstoff SodiumNitrate = new Werkstoff( + new short[] { 0x84, 0x66, 0x84 }, + "Sodium Nitrate", + subscriptNumbers("NaNO3"), + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 82, + TextureSet.SET_ROUGH, + new Pair<>(Materials.Sodium, 1), + new Pair<>(Materials.Nitrogen, 1), + new Pair<>(Materials.Oxygen, 3)); + public static final Werkstoff RHNitrate = new Werkstoff( + new short[] { 0x77, 0x66, 0x49 }, + "Rhodium Nitrate", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 83, + TextureSet.SET_QUARTZ); + public static final Werkstoff ZincSulfate = new Werkstoff( + new short[] { 0x84, 0x66, 0x49 }, + "Zinc Sulfate", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 84, + TextureSet.SET_QUARTZ, + new Pair<>(Materials.Zinc, 1), + new Pair<>(Materials.Sulfur, 1), + new Pair<>(Materials.Oxygen, 4)); + public static final Werkstoff RhFilterCake = new Werkstoff( + new short[] { 0x77, 0x66, 0x49 }, + "Rhodium Filter Cake", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 85, + TextureSet.SET_QUARTZ); + public static final Werkstoff RHFilterCakeSolution = new Werkstoff( + new short[] { 0x66, 0x77, 0x88 }, + "Rhodium Filter Cake Solution", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 86, + TextureSet.SET_FLUID); + public static final Werkstoff ReRh = new Werkstoff( + new short[] { 0x77, 0x66, 0x49 }, + "Reprecipitated Rhodium", + subscriptNumbers("Rh2NH4"), + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 87, + TextureSet.SET_QUARTZ); + public static final Werkstoff LuVTierMaterial = new Werkstoff( + Materials.Chrome.getRGBA(), + "Rhodium-Plated Palladium", + new Werkstoff.Stats().setCentrifuge(true) + .setBlastFurnace(true) + .setMeltingPoint(4500) + .setMeltingVoltage(480), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addMolten() + .addMetalItems() + .addMixerRecipes((short) 1) + .addSimpleMetalWorkingItems() + .addCraftingMetalWorkingItems() + .addMultipleIngotMetalWorkingItems(), + 88, + TextureSet.SET_METALLIC, + new Pair<>(Materials.Palladium, 3), + new Pair<>(WerkstoffLoader.Rhodium, 1)); + public static final Werkstoff Tiberium = new Werkstoff( + new short[] { 0x22, 0xEE, 0x22 }, + "Tiberium", + "Tr", + new Werkstoff.Stats().setProtons(123) + .setMass(326) + .setBlastFurnace(true) + .setMeltingPoint(1800) + .setRadioactive(true) + .setToxic(true), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().addGems() + .addCraftingMetalWorkingItems() + .addSimpleMetalWorkingItems(), + 89, + TextureSet.SET_DIAMOND); + public static final Werkstoff Ruridit = new Werkstoff( + new short[] { 0xA4, 0xA4, 0xA4 }, + "Ruridit", + new Werkstoff.Stats().setCentrifuge(true) + .setBlastFurnace(true) + .setMeltingPoint(4500) + .setMeltingVoltage(480), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addMolten() + .addMetalItems() + .addMixerRecipes((short) 1) + .addSimpleMetalWorkingItems() + .addCraftingMetalWorkingItems() + .addMultipleIngotMetalWorkingItems(), + 90, + TextureSet.SET_METALLIC, + new Pair<>(WerkstoffLoader.Ruthenium, 2), + new Pair<>(Materials.Iridium, 1)); + public static final Werkstoff Fluorspar = new Werkstoff( + new short[] { 185, 69, 251 }, + "Fluorspar", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 91, + TextureSet.SET_GEM_VERTICAL, + new Pair<>(Materials.Calcium, 1), + new Pair<>(Materials.Fluorine, 2)); + public static final Werkstoff HDCS = new Werkstoff( + new short[] { 0x33, 0x44, 0x33 }, + "High Durability Compound Steel", + new Werkstoff.Stats().setCentrifuge(true) + .setBlastFurnace(true) + .setMeltingPoint(9000) + .setMeltingVoltage(7680), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addMolten() + .addMetalItems() + .addMixerRecipes() + .addSimpleMetalWorkingItems() + .addCraftingMetalWorkingItems() + .addMultipleIngotMetalWorkingItems(), + 92, + TextureSet.SET_SHINY, + new Pair<>(Materials.TungstenSteel, 12), + new Pair<>(Materials.HSSE, 9), + new Pair<>(Materials.HSSG, 6), + new Pair<>(WerkstoffLoader.Ruridit, 3), + new Pair<>(WerkstoffLoader.MagnetoResonaticDust, 2), + new Pair<>(Materials.Plutonium, 1)); + public static final Werkstoff Atheneite = new Werkstoff( + new short[] { 175, 175, 175 }, + "Atheneite", + subscriptNumbers("(Pd,Hg)3As"), + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 93, + TextureSet.SET_SHINY, + new Pair<>(WerkstoffLoader.PDMetallicPowder, 3), + new Pair<>(Materials.Mercury, 3), + new Pair<>(Materials.Arsenic, 1)); + public static final Werkstoff Temagamite = new Werkstoff( + new short[] { 245, 245, 245 }, + "Temagamite", + subscriptNumbers("Pd3HgTe"), + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 94, + TextureSet.SET_ROUGH, + new Pair<>(WerkstoffLoader.PDMetallicPowder, 3), + new Pair<>(Materials.Mercury, 1), + new Pair<>(Materials.Tellurium, 1)); + public static final Werkstoff Terlinguaite = new Werkstoff( + new short[] { 245, 245, 245 }, + "Terlinguaite", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures(), + 95, + TextureSet.SET_GEM_HORIZONTAL, + new Pair<>(Materials.Mercury, 2), + new Pair<>(Materials.Chlorine, 1), + new Pair<>(Materials.Oxygen, 1)); + public static final Werkstoff AdemicSteel = new Werkstoff( + new short[] { 0xcc, 0xcc, 0xcc }, + "Ademic Steel", + "The break in the line", + new Werkstoff.Stats().setCentrifuge(true) + .setBlastFurnace(true) + .setDurOverride(6144) + .setMeltingPoint(1800) + .setSpeedOverride(12) + .setQualityOverride((byte) 4) + .setMeltingVoltage(1920), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().onlyDust() + .addMetalItems() + .addCraftingMetalWorkingItems() + .addMolten() + .addSimpleMetalWorkingItems() + .addMultipleIngotMetalWorkingItems(), + 96, + TextureSet.SET_METALLIC, + new Pair<>(Materials.Steel, 2), + new Pair<>(Materials.VanadiumSteel, 1), + new Pair<>(Materials.DamascusSteel, 1), + new Pair<>(Materials.Carbon, 4)); + public static final Werkstoff RawAdemicSteel = new Werkstoff( + new short[] { 0xed, 0xed, 0xed }, + "Raw Ademic Steel", + new Werkstoff.Stats().setCentrifuge(true), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().onlyDust() + .addMixerRecipes(), + 97, + TextureSet.SET_ROUGH, + new Pair<>(Materials.Steel, 2), + new Pair<>(Materials.VanadiumSteel, 1), + new Pair<>(Materials.DamascusSteel, 1)); + public static final Werkstoff HexafluorosilicicAcid = new Werkstoff( + new short[] { 0x2c, 0x70, 0xb5 }, + "Hexafluorosilicic Acid", + subscriptNumbers("H2SiF6"), + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 98, + TextureSet.SET_FLUID, + new Pair<>(Materials.Hydrogen, 2), + new Pair<>(Materials.Silicon, 1), + new Pair<>(Materials.Fluorine, 6)); + public static final Werkstoff Potassiumfluorosilicate = new Werkstoff( + new short[] { 0x2e, 0x97, 0xb2 }, + "Potassiumfluorosilicate", + subscriptNumbers("K2SiF6"), + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 99, + TextureSet.SET_SHINY, + new Pair<>(Materials.Potassium, 2), + new Pair<>(Materials.Silicon, 1), + new Pair<>(Materials.Fluorine, 6)); + public static final Werkstoff Alumina = new Werkstoff( + new short[] { 0xa0, 0xad, 0xb1 }, + "Alumina", + subscriptNumbers("Al2O3"), + new Werkstoff.Stats(), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 100, + TextureSet.SET_DULL); + public static final Werkstoff PotassiumCarbonate = new Werkstoff( + new short[] { 0x7b, 0x96, 0x4f }, + "Potassium Carbonate", + subscriptNumbers("K2CO3"), + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 101, + TextureSet.SET_DULL, + new Pair<>(Materials.Potassium, 2), + new Pair<>(Materials.Carbon, 1), + new Pair<>(Materials.Oxygen, 3)); + public static final Werkstoff RawFluorophlogopite = new Werkstoff( + new short[] { 0x36, 0x51, 0x0b }, + "Raw Fluorophlogopite", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust(), + 102, + TextureSet.SET_DULL); + public static final Werkstoff HotFluorophlogopite = new Werkstoff( + new short[] { 0xbf, 0xd3, 0x55 }, + "Unformed Fluorophlogopite", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .addCells(), + 103, + TextureSet.SET_FLUID); + public static final Werkstoff Fluorophlogopite = new Werkstoff( + new short[] { 0xbf, 0xd3, 0x55 }, + "Fluorophlogopite", + new Werkstoff.Stats(), + Werkstoff.Types.MIXTURE, + new Werkstoff.GenerationFeatures().disable() + .onlyDust() + .addMetalItems(), + 104, + TextureSet.SET_SHINY); + + public static HashMap<OrePrefixes, BWMetaGeneratedItems> items = new HashMap<>(); + public static HashBiMap<Werkstoff, Fluid> fluids = HashBiMap.create(); + public static HashBiMap<Werkstoff, Fluid> molten = HashBiMap.create(); + public static Block BWOres; + public static Block BWSmallOres; + public static Block BWBlocks; + public static Block BWBlockCasings; + public static Block BWBlockCasingsAdvanced; + public static boolean registered; + public static final HashSet<OrePrefixes> ENABLED_ORE_PREFIXES = new HashSet<>(); + + public static Werkstoff getWerkstoff(String Name) { + try { + Field f = WerkstoffLoader.class.getField(Name); + return (Werkstoff) f.get(null); + } catch (IllegalAccessException | NoSuchFieldException | ClassCastException e) { + MainMod.LOGGER.catching(e); + } + return Werkstoff.default_null_Werkstoff; + } + + public static ItemStack getCorrespondingItemStack(OrePrefixes orePrefixes, Werkstoff werkstoff) { + return WerkstoffLoader.getCorrespondingItemStack(orePrefixes, werkstoff, 1); + } + + public static ItemStack getCorrespondingItemStackUnsafe(OrePrefixes orePrefixes, Werkstoff werkstoff, int amount) { + if (!werkstoff.getGenerationFeatures().enforceUnification) { + ItemStack ret = GTOreDictUnificator.get(orePrefixes, werkstoff.getBridgeMaterial(), amount); + if (ret != null) return ret; + ret = OreDictHandler.getItemStack(werkstoff.getVarName(), orePrefixes, amount); + if (ret != null) return ret; + } + if (orePrefixes == ore) return new ItemStack(WerkstoffLoader.BWOres, amount, werkstoff.getmID()); + if (orePrefixes == oreSmall) return new ItemStack(WerkstoffLoader.BWSmallOres, amount, werkstoff.getmID()); + else if (orePrefixes == block) return new ItemStack(WerkstoffLoader.BWBlocks, amount, werkstoff.getmID()); + else if (orePrefixes == OrePrefixes.blockCasing) + return new ItemStack(WerkstoffLoader.BWBlockCasings, amount, werkstoff.getmID()); + else if (orePrefixes == OrePrefixes.blockCasingAdvanced) + return new ItemStack(WerkstoffLoader.BWBlockCasingsAdvanced, amount, werkstoff.getmID()); + else if (WerkstoffLoader.items.get(orePrefixes) == null) return null; + return new ItemStack(WerkstoffLoader.items.get(orePrefixes), amount, werkstoff.getmID()).copy(); + } + + public static ItemStack getCorrespondingItemStack(OrePrefixes orePrefixes, Werkstoff werkstoff, int amount) { + ItemStack stack = getCorrespondingItemStackUnsafe(orePrefixes, werkstoff, amount); + if (stack != null) return stack; + MainMod.LOGGER.catching( + Level.ERROR, + new Exception( + "NO SUCH ITEM! " + orePrefixes + + werkstoff.getVarName() + + " If you encounter this as a user, make sure to contact the authors of the pack/the mods you're playing! " + + "If you are a Developer, you forgot to enable " + + orePrefixes + + " OrePrefix for Werkstoff " + + werkstoff.getDefaultName())); + return new ItemStack(WerkstoffLoader.items.get(orePrefixes), amount, werkstoff.getmID()).copy(); + } + + public static void runInit() { + MainMod.LOGGER.info("Making Meta Items for BW Materials"); + long timepre = System.nanoTime(); + WerkstoffAdderRegistry.run(); + addSubTags(); + addItemsForGeneration(); + addBridgeSubTags(); + runAdditionalOreDict(); + long timepost = System.nanoTime(); + MainMod.LOGGER.info( + "Making Meta Items for BW Materials took " + (timepost - timepre) + + "ns/" + + (timepost - timepre) / 1000000 + + "ms/" + + (timepost - timepre) / 1000000000 + + "s!"); + } + + public static void run() { + if (!registered) { + MainMod.LOGGER.info("Loading Processing Recipes for BW Materials"); + long timepre = System.nanoTime(); + ProgressManager.ProgressBar progressBar = ProgressManager + .push("Register BW Materials", Werkstoff.werkstoffHashSet.size() + 1); + DebugLog.log("Loading Recipes" + (System.nanoTime() - timepre)); + Integer[] clsArr = {}; + int size = 0; + if (BetterLoadingScreen.isModLoaded()) clsArr = CLSCompat.initCls(); + + IWerkstoffRunnable[] werkstoffRunnables = { new ToolLoader(), new DustLoader(), new GemLoader(), + new SimpleMetalLoader(), new CasingLoader(), new AspectLoader(), new OreLoader(), new RawOreLoader(), + new CrushedLoader(), new CraftingMaterialLoader(), new CellLoader(), new MoltenCellLoader(), + new MultipleMetalLoader(), new MetalLoader(), new BlockLoader() }; + + long timepreone = 0; + for (Werkstoff werkstoff : Werkstoff.werkstoffHashSet) { + timepreone = System.nanoTime(); + DebugLog.log( + "Werkstoff is null or id < 0 ? " + (werkstoff == null || werkstoff.getmID() < 0) + + " " + + (System.nanoTime() - timepreone)); + if (werkstoff == null || werkstoff.getmID() < 0) { + progressBar.step(""); + continue; + } + if (BetterLoadingScreen.isModLoaded()) size = CLSCompat.invokeStepSize(werkstoff, clsArr, size); + DebugLog.log("Werkstoff: " + werkstoff.getDefaultName() + " " + (System.nanoTime() - timepreone)); + for (IWerkstoffRunnable runnable : werkstoffRunnables) { + String loaderName = runnable.getClass() + .getSimpleName(); + DebugLog.log(loaderName + " started " + (System.nanoTime() - timepreone)); + runnable.run(werkstoff); + DebugLog.log(loaderName + " done " + (System.nanoTime() - timepreone)); + } + DebugLog.log("Done" + " " + (System.nanoTime() - timepreone)); + progressBar.step(werkstoff.getDefaultName()); + } + DebugLog.log("Loading New Circuits" + " " + (System.nanoTime() - timepreone)); + BWCircuitsLoader.initNewCircuits(); + + if (BetterLoadingScreen.isModLoaded()) { + CLSCompat.disableCls(); + } + + progressBar.step("Load Additional Recipes"); + AdditionalRecipes.run(); + ProgressManager.pop(progressBar); + long timepost = System.nanoTime(); + MainMod.LOGGER.info( + "Loading Processing Recipes for BW Materials took " + (timepost - timepre) + + "ns/" + + (timepost - timepre) / 1000000 + + "ms/" + + (timepost - timepre) / 1000000000 + + "s!"); + registered = true; + } + } + + @SuppressWarnings("unchecked") + private static void addSubTags() { + WerkstoffLoader.CubicZirconia.getStats() + .setDurOverride(Materials.Diamond.mDurability); + WerkstoffLoader.HDCS.getStats() + .setSpeedOverride(Materials.HSSS.mToolSpeed); + WerkstoffLoader.HDCS.getStats() + .setDurMod(10f); + Materials.Helium.add(WerkstoffLoader.NOBLE_GAS); + WerkstoffLoader.Neon.add(WerkstoffLoader.NOBLE_GAS); + Materials.Argon.add(WerkstoffLoader.NOBLE_GAS); + WerkstoffLoader.Krypton.add(WerkstoffLoader.NOBLE_GAS); + WerkstoffLoader.Xenon.add(WerkstoffLoader.NOBLE_GAS, WerkstoffLoader.ANAEROBE_GAS); + Materials.Radon.add(WerkstoffLoader.NOBLE_GAS); + WerkstoffLoader.Oganesson.add(WerkstoffLoader.NOBLE_GAS, WerkstoffLoader.ANAEROBE_GAS); + + Materials.Nitrogen.add(WerkstoffLoader.ANAEROBE_GAS); + + WerkstoffLoader.Calcium.add(WerkstoffLoader.ANAEROBE_SMELTING); + + WerkstoffLoader.LuVTierMaterial.add(WerkstoffLoader.NOBLE_GAS_SMELTING); + WerkstoffLoader.Ruridit.add(WerkstoffLoader.NOBLE_GAS_SMELTING); + WerkstoffLoader.AdemicSteel.add(WerkstoffLoader.NOBLE_GAS_SMELTING); + + WerkstoffLoader.MagnetoResonaticDust.add(WerkstoffLoader.NO_BLAST); + + // Calcium Smelting block + Materials.Calcium.mBlastFurnaceRequired = true; + + Materials.Salt.mDurability = WerkstoffLoader.Salt.getDurability(); + Materials.Spodumene.mDurability = WerkstoffLoader.Spodumen.getDurability(); + Materials.RockSalt.mDurability = WerkstoffLoader.RockSalt.getDurability(); + Materials.Calcium.mDurability = WerkstoffLoader.Calcium.getDurability(); + + Materials.Salt.mToolSpeed = WerkstoffLoader.Salt.getToolSpeed(); + Materials.Spodumene.mToolSpeed = WerkstoffLoader.Spodumen.getToolSpeed(); + Materials.RockSalt.mToolSpeed = WerkstoffLoader.RockSalt.getToolSpeed(); + Materials.Calcium.mToolSpeed = WerkstoffLoader.Calcium.getToolSpeed(); + + Materials.Salt.mToolQuality = WerkstoffLoader.Salt.getToolQuality(); + Materials.Spodumene.mToolQuality = WerkstoffLoader.Spodumen.getToolQuality(); + Materials.RockSalt.mToolQuality = WerkstoffLoader.RockSalt.getToolQuality(); + Materials.Calcium.mToolQuality = WerkstoffLoader.Calcium.getToolQuality(); + + for (Werkstoff W : Werkstoff.werkstoffHashSet) { + for (Pair<ISubTagContainer, Integer> pair : W.getContents() + .getValue() + .toArray(new Pair[0])) { + + if (pair.getKey() instanceof Materials && pair.getKey() == Materials.Neodymium) { + W.add(SubTag.ELECTROMAGNETIC_SEPERATION_NEODYMIUM); + break; + } + if (pair.getKey() instanceof Materials && pair.getKey() == Materials.Iron) { + W.add(SubTag.ELECTROMAGNETIC_SEPERATION_IRON); + break; + } else if (pair.getKey() instanceof Materials && pair.getKey() == Materials.Gold) { + W.add(SubTag.ELECTROMAGNETIC_SEPERATION_GOLD); + break; + } + } + if (W.hasItemType(gem)) { + W.add(SubTag.CRYSTAL); + W.add(SubTag.CRYSTALLISABLE); + } + } + } + + private static void addBridgeSubTags() { + // add specific GT materials subtags to various werkstoff bridgematerials + + SubTag.METAL.addTo(LuVTierMaterial.getBridgeMaterial()); + } + + public static long toGenerateGlobal; + + private static void addItemsForGeneration() { + for (Werkstoff werkstoff : Werkstoff.werkstoffHashSet) { + if (werkstoff.hasItemType(cell)) { + if (!FluidRegistry.isFluidRegistered(werkstoff.getDefaultName())) { + DebugLog.log("Adding new Fluid: " + werkstoff.getDefaultName()); + Fluid fluid = GTFluidFactory.builder(werkstoff.getDefaultName()) + .withLocalizedName(werkstoff.getDefaultName()) + .withStateAndTemperature( + werkstoff.getStats() + .getFluidState(), + 300) + .withColorRGBA(werkstoff.getRGBA()) + .withTextureName("autogenerated") + .buildAndRegister() + .asFluid(); + WerkstoffLoader.fluids.put(werkstoff, fluid); + } else { + WerkstoffLoader.fluids.put(werkstoff, FluidRegistry.getFluid(werkstoff.getDefaultName())); + } + } + if (werkstoff.hasItemType(OrePrefixes.cellMolten)) { + if (!FluidRegistry.isFluidRegistered("molten." + werkstoff.getDefaultName())) { + DebugLog.log("Adding new Molten: " + werkstoff.getDefaultName()); + Fluid fluid = GTFluidFactory.builder("molten." + werkstoff.getDefaultName()) + .withLocalizedName("Molten " + werkstoff.getDefaultName()) + .withStateAndTemperature( + FluidState.MOLTEN, + werkstoff.getStats() + .getMeltingPoint() > 0 ? werkstoff.getStats() + .getMeltingPoint() : 300) + .withColorRGBA(werkstoff.getRGBA()) + .withTextureName("molten.autogenerated") + .buildAndRegister() + .asFluid(); + WerkstoffLoader.molten.put(werkstoff, fluid); + } else { + WerkstoffLoader.molten.put(werkstoff, FluidRegistry.getFluid(werkstoff.getDefaultName())); + } + } + for (OrePrefixes p : values()) if (Materials.get(werkstoff.getDefaultName()) != null + && Materials.get(werkstoff.getDefaultName()).mMetaItemSubID != -1 + && (werkstoff.getGenerationFeatures().toGenerate & p.mMaterialGenerationBits) != 0 + && OreDictHandler.getItemStack(werkstoff.getDefaultName(), p, 1) != null) { + DebugLog.log( + "Found: " + p + + werkstoff.getVarName() + + " in GT material system, disable and reroute my Items to that, also add a Tooltip."); + werkstoff.getGenerationFeatures() + .setBlacklist(p); + } + WerkstoffLoader.toGenerateGlobal = WerkstoffLoader.toGenerateGlobal + | werkstoff.getGenerationFeatures().toGenerate; + } + DebugLog.log("GlobalGeneration: " + WerkstoffLoader.toGenerateGlobal); + if ((WerkstoffLoader.toGenerateGlobal & 0b1) != 0) { + WerkstoffLoader.items.put(dust, new BWMetaGeneratedItems(dust)); + WerkstoffLoader.items.put(dustTiny, new BWMetaGeneratedItems(dustTiny)); + WerkstoffLoader.items.put(dustSmall, new BWMetaGeneratedItems(dustSmall)); + } + if ((WerkstoffLoader.toGenerateGlobal & 0b10) != 0) { + WerkstoffLoader.items.put(ingot, new BWMetaGeneratedItems(ingot)); + WerkstoffLoader.items.put(ingotHot, new BWMetaGeneratedItems(ingotHot)); // 1750 + WerkstoffLoader.items.put(nugget, new BWMetaGeneratedItems(nugget)); + } + if ((WerkstoffLoader.toGenerateGlobal & 0b100) != 0) { + WerkstoffLoader.items.put(gem, new BWMetaGeneratedItems(gem)); + WerkstoffLoader.items.put(gemChipped, new BWMetaGeneratedItems(gemChipped)); + WerkstoffLoader.items.put(gemExquisite, new BWMetaGeneratedItems(gemExquisite)); + WerkstoffLoader.items.put(gemFlawed, new BWMetaGeneratedItems(gemFlawed)); + WerkstoffLoader.items.put(gemFlawless, new BWMetaGeneratedItems(gemFlawless)); + WerkstoffLoader.items.put(lens, new BWMetaGeneratedItems(lens)); + } + if ((WerkstoffLoader.toGenerateGlobal & 0b1000) != 0) { + gameRegistryHandler(); + WerkstoffLoader.items.put(crushed, new BWMetaGeneratedItems(crushed)); + WerkstoffLoader.items.put(crushedPurified, new BWMetaGeneratedItems(crushedPurified)); + WerkstoffLoader.items.put(crushedCentrifuged, new BWMetaGeneratedItems(crushedCentrifuged)); + WerkstoffLoader.items.put(dustPure, new BWMetaGeneratedItems(dustPure)); + WerkstoffLoader.items.put(dustImpure, new BWMetaGeneratedItems(dustImpure)); + WerkstoffLoader.items.put(rawOre, new BWMetaGeneratedItems(rawOre)); + } + if ((WerkstoffLoader.toGenerateGlobal & 0b10000) != 0) { + WerkstoffLoader.items.put(cell, new BWMetaGeneratedItems(cell)); + if (Forestry.isModLoaded()) { + BWMetaGeneratedItems capsuleClass = new BWMetaGeneratedItems(capsule); + API.hideItem(new ItemStack(capsuleClass, 1, WILDCARD)); + WerkstoffLoader.items.put(capsule, capsuleClass); + } + } + if ((WerkstoffLoader.toGenerateGlobal & 0b100000) != 0) { + WerkstoffLoader.items.put(cellPlasma, new BWMetaGeneratedItems(cellPlasma)); + } + if ((WerkstoffLoader.toGenerateGlobal & 0b1000000) != 0) { + WerkstoffLoader.items.put(OrePrefixes.cellMolten, new BWMetaGeneratedItems(OrePrefixes.cellMolten)); + if (Forestry.isModLoaded()) { + BWMetaGeneratedItems capsuleMoltenClass = new BWMetaGeneratedItems(OrePrefixes.capsuleMolten); + API.hideItem(new ItemStack(capsuleMoltenClass, 1, WILDCARD)); + WerkstoffLoader.items.put(OrePrefixes.capsuleMolten, capsuleMoltenClass); + } + } + if ((WerkstoffLoader.toGenerateGlobal & 0b10000000) != 0) { + WerkstoffLoader.items.put(plate, new BWMetaGeneratedItems(plate)); + WerkstoffLoader.items.put(foil, new BWMetaGeneratedItems(foil)); + WerkstoffLoader.items.put(stick, new BWMetaGeneratedItems(stick)); + WerkstoffLoader.items.put(stickLong, new BWMetaGeneratedItems(stickLong)); + WerkstoffLoader.items.put(toolHeadWrench, new BWMetaGeneratedItems(toolHeadWrench)); + WerkstoffLoader.items.put(toolHeadHammer, new BWMetaGeneratedItems(toolHeadHammer)); + WerkstoffLoader.items.put(toolHeadSaw, new BWMetaGeneratedItems(toolHeadSaw)); + WerkstoffLoader.items.put(turbineBlade, new BWMetaGeneratedItems(turbineBlade)); + } + if ((WerkstoffLoader.toGenerateGlobal & 0b100000000) != 0) { + WerkstoffLoader.items.put(gearGt, new BWMetaGeneratedItems(gearGt)); + WerkstoffLoader.items.put(gearGtSmall, new BWMetaGeneratedItems(gearGtSmall)); + WerkstoffLoader.items.put(bolt, new BWMetaGeneratedItems(bolt)); + WerkstoffLoader.items.put(screw, new BWMetaGeneratedItems(screw)); + WerkstoffLoader.items.put(ring, new BWMetaGeneratedItems(ring)); + WerkstoffLoader.items.put(spring, new BWMetaGeneratedItems(spring)); + WerkstoffLoader.items.put(springSmall, new BWMetaGeneratedItems(springSmall)); + WerkstoffLoader.items.put(rotor, new BWMetaGeneratedItems(rotor)); + WerkstoffLoader.items.put(wireFine, new BWMetaGeneratedItems(wireFine)); + } + if ((WerkstoffLoader.toGenerateGlobal & 0b1000000000) != 0) { + WerkstoffLoader.items.put(plateDouble, new BWMetaGeneratedItems(plateDouble)); + WerkstoffLoader.items.put(plateTriple, new BWMetaGeneratedItems(plateTriple)); + WerkstoffLoader.items.put(plateQuadruple, new BWMetaGeneratedItems(plateQuadruple)); + WerkstoffLoader.items.put(plateQuintuple, new BWMetaGeneratedItems(plateQuintuple)); + WerkstoffLoader.items.put(plateDense, new BWMetaGeneratedItems(plateDense)); + WerkstoffLoader.items.put(ingotDouble, new BWMetaGeneratedItems(ingotDouble)); + WerkstoffLoader.items.put(ingotTriple, new BWMetaGeneratedItems(ingotTriple)); + WerkstoffLoader.items.put(ingotQuadruple, new BWMetaGeneratedItems(ingotQuadruple)); + WerkstoffLoader.items.put(ingotQuintuple, new BWMetaGeneratedItems(ingotQuintuple)); + } + ENABLED_ORE_PREFIXES.addAll(WerkstoffLoader.items.keySet()); + ENABLED_ORE_PREFIXES.add(ore); + ENABLED_ORE_PREFIXES.add(oreSmall); + WerkstoffLoader.runGTItemDataRegistrator(); + } + + static void gameRegistryHandler() { + if (SideReference.Side.Client) BWBlockOreRenderer.register(); + + GameRegistry.registerTileEntity(BWTileEntityMetaGeneratedOre.class, "bw.blockoresTE"); + GameRegistry.registerTileEntity(BWTileEntityMetaGeneratedSmallOre.class, "bw.blockoresSmallTE"); + GameRegistry.registerTileEntity(BWTileEntityMetaGeneratedWerkstoffBlock.class, "bw.werkstoffblockTE"); + GameRegistry.registerTileEntity(BWTileEntityMetaGeneratedBlocksCasing.class, "bw.werkstoffblockcasingTE"); + GameRegistry.registerTileEntity( + BWTileEntityMetaGeneratedBlocksCasingAdvanced.class, + "bw.werkstoffblockscasingadvancedTE"); + + WerkstoffLoader.BWOres = new BWMetaGeneratedOres( + Material.rock, + BWTileEntityMetaGeneratedOre.class, + "bw.blockores"); + WerkstoffLoader.BWSmallOres = new BWMetaGeneratedSmallOres( + Material.rock, + BWTileEntityMetaGeneratedSmallOre.class, + "bw.blockoresSmall"); + WerkstoffLoader.BWBlocks = new BWMetaGeneratedWerkstoffBlocks( + Material.iron, + BWTileEntityMetaGeneratedWerkstoffBlock.class, + "bw.werkstoffblocks"); + WerkstoffLoader.BWBlockCasings = new BWMetaGeneratedBlocksCasing( + Material.iron, + BWTileEntityMetaGeneratedBlocksCasing.class, + "bw.werkstoffblockscasing", + OrePrefixes.blockCasing); + WerkstoffLoader.BWBlockCasingsAdvanced = new BWMetaGeneratedBlocksCasing( + Material.iron, + BWTileEntityMetaGeneratedBlocksCasingAdvanced.class, + "bw.werkstoffblockscasingadvanced", + OrePrefixes.blockCasingAdvanced); + + GameRegistry.registerBlock(WerkstoffLoader.BWOres, BWItemMetaGeneratedBlock.class, "bw.blockores.01"); + GameRegistry.registerBlock(WerkstoffLoader.BWSmallOres, BWItemMetaGeneratedBlock.class, "bw.blockores.02"); + GameRegistry.registerBlock(WerkstoffLoader.BWBlocks, BWItemMetaGeneratedBlock.class, "bw.werkstoffblocks.01"); + if (!ConfigHandler.disableBoltedBlocksCasing) GameRegistry.registerBlock( + WerkstoffLoader.BWBlockCasings, + BWItemMetaGeneratedBlock.class, + "bw.werkstoffblockscasing.01"); + if (!ConfigHandler.disableReboltedBlocksCasing) GameRegistry.registerBlock( + WerkstoffLoader.BWBlockCasingsAdvanced, + BWItemMetaGeneratedBlock.class, + "bw.werkstoffblockscasingadvanced.01"); + + GTMetaItemEnhancer.addAdditionalOreDictToForestry(); + GTMetaItemEnhancer.init(); + } + + private static void runGTItemDataRegistrator() { + IWerkstoffRunnable[] registrations = { new BridgeMaterialsLoader(), new AssociationLoader(), + new CasingRegistrator() }; + for (Werkstoff werkstoff : Werkstoff.werkstoffHashSet) { + for (IWerkstoffRunnable registration : registrations) { + registration.run(werkstoff); + } + } + addFakeItemDataToInWorldBlocksAndCleanUpFakeData(); + addVanillaCasingsToGTOreDictUnificator(); + } + + public static void addVanillaCasingsToGTOreDictUnificator() { + GTOreDictUnificator + .addAssociation(OrePrefixes.blockCasing, Materials.Aluminium, ItemList.Casing_FrostProof.get(1L), false); + GTOreDictUnificator + .addAssociation(OrePrefixes.blockCasing, Materials.Nickel, ItemList.Casing_HeatProof.get(1L), false); + GTOreDictUnificator + .addAssociation(OrePrefixes.blockCasing, Materials.Lead, ItemList.Casing_RadiationProof.get(1L), false); + GTOreDictUnificator + .addAssociation(OrePrefixes.blockCasing, Materials.Steel, ItemList.Casing_SolidSteel.get(1L), false); + GTOreDictUnificator.addAssociation( + OrePrefixes.blockCasing, + Materials.TungstenSteel, + ItemList.Casing_RobustTungstenSteel.get(1L), + false); + GTOreDictUnificator.addAssociation( + OrePrefixes.blockCasing, + Materials.Polytetrafluoroethylene, + ItemList.Casing_Chemically_Inert.get(1L), + false); + } + + /** + * very hacky way to make my ores/blocks/smallores detectable by gt assosication in world, well at least the prefix. + * used for the miners mostly removing this hacky material from the materials map instantly. we only need the item + * data. + */ + @SuppressWarnings("unchecked") + private static void addFakeItemDataToInWorldBlocksAndCleanUpFakeData() { + + Map<String, Materials> MATERIALS_MAP = null; + + try { + Field f = Materials.class.getDeclaredField("MATERIALS_MAP"); + f.setAccessible(true); + MATERIALS_MAP = (Map<String, Materials>) f.get(null); + } catch (NoSuchFieldException | IllegalAccessException | ClassCastException e) { + e.printStackTrace(); + } + + if (MATERIALS_MAP == null) throw new NullPointerException("MATERIALS_MAP null!"); + + Materials oreMat = new Materials(-1, null, 0, 0, 0, false, "bwores", "bwores", null, true, null); + Materials smallOreMat = new Materials(-1, null, 0, 0, 0, false, "bwsmallores", "bwsmallores", null, true, null); + Materials blockMat = new Materials(-1, null, 0, 0, 0, false, "bwblocks", "bwblocks", null, true, null); + + for (int i = 0; i < 16; i++) { + GTOreDictUnificator.addAssociation(ore, oreMat, new ItemStack(BWOres, 1, i), true); + GTOreDictUnificator.addAssociation(oreSmall, smallOreMat, new ItemStack(BWSmallOres, 1, i), true); + GTOreDictUnificator.addAssociation(block, blockMat, new ItemStack(BWBlocks, 1, i), true); + } + + MATERIALS_MAP.remove("bwores"); + MATERIALS_MAP.remove("bwsmallores"); + MATERIALS_MAP.remove("bwblocks"); + } + + public static void removeIC2Recipes() { + try { + Set<Map.Entry<IRecipeInput, RecipeOutput>> remset = new HashSet<>(); + for (Map.Entry<IRecipeInput, RecipeOutput> curr : Recipes.macerator.getRecipes() + .entrySet()) { + if (curr.getKey() instanceof RecipeInputOreDict) { + if ("oreNULL".equalsIgnoreCase(((RecipeInputOreDict) curr.getKey()).input)) { + remset.add(curr); + } + for (ItemStack stack : curr.getValue().items) { + if (stack.getItem() instanceof BWMetaGeneratedItems) remset.add(curr); + } + } + } + Recipes.macerator.getRecipes() + .entrySet() + .removeAll(remset); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private static void runAdditionalOreDict() { + for (Werkstoff werkstoff : Werkstoff.werkstoffHashSet) { + if (werkstoff.hasItemType(ore)) { + GTOreDictUnificator.registerOre(ore + werkstoff.getVarName(), werkstoff.get(ore)); + GTOreDictUnificator.registerOre(oreSmall + werkstoff.getVarName(), werkstoff.get(oreSmall)); + werkstoff.getADDITIONAL_OREDICT() + .forEach(e -> OreDictionary.registerOre(ore + e, werkstoff.get(ore))); + werkstoff.getADDITIONAL_OREDICT() + .forEach(e -> OreDictionary.registerOre(oreSmall + e, werkstoff.get(oreSmall))); + } + + if (werkstoff.hasItemType(gem)) OreDictionary.registerOre( + "craftingLens" + BWColorUtil.getDyeFromColor(werkstoff.getRGBA()).mName.replace(" ", ""), + werkstoff.get(lens)); + + if (werkstoff.hasItemType(gem) || werkstoff.hasItemType(ingot)) { + GTOreDictUnificator.registerOre(block + werkstoff.getVarName(), werkstoff.get(block)); + werkstoff.getADDITIONAL_OREDICT() + .forEach(e -> OreDictionary.registerOre(block + e, werkstoff.get(block))); + } + + werkstoff.getADDITIONAL_OREDICT() + .forEach( + s -> ENABLED_ORE_PREFIXES.stream() + .filter(o -> Objects.nonNull(werkstoff.get(o))) + .forEach(od -> OreDictionary.registerOre(od + s, werkstoff.get(od)))); + } + + GTOreDictUnificator.registerOre("craftingIndustrialDiamond", WerkstoffLoader.CubicZirconia.get(gemExquisite)); + } +} diff --git a/src/main/java/bartworks/system/material/gtenhancement/BWGTMetaItems.java b/src/main/java/bartworks/system/material/gtenhancement/BWGTMetaItems.java new file mode 100644 index 0000000000..b543150e35 --- /dev/null +++ b/src/main/java/bartworks/system/material/gtenhancement/BWGTMetaItems.java @@ -0,0 +1,207 @@ +/* + * 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.system.material.gtenhancement; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import net.minecraftforge.oredict.OreDictionary; + +import bartworks.API.SideReference; +import bartworks.client.textures.PrefixTextureLinker; +import bartworks.system.material.BWMetaGeneratedItems; +import bartworks.system.material.Werkstoff; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TextureSet; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.common.render.items.GeneratedMaterialRenderer; + +public class BWGTMetaItems extends BWMetaGeneratedItems { + + private boolean hasList; + private final Set<Integer> hiddenThings = new HashSet<>(); + + public BWGTMetaItems(OrePrefixes orePrefixes, List<Materials> noSubIDMaterials) { + super(orePrefixes, null); + // materialloop: + for (int i = 0; i < Materials.values().length; i++) { + ItemStack tStack = new ItemStack(this, 1, i); + Materials material = Materials.values()[i]; + if (material.getMolten(1) == null && orePrefixes == OrePrefixes.capsuleMolten + || material.getFluid(1) == null && material.getGas(1) == null + && (orePrefixes == OrePrefixes.capsule || orePrefixes == OrePrefixes.bottle)) + continue; + + if (OreDictionary.doesOreNameExist(this.orePrefixes.name() + material.mDefaultLocalName.replace(" ", ""))) { + this.hiddenThings.add(i); + continue; + } + GTOreDictUnificator + .registerOre(this.orePrefixes.name() + material.mDefaultLocalName.replace(" ", ""), tStack); + } + + if (noSubIDMaterials != null) { + this.hasList = true; + // materialloop: + for (int i = 0; i < noSubIDMaterials.size(); i++) { + ItemStack tStack = new ItemStack(this, 1, i + 1001); + Materials w = noSubIDMaterials.get(i); + if (w.getMolten(1) == null && orePrefixes == OrePrefixes.capsuleMolten + || w.getFluid(1) == null && w.getGas(1) == null + && (orePrefixes == OrePrefixes.capsule || orePrefixes == OrePrefixes.bottle)) + continue; + + if (OreDictionary.doesOreNameExist(this.orePrefixes.name() + w.mDefaultLocalName.replace(" ", ""))) { + this.hiddenThings.add(i); + continue; + } + GTOreDictUnificator.registerOre(this.orePrefixes.name() + w.mDefaultLocalName.replace(" ", ""), tStack); + } + } + } + + private Materials getMaterial(ItemStack is) { + if (is == null || is.getItem() != this) return null; + final int meta = is.getItemDamage(); + return this.getMaterialFromMeta(meta); + } + + @Override + public String getItemStackDisplayName(ItemStack aStack) { + Materials material = this.getMaterial(aStack); + if (material == null) material = Materials._NULL; + return material.getLocalizedNameForItem(this.itemTypeLocalizedName); + } + + @Override + protected void addAdditionalToolTips(List<String> aList, ItemStack aStack, EntityPlayer aPlayer) { + Materials material = this.getMaterial(aStack); + if (material != null) { + String tooltip = material.getToolTip(); + if (tooltip != null && !tooltip.isEmpty()) { + aList.add(tooltip); + } + } + } + + @Override + public IIconContainer getIconContainer(int aMetaData) { + if (this.orePrefixes.mTextureIndex == -1) return this.getIconContainerBartWorks(aMetaData); + Materials material = this.getMaterialFromMeta(aMetaData); + if (material != null) { + return material.mIconSet.mTextures[this.orePrefixes.mTextureIndex]; + } + return null; + } + + @Override + protected IIconContainer getIconContainerBartWorks(int aMetaData) { + if (SideReference.Side.Server || PrefixTextureLinker.texMap == null) return null; + + HashMap<TextureSet, Textures.ItemIcons.CustomIcon> iconLink = PrefixTextureLinker.texMap.get(this.orePrefixes); + + if (iconLink == null) return null; + + Materials material = this.getMaterialFromMeta(aMetaData); + + if (material == null || material.mIconSet == null) return null; + + return iconLink.getOrDefault(material.mIconSet, iconLink.get(TextureSet.SET_DULL)); + } + + @Override + public IIcon getIconFromDamage(int aMetaData) { + return this.getIcon(aMetaData, 0); + } + + @Override + public GeneratedMaterialRenderer getMaterialRenderer(int aMetaData) { + return this.getMaterialFromMeta(aMetaData).renderer; + } + + public Materials getMaterialFromMeta(int aMetaData) { + if (aMetaData > 1000 && this.hasList) { + return GTMetaItemEnhancer.NoMetaValue.get(aMetaData - 1001); + } + if (aMetaData < 0 || aMetaData >= Materials.values().length) { + return null; + } + return Materials.values()[aMetaData]; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item var1, CreativeTabs aCreativeTab, List<ItemStack> aList) { + for (int i = 0; i < Materials.values().length; i++) { + Materials w = Materials.values()[i]; + if (w == null || (w.mTypes & Werkstoff.GenerationFeatures.getPrefixDataRaw(this.orePrefixes)) == 0 + && Werkstoff.GenerationFeatures.getPrefixDataRaw(this.orePrefixes) != 0) continue; + if (w.getMolten(1) == null && this.orePrefixes == OrePrefixes.capsuleMolten + || w.getFluid(1) == null && w.getGas(1) == null + && (this.orePrefixes == OrePrefixes.capsule || this.orePrefixes == OrePrefixes.bottle)) + continue; + else if (this.hiddenThings.contains(i)) continue; + aList.add(new ItemStack(this, 1, i)); + } + if (this.hasList) for (int i = 0; i < GTMetaItemEnhancer.NoMetaValue.size(); i++) { + Materials w = GTMetaItemEnhancer.NoMetaValue.get(i); + if (w == null || (w.mTypes & Werkstoff.GenerationFeatures.getPrefixDataRaw(this.orePrefixes)) == 0 + && Werkstoff.GenerationFeatures.getPrefixDataRaw(this.orePrefixes) != 0) continue; + if (w.getMolten(1) == null && this.orePrefixes == OrePrefixes.capsuleMolten + || w.getFluid(1) == null && w.getGas(1) == null + && (this.orePrefixes == OrePrefixes.capsule || this.orePrefixes == OrePrefixes.bottle)) + continue; + else if (this.hiddenThings.contains(i)) continue; + aList.add(new ItemStack(this, 1, i + 1001)); + } + } + + @Override + public short[] getColorForGUI(ItemStack aStack) { + return this.getMaterial(aStack).mRGBa; + } + + @Override + public String getNameForGUI(ItemStack aStack) { + return this.getMaterial(aStack).mDefaultLocalName; + } + + @Override + public void onUpdate(ItemStack aStack, World aWorld, Entity aPlayer, int aTimer, boolean aIsInHand) {} + + @Override + public short[] getRGBa(ItemStack aStack) { + return this.getMaterial(aStack).mRGBa; + } + + @Override + public boolean onEntityItemUpdate(EntityItem aItemEntity) { + return false; + } +} diff --git a/src/main/java/bartworks/system/material/gtenhancement/GTMetaItemEnhancer.java b/src/main/java/bartworks/system/material/gtenhancement/GTMetaItemEnhancer.java new file mode 100644 index 0000000000..d3c1bb2ece --- /dev/null +++ b/src/main/java/bartworks/system/material/gtenhancement/GTMetaItemEnhancer.java @@ -0,0 +1,150 @@ +/* + * 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.system.material.gtenhancement; + +import static gregtech.api.enums.Mods.Forestry; +import static gregtech.api.recipe.RecipeMaps.fluidCannerRecipes; +import static gregtech.api.util.GTRecipeBuilder.TICKS; +import static gregtech.api.util.GTRecipeBuilder.WILDCARD; + +import java.util.List; +import java.util.stream.Collectors; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +import codechicken.nei.api.API; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.GTUtility; + +public class GTMetaItemEnhancer { + + static List<Materials> NoMetaValue; + + private GTMetaItemEnhancer() {} + + public static void init() { + if (!Forestry.isModLoaded()) { + return; + } + NoMetaValue = Materials.getMaterialsMap() + .values() + .stream() + .filter(m -> m.mMetaItemSubID == -1) + .collect(Collectors.toList()); + Item moltenCapsuls = new BWGTMetaItems(OrePrefixes.capsuleMolten, null); + Item capsuls = new BWGTMetaItems(OrePrefixes.capsule, NoMetaValue); + // Item bottles = new BWGTMetaItems(OrePrefixes.bottle, NoMetaValue); + + Materials[] values = Materials.values(); + for (int i = 0, valuesLength = values.length; i < valuesLength; i++) { + Materials m = values[i]; + if (m.mStandardMoltenFluid != null && GTOreDictUnificator.get(OrePrefixes.cellMolten, m, 1) != null) { + final FluidContainerRegistry.FluidContainerData emptyData = new FluidContainerRegistry.FluidContainerData( + m.getMolten(144), + new ItemStack(moltenCapsuls, 1, i), + GTModHandler.getModItem(Forestry.ID, "refractoryEmpty", 1)); + FluidContainerRegistry.registerFluidContainer(emptyData); + GTUtility.addFluidContainerData(emptyData); + + GTValues.RA.stdBuilder() + .itemInputs(GTModHandler.getModItem(Forestry.ID, "refractoryEmpty", 1)) + .itemOutputs(new ItemStack(moltenCapsuls, 1, i)) + .fluidInputs(m.getMolten(144)) + .duration(2 * TICKS) + .eut(2) + .addTo(fluidCannerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(moltenCapsuls, 1, i)) + .fluidOutputs(m.getMolten(144)) + .duration(2 * TICKS) + .eut(2) + .addTo(fluidCannerRecipes); + + } + if (m.getFluid(1) == null && m.getGas(1) == null || OreDictionary.doesOreNameExist("capsule" + m.mName)) + continue; + addFluidData(m, GTModHandler.getModItem(Forestry.ID, "waxCapsule", 1), capsuls, 1000, i, true); + // addFluidData(m, new ItemStack(Items.glass_bottle), bottles, 250, i, false); + } + for (int i = 0, valuesLength = NoMetaValue.size(); i < valuesLength; i++) { + Materials m = NoMetaValue.get(i); + if (m.getFluid(1) == null && m.getGas(1) == null || OreDictionary.doesOreNameExist("capsule" + m.mName)) + continue; + addFluidData(m, GTModHandler.getModItem(Forestry.ID, "waxCapsule", 1), capsuls, 1000, i + 1001, true); + // addFluidData(m, new ItemStack(Items.glass_bottle), bottles, 250, i + 1001, false); + } + + API.hideItem(new ItemStack(capsuls, 1, WILDCARD)); + API.hideItem(new ItemStack(moltenCapsuls, 1, WILDCARD)); + } + + private static void addFluidData(Materials m, ItemStack container, Item filled, int amount, int it, boolean empty) { + Fluid f = m.getFluid(1) != null ? m.getFluid(1) + .getFluid() + : m.getGas(1) + .getFluid(); + final FluidContainerRegistry.FluidContainerData emptyData = new FluidContainerRegistry.FluidContainerData( + new FluidStack(f, amount), + new ItemStack(filled, 1, it), + container); + FluidContainerRegistry.registerFluidContainer(emptyData); + GTUtility.addFluidContainerData(emptyData); + + GTValues.RA.stdBuilder() + .itemInputs(container) + .itemOutputs(new ItemStack(filled, 1, it)) + .fluidInputs(new FluidStack(f, amount)) + .duration(amount / 62) + .eut(2) + .addTo(fluidCannerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(filled, 1, it)) + .fluidOutputs(new FluidStack(f, amount)) + .duration(amount / 62) + .eut(2) + .addTo(fluidCannerRecipes); + + } + + public static void addAdditionalOreDictToForestry() { + if (!Forestry.isModLoaded()) return; + OreDictionary.registerOre("capsuleWater", getForestryItem("waxCapsuleWater")); + OreDictionary.registerOre("capsuleIce", getForestryItem("waxCapsuleIce")); + OreDictionary.registerOre("capsuleHoney", getForestryItem("waxCapsuleHoney")); + OreDictionary.registerOre("capsuleJuice", getForestryItem("waxCapsuleJuice")); + OreDictionary.registerOre("capsuleSeedOil", getForestryItem("waxCapsuleSeedOil")); + OreDictionary.registerOre("capsuleEthanol", getForestryItem("waxCapsuleEthanol")); + OreDictionary.registerOre("capsuleBiomass", getForestryItem("waxCapsuleBiomass")); + OreDictionary.registerOre("capsuleShortMead", getForestryItem("waxCapsuleShortMead")); + OreDictionary.registerOre("capsuleMead", getForestryItem("waxCapsuleMead")); + OreDictionary.registerOre("capsuleFuel", getForestryItem("waxCapsuleFuel")); + OreDictionary.registerOre("capsuleOil", getForestryItem("waxCapsuleOil")); + OreDictionary.registerOre("capsuleLava", getForestryItem("refractoryLava")); + } + + private static ItemStack getForestryItem(String itemName) { + return GTModHandler.getModItem(Forestry.ID, itemName, 1); + } +} diff --git a/src/main/java/bartworks/system/material/gtenhancement/PlatinumSludgeOverHaul.java b/src/main/java/bartworks/system/material/gtenhancement/PlatinumSludgeOverHaul.java new file mode 100644 index 0000000000..a20996d463 --- /dev/null +++ b/src/main/java/bartworks/system/material/gtenhancement/PlatinumSludgeOverHaul.java @@ -0,0 +1,1102 @@ +/* + * 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.system.material.gtenhancement; + +import static bartworks.system.material.WerkstoffLoader.AcidicIridiumSolution; +import static bartworks.system.material.WerkstoffLoader.AcidicOsmiumSolution; +import static bartworks.system.material.WerkstoffLoader.AmmoniumChloride; +import static bartworks.system.material.WerkstoffLoader.AquaRegia; +import static bartworks.system.material.WerkstoffLoader.CalciumChloride; +import static bartworks.system.material.WerkstoffLoader.CrudeRhMetall; +import static bartworks.system.material.WerkstoffLoader.FormicAcid; +import static bartworks.system.material.WerkstoffLoader.HotRutheniumTetroxideSollution; +import static bartworks.system.material.WerkstoffLoader.IrLeachResidue; +import static bartworks.system.material.WerkstoffLoader.IrOsLeachResidue; +import static bartworks.system.material.WerkstoffLoader.IridiumChloride; +import static bartworks.system.material.WerkstoffLoader.IridiumDioxide; +import static bartworks.system.material.WerkstoffLoader.LeachResidue; +import static bartworks.system.material.WerkstoffLoader.OsmiumSolution; +import static bartworks.system.material.WerkstoffLoader.PDAmmonia; +import static bartworks.system.material.WerkstoffLoader.PDMetallicPowder; +import static bartworks.system.material.WerkstoffLoader.PDRawPowder; +import static bartworks.system.material.WerkstoffLoader.PDSalt; +import static bartworks.system.material.WerkstoffLoader.PGSDResidue; +import static bartworks.system.material.WerkstoffLoader.PGSDResidue2; +import static bartworks.system.material.WerkstoffLoader.PTConcentrate; +import static bartworks.system.material.WerkstoffLoader.PTMetallicPowder; +import static bartworks.system.material.WerkstoffLoader.PTRawPowder; +import static bartworks.system.material.WerkstoffLoader.PTResidue; +import static bartworks.system.material.WerkstoffLoader.PTSaltCrude; +import static bartworks.system.material.WerkstoffLoader.PTSaltRefined; +import static bartworks.system.material.WerkstoffLoader.PotassiumDisulfate; +import static bartworks.system.material.WerkstoffLoader.RHFilterCakeSolution; +import static bartworks.system.material.WerkstoffLoader.RHNitrate; +import static bartworks.system.material.WerkstoffLoader.RHSalt; +import static bartworks.system.material.WerkstoffLoader.RHSaltSolution; +import static bartworks.system.material.WerkstoffLoader.RHSulfate; +import static bartworks.system.material.WerkstoffLoader.RHSulfateSolution; +import static bartworks.system.material.WerkstoffLoader.ReRh; +import static bartworks.system.material.WerkstoffLoader.RhFilterCake; +import static bartworks.system.material.WerkstoffLoader.Rhodium; +import static bartworks.system.material.WerkstoffLoader.Ruthenium; +import static bartworks.system.material.WerkstoffLoader.RutheniumTetroxide; +import static bartworks.system.material.WerkstoffLoader.RutheniumTetroxideSollution; +import static bartworks.system.material.WerkstoffLoader.SodiumNitrate; +import static bartworks.system.material.WerkstoffLoader.SodiumRuthenate; +import static bartworks.system.material.WerkstoffLoader.Sodiumformate; +import static bartworks.system.material.WerkstoffLoader.Sodiumsulfate; +import static bartworks.system.material.WerkstoffLoader.ZincSulfate; +import static gregtech.api.enums.Mods.GalaxySpace; +import static gregtech.api.enums.Mods.NewHorizonsCoreMod; +import static gregtech.api.enums.OrePrefixes.cell; +import static gregtech.api.enums.OrePrefixes.crushed; +import static gregtech.api.enums.OrePrefixes.crushedCentrifuged; +import static gregtech.api.enums.OrePrefixes.crushedPurified; +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.dustImpure; +import static gregtech.api.enums.OrePrefixes.dustPure; +import static gregtech.api.enums.OrePrefixes.dustRefined; +import static gregtech.api.enums.OrePrefixes.dustSmall; +import static gregtech.api.enums.OrePrefixes.dustTiny; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.enums.OrePrefixes.nugget; +import static gregtech.api.enums.OrePrefixes.rawOre; +import static gregtech.api.recipe.RecipeMaps.*; +import static gregtech.api.util.GTRecipeBuilder.MINUTES; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; +import static gregtech.api.util.GTRecipeBuilder.TICKS; +import static gregtech.api.util.GTRecipeConstants.COIL_HEAT; +import static gregtech.api.util.GTRecipeConstants.UniversalChemical; +import static gtPlusPlus.core.material.MaterialsAlloy.HELICOPTER; +import static gtPlusPlus.core.material.MaterialsElements.STANDALONE.WHITE_METAL; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.FurnaceRecipes; +import net.minecraft.item.crafting.IRecipe; + +import bartworks.MainMod; +import bartworks.system.material.BWMetaGeneratedItems; +import bartworks.system.material.Werkstoff; +import bartworks.util.BWUtil; +import bwcrossmod.BartWorksCrossmod; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.interfaces.IRecipeMutableAccess; +import gregtech.api.interfaces.ISubTagContainer; +import gregtech.api.items.GTGenericBlock; +import gregtech.api.items.GTGenericItem; +import gregtech.api.objects.ItemData; +import gregtech.api.objects.MaterialStack; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.common.blocks.BlockOresAbstract; + +public class PlatinumSludgeOverHaul { + + private static final Materials[] BLACKLIST = { Materials.HSSS, Materials.EnderiumBase, Materials.Osmiridium, + Materials.TPV, Materials.get("Uraniumtriplatinid"), Materials.get("Tetranaquadahdiindiumhexaplatiumosminid"), + Materials.get("Longasssuperconductornameforuvwire"), }; + private static final OrePrefixes[] OPBLACKLIST = { crushedCentrifuged, crushed, crushedPurified, dustPure, + dustImpure, dustRefined, dust, dustTiny, dustSmall }; + + private PlatinumSludgeOverHaul() {} + + private static void runHelperrecipes() { + // DilutedSulfuricAcid + // 2H2SO4 + H2O = 3H2SO4(d) + GTValues.RA.stdBuilder() + .itemInputs( + Materials.SulfuricAcid.getCells(2), + Materials.Water.getCells(1), + GTUtility.getIntegratedCircuit(1)) + .itemOutputs(Materials.DilutedSulfuricAcid.getCells(3)) + .duration(1 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(mixerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(Materials.Water.getCells(1), GTUtility.getIntegratedCircuit(1)) + .itemOutputs(Materials.Empty.getCells(1)) + .fluidInputs(Materials.SulfuricAcid.getFluid(2000)) + .fluidOutputs(Materials.DilutedSulfuricAcid.getFluid(3000)) + .duration(1 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(mixerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(Materials.SulfuricAcid.getCells(2), GTUtility.getIntegratedCircuit(1)) + .itemOutputs(Materials.Empty.getCells(2)) + .fluidInputs(Materials.Water.getFluid(1000)) + .fluidOutputs(Materials.DilutedSulfuricAcid.getFluid(3000)) + .duration(1 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(mixerRecipes); + // FormicAcid + // CO + NaOH = CHO2Na + GTValues.RA.stdBuilder() + .itemInputs(Materials.CarbonMonoxide.getCells(1), Materials.SodiumHydroxide.getDust(3)) + .itemOutputs(Sodiumformate.get(cell)) + .duration(15 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + // H2SO4 + 2CHO2Na = 2CH2O2 + Na2SO4 + + GTValues.RA.stdBuilder() + .itemInputs(Sodiumformate.get(cell, 2), GTUtility.getIntegratedCircuit(1)) + .itemOutputs(FormicAcid.get(cell, 2), Sodiumsulfate.get(dust, 7)) + .fluidInputs(Materials.SulfuricAcid.getFluid(1000)) + .duration(15 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GTValues.RA.stdBuilder() + .itemInputs(Materials.SulfuricAcid.getCells(1), GTUtility.getIntegratedCircuit(1)) + .itemOutputs(Materials.Empty.getCells(1), Sodiumsulfate.get(dust, 7)) + .fluidInputs(Sodiumformate.getFluidOrGas(2000)) + .fluidOutputs(FormicAcid.getFluidOrGas(2000)) + .duration(15 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + // AquaRegia + GTValues.RA.stdBuilder() + .itemInputs( + Materials.DilutedSulfuricAcid.getCells(1), + Materials.NitricAcid.getCells(1), + GTUtility.getIntegratedCircuit(1)) + .itemOutputs(AquaRegia.get(cell, 2)) + .duration(1 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(mixerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs( + Materials.DilutedSulfuricAcid.getCells(1), + Materials.NitricAcid.getCells(1), + GTUtility.getIntegratedCircuit(2)) + .itemOutputs(Materials.Empty.getCells(2)) + .fluidOutputs(AquaRegia.getFluidOrGas(2000)) + .duration(1 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(mixerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(Materials.NitricAcid.getCells(1), GTUtility.getIntegratedCircuit(3)) + .itemOutputs(Materials.Empty.getCells(1)) + .fluidInputs(Materials.DilutedSulfuricAcid.getFluid(1000)) + .fluidOutputs(AquaRegia.getFluidOrGas(2000)) + .duration(1 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(mixerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(Materials.DilutedSulfuricAcid.getCells(1), GTUtility.getIntegratedCircuit(4)) + .itemOutputs(Materials.Empty.getCells(1)) + .fluidInputs(Materials.NitricAcid.getFluid(1000)) + .fluidOutputs(AquaRegia.getFluidOrGas(2000)) + .duration(1 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(mixerRecipes); + + // AmmoniumChloride + // NH3 + HCl = NH4Cl + + GTValues.RA.stdBuilder() + .itemInputs(Materials.Ammonia.getCells(1), GTUtility.getIntegratedCircuit(1)) + .itemOutputs(AmmoniumChloride.get(cell, 1)) + .fluidInputs(Materials.HydrochloricAcid.getFluid(1000)) + .duration(15 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GTValues.RA.stdBuilder() + .itemInputs(Materials.HydrochloricAcid.getCells(1), GTUtility.getIntegratedCircuit(1)) + .itemOutputs(Materials.Empty.getCells(1)) + .fluidInputs(Materials.Ammonia.getGas(1000)) + .fluidOutputs(AmmoniumChloride.getFluidOrGas(1000)) + .duration(15 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GTValues.RA.stdBuilder() + .itemInputs(GTUtility.getIntegratedCircuit(9)) + .fluidInputs(Materials.Ammonia.getGas(64000), Materials.HydrochloricAcid.getFluid(64000)) + .fluidOutputs(AmmoniumChloride.getFluidOrGas(64000)) + .duration(3 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(multiblockChemicalReactorRecipes); + + // base solution + for (Werkstoff w : Werkstoff.werkstoffHashSet) if (w.containsStuff(Materials.Sulfur) + && (w.containsStuff(Materials.Copper) || w.containsStuff(Materials.Nickel))) { + + GTValues.RA.stdBuilder() + .itemInputs(w.get(crushedPurified), GTUtility.getIntegratedCircuit(1)) + .fluidInputs(AquaRegia.getFluidOrGas(150)) + .fluidOutputs(PTConcentrate.getFluidOrGas(150)) + .duration(12 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GTValues.RA.stdBuilder() + .itemInputs(w.get(crushedPurified, 9), GTUtility.getIntegratedCircuit(9)) + .fluidInputs(AquaRegia.getFluidOrGas(1350)) + .fluidOutputs(PTConcentrate.getFluidOrGas(1350)) + .duration(11 * SECONDS + 5 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GTValues.RA.stdBuilder() + .itemInputs(w.get(crushedPurified, 9), PTMetallicPowder.get(dust, 9)) + .itemOutputs(PTResidue.get(dust)) + .fluidInputs(AquaRegia.getFluidOrGas(10350)) + .fluidOutputs(PTConcentrate.getFluidOrGas(10350)) + .duration(1 * MINUTES + 52 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + } + for (Materials m : Materials.values()) if (PlatinumSludgeOverHaul.materialsContains(m, Materials.Sulfur) + && (PlatinumSludgeOverHaul.materialsContains(m, Materials.Copper) + || PlatinumSludgeOverHaul.materialsContains(m, Materials.Nickel))) { + + GTValues.RA.stdBuilder() + .itemInputs(GTOreDictUnificator.get(crushedPurified, m, 1), GTUtility.getIntegratedCircuit(1)) + .fluidInputs(AquaRegia.getFluidOrGas(150)) + .fluidOutputs(PTConcentrate.getFluidOrGas(150)) + .duration(12 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GTValues.RA.stdBuilder() + .itemInputs(GTOreDictUnificator.get(crushedPurified, m, 9), GTUtility.getIntegratedCircuit(9)) + .fluidInputs(AquaRegia.getFluidOrGas(1350)) + .fluidOutputs(PTConcentrate.getFluidOrGas(1350)) + .duration(1 * MINUTES + 52 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GTValues.RA.stdBuilder() + .itemInputs(GTOreDictUnificator.get(crushedPurified, m, 9), PTMetallicPowder.get(dust, 9)) + .itemOutputs(PTResidue.get(dust)) + .fluidInputs(AquaRegia.getFluidOrGas(10350)) + .fluidOutputs(PTConcentrate.getFluidOrGas(10350)) + .duration(1 * MINUTES + 52 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + } + // Pt + GTValues.RA.stdBuilder() + .itemInputs(PTMetallicPowder.get(dust, 3), GTUtility.getIntegratedCircuit(1)) + .itemOutputs(Materials.Platinum.getNuggets(2)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_MV) + .metadata(COIL_HEAT, Materials.Platinum.mMeltingPoint) + .addTo(blastFurnaceRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(PTMetallicPowder.get(dust), GTUtility.getIntegratedCircuit(1)) + .itemOutputs(PTResidue.get(dustTiny)) + .fluidInputs(AquaRegia.getFluidOrGas(1000)) + .fluidOutputs(PTConcentrate.getFluidOrGas(1000)) + .duration(12 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GTValues.RA.stdBuilder() + .itemInputs(PTMetallicPowder.get(dust, 9), GTUtility.getIntegratedCircuit(9)) + .itemOutputs(PTResidue.get(dust)) + .fluidInputs(AquaRegia.getFluidOrGas(9000)) + .fluidOutputs(PTConcentrate.getFluidOrGas(9000)) + .duration(1 * MINUTES + 52 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GTValues.RA.stdBuilder() + .itemInputs(PTConcentrate.get(cell, 2)) + .itemOutputs( + PTSaltCrude.get(dustTiny, 16), + PTRawPowder.get(dustTiny, 4), + Materials.NitrogenDioxide.getCells(1), + Materials.DilutedSulfuricAcid.getCells(1)) + .fluidInputs(AmmoniumChloride.getFluidOrGas(400)) + .fluidOutputs(PDAmmonia.getFluidOrGas(400)) + .duration(60 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(centrifugeRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(GTUtility.getIntegratedCircuit(1)) + .itemOutputs(PTSaltCrude.get(dustTiny, 16), PTRawPowder.get(dustTiny, 4)) + .fluidInputs(PTConcentrate.getFluidOrGas(2000), AmmoniumChloride.getFluidOrGas(400)) + .fluidOutputs( + PDAmmonia.getFluidOrGas(400), + Materials.NitrogenDioxide.getGas(1000), + Materials.DilutedSulfuricAcid.getFluid(1000)) + .duration(1200) + .eut(30) + .addTo(multiblockChemicalReactorRecipes); + // transitional recipe. to be removed in 2.8.0 and onwards + GTValues.RA.stdBuilder() + .itemInputs(GTUtility.getIntegratedCircuit(2)) + .itemOutputs(PTSaltCrude.get(dust, 16), PTRawPowder.get(dust, 4)) + .fluidInputs(PTConcentrate.getFluidOrGas(18000), AmmoniumChloride.getFluidOrGas(3600)) + .fluidOutputs( + PDAmmonia.getFluidOrGas(3600), + Materials.NitrogenDioxide.getGas(9000), + Materials.DilutedSulfuricAcid.getFluid(9000)) + .duration(1400) + .eut(240) + .addTo(multiblockChemicalReactorRecipes); + GTValues.RA.stdBuilder() + .itemInputs(GTUtility.getIntegratedCircuit(3)) + .itemOutputs(PTSaltCrude.get(dust, 16), PTRawPowder.get(dust, 4)) + .fluidInputs(PTConcentrate.getFluidOrGas(18000), AmmoniumChloride.getFluidOrGas(3600)) + .fluidOutputs( + PDAmmonia.getFluidOrGas(3600), + Materials.NitrogenDioxide.getGas(9000), + Materials.DilutedSulfuricAcid.getFluid(9000)) + .duration(700) + .eut(480) + .addTo(multiblockChemicalReactorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(PTSaltCrude.get(dust)) + .itemOutputs( + PTSaltRefined.get(dust), + PTSaltRefined.get(dust), + PTSaltRefined.get(dust), + PTSaltRefined.get(dust), + PTSaltRefined.get(dust), + PTSaltRefined.get(dust), + PTSaltRefined.get(dust), + PTSaltRefined.get(dust), + PTSaltRefined.get(dust)) + .outputChances(1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1500) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(sifterRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(PTSaltRefined.get(dust), GTUtility.getIntegratedCircuit(1)) + .itemOutputs(PTMetallicPowder.get(dust)) + .fluidOutputs(Materials.Chlorine.getGas(87)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_MV) + .metadata(COIL_HEAT, 900) + .addTo(blastFurnaceRecipes); + + // 2PtCl + Ca = 2Pt + CaCl2 + + GTValues.RA.stdBuilder() + .itemInputs(PTRawPowder.get(dust, 4), Materials.Calcium.getDust(1)) + .itemOutputs(Materials.Platinum.getDust(2), CalciumChloride.get(dust, 3)) + .duration(1 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + // Pd + + GTValues.RA.stdBuilder() + .itemInputs(PDMetallicPowder.get(dust), GTUtility.getIntegratedCircuit(1)) + .fluidInputs(Materials.Ammonia.getGas(1000)) + .fluidOutputs(PDAmmonia.getFluidOrGas(1000)) + .duration(12 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GTValues.RA.stdBuilder() + .itemInputs(PDMetallicPowder.get(dust), GTUtility.getIntegratedCircuit(1)) + .itemOutputs(PDSalt.get(dustTiny, 16), PDRawPowder.get(dustTiny, 2)) + .fluidInputs(PDAmmonia.getFluidOrGas(1000)) + .duration(12 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GTValues.RA.stdBuilder() + .itemInputs(PDMetallicPowder.get(dust, 9), GTUtility.getIntegratedCircuit(9)) + .itemOutputs(PDSalt.get(dust, 16), PDRawPowder.get(dust, 2)) + .fluidInputs(PDAmmonia.getFluidOrGas(9000)) + .duration(1 * MINUTES + 52 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GTValues.RA.stdBuilder() + .itemInputs(GTUtility.getIntegratedCircuit(2)) + .itemOutputs(PDSalt.get(dust)) + .fluidInputs(PDAmmonia.getFluidOrGas(1000)) + .duration(12 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GTValues.RA.stdBuilder() + .itemInputs(PDSalt.get(dust)) + .itemOutputs( + PDMetallicPowder.get(dust), + PDMetallicPowder.get(dust), + PDMetallicPowder.get(dust), + PDMetallicPowder.get(dust), + PDMetallicPowder.get(dust), + PDMetallicPowder.get(dust), + PDMetallicPowder.get(dust), + PDMetallicPowder.get(dust), + PDMetallicPowder.get(dust)) + .outputChances(1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1500) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(sifterRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(PDRawPowder.get(dust, 4), Materials.Empty.getCells(1)) + .itemOutputs(Materials.Palladium.getDust(2), Materials.Ethylene.getCells(1)) + .fluidInputs(FormicAcid.getFluidOrGas(4000)) + .fluidOutputs(Materials.Ammonia.getGas(4000)) + .duration(12 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(chemicalReactorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(PDRawPowder.get(dust, 4)) + .itemOutputs(Materials.Palladium.getDust(2)) + .fluidInputs(FormicAcid.getFluidOrGas(4000)) + .fluidOutputs( + Materials.Ammonia.getGas(4000), + Materials.Ethylene.getGas(1000), + Materials.Water.getFluid(1000)) + .duration(12 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(multiblockChemicalReactorRecipes); + + // Na2SO4 + 2H = 2Na + H2SO4 + + GTValues.RA.stdBuilder() + .itemInputs(Sodiumsulfate.get(dust, 7), Materials.Hydrogen.getCells(2)) + .itemOutputs(Materials.Sodium.getDust(2), Materials.Empty.getCells(2)) + .fluidOutputs(Materials.SulfuricAcid.getFluid(1000)) + .duration(1 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + // Rh/Os/Ir/Ru + GTValues.RA.stdBuilder() + .itemInputs(PTResidue.get(dust), GTUtility.getIntegratedCircuit(11)) + .itemOutputs(LeachResidue.get(dust)) + .fluidInputs(PotassiumDisulfate.getMolten(360)) + .fluidOutputs(RHSulfate.getFluidOrGas(360)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_MV) + .metadata(COIL_HEAT, 775) + .addTo(blastFurnaceRecipes); + + // Ru + GTValues.RA.stdBuilder() + .itemInputs(LeachResidue.get(dust, 10), Materials.Saltpeter.getDust(10)) + .itemOutputs(SodiumRuthenate.get(dust, 3), IrOsLeachResidue.get(dust, 6)) + .fluidInputs(Materials.SaltWater.getFluid(1000)) + .fluidOutputs(GTModHandler.getSteam(1000)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_MV) + .metadata(COIL_HEAT, 775) + .addTo(blastFurnaceRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(SodiumRuthenate.get(dust, 6), Materials.Chlorine.getCells(3)) + .itemOutputs(Materials.Empty.getCells(3)) + .fluidOutputs(RutheniumTetroxideSollution.getFluidOrGas(9000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GTValues.RA.stdBuilder() + .itemInputs(GTUtility.getIntegratedCircuit(1)) + .fluidInputs(RutheniumTetroxideSollution.getFluidOrGas(1000)) + .fluidOutputs(HotRutheniumTetroxideSollution.getFluidOrGas(2000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_HV) + .noOptimize() + .addTo(fluidHeaterRecipes); + + GTValues.RA.stdBuilder() + .itemOutputs(Materials.Salt.getDust(6)) + .fluidInputs(HotRutheniumTetroxideSollution.getFluidOrGas(9000)) + .fluidOutputs(Materials.Water.getFluid(1800), RutheniumTetroxide.getFluidOrGas(7200)) + .duration(1 * MINUTES + 15 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(distillationTowerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(RutheniumTetroxide.get(dust, 1), Materials.HydrochloricAcid.getCells(6)) + .itemOutputs(Ruthenium.get(dust), Materials.Chlorine.getCells(6)) + .fluidOutputs(Materials.Water.getFluid(2000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + // Os + GTValues.RA.stdBuilder() + .itemInputs(IrOsLeachResidue.get(dust, 4), GTUtility.getIntegratedCircuit(11)) + .itemOutputs(IrLeachResidue.get(dust, 2)) + .fluidInputs(Materials.HydrochloricAcid.getFluid(1000)) + .fluidOutputs(AcidicOsmiumSolution.getFluidOrGas(2000)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_MV) + .metadata(COIL_HEAT, 775) + .addTo(blastFurnaceRecipes); + + GTValues.RA.stdBuilder() + .fluidInputs(AcidicOsmiumSolution.getFluidOrGas(1000)) + .fluidOutputs(OsmiumSolution.getFluidOrGas(100), Materials.Water.getFluid(900)) + .duration(7 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_IV) + .addTo(distillationTowerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(OsmiumSolution.get(cell), Materials.HydrochloricAcid.getCells(6)) + .itemOutputs(Materials.Osmium.getDust(1), Materials.Chlorine.getCells(7)) + .fluidOutputs(Materials.Water.getFluid(2000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + // Ir + GTValues.RA.stdBuilder() + .itemInputs(IrLeachResidue.get(dust), GTUtility.getIntegratedCircuit(1)) + .itemOutputs(PGSDResidue.get(dust), IridiumDioxide.get(dust)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_MV) + .metadata(COIL_HEAT, 775) + .addTo(blastFurnaceRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(IridiumDioxide.get(dust), Materials.HydrochloricAcid.getCells(1)) + .itemOutputs(Materials.Empty.getCells(1)) + .fluidOutputs(AcidicIridiumSolution.getFluidOrGas(1000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GTValues.RA.stdBuilder() + .itemInputs(AcidicIridiumSolution.get(cell), AmmoniumChloride.get(cell, 3)) + .itemOutputs(Materials.Empty.getCells(4), IridiumChloride.get(dust)) + .fluidOutputs(Materials.Ammonia.getGas(3000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GTValues.RA.stdBuilder() + .itemInputs(IridiumChloride.get(dust), Materials.Calcium.getDust(1)) + .itemOutputs(PGSDResidue2.get(dust), Materials.Iridium.getDust(1)) + .fluidOutputs(CalciumChloride.getFluidOrGas(3000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_EV) + .addTo(UniversalChemical); + // Rh + + GTValues.RA.stdBuilder() + .itemInputs(RHSulfate.get(cell, 11), GTUtility.getIntegratedCircuit(1)) + .itemOutputs(RHSulfateSolution.get(cell, 11), LeachResidue.get(dustTiny, 10)) + .fluidInputs(Materials.Water.getFluid(10000)) + .fluidOutputs(Materials.Potassium.getMolten(2000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GTValues.RA.stdBuilder() + .itemInputs(GTUtility.getIntegratedCircuit(3)) + .itemOutputs(LeachResidue.get(dust, 4)) + .fluidInputs(Materials.Water.getFluid(36000), RHSulfate.getFluidOrGas(39600)) + .fluidOutputs(Materials.Potassium.getMolten(7200), RHSulfateSolution.getFluidOrGas(39600)) + .duration(1 * MINUTES) + .eut(TierEU.RECIPE_LV) + .addTo(multiblockChemicalReactorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(Materials.Zinc.getDust(1)) + .itemOutputs(ZincSulfate.get(dust, 6), CrudeRhMetall.get(dust)) + .fluidInputs(RHSulfateSolution.getFluidOrGas(1000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GTValues.RA.stdBuilder() + .itemInputs(CrudeRhMetall.get(dust), Materials.Salt.getDust(1)) + .itemOutputs(RHSalt.get(dust, 3)) + .fluidInputs(Materials.Chlorine.getGas(1000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_MV) + .metadata(COIL_HEAT, 600) + .addTo(blastFurnaceRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(RHSalt.get(dust, 10)) + .fluidInputs(Materials.Water.getFluid(2000)) + .fluidOutputs(RHSaltSolution.getFluidOrGas(2000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(mixerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(SodiumNitrate.get(dust, 5), GTUtility.getIntegratedCircuit(1)) + .itemOutputs(RHNitrate.get(dust), Materials.Salt.getDust(2)) + .fluidInputs(RHSaltSolution.getFluidOrGas(1000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + // Na + HNO3 = NaNO3 + H + + GTValues.RA.stdBuilder() + .itemInputs(Materials.Sodium.getDust(1)) + .itemOutputs(SodiumNitrate.get(dust, 5)) + .fluidInputs(Materials.NitricAcid.getFluid(1000)) + .fluidOutputs(Materials.Hydrogen.getGas(1000)) + .duration(8 * TICKS) + .eut(60) + .addTo(UniversalChemical); + + GTValues.RA.stdBuilder() + .itemInputs(RHNitrate.get(dust)) + .itemOutputs( + RhFilterCake.get(dust), + RhFilterCake.get(dust), + RhFilterCake.get(dust), + RhFilterCake.get(dust), + RhFilterCake.get(dust), + RhFilterCake.get(dust), + RhFilterCake.get(dust), + RhFilterCake.get(dust), + RhFilterCake.get(dust)) + .outputChances(1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1500) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(sifterRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(RhFilterCake.get(dust)) + .fluidInputs(Materials.Water.getFluid(1000)) + .fluidOutputs(RHFilterCakeSolution.getFluidOrGas(1000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(mixerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(GTUtility.getIntegratedCircuit(2)) + .itemOutputs(ReRh.get(dust)) + .fluidInputs(RHFilterCakeSolution.getFluidOrGas(1000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GTValues.RA.stdBuilder() + .itemInputs(ReRh.get(dust), Materials.Empty.getCells(1)) + .itemOutputs(Rhodium.get(dust), Materials.Ammonia.getCells(1)) + .fluidInputs(Materials.HydrochloricAcid.getFluid(1000)) + .fluidOutputs(Materials.Chlorine.getGas(1000)) + .duration(15 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + } + + private static boolean materialsContains(Materials one, ISubTagContainer other) { + if (one == null || one.mMaterialList == null || one.mMaterialList.isEmpty()) return false; + for (MaterialStack stack : one.mMaterialList) if (stack.mMaterial.equals(other)) return true; + return false; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + public static void replacePureElements() { + // furnace + for (Object entry : FurnaceRecipes.smelting() + .getSmeltingList() + .entrySet()) { + Map.Entry realEntry = (Map.Entry) entry; + if (GTUtility.isStackValid(realEntry.getKey()) + && BWUtil.checkStackAndPrefix((ItemStack) realEntry.getKey())) { + ItemData association = GTOreDictUnificator.getAssociation((ItemStack) realEntry.getKey()); + if (!dust.equals(association.mPrefix) && !dustTiny.equals(association.mPrefix) + || !association.mMaterial.mMaterial.equals(Materials.Platinum)) + if (GTUtility.isStackValid(realEntry.getValue()) + && BWUtil.checkStackAndPrefix((ItemStack) realEntry.getValue())) { + ItemData ass = GTOreDictUnificator.getAssociation((ItemStack) realEntry.getValue()); + if (ass.mMaterial.mMaterial.equals(Materials.Platinum)) + if (!PlatinumSludgeOverHaul.isInBlackList((ItemStack) realEntry.getKey())) + realEntry.setValue( + PTMetallicPowder.get( + ass.mPrefix == nugget ? dustTiny : dust, + ((ItemStack) realEntry.getValue()).stackSize * 2)); + else if (ass.mMaterial.mMaterial.equals(Materials.Palladium)) + if (!PlatinumSludgeOverHaul.isInBlackList((ItemStack) realEntry.getKey())) + realEntry.setValue( + PDMetallicPowder.get( + ass.mPrefix == nugget ? dustTiny : dust, + ((ItemStack) realEntry.getValue()).stackSize * 2)); + } + } + } + // vanilla crafting + CraftingManager.getInstance() + .getRecipeList() + .forEach(PlatinumSludgeOverHaul::setnewMaterialInRecipe); + // gt crafting + GTModHandler.sBufferRecipeList.forEach(PlatinumSludgeOverHaul::setnewMaterialInRecipe); + // gt machines + maploop: for (RecipeMap<?> map : RecipeMap.ALL_RECIPE_MAPS.values()) { + if (map == fusionRecipes || map == unpackagerRecipes + || map == packagerRecipes + || map == replicatorRecipes + || "gt.recipe.eyeofharmony".equals(map.unlocalizedName) + || "gtpp.recipe.quantumforcesmelter".equals(map.unlocalizedName)) continue; + HashSet<GTRecipe> toDel = new HashSet<>(); + recipeloop: for (GTRecipe recipe : map.getAllRecipes()) { + if (recipe.mFakeRecipe) continue maploop; + + for (int i = 0; i < recipe.mFluidOutputs.length; i++) { + if (map.equals(fluidExtractionRecipes)) continue maploop; + if ("gtpp.recipe.alloyblastsmelter".equals(map.unlocalizedName)) continue maploop; + if (map.equals(multiblockChemicalReactorRecipes) || map.equals(chemicalReactorRecipes)) { + if (GTUtility.areFluidsEqual(Ruthenium.getMolten(1), recipe.mFluidOutputs[i]) + || GTUtility.areFluidsEqual(Rhodium.getMolten(1), recipe.mFluidOutputs[i])) + toDel.add(recipe); + else if (GTUtility.areFluidsEqual(Materials.Iridium.getMolten(1), recipe.mFluidOutputs[i])) { + recipe.mFluidOutputs[i] = AcidicIridiumSolution.getFluidOrGas(1000); + recipe.reloadOwner(); + } else if (GTUtility.areFluidsEqual(Materials.Platinum.getMolten(1), recipe.mFluidOutputs[i])) { + recipe.mFluidOutputs[i] = PTConcentrate.getFluidOrGas(1000); + recipe.reloadOwner(); + } else if (GTUtility.areFluidsEqual(Materials.Osmium.getMolten(1), recipe.mFluidOutputs[i])) { + recipe.mFluidOutputs[i] = AcidicOsmiumSolution.getFluidOrGas(1000); + recipe.reloadOwner(); + } + } else if (GTUtility.areFluidsEqual(Ruthenium.getMolten(1), recipe.mFluidOutputs[i]) + || GTUtility.areFluidsEqual(Rhodium.getMolten(1), recipe.mFluidOutputs[i]) + || GTUtility.areFluidsEqual(Materials.Iridium.getMolten(1), recipe.mFluidOutputs[i]) + || GTUtility.areFluidsEqual(Materials.Platinum.getMolten(1), recipe.mFluidOutputs[i])) + toDel.add(recipe); + else if (GTUtility.areFluidsEqual(Materials.Osmium.getMolten(1), recipe.mFluidOutputs[i])) + toDel.add(recipe); + } + for (int i = 0; i < recipe.mOutputs.length; i++) { + if (!GTUtility.isStackValid(recipe.mOutputs[i])) continue; + if ((BWUtil.areStacksEqualOrNull(Ruthenium.get(dust), recipe.mOutputs[i]) + || BWUtil.areStacksEqualOrNull(Ruthenium.get(dustImpure), recipe.mOutputs[i]) + || BWUtil.areStacksEqualOrNull(Ruthenium.get(dustPure), recipe.mOutputs[i])) + && !BWUtil.areStacksEqualOrNull(Ruthenium.get(ingot), recipe.mInputs[0])) { + for (ItemStack mInput : recipe.mInputs) + if (PlatinumSludgeOverHaul.isInBlackList(mInput)) continue recipeloop; + int amount = recipe.mOutputs[i].stackSize * 2; + recipe.mOutputs[i] = LeachResidue.get(dust, amount); + recipe.reloadOwner(); + } + if ((BWUtil.areStacksEqualOrNull(Rhodium.get(dust), recipe.mOutputs[i]) + || BWUtil.areStacksEqualOrNull(Rhodium.get(dustImpure), recipe.mOutputs[i]) + || BWUtil.areStacksEqualOrNull(Rhodium.get(dustPure), recipe.mOutputs[i])) + && !BWUtil.areStacksEqualOrNull(Rhodium.get(ingot), recipe.mInputs[0])) { + for (ItemStack mInput : recipe.mInputs) + if (PlatinumSludgeOverHaul.isInBlackList(mInput)) continue recipeloop; + int amount = recipe.mOutputs[i].stackSize * 2; + recipe.mOutputs[i] = CrudeRhMetall.get(dust, amount); + recipe.reloadOwner(); + } + if (!BWUtil.checkStackAndPrefix(recipe.mOutputs[i])) continue; + // Pt + if (GTOreDictUnificator.getAssociation(recipe.mOutputs[i]).mMaterial.mMaterial + .equals(Materials.Platinum)) { + for (ItemStack mInput : recipe.mInputs) { + if (PlatinumSludgeOverHaul.isInBlackList(mInput)) continue recipeloop; + } + if (dust.equals(GTOreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix) + || dustImpure.equals(GTOreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix) + || dustPure.equals(GTOreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { + int amount = recipe.mOutputs[i].stackSize; + recipe.mOutputs[i] = BWUtil.setStackSize(PTMetallicPowder.get(dust), amount * 2); + recipe.reloadOwner(); + } else if (dustSmall.equals(GTOreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { + int amount = recipe.mOutputs[i].stackSize; + recipe.mOutputs[i] = BWUtil.setStackSize(PTMetallicPowder.get(dustSmall), amount * 2); + recipe.reloadOwner(); + } else if (dustTiny.equals(GTOreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { + int amount = recipe.mOutputs[i].stackSize; + recipe.mOutputs[i] = BWUtil.setStackSize(PTMetallicPowder.get(dustTiny), amount * 2); + recipe.reloadOwner(); + } + } else if (GTOreDictUnificator.getAssociation(recipe.mOutputs[i]).mMaterial.mMaterial + .equals(Materials.Palladium)) { + for (ItemStack mInput : recipe.mInputs) { + if (PlatinumSludgeOverHaul.isInBlackList(mInput)) continue recipeloop; + } + if (dust.equals(GTOreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix) + || dustImpure.equals(GTOreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix) + || dustPure.equals(GTOreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { + int amount = recipe.mOutputs[i].stackSize; + recipe.mOutputs[i] = BWUtil.setStackSize(PDMetallicPowder.get(dust), amount * 4); + recipe.reloadOwner(); + } else + if (dustSmall.equals(GTOreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { + int amount = recipe.mOutputs[i].stackSize; + recipe.mOutputs[i] = BWUtil + .setStackSize(PDMetallicPowder.get(dustSmall), amount * 4); + recipe.reloadOwner(); + } else if (dustTiny + .equals(GTOreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { + int amount = recipe.mOutputs[i].stackSize; + recipe.mOutputs[i] = BWUtil + .setStackSize(PDMetallicPowder.get(dustTiny), amount * 4); + recipe.reloadOwner(); + } + } else if (GTOreDictUnificator.getAssociation(recipe.mOutputs[i]).mMaterial.mMaterial + .equals(Materials.Osmium)) { + for (ItemStack mInput : recipe.mInputs) { + if (PlatinumSludgeOverHaul.isInBlackList(mInput)) continue recipeloop; + } + if (dust.equals(GTOreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix) + || dustImpure.equals(GTOreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix) + || dustPure + .equals(GTOreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { + int amount = recipe.mOutputs[i].stackSize; + recipe.mOutputs[i] = BWUtil.setStackSize(IrOsLeachResidue.get(dust), amount); + recipe.reloadOwner(); + } else if (dustSmall + .equals(GTOreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { + int amount = recipe.mOutputs[i].stackSize; + recipe.mOutputs[i] = BWUtil + .setStackSize(IrOsLeachResidue.get(dustSmall), amount); + recipe.reloadOwner(); + } else if (dustTiny + .equals(GTOreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { + int amount = recipe.mOutputs[i].stackSize; + recipe.mOutputs[i] = BWUtil + .setStackSize(IrOsLeachResidue.get(dustTiny), amount); + recipe.reloadOwner(); + } + } else if (GTOreDictUnificator.getAssociation(recipe.mOutputs[i]).mMaterial.mMaterial + .equals(Materials.Iridium)) { + for (ItemStack mInput : recipe.mInputs) { + if (PlatinumSludgeOverHaul.isInBlackList(mInput)) continue recipeloop; + } + if (dust.equals(GTOreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix) + || dustImpure + .equals(GTOreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix) + || dustPure + .equals(GTOreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { + int amount = recipe.mOutputs[i].stackSize; + recipe.mOutputs[i] = BWUtil.setStackSize(IrLeachResidue.get(dust), amount); + recipe.reloadOwner(); + } else if (dustSmall + .equals(GTOreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { + int amount = recipe.mOutputs[i].stackSize; + recipe.mOutputs[i] = BWUtil + .setStackSize(IrLeachResidue.get(dustSmall), amount); + recipe.reloadOwner(); + } else if (dustTiny + .equals(GTOreDictUnificator.getAssociation(recipe.mOutputs[i]).mPrefix)) { + int amount = recipe.mOutputs[i].stackSize; + recipe.mOutputs[i] = BWUtil + .setStackSize(IrLeachResidue.get(dustTiny), amount); + recipe.reloadOwner(); + } + } + } + } + map.getBackend() + .removeRecipes(toDel); + } + // TODO: remove EnderIO recipes + + // fix HV tier + PlatinumSludgeOverHaul.replaceHVCircuitMaterials(); + // add new recipes + PlatinumSludgeOverHaul.runHelperrecipes(); + } + + @SuppressWarnings("deprecation") + private static void replaceHVCircuitMaterials() { + GTValues.RA.stdBuilder() + .itemInputs(Materials.Redstone.getDust(1), Materials.Electrum.getDust(1), GTUtility.getIntegratedCircuit(1)) + .itemOutputs(Materials.Electrotine.getDust(8)) + .duration(1 * MINUTES + 30 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(mixerRecipes); + + for (GTRecipe recipe : circuitAssemblerRecipes.getAllRecipes()) { + if (recipe.mEUt > 512) continue; + if (BWUtil.checkStackAndPrefix(recipe.mOutputs[0])) { + for (int i = 0; i < recipe.mInputs.length; i++) { + ItemStack stack = recipe.mInputs[i]; + ItemData ass = GTOreDictUnificator.getAssociation(stack); + if (BWUtil.checkStackAndPrefix(stack) && ass.mMaterial.mMaterial.equals(Materials.Platinum)) { + recipe.mInputs[i] = GTOreDictUnificator.get(ass.mPrefix, Materials.BlueAlloy, stack.stackSize); + recipe.reloadOwner(); + } + } + } + } + } + + private static void setnewMaterialInRecipe(IRecipe recipe) { + ItemStack otpt = recipe.getRecipeOutput(); + + if (!(recipe instanceof IRecipeMutableAccess mutableRecipe)) { + return; + } + + Object input = mutableRecipe.gt5u$getRecipeInputs(); + + if (input == null) { + return; + } + + if (GTUtility.areStacksEqual(otpt, Materials.Platinum.getDust(1), true)) { + if (PlatinumSludgeOverHaul.checkRecipe(input, Materials.Platinum)) return; + mutableRecipe.gt5u$setRecipeOutputItem(PTMetallicPowder.get(dust, otpt.stackSize * 2)); + } else if (GTUtility.areStacksEqual(otpt, Materials.Palladium.getDust(1), true)) { + if (PlatinumSludgeOverHaul.checkRecipe(input, Materials.Palladium)) return; + mutableRecipe.gt5u$setRecipeOutputItem(PDMetallicPowder.get(dust, otpt.stackSize * 2)); + } else if (GTUtility.areStacksEqual(otpt, Materials.Iridium.getDust(1), true)) { + if (PlatinumSludgeOverHaul.checkRecipe(input, Materials.Iridium)) return; + mutableRecipe.gt5u$setRecipeOutputItem(IrLeachResidue.get(dust, otpt.stackSize)); + } else if (GTUtility.areStacksEqual(otpt, Materials.Osmium.getDust(1), true)) { + if (PlatinumSludgeOverHaul.checkRecipe(input, Materials.Osmium)) return; + mutableRecipe.gt5u$setRecipeOutputItem(IrOsLeachResidue.get(dust, otpt.stackSize)); + } + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + public static boolean checkRecipe(Object input, Materials mat) { + if (input instanceof List || input instanceof Object[]) { + Set lists = new HashSet(), stacks = new HashSet(); + List ip = input instanceof List ? (List) input : new ArrayList(); + Object[] ip2 = input instanceof Object[] ? (Object[]) input : new Object[0]; + + for (Object o : ip) { + if (o instanceof List) lists.add(o); + else if (o instanceof ItemStack) stacks.add(o); + } + for (Object o : ip2) { + if (o instanceof List) lists.add(o); + else if (o instanceof ItemStack) stacks.add(o); + } + + for (Object o : lists) { + if (!((List) o).isEmpty()) stacks.add(((List) o).get(0)); + } + + boolean allSame = false; + for (Object stack : stacks) { + if (!(stack instanceof ItemStack)) { + allSame = false; + break; + } + allSame = BWUtil.checkStackAndPrefix((ItemStack) stack) + && GTOreDictUnificator.getAssociation((ItemStack) stack).mMaterial.mMaterial.equals(mat); + if (!allSame) break; + } + return allSame; + } + return false; + } + + private static boolean isInBlackList(ItemStack stack) { + if (stack == null || stack.getItem() instanceof BWMetaGeneratedItems + || MainMod.MOD_ID.equals(GameRegistry.findUniqueIdentifierFor(stack.getItem()).modId) + || BartWorksCrossmod.MOD_ID.equals(GameRegistry.findUniqueIdentifierFor(stack.getItem()).modId)) + return true; + + if (GameRegistry.findUniqueIdentifierFor(stack.getItem()).modId.equals(NewHorizonsCoreMod.ID) + && !stack.getUnlocalizedName() + .contains("dust") + && !stack.getUnlocalizedName() + .contains("Dust")) + return true; + + if (Block.getBlockFromItem(stack.getItem()) instanceof GTGenericBlock + && !(Block.getBlockFromItem(stack.getItem()) instanceof BlockOresAbstract)) return true; + + if (Arrays.stream(ItemList.values()) + .filter(ItemList::hasBeenSet) + .anyMatch(e -> !BWUtil.checkStackAndPrefix(stack) && GTUtility.areStacksEqual(e.get(1), stack, true))) + return true; + + if (stack.getItem() instanceof GTGenericItem) { + if (!BWUtil.checkStackAndPrefix(stack)) return false; + if (GTOreDictUnificator.getAssociation(stack).mPrefix != rawOre) { + return !Arrays.asList(PlatinumSludgeOverHaul.OPBLACKLIST) + .contains(GTOreDictUnificator.getAssociation(stack).mPrefix) + || Arrays.asList(PlatinumSludgeOverHaul.BLACKLIST) + .contains(GTOreDictUnificator.getAssociation(stack).mMaterial.mMaterial); + } + } + + try { + if (Class.forName("gtPlusPlus.core.item.base.BaseItemComponent") + .isAssignableFrom( + stack.getItem() + .getClass()) + && !stack.getUnlocalizedName() + .contains("dust") + && !stack.getUnlocalizedName() + .contains("Dust")) { + return true; + } + if (Class.forName("gtPlusPlus.core.block.base.BlockBaseModular") + .isAssignableFrom( + Block.getBlockFromItem(stack.getItem()) + .getClass())) { + return true; + } + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + if (stack.getItem() == HELICOPTER.getDust(1) + .getItem()) { + return true; + } + if (stack.getItem() == WHITE_METAL.getDust(1) + .getItem()) { + return true; + } + if (GalaxySpace.isModLoaded()) { + if (stack.getItem() == GTModHandler.getModItem(GalaxySpace.ID, "metalsblock", 1L, 7) + .getItem()) { + return true; + } + } + if (NewHorizonsCoreMod.isModLoaded()) { + if (stack.getItem() == GTModHandler.getModItem(NewHorizonsCoreMod.ID, "item.IndustryFrame", 1L) + .getItem()) { + return true; + } + } + if (!BWUtil.checkStackAndPrefix(stack)) { + return false; + } + return Arrays.asList(PlatinumSludgeOverHaul.BLACKLIST) + .contains(GTOreDictUnificator.getAssociation(stack).mMaterial.mMaterial); + } +} diff --git a/src/main/java/bartworks/system/material/processingLoaders/AddSomeRecipes.java b/src/main/java/bartworks/system/material/processingLoaders/AddSomeRecipes.java new file mode 100644 index 0000000000..d1a4b2d2cf --- /dev/null +++ b/src/main/java/bartworks/system/material/processingLoaders/AddSomeRecipes.java @@ -0,0 +1,95 @@ +/* + * 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.system.material.processingLoaders; + +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.dustSmall; +import static gregtech.api.recipe.RecipeMaps.centrifugeRecipes; +import static gregtech.api.util.GTRecipeBuilder.MINUTES; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; +import static gregtech.api.util.GTRecipeBuilder.TICKS; + +import bartworks.system.material.BWNonMetaMaterialItems; +import bartworks.system.material.WerkstoffLoader; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GTOreDictUnificator; + +public class AddSomeRecipes implements Runnable { + + public void run() { + + GTValues.RA.stdBuilder() + .itemInputs(BWNonMetaMaterialItems.Depleted_Tiberium_1.get(1)) + .itemOutputs( + WerkstoffLoader.Zirconium.get(dust), + WerkstoffLoader.Zirconium.get(dust), + WerkstoffLoader.Tiberium.get(dustSmall, 2), + WerkstoffLoader.Zirconium.get(dust, 2), + GTOreDictUnificator.get(dust, Materials.TungstenSteel, 8L), + GTOreDictUnificator.get(dust, Materials.Platinum, 1L)) + .outputChances(100_00, 50_00, 50_00, 25_00, 100_00, 100_00) + .fluidOutputs(WerkstoffLoader.Xenon.getFluidOrGas(1)) + .duration(12 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_EV) + .addTo(centrifugeRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(BWNonMetaMaterialItems.Depleted_Tiberium_2.get(1)) + .itemOutputs( + WerkstoffLoader.Zirconium.get(dust, 2), + WerkstoffLoader.Zirconium.get(dust, 2), + WerkstoffLoader.Tiberium.get(dust), + WerkstoffLoader.Zirconium.get(dust, 4), + GTOreDictUnificator.get(dust, Materials.TungstenSteel, 18L), + GTOreDictUnificator.get(dust, Materials.Platinum, 2L)) + .outputChances(100_00, 50_00, 50_00, 25_00, 100_00, 100_00) + .fluidOutputs(WerkstoffLoader.Xenon.getFluidOrGas(2)) + .duration(12 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_EV) + .addTo(centrifugeRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(BWNonMetaMaterialItems.Depleted_Tiberium_4.get(1)) + .itemOutputs( + WerkstoffLoader.Zirconium.get(dust, 4), + WerkstoffLoader.Zirconium.get(dust, 4), + WerkstoffLoader.Tiberium.get(dust, 2), + WerkstoffLoader.Zirconium.get(dust, 8), + GTOreDictUnificator.get(dust, Materials.TungstenSteel, 38L), + GTOreDictUnificator.get(dust, Materials.Platinum, 4L)) + .outputChances(100_00, 50_00, 50_00, 25_00, 100_00, 100_00) + .fluidOutputs(WerkstoffLoader.Xenon.getFluidOrGas(4)) + .duration(50 * SECONDS) + .eut(TierEU.RECIPE_EV) + .addTo(centrifugeRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(BWNonMetaMaterialItems.Depleted_TheCoreCell.get(1)) + .itemOutputs( + ItemList.Depleted_Naquadah_4.get(8), + WerkstoffLoader.Zirconium.get(dust, 64), + WerkstoffLoader.Zirconium.get(dust, 64), + GTOreDictUnificator.get(dust, Materials.TungstenSteel, 64L), + GTOreDictUnificator.get(dust, Materials.TungstenSteel, 64L), + GTOreDictUnificator.get(dust, Materials.TungstenSteel, 48L)) + .outputChances(100_00, 50_00, 50_00, 100_00, 100_00, 100_00) + .duration(1 * MINUTES + 40 * SECONDS) + .eut(TierEU.RECIPE_IV) + .addTo(centrifugeRecipes); + + } +} diff --git a/src/main/java/bartworks/system/material/processingLoaders/AdditionalRecipes.java b/src/main/java/bartworks/system/material/processingLoaders/AdditionalRecipes.java new file mode 100644 index 0000000000..416b12dbf7 --- /dev/null +++ b/src/main/java/bartworks/system/material/processingLoaders/AdditionalRecipes.java @@ -0,0 +1,537 @@ +/* + * 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.system.material.processingLoaders; + +import static bartworks.API.recipe.BartWorksRecipeMaps.bacterialVatRecipes; +import static bartworks.API.recipe.BartWorksRecipeMaps.bioLabRecipes; +import static gregtech.api.enums.Mods.Gendustry; +import static gregtech.api.enums.OrePrefixes.bolt; +import static gregtech.api.enums.OrePrefixes.crushed; +import static gregtech.api.enums.OrePrefixes.crushedPurified; +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.dustSmall; +import static gregtech.api.enums.OrePrefixes.gem; +import static gregtech.api.enums.OrePrefixes.gemChipped; +import static gregtech.api.enums.OrePrefixes.gemFlawed; +import static gregtech.api.enums.OrePrefixes.stick; +import static gregtech.api.enums.OrePrefixes.stickLong; +import static gregtech.api.recipe.RecipeMaps.assemblerRecipes; +import static gregtech.api.recipe.RecipeMaps.autoclaveRecipes; +import static gregtech.api.recipe.RecipeMaps.blastFurnaceRecipes; +import static gregtech.api.recipe.RecipeMaps.cannerRecipes; +import static gregtech.api.recipe.RecipeMaps.centrifugeRecipes; +import static gregtech.api.recipe.RecipeMaps.distillationTowerRecipes; +import static gregtech.api.recipe.RecipeMaps.extremeNaquadahReactorFuels; +import static gregtech.api.recipe.RecipeMaps.fusionRecipes; +import static gregtech.api.recipe.RecipeMaps.hugeNaquadahReactorFuels; +import static gregtech.api.recipe.RecipeMaps.implosionRecipes; +import static gregtech.api.recipe.RecipeMaps.largeNaquadahReactorFuels; +import static gregtech.api.recipe.RecipeMaps.primitiveBlastRecipes; +import static gregtech.api.recipe.RecipeMaps.sifterRecipes; +import static gregtech.api.recipe.RecipeMaps.smallNaquadahReactorFuels; +import static gregtech.api.recipe.RecipeMaps.ultraHugeNaquadahReactorFuels; +import static gregtech.api.util.GTRecipeBuilder.MINUTES; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; +import static gregtech.api.util.GTRecipeBuilder.TICKS; +import static gregtech.api.util.GTRecipeConstants.ADDITIVE_AMOUNT; +import static gregtech.api.util.GTRecipeConstants.COIL_HEAT; +import static gregtech.api.util.GTRecipeConstants.FUEL_VALUE; +import static gregtech.api.util.GTRecipeConstants.FUSION_THRESHOLD; +import static gregtech.api.util.GTRecipeConstants.UniversalChemical; + +import java.util.Arrays; +import java.util.List; +import java.util.Objects; + +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; + +import bartworks.API.recipe.BartWorksRecipeMaps; +import bartworks.common.loaders.BioCultureLoader; +import bartworks.common.loaders.BioItemList; +import bartworks.common.loaders.FluidLoader; +import bartworks.common.loaders.ItemRegistry; +import bartworks.system.material.BWNonMetaMaterialItems; +import bartworks.system.material.WerkstoffLoader; +import bartworks.util.BioCulture; +import bartworks.util.BioDNA; +import bartworks.util.BioData; +import bartworks.util.BioPlasmid; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.GTUtility; +import gregtech.common.items.behaviors.BehaviourDataOrb; + +public class AdditionalRecipes { + + private static void runBWRecipes() { + + FluidStack[] dnaFluid = { Gendustry.isModLoaded() ? FluidRegistry.getFluidStack("liquiddna", 1000) + : Materials.Biomass.getFluid(1000L) }; + + for (ItemStack stack : BioItemList.getAllPetriDishes()) { + BioData DNA = BioData.getBioDataFromNBTTag( + stack.getTagCompound() + .getCompoundTag("DNA")); + if (DNA != null) { + ItemStack Detergent = BioItemList.getOther(1); + ItemStack DNAFlask = BioItemList.getDNASampleFlask(null); + ItemStack EthanolCell = Materials.Ethanol.getCells(1); + GTValues.RA.stdBuilder() + .itemInputs(stack, DNAFlask, Detergent, EthanolCell) + .itemOutputs( + BioItemList.getDNASampleFlask(BioDNA.convertDataToDNA(DNA)), + GTOreDictUnificator.get(OrePrefixes.cell, Materials.Empty, 1L)) + .outputChances(DNA.getChance(), 100_00) + .fluidInputs(FluidRegistry.getFluidStack("ic2distilledwater", 1000)) + .special(BioItemList.mBioLabParts[0]) + .duration(25 * SECONDS) + .eut(GTValues.VP[3 + DNA.getTier()]) + .ignoreCollision() + .fake() + .addTo(bioLabRecipes); + } + + } + + for (ItemStack stack : BioItemList.getAllDNASampleFlasks()) { + BioData DNA = BioData.getBioDataFromNBTTag(stack.getTagCompound()); + + if (DNA != null) { + ItemStack Outp = ItemList.Tool_DataOrb.get(1L); + BehaviourDataOrb.setDataTitle(Outp, "DNA Sample"); + BehaviourDataOrb.setDataName(Outp, DNA.getName()); + + GTValues.RA.stdBuilder() + .itemInputs( + stack, + FluidLoader.BioLabFluidCells[0], + FluidLoader.BioLabFluidCells[3], + ItemList.Tool_DataOrb.get(1L)) + .itemOutputs(Outp, ItemList.Cell_Empty.get(2L)) + .outputChances(DNA.getChance(), 100_00) + .fluidInputs(dnaFluid) + .special(BioItemList.mBioLabParts[1]) + .duration(25 * SECONDS) + .eut(GTValues.VP[4 + DNA.getTier()]) + .ignoreCollision() + .fake() + .addTo(bioLabRecipes); + } + } + + for (ItemStack stack : BioItemList.getAllPlasmidCells()) { + BioData DNA = BioData.getBioDataFromNBTTag(stack.getTagCompound()); + + if (DNA != null) { + ItemStack inp = ItemList.Tool_DataOrb.get(0L); + BehaviourDataOrb.setDataTitle(inp, "DNA Sample"); + BehaviourDataOrb.setDataName(inp, DNA.getName()); + ItemStack inp2 = ItemList.Tool_DataOrb.get(0L); + BehaviourDataOrb.setDataTitle(inp2, "DNA Sample"); + BehaviourDataOrb.setDataName(inp2, BioCultureLoader.BIO_DATA_BETA_LACMATASE.getName()); + + GTValues.RA.stdBuilder() + .itemInputs(FluidLoader.BioLabFluidCells[1], BioItemList.getPlasmidCell(null), inp, inp2) + .itemOutputs(stack, ItemList.Cell_Empty.get(1L)) + .outputChances(DNA.getChance(), 100_00) + .fluidInputs(dnaFluid) + .special(BioItemList.mBioLabParts[2]) + .duration(25 * SECONDS) + .eut(GTValues.VP[4 + DNA.getTier()]) + .ignoreCollision() + .fake() + .addTo(bioLabRecipes); + } + } + + for (ItemStack stack : BioItemList.getAllPetriDishes()) { + BioData DNA = BioData.getBioDataFromNBTTag( + stack.getTagCompound() + .getCompoundTag("DNA")); + BioData Plasmid = BioData.getBioDataFromNBTTag( + stack.getTagCompound() + .getCompoundTag("Plasmid")); + if (!Objects.equals(DNA.getName(), Plasmid.getName())) { + GTValues.RA.stdBuilder() + .itemInputs( + BioItemList.getPetriDish(BioCulture.getBioCulture(DNA.getName())), + BioItemList.getPlasmidCell(BioPlasmid.convertDataToPlasmid(Plasmid)), + FluidLoader.BioLabFluidCells[2]) + .itemOutputs(stack, ItemList.Cell_Empty.get(1L)) + .outputChances(Plasmid.getChance(), 100_00) + .fluidInputs(FluidRegistry.getFluidStack("ic2distilledwater", 1000)) + .special(BioItemList.mBioLabParts[3]) + .duration(25 * SECONDS) + .eut(TierEU.RECIPE_LuV) + .ignoreCollision() + .fake() + .addTo(bioLabRecipes); + } + } + + ItemStack Outp = ItemList.Tool_DataOrb.get(1L); + BehaviourDataOrb.setDataTitle(Outp, "DNA Sample"); + BehaviourDataOrb.setDataName(Outp, "Any DNA"); + // Clonal Cellular Synthesis- [Liquid DNA] + Medium Petri Dish + Plasma Membrane + Stem Cells + Genome Data + GTValues.RA.stdBuilder() + .itemInputs( + BioItemList.getPetriDish(null), + BioItemList.getOther(4), + ItemList.Circuit_Chip_Stemcell.get(2L), + Outp) + .itemOutputs( + BioItemList.getPetriDish(null) + .setStackDisplayName("The Culture made from DNA")) + .outputChances(75_00) + .fluidInputs(new FluidStack(dnaFluid[0].getFluid(), 8000)) + .special(BioItemList.mBioLabParts[4]) + .duration(25 * SECONDS) + .eut(TierEU.RECIPE_LuV) + .ignoreCollision() + .fake() + .addTo(bioLabRecipes); + + FluidStack[] easyFluids = { Materials.Water.getFluid(1000L), + FluidRegistry.getFluidStack("ic2distilledwater", 1000) }; + for (FluidStack fluidStack : easyFluids) { + for (BioCulture bioCulture : BioCulture.BIO_CULTURE_ARRAY_LIST) { + if (bioCulture.isBreedable() && bioCulture.getTier() == 0) { + GTValues.RA.stdBuilder() + .itemInputs(GTUtility.getIntegratedCircuit(1), new ItemStack(Items.sugar, 64)) + .special(BioItemList.getPetriDish(bioCulture)) + .fluidInputs(fluidStack) + .fluidOutputs(new FluidStack(bioCulture.getFluid(), 10)) + .duration(50 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(bacterialVatRecipes); + + GTValues.RA.stdBuilder() + .itemInputs( + BioItemList.getPetriDish(null), + fluidStack.equals(Materials.Water.getFluid(1000L)) ? Materials.Water.getCells(1) + : GTUtility.getContainersFromFluid(GTModHandler.getDistilledWater(1000)) + .get(0)) + .itemOutputs(BioItemList.getPetriDish(bioCulture), Materials.Empty.getCells(1)) + .outputChances(bioCulture.getChance(), 100_00) + .fluidInputs(new FluidStack(bioCulture.getFluid(), 1000)) + .duration(25 * SECONDS) + .eut(TierEU.RECIPE_HV) + .ignoreCollision() + .fake() + .addTo(bioLabRecipes); + } + } + } + + List<Pair<Materials, Integer>> liquidFuels = Arrays.asList( + ImmutablePair.of(Materials.PhosphoricAcid, 36), + ImmutablePair.of(Materials.DilutedHydrochloricAcid, 14), + ImmutablePair.of(Materials.HypochlorousAcid, 30), + ImmutablePair.of(Materials.HydrofluoricAcid, 40), + ImmutablePair.of(Materials.HydrochloricAcid, 28), + ImmutablePair.of(Materials.NitricAcid, 24), + ImmutablePair.of(Materials.Mercury, 32), + ImmutablePair.of(Materials.DilutedSulfuricAcid, 9), + ImmutablePair.of(Materials.SulfuricAcid, 18), + ImmutablePair.of(Materials.AceticAcid, 11), + ImmutablePair.of(WerkstoffLoader.FormicAcid.getBridgeMaterial(), 40)); + for (Pair<Materials, Integer> fuel : liquidFuels) { + GTValues.RA.stdBuilder() + .itemInputs( + fuel.getLeft() + .getCells(1)) + .itemOutputs(Materials.Empty.getCells(1)) + .metadata(FUEL_VALUE, fuel.getRight()) + .addTo(BartWorksRecipeMaps.acidGenFuels); + } + GTValues.RA.stdBuilder() + .itemInputs(GTOreDictUnificator.get(OrePrefixes.cellMolten, Materials.Redstone, 1)) + .itemOutputs(Materials.Empty.getCells(1)) + .metadata(FUEL_VALUE, 10) + .addTo(BartWorksRecipeMaps.acidGenFuels); + } + + @SuppressWarnings("deprecation") + public static void run() { + runBWRecipes(); + + GTValues.RA.stdBuilder() + .itemInputs(WerkstoffLoader.RawAdemicSteel.get(dust)) + .itemOutputs(WerkstoffLoader.AdemicSteel.get(dust)) + .duration(1 * SECONDS) + .eut(TierEU.RECIPE_LV) + .metadata(ADDITIVE_AMOUNT, 4) + .addTo(implosionRecipes); + + // Thorium/Yttrium Glas + GTValues.RA.stdBuilder() + .itemInputs(WerkstoffLoader.YttriumOxide.get(dustSmall, 2), WerkstoffLoader.Thorianit.get(dustSmall, 2)) + .itemOutputs(new ItemStack(ItemRegistry.bw_glasses[0], 1, 12)) + .fluidInputs(Materials.Glass.getMolten(144)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_IV) + .metadata(COIL_HEAT, 3663) + .addTo(blastFurnaceRecipes); + + // Thorianite recipes + GTValues.RA.stdBuilder() + .itemInputs(WerkstoffLoader.Thorianit.get(crushedPurified)) + .itemOutputs( + WerkstoffLoader.Thorianit.get(dust), + WerkstoffLoader.Thorianit.get(dust), + WerkstoffLoader.Thorianit.get(dust), + Materials.Thorium.getDust(1), + Materials.Thorium.getDust(1), + WerkstoffLoader.Thorium232.get(dust)) + .outputChances(7000, 1300, 700, 600, 300, 100) + .duration(20 * SECONDS) + .eut((int) TierEU.RECIPE_IV) + .addTo(sifterRecipes); + + // 3ThO2 + 4Al = 3Th + 2Al2O3 + GTValues.RA.stdBuilder() + .itemInputs(WerkstoffLoader.Thorianit.get(dust, 9), Materials.Aluminium.getDust(4)) + .itemOutputs(Materials.Thorium.getDust(3), Materials.Aluminiumoxide.getDust(10)) + .duration(50 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + // ThO2 + 2Mg = Th + 2MgO + GTValues.RA.stdBuilder() + .itemInputs(WerkstoffLoader.Thorianit.get(dust, 3), Materials.Magnesium.getDust(2)) + .itemOutputs(Materials.Thorium.getDust(1), Materials.Magnesia.getDust(4)) + .duration(50 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + GTValues.RA.stdBuilder() + .itemInputs(WerkstoffLoader.Thorianit.get(crushed), ItemList.Crop_Drop_Thorium.get(9)) + .itemOutputs(WerkstoffLoader.Thorianit.get(crushedPurified, 4)) + .fluidInputs(Materials.Water.getFluid(1000)) + .fluidOutputs(Materials.Thorium.getMolten(144)) + .duration(4 * SECONDS + 16 * TICKS) + .eut(24) + .addTo(UniversalChemical); + + // Prasiolite + GTValues.RA.stdBuilder() + .itemInputs(GTOreDictUnificator.get(dust, Materials.Quartzite, 40L), Materials.Amethyst.getDust(10)) + .itemOutputs(WerkstoffLoader.Prasiolite.get(OrePrefixes.gemFlawed, 20)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_MV) + .metadata(COIL_HEAT, 500) + .addTo(blastFurnaceRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(GTOreDictUnificator.get(dust, Materials.Quartzite, 40L)) + .itemOutputs(Materials.Amethyst.getDust(10)) + .duration(40 * SECONDS) + .eut(0) + .metadata(ADDITIVE_AMOUNT, 6) + .addTo(primitiveBlastRecipes); + + // Cubic Circonia + // 2Y + 3O = Y2O3 + GTValues.RA.stdBuilder() + .itemInputs(Materials.Yttrium.getDust(2), GTUtility.getIntegratedCircuit(5)) + .itemOutputs(WerkstoffLoader.YttriumOxide.get(dust, 5)) + .fluidInputs(Materials.Oxygen.getGas(3000)) + .duration(3 * MINUTES + 24 * SECONDS + 16 * TICKS) + .eut(TierEU.RECIPE_LV) + .addTo(UniversalChemical); + + // Zr + 2O =Y22O3= ZrO2 + GTValues.RA.stdBuilder() + .itemInputs(WerkstoffLoader.Zirconium.get(dust, 10), WerkstoffLoader.YttriumOxide.get(dust, 0)) + .itemOutputs(WerkstoffLoader.CubicZirconia.get(gemFlawed, 40)) + .fluidInputs(Materials.Oxygen.getGas(20000)) + .duration(48 * MINUTES) + .eut(TierEU.RECIPE_HV) + .metadata(COIL_HEAT, 2953) + .noOptimize() + .addTo(blastFurnaceRecipes); + + // Tellurium + GTValues.RA.stdBuilder() + .itemInputs(GTOreDictUnificator.get(crushed, Materials.Lead, 10L), GTUtility.getIntegratedCircuit(17)) + .itemOutputs(Materials.Lead.getIngots(10), Materials.Tellurium.getNuggets(20)) + .duration(40 * SECONDS) + .eut(TierEU.RECIPE_MV) + .metadata(COIL_HEAT, 722) + .addTo(blastFurnaceRecipes); + + GTValues.RA.stdBuilder() + .fluidInputs(Materials.Plutonium.getMolten(48), Materials.Beryllium.getMolten(48)) + .fluidOutputs(WerkstoffLoader.Californium.getMolten(48)) + .duration(12 * SECONDS) + .eut(49152) + .metadata(FUSION_THRESHOLD, 480_000_000) + .addTo(fusionRecipes); + + GTValues.RA.stdBuilder() + .fluidInputs(WerkstoffLoader.Californium.getMolten(32), WerkstoffLoader.Calcium.getMolten(720)) + .fluidOutputs(WerkstoffLoader.Oganesson.getFluidOrGas(720)) + .duration(24 * SECONDS) + .eut(49152) + .metadata(FUSION_THRESHOLD, 600_000_000) + .addTo(fusionRecipes); + + GTValues.RA.stdBuilder() + .fluidInputs(Materials.LiquidAir.getFluid(100000000)) + .fluidOutputs( + Materials.Nitrogen.getGas(78084000), + Materials.Oxygen.getGas(20946000), + Materials.Argon.getGas(934000), + Materials.CarbonDioxide.getGas(40700), + WerkstoffLoader.Neon.getFluidOrGas(1818), + Materials.Helium.getGas(524), + Materials.Methane.getGas(180), + WerkstoffLoader.Krypton.getFluidOrGas(114), + Materials.Hydrogen.getGas(55), + WerkstoffLoader.Xenon.getFluidOrGas(9)) + .duration(6 * MINUTES + 15 * SECONDS) + .eut(TierEU.RECIPE_EV) + .addTo(distillationTowerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(WerkstoffLoader.MagnetoResonaticDust.get(dust)) + .itemOutputs(WerkstoffLoader.MagnetoResonaticDust.get(gemChipped, 9)) + .outputChances(90_00) + .fluidInputs(WerkstoffLoader.Neon.getFluidOrGas(1000)) + .duration(25 * SECONDS) + .eut(TierEU.RECIPE_IV) + .addTo(autoclaveRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(WerkstoffLoader.MagnetoResonaticDust.get(dust)) + .itemOutputs(WerkstoffLoader.MagnetoResonaticDust.get(gem)) + .fluidInputs(WerkstoffLoader.Krypton.getFluidOrGas(1000)) + .duration(25 * SECONDS) + .eut(TierEU.RECIPE_IV) + .addTo(autoclaveRecipes); + + // Milk + + GTValues.RA.stdBuilder() + .itemInputs(GTUtility.getIntegratedCircuit(1)) + .itemOutputs( + Materials.Sugar.getDustSmall(21), + Materials.Calcium.getDustTiny(1), + Materials.Magnesium.getDustTiny(1), + Materials.Potassium.getDustTiny(1), + Materials.Sodium.getDustTiny(4), + Materials.Phosphorus.getDustTiny(1)) + .outputChances(100_00, 100_00, 10_00, 100_00, 10_00, 10_00) + .fluidInputs(Materials.Milk.getFluid(10000)) + .fluidOutputs(Materials.Water.getFluid(8832)) + .duration(2 * SECONDS + 10 * TICKS) + .eut(TierEU.RECIPE_MV) + .addTo(centrifugeRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(WerkstoffLoader.Tiberium.get(bolt)) + .duration(0) + .eut(0) + .metadata(FUEL_VALUE, 12_500) + .addTo(smallNaquadahReactorFuels); + + GTValues.RA.stdBuilder() + .itemInputs(WerkstoffLoader.Tiberium.get(stick)) + .duration(0) + .eut(0) + .metadata(FUEL_VALUE, 62_500) + .addTo(largeNaquadahReactorFuels); + + GTValues.RA.stdBuilder() + .itemInputs(WerkstoffLoader.Tiberium.get(stickLong)) + .duration(0) + .eut(0) + .metadata(FUEL_VALUE, 125_000) + .addTo(hugeNaquadahReactorFuels); + + GTValues.RA.stdBuilder() + .itemInputs(WerkstoffLoader.Tiberium.get(stick)) + .duration(0) + .eut(0) + .metadata(FUEL_VALUE, 31_250) + .addTo(extremeNaquadahReactorFuels); + + GTValues.RA.stdBuilder() + .itemInputs(WerkstoffLoader.Tiberium.get(stickLong)) + .duration(0) + .eut(0) + .metadata(FUEL_VALUE, 125_000) + .addTo(ultraHugeNaquadahReactorFuels); + + LoadItemContainers.run(); + + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Large_Fluid_Cell_TungstenSteel.get(1L), WerkstoffLoader.Tiberium.get(dust, 3)) + .itemOutputs(BWNonMetaMaterialItems.TiberiumCell_1.get(1L)) + .duration(1 * SECONDS + 10 * TICKS) + .eut(16) + .addTo(cannerRecipes); + GTValues.RA.stdBuilder() + .itemInputs( + BWNonMetaMaterialItems.TiberiumCell_1.get(2L), + GTOreDictUnificator.get(stick, Materials.TungstenSteel, 4L)) + .itemOutputs(BWNonMetaMaterialItems.TiberiumCell_2.get(1L)) + .duration(5 * SECONDS) + .eut(400) + .addTo(assemblerRecipes); + GTValues.RA.stdBuilder() + .itemInputs( + BWNonMetaMaterialItems.TiberiumCell_1.get(4L), + GTOreDictUnificator.get(stickLong, Materials.TungstenSteel, 6L)) + .itemOutputs(BWNonMetaMaterialItems.TiberiumCell_4.get(1L)) + .duration(7 * SECONDS + 10 * TICKS) + .eut(400) + .addTo(assemblerRecipes); + GTValues.RA.stdBuilder() + .itemInputs( + BWNonMetaMaterialItems.TiberiumCell_2.get(2L), + GTOreDictUnificator.get(stick, Materials.TungstenSteel, 4L)) + .itemOutputs(BWNonMetaMaterialItems.TiberiumCell_4.get(1L)) + .duration(5 * SECONDS) + .eut(400) + .addTo(assemblerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs( + ItemList.NaquadahCell_1.get(32L), + GTOreDictUnificator.get(stickLong, Materials.TungstenSteel, 64L), + GTOreDictUnificator.get(stickLong, Materials.TungstenSteel, 64L), + GTOreDictUnificator.get(stickLong, Materials.TungstenSteel, 64L), + WerkstoffLoader.Tiberium.get(dust, 64), + WerkstoffLoader.Tiberium.get(dust, 64)) + .itemOutputs(BWNonMetaMaterialItems.TheCoreCell.get(1L)) + .duration(5 * SECONDS) + .eut(TierEU.RECIPE_LuV) + .addTo(assemblerRecipes); + + GregTechAPI.sAfterGTPostload.add(new AddSomeRecipes()); + } +} diff --git a/src/main/java/bartworks/system/material/processingLoaders/DownTierLoader.java b/src/main/java/bartworks/system/material/processingLoaders/DownTierLoader.java new file mode 100644 index 0000000000..7be8b72bf0 --- /dev/null +++ b/src/main/java/bartworks/system/material/processingLoaders/DownTierLoader.java @@ -0,0 +1,47 @@ +/* + * 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.system.material.processingLoaders; + +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; + +import bartworks.util.BWUtil; +import bartworks.util.StreamUtils; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.util.GTRecipe; + +public class DownTierLoader { + + public static void run() { + RecipeMap.ALL_RECIPE_MAPS.values() + .stream() + .filter(map -> StreamUtils.filterVisualMaps(map) && map != RecipeMaps.fusionRecipes) + .forEach(map -> { + Set<GTRecipe> newRecipes = new HashSet<>(); + Set<GTRecipe> toRem = new HashSet<>(); + map.getAllRecipes() + .stream() + .filter(recipe -> Objects.nonNull(recipe) && recipe.mEUt > 128) + .forEach(recipe -> { + toRem.add(recipe); + newRecipes.add(BWUtil.copyAndSetTierToNewRecipe(recipe, (byte) 2)); + }); + map.getBackend() + .removeRecipes(toRem); + newRecipes.forEach(map::add); + }); + } +} diff --git a/src/main/java/bartworks/system/material/processingLoaders/LoadItemContainers.java b/src/main/java/bartworks/system/material/processingLoaders/LoadItemContainers.java new file mode 100644 index 0000000000..2e43490a25 --- /dev/null +++ b/src/main/java/bartworks/system/material/processingLoaders/LoadItemContainers.java @@ -0,0 +1,76 @@ +/* + * 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.system.material.processingLoaders; + +import bartworks.system.material.BWNonMetaMaterialItems; +import gregtech.api.items.ItemRadioactiveCellIC; +import gregtech.common.items.ItemDepletedCell; + +public class LoadItemContainers { + + public static void run() { + BWNonMetaMaterialItems.Depleted_Tiberium_1 + .set(new ItemDepletedCell("TiberiumcellDep", "Fuel Rod (Depleted Tiberium)", 1)); + BWNonMetaMaterialItems.Depleted_Tiberium_2 + .set(new ItemDepletedCell("Double_TiberiumcellDep", "Dual Fuel Rod (Depleted Tiberium)", 1)); + BWNonMetaMaterialItems.Depleted_Tiberium_4 + .set(new ItemDepletedCell("Quad_TiberiumcellDep", "Quad Fuel Rod (Depleted Tiberium)", 1)); + BWNonMetaMaterialItems.TiberiumCell_1.set( + new ItemRadioactiveCellIC( + "Tiberiumcell", + "Fuel Rod (Tiberium)", + 1, + 50000, + 2F, + 1, + 0.5F, + BWNonMetaMaterialItems.Depleted_Tiberium_1.get(1), + false)); + BWNonMetaMaterialItems.TiberiumCell_2.set( + new ItemRadioactiveCellIC( + "Double_Tiberiumcell", + "Dual Fuel Rod (Tiberium)", + 2, + 50000, + 2F, + 1, + 0.5F, + BWNonMetaMaterialItems.Depleted_Tiberium_2.get(1), + false)); + BWNonMetaMaterialItems.TiberiumCell_4.set( + new ItemRadioactiveCellIC( + "Quad_Tiberiumcell", + "Quad Fuel Rod (Tiberium)", + 4, + 50000, + 2F, + 1, + 0.5F, + BWNonMetaMaterialItems.Depleted_Tiberium_4.get(1), + false)); + BWNonMetaMaterialItems.Depleted_TheCoreCell + .set(new ItemDepletedCell("Core_Reactor_CellDep", "Depleted \"The Core\" Cell", 32)); + BWNonMetaMaterialItems.TheCoreCell.set( + new ItemRadioactiveCellIC( + "Core_Reactor_Cell", + "\"The Core\" Cell", + 32, + 100000, + 8F, + 32, + 1F, + BWNonMetaMaterialItems.Depleted_TheCoreCell.get(1), + false)); + } +} diff --git a/src/main/java/bartworks/system/material/werkstoff_loaders/IWerkstoffRunnable.java b/src/main/java/bartworks/system/material/werkstoff_loaders/IWerkstoffRunnable.java new file mode 100644 index 0000000000..8399091f8b --- /dev/null +++ b/src/main/java/bartworks/system/material/werkstoff_loaders/IWerkstoffRunnable.java @@ -0,0 +1,21 @@ +/* + * 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.system.material.werkstoff_loaders; + +import bartworks.system.material.Werkstoff; + +public interface IWerkstoffRunnable { + + void run(Werkstoff werkstoff); +} diff --git a/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/AspectLoader.java b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/AspectLoader.java new file mode 100644 index 0000000000..6635db3b3b --- /dev/null +++ b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/AspectLoader.java @@ -0,0 +1,57 @@ +/* + * 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.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.Mods.Thaumcraft; + +import java.util.Objects; + +import bartworks.system.material.Werkstoff; +import bartworks.system.material.WerkstoffLoader; +import bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; +import bartworks.util.Pair; +import bartworks.util.log.DebugLog; +import bwcrossmod.thaumcraft.util.ThaumcraftHandler; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TCAspects; + +public class AspectLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + if (!Thaumcraft.isModLoaded()) { + return; + } + + for (OrePrefixes enabledOrePrefixes : WerkstoffLoader.ENABLED_ORE_PREFIXES) { + if (werkstoff.hasItemType(enabledOrePrefixes)) { + if (enabledOrePrefixes.mMaterialAmount >= 3628800L || enabledOrePrefixes == OrePrefixes.ore) { + DebugLog.log( + "OrePrefix: " + enabledOrePrefixes.name() + + " mMaterialAmount: " + + enabledOrePrefixes.mMaterialAmount / 3628800L); + if (Objects.nonNull(WerkstoffLoader.items.get(enabledOrePrefixes))) + ThaumcraftHandler.AspectAdder.addAspectViaBW( + werkstoff.get(enabledOrePrefixes), + werkstoff.getTCAspects( + enabledOrePrefixes == OrePrefixes.ore ? 1 + : (int) (enabledOrePrefixes.mMaterialAmount / 3628800L))); + } else if (enabledOrePrefixes.mMaterialAmount >= 0L + && Objects.nonNull(WerkstoffLoader.items.get(enabledOrePrefixes))) + ThaumcraftHandler.AspectAdder + .addAspectViaBW(werkstoff.get(enabledOrePrefixes), new Pair<>(TCAspects.PERDITIO.mAspect, 1)); + } + } + } +} diff --git a/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/BlockLoader.java b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/BlockLoader.java new file mode 100644 index 0000000000..3637385328 --- /dev/null +++ b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/BlockLoader.java @@ -0,0 +1,73 @@ +/* + * 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.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.OrePrefixes.block; +import static gregtech.api.enums.OrePrefixes.cellMolten; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.enums.OrePrefixes.plate; +import static gregtech.api.recipe.RecipeMaps.cutterRecipes; +import static gregtech.api.recipe.RecipeMaps.fluidExtractionRecipes; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; +import static gregtech.api.util.GTRecipeBuilder.TICKS; +import static gregtech.api.util.GTRecipeConstants.UniversalArcFurnace; + +import bartworks.system.material.Werkstoff; +import bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.TierEU; +import gregtech.api.recipe.RecipeCategories; +import gregtech.api.util.GTRecipeConstants; + +public class BlockLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + if (!werkstoff.hasItemType(block)) return; + if (werkstoff.hasItemType(ingot)) { + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(block)) + .itemOutputs(werkstoff.get(ingot, 9)) + .duration(16 * TICKS) + .eut(90) + .metadata(GTRecipeConstants.RECYCLE, true) + .addTo(UniversalArcFurnace); + } + if (werkstoff.hasItemType(cellMolten)) { + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(block)) + .fluidOutputs(werkstoff.getMolten(1296)) + .recipeCategory(RecipeCategories.fluidExtractorRecycling) + .duration(14 * SECONDS + 8 * TICKS) + .eut(8) + .addTo(fluidExtractionRecipes); + + } + if (werkstoff.hasItemType(plate)) { + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(block)) + .itemOutputs(werkstoff.get(plate, 9)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 10L, + 1L)) + .eut(TierEU.RECIPE_LV) + .addTo(cutterRecipes); + + } + } +} diff --git a/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/CasingLoader.java b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/CasingLoader.java new file mode 100644 index 0000000000..06bda56804 --- /dev/null +++ b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/CasingLoader.java @@ -0,0 +1,77 @@ +/* + * 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.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.OrePrefixes.blockCasing; +import static gregtech.api.enums.OrePrefixes.blockCasingAdvanced; +import static gregtech.api.enums.OrePrefixes.gearGt; +import static gregtech.api.enums.OrePrefixes.gearGtSmall; +import static gregtech.api.enums.OrePrefixes.plank; +import static gregtech.api.enums.OrePrefixes.plate; +import static gregtech.api.enums.OrePrefixes.plateDouble; +import static gregtech.api.enums.OrePrefixes.screw; +import static gregtech.api.recipe.RecipeMaps.assemblerRecipes; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; + +import bartworks.system.material.BWGTMaterialReference; +import bartworks.system.material.Werkstoff; +import bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GTModHandler; + +public class CasingLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + if (werkstoff == BWGTMaterialReference.Wood /* || werkstoff == BW_GT_MaterialReference.WoodSealed */) { + addCasingRecipes(werkstoff, plank); + } else { + if (!werkstoff.hasGenerationFeature(blockCasing) || !werkstoff.doesOreDictedItemExists(plate) + || !werkstoff.doesOreDictedItemExists(screw) + || !werkstoff.doesOreDictedItemExists(gearGtSmall) + || !werkstoff.doesOreDictedItemExists(gearGt) + || !werkstoff.doesOreDictedItemExists(plateDouble)) return; + + addCasingRecipes(werkstoff, plateDouble); + } + } + + private static void addCasingRecipes(Werkstoff werkstoff, OrePrefixes reboltedCasingsOuterStuff) { + GTModHandler.addCraftingRecipe( + werkstoff.get(blockCasing), + new Object[] { "PSP", "PGP", "PSP", 'P', werkstoff.get(plate), 'S', werkstoff.get(screw), 'G', + werkstoff.get(gearGtSmall) }); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(plate, 6), werkstoff.get(screw, 2), werkstoff.get(gearGtSmall)) + .itemOutputs(werkstoff.get(blockCasing)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(assemblerRecipes); + + GTModHandler.addCraftingRecipe( + werkstoff.get(blockCasingAdvanced), + new Object[] { "PSP", "PGP", "PSP", 'P', werkstoff.get(reboltedCasingsOuterStuff), 'S', + werkstoff.get(screw), 'G', werkstoff.get(gearGt) }); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(reboltedCasingsOuterStuff, 6), werkstoff.get(screw, 2), werkstoff.get(gearGt)) + .itemOutputs(werkstoff.get(blockCasingAdvanced)) + .duration(10 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(assemblerRecipes); + } +} diff --git a/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/CellLoader.java b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/CellLoader.java new file mode 100644 index 0000000000..5458d24244 --- /dev/null +++ b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/CellLoader.java @@ -0,0 +1,330 @@ +/* + * 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.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.Mods.Forestry; +import static gregtech.api.enums.OrePrefixes.capsule; +import static gregtech.api.enums.OrePrefixes.cell; +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.recipe.RecipeMaps.fluidCannerRecipes; +import static gregtech.api.recipe.RecipeMaps.fluidExtractionRecipes; +import static gregtech.api.recipe.RecipeMaps.fluidSolidifierRecipes; +import static gregtech.api.recipe.RecipeMaps.scannerFakeRecipes; +import static gregtech.api.util.GTRecipeBuilder.TICKS; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Objects; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; + +import bartworks.system.material.Werkstoff; +import bartworks.system.material.WerkstoffLoader; +import bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; +import bartworks.util.Pair; +import gregtech.api.enums.Element; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TextureSet; +import gregtech.api.enums.TierEU; +import gregtech.api.interfaces.ISubTagContainer; +import gregtech.api.recipe.RecipeCategories; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.common.items.behaviors.BehaviourDataOrb; + +public class CellLoader implements IWerkstoffRunnable { + + @Override + @SuppressWarnings("unchecked") + public void run(Werkstoff werkstoff) { + if (!werkstoff.hasItemType(cell)) return; + + if ((werkstoff.getStats() + .isElektrolysis() + || werkstoff.getStats() + .isCentrifuge()) + && !werkstoff.hasItemType(dust)) { + List<FluidStack> flOutputs = new ArrayList<>(); + List<ItemStack> stOutputs = new ArrayList<>(); + HashMap<ISubTagContainer, Pair<Integer, Integer>> tracker = new HashMap<>(); + int cells = 0; + for (Pair<ISubTagContainer, Integer> container : werkstoff.getContents() + .getValue() + .toArray(new Pair[0])) { + if (container.getKey() instanceof Materials) { + if ((((Materials) container.getKey()).hasCorrespondingGas() + || ((Materials) container.getKey()).hasCorrespondingFluid() + || ((Materials) container.getKey()).mIconSet == TextureSet.SET_FLUID) + && ((Materials) container.getKey()).getDust(0) == null) { + FluidStack tmpFl = ((Materials) container.getKey()).getGas(1000L * container.getValue()); + if (tmpFl == null || tmpFl.getFluid() == null) { + tmpFl = ((Materials) container.getKey()).getFluid(1000L * container.getValue()); + } + flOutputs.add(tmpFl); + if (flOutputs.size() > 1) { + if (!tracker.containsKey(container.getKey())) { + stOutputs.add(((Materials) container.getKey()).getCells(container.getValue())); + tracker.put(container.getKey(), new Pair<>(container.getValue(), stOutputs.size() - 1)); + } else { + stOutputs.add( + ((Materials) container.getKey()).getCells( + tracker.get(container.getKey()) + .getKey() + container.getValue())); + stOutputs.remove( + tracker.get(container.getKey()) + .getValue() + 1); + } + cells += container.getValue(); + } + } else { + if (((Materials) container.getKey()).getDust(container.getValue()) == null) continue; + if (!tracker.containsKey(container.getKey())) { + stOutputs.add(((Materials) container.getKey()).getDust(container.getValue())); + tracker.put(container.getKey(), new Pair<>(container.getValue(), stOutputs.size() - 1)); + } else { + stOutputs.add( + ((Materials) container.getKey()).getDust( + tracker.get(container.getKey()) + .getKey() + container.getValue())); + stOutputs.remove( + tracker.get(container.getKey()) + .getValue() + 1); + } + } + } else if (container.getKey() instanceof Werkstoff) { + if (((Werkstoff) container.getKey()).getStats() + .isGas() || ((Werkstoff) container.getKey()).hasItemType(cell)) { + FluidStack tmpFl = ((Werkstoff) container.getKey()).getFluidOrGas(1000 * container.getValue()); + if (tmpFl == null || tmpFl.getFluid() == null) { + tmpFl = ((Werkstoff) container.getKey()).getFluidOrGas(1000 * container.getValue()); + } + flOutputs.add(tmpFl); + if (flOutputs.size() > 1) { + if (!tracker.containsKey(container.getKey())) { + stOutputs.add(((Werkstoff) container.getKey()).get(cell, container.getValue())); + tracker.put(container.getKey(), new Pair<>(container.getValue(), stOutputs.size() - 1)); + } else { + stOutputs.add( + ((Werkstoff) container.getKey()).get( + cell, + tracker.get(container.getKey()) + .getKey() + container.getValue())); + stOutputs.remove( + tracker.get(container.getKey()) + .getValue() + 1); + } + cells += container.getValue(); + } + } else { + if (!((Werkstoff) container.getKey()).hasItemType(dust)) continue; + if (!tracker.containsKey(container.getKey())) { + stOutputs.add(((Werkstoff) container.getKey()).get(dust, container.getValue())); + tracker.put(container.getKey(), new Pair<>(container.getValue(), stOutputs.size() - 1)); + } else { + stOutputs.add( + ((Werkstoff) container.getKey()).get( + dust, + tracker.get(container.getKey()) + .getKey() + container.getValue())); + stOutputs.remove( + tracker.get(container.getKey()) + .getValue() + 1); + } + } + } + } + ItemStack input = werkstoff.get(cell); + input.stackSize = 1; + + int cellEmpty = cells - 1; + + stOutputs.add(Materials.Empty.getCells(-cellEmpty)); + if (werkstoff.getStats() + .isElektrolysis()) + RecipeMaps.electrolyzerRecipes.add( + new GTRecipe( + true, + new ItemStack[] { input, cellEmpty > 0 ? Materials.Empty.getCells(cellEmpty) : null }, + stOutputs.toArray(new ItemStack[0]), + null, + null, + new FluidStack[] { null }, + new FluidStack[] { flOutputs.size() > 0 ? flOutputs.get(0) : null }, + (int) Math.max( + 1L, + Math.abs( + werkstoff.getStats() + .getProtons() + * werkstoff.getContents() + .getValue() + .size())), + Math.min( + 4, + werkstoff.getContents() + .getValue() + .size()) + * 30, + 0)); + if (werkstoff.getStats() + .isCentrifuge()) + RecipeMaps.centrifugeRecipes.add( + new GTRecipe( + true, + new ItemStack[] { input, cellEmpty > 0 ? Materials.Empty.getCells(cellEmpty) : null }, + stOutputs.toArray(new ItemStack[0]), + null, + null, + new FluidStack[] { null }, + new FluidStack[] { flOutputs.size() > 0 ? flOutputs.get(0) : null }, + (int) Math.max( + 1L, + Math.abs( + werkstoff.getStats() + .getMass() + * werkstoff.getContents() + .getValue() + .size())), + Math.min( + 4, + werkstoff.getContents() + .getValue() + .size()) + * 5, + 0)); + } + + // Tank "Recipe" + GTUtility.addFluidContainerData( + new FluidContainerRegistry.FluidContainerData( + new FluidStack(Objects.requireNonNull(WerkstoffLoader.fluids.get(werkstoff)), 1000), + werkstoff.get(cell), + Materials.Empty.getCells(1))); + FluidContainerRegistry.registerFluidContainer( + werkstoff.getFluidOrGas(1) + .getFluid(), + werkstoff.get(cell), + Materials.Empty.getCells(1)); + + GTValues.RA.stdBuilder() + .itemInputs(Materials.Empty.getCells(1)) + .itemOutputs(werkstoff.get(cell)) + .fluidInputs(new FluidStack(Objects.requireNonNull(WerkstoffLoader.fluids.get(werkstoff)), 1000)) + .duration(16 * TICKS) + .eut(2) + .addTo(fluidCannerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(cell)) + .itemOutputs(Materials.Empty.getCells(1)) + .fluidOutputs(new FluidStack(Objects.requireNonNull(WerkstoffLoader.fluids.get(werkstoff)), 1000)) + .duration(16 * TICKS) + .eut(2) + .addTo(fluidCannerRecipes); + + if (Forestry.isModLoaded()) { + FluidContainerRegistry.FluidContainerData emptyData = new FluidContainerRegistry.FluidContainerData( + new FluidStack(Objects.requireNonNull(WerkstoffLoader.fluids.get(werkstoff)), 1000), + werkstoff.get(capsule), + GTModHandler.getModItem(Forestry.ID, "waxCapsule", 1), + true); + GTUtility.addFluidContainerData(emptyData); + FluidContainerRegistry.registerFluidContainer(emptyData); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(capsule)) + .fluidOutputs(new FluidStack(Objects.requireNonNull(WerkstoffLoader.fluids.get(werkstoff)), 1000)) + .duration(16 * TICKS) + .eut(2) + .addTo(fluidCannerRecipes); + } + + if (werkstoff.hasItemType(dust)) { + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(dust)) + .fluidOutputs(werkstoff.getFluidOrGas(1000)) + .duration( + werkstoff.getStats() + .getMass()) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .recipeCategory(RecipeCategories.fluidExtractorRecycling) + .addTo(fluidExtractionRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(GTUtility.getIntegratedCircuit(1)) + .itemOutputs(werkstoff.get(dust)) + .fluidInputs(werkstoff.getFluidOrGas(1000)) + .duration( + (int) werkstoff.getStats() + .getMass()) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .addTo(fluidSolidifierRecipes); + + } + + if (Werkstoff.Types.ELEMENT.equals(werkstoff.getType())) { + Materials werkstoffBridgeMaterial = null; + boolean ElementSet = false; + for (Element e : Element.values()) { + if (e.toString() + .equals(werkstoff.getToolTip())) { + werkstoffBridgeMaterial = werkstoff.getBridgeMaterial() != null ? werkstoff.getBridgeMaterial() + : new Materials( + -1, + werkstoff.getTexSet(), + 0, + 0, + 0, + false, + werkstoff.getDefaultName(), + werkstoff.getDefaultName()); + werkstoffBridgeMaterial.mElement = e; + e.mLinkedMaterials.add(werkstoffBridgeMaterial); + ElementSet = true; + werkstoff.setBridgeMaterial(werkstoffBridgeMaterial); + break; + } + } + if (!ElementSet) return; + + GTOreDictUnificator.addAssociation(cell, werkstoffBridgeMaterial, werkstoff.get(cell), false); + + ItemStack scannerOutput = ItemList.Tool_DataOrb.get(1L); + BehaviourDataOrb.setDataTitle(scannerOutput, "Elemental-Scan"); + BehaviourDataOrb.setDataName(scannerOutput, werkstoff.getToolTip()); + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(cell)) + .itemOutputs(scannerOutput) + .special(ItemList.Tool_DataOrb.get(1L)) + .duration(werkstoffBridgeMaterial.getMass() * 8192) + .eut(TierEU.RECIPE_LV) + .noOptimize() + .ignoreCollision() + .fake() + .addTo(scannerFakeRecipes); + } + } +} diff --git a/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/CraftingMaterialLoader.java b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/CraftingMaterialLoader.java new file mode 100644 index 0000000000..022cf4c3e6 --- /dev/null +++ b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/CraftingMaterialLoader.java @@ -0,0 +1,295 @@ +/* + * 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.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.OrePrefixes.bolt; +import static gregtech.api.enums.OrePrefixes.cellMolten; +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.dustSmall; +import static gregtech.api.enums.OrePrefixes.dustTiny; +import static gregtech.api.enums.OrePrefixes.gearGt; +import static gregtech.api.enums.OrePrefixes.gearGtSmall; +import static gregtech.api.enums.OrePrefixes.gem; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.enums.OrePrefixes.plate; +import static gregtech.api.enums.OrePrefixes.ring; +import static gregtech.api.enums.OrePrefixes.rotor; +import static gregtech.api.enums.OrePrefixes.screw; +import static gregtech.api.enums.OrePrefixes.stick; +import static gregtech.api.enums.OrePrefixes.wireFine; +import static gregtech.api.recipe.RecipeMaps.assemblerRecipes; +import static gregtech.api.recipe.RecipeMaps.cutterRecipes; +import static gregtech.api.recipe.RecipeMaps.extruderRecipes; +import static gregtech.api.recipe.RecipeMaps.latheRecipes; +import static gregtech.api.recipe.RecipeMaps.maceratorRecipes; +import static gregtech.api.recipe.RecipeMaps.wiremillRecipes; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; +import static gregtech.api.util.GTRecipeBuilder.TICKS; + +import bartworks.system.material.Werkstoff; +import bartworks.system.material.WerkstoffLoader; +import bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTUtility; +import gregtech.common.GTProxy; + +public class CraftingMaterialLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + if (werkstoff.hasItemType(screw)) { + int tVoltageMultiplier = werkstoff.getStats() + .getMeltingPoint() >= 2800 ? 60 : 15; + + // bolt + + GTValues.RA.stdBuilder() + .itemInputs( + werkstoff.hasItemType(gem) ? werkstoff.get(gem) : werkstoff.get(ingot), + ItemList.Shape_Extruder_Bolt.get(0L)) + .itemOutputs(werkstoff.get(bolt, 8)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 2L, + 1)) + .eut(8 * tVoltageMultiplier) + .addTo(extruderRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(stick)) + .itemOutputs(werkstoff.get(bolt, 4)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 2L, + 1L)) + .eut(4) + .addTo(cutterRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(bolt)) + .itemOutputs(werkstoff.get(dustTiny, 1)) + .duration(2 * TICKS) + .eut(8) + .addTo(maceratorRecipes); + + // screw + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(bolt)) + .itemOutputs(werkstoff.get(screw)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() / 8L, + 1L)) + .eut(4) + .addTo(latheRecipes); + + GTModHandler.addCraftingRecipe( + werkstoff.get(screw), + GTProxy.tBits, + new Object[] { "fX", "X ", 'X', werkstoff.get(bolt) }); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(screw)) + .itemOutputs(werkstoff.get(dustTiny, 1)) + .duration(2 * TICKS) + .eut(8) + .addTo(maceratorRecipes); + + if (werkstoff.hasItemType(gem)) return; + + // ring + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot), ItemList.Shape_Extruder_Ring.get(0L)) + .itemOutputs(werkstoff.get(ring, 4)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 2L, + 1)) + .eut(6 * tVoltageMultiplier) + .addTo(extruderRecipes); + + GTModHandler.addCraftingRecipe( + werkstoff.get(ring), + GTProxy.tBits, + new Object[] { "h ", "fX", 'X', werkstoff.get(stick) }); + + // Gear + GTModHandler.addCraftingRecipe( + werkstoff.get(gearGt), + GTProxy.tBits, + new Object[] { "SPS", "PwP", "SPS", 'P', werkstoff.get(plate), 'S', werkstoff.get(stick) }); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot, 4), ItemList.Shape_Extruder_Gear.get(0L)) + .itemOutputs(werkstoff.get(gearGt)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 5L, + 1)) + .eut(8 * tVoltageMultiplier) + .addTo(extruderRecipes); + // wireFine + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot), ItemList.Shape_Extruder_Wire.get(0L)) + .itemOutputs(werkstoff.get(wireFine, 8)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 1.5F, + 1F)) + .eut(8 * tVoltageMultiplier) + .addTo(extruderRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot), GTUtility.getIntegratedCircuit(3)) + .itemOutputs(werkstoff.get(wireFine, 8)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass(), + 1)) + .eut(8 * tVoltageMultiplier) + .addTo(wiremillRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(stick), GTUtility.getIntegratedCircuit(3)) + .itemOutputs(werkstoff.get(wireFine, 4)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 0.5F, + 1F)) + .eut(8 * tVoltageMultiplier) + .addTo(wiremillRecipes); + + // smallGear + if (WerkstoffLoader.smallGearShape != null) { + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot), WerkstoffLoader.smallGearShape.get(0L)) + .itemOutputs(werkstoff.get(gearGtSmall)) + .duration( + (int) werkstoff.getStats() + .getMass()) + .eut(8 * tVoltageMultiplier) + .addTo(extruderRecipes); + + } + + GTModHandler.addCraftingRecipe( + werkstoff.get(gearGtSmall), + GTProxy.tBits, + new Object[] { " S ", "hPx", " S ", 'S', werkstoff.get(stick), 'P', werkstoff.get(plate) }); + + // Rotor + GTModHandler.addCraftingRecipe( + werkstoff.get(rotor), + GTProxy.tBits, + new Object[] { "PhP", "SRf", "PdP", 'P', werkstoff.get(plate), 'R', werkstoff.get(ring), 'S', + werkstoff.get(screw) }); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(plate, 4), werkstoff.get(ring)) + .itemOutputs(werkstoff.get(rotor)) + .fluidInputs(Materials.Tin.getMolten(32)) + .duration(12 * SECONDS) + .eut(24) + .addTo(assemblerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(plate, 4), werkstoff.get(ring)) + .itemOutputs(werkstoff.get(rotor)) + .fluidInputs(Materials.Lead.getMolten(48)) + .duration(12 * SECONDS) + .eut(24) + .addTo(assemblerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(plate, 4), werkstoff.get(ring)) + .itemOutputs(werkstoff.get(rotor)) + .fluidInputs(Materials.SolderingAlloy.getMolten(16)) + .duration(12 * SECONDS) + .eut(24) + .addTo(assemblerRecipes); + + if (WerkstoffLoader.rotorShape != null) { + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot, 5), WerkstoffLoader.rotorShape.get(0L)) + .itemOutputs(werkstoff.get(rotor)) + .duration(10 * SECONDS) + .eut(60) + .addTo(extruderRecipes); + + } + + // molten -> metal + if (werkstoff.hasItemType(cellMolten)) { + + /* + * !! No more hardcoded gear, etc. recipe gen, now must go through GenerationFeatures() !! + * GT_Values.RA.addFluidSolidifierRecipe( ItemList.Shape_Mold_Gear.get(0L), werkstoff.getMolten(576), + * werkstoff.get(gearGt), 128, 8); GT_Values.RA.addFluidSolidifierRecipe( + * ItemList.Shape_Mold_Gear_Small.get(0L), werkstoff.getMolten(144), werkstoff.get(gearGtSmall), 16, 8); + * if (WerkstoffLoader.ringMold != null) GT_Values.RA.addFluidSolidifierRecipe( + * WerkstoffLoader.ringMold.get(0L), werkstoff.getMolten(36), werkstoff.get(ring), 100, 4 * + * tVoltageMultiplier); if (WerkstoffLoader.boltMold != null) GT_Values.RA.addFluidSolidifierRecipe( + * WerkstoffLoader.boltMold.get(0L), werkstoff.getMolten(18), werkstoff.get(bolt), 50, 2 * + * tVoltageMultiplier); if (WerkstoffLoader.rotorMold != null) GT_Values.RA.addFluidSolidifierRecipe( + * WerkstoffLoader.rotorMold.get(0L), werkstoff.getMolten(612), werkstoff.get(rotor), 100, 60); + */ + } + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(gearGt)) + .itemOutputs(werkstoff.get(dust, 4)) + .duration(2 * TICKS) + .eut(8) + .addTo(maceratorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(gearGtSmall)) + .itemOutputs(werkstoff.get(dust, 1)) + .duration(2 * TICKS) + .eut(8) + .addTo(maceratorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(rotor)) + .itemOutputs(werkstoff.get(dust, 4), werkstoff.get(dustSmall)) + .duration(2 * TICKS) + .eut(8) + .addTo(maceratorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(ring)) + .itemOutputs(werkstoff.get(dustSmall, 1)) + .duration(2 * TICKS) + .eut(8) + .addTo(maceratorRecipes); + + } + } +} diff --git a/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/CrushedLoader.java b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/CrushedLoader.java new file mode 100644 index 0000000000..ab3874f6bc --- /dev/null +++ b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/CrushedLoader.java @@ -0,0 +1,301 @@ +/* + * 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.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.GTValues.RA; +import static gregtech.api.enums.OrePrefixes.crushed; +import static gregtech.api.enums.OrePrefixes.crushedCentrifuged; +import static gregtech.api.enums.OrePrefixes.crushedPurified; +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.dustImpure; +import static gregtech.api.enums.OrePrefixes.dustPure; +import static gregtech.api.enums.OrePrefixes.dustSmall; +import static gregtech.api.enums.OrePrefixes.gem; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.enums.OrePrefixes.nugget; +import static gregtech.api.enums.OrePrefixes.ore; +import static gregtech.api.recipe.RecipeMaps.autoclaveRecipes; +import static gregtech.api.recipe.RecipeMaps.centrifugeRecipes; +import static gregtech.api.recipe.RecipeMaps.chemicalBathRecipes; +import static gregtech.api.recipe.RecipeMaps.electroMagneticSeparatorRecipes; +import static gregtech.api.recipe.RecipeMaps.hammerRecipes; +import static gregtech.api.recipe.RecipeMaps.maceratorRecipes; +import static gregtech.api.recipe.RecipeMaps.oreWasherRecipes; +import static gregtech.api.recipe.RecipeMaps.thermalCentrifugeRecipes; +import static gregtech.api.util.GTRecipeBuilder.MINUTES; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; +import static gregtech.api.util.GTRecipeBuilder.TICKS; + +import bartworks.system.material.Werkstoff; +import bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.Materials; +import gregtech.api.enums.SubTag; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTOreDictUnificator; + +public class CrushedLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + if (!werkstoff.hasItemType(ore) || !werkstoff.hasItemType(dust)) return; + + if (werkstoff.hasItemType(ingot) && !werkstoff.getStats() + .isBlastFurnace()) { + if (Werkstoff.Types.ELEMENT.equals(werkstoff.getType())) { + GTModHandler.addSmeltingRecipe(werkstoff.get(crushed), werkstoff.get(nugget, 10)); + GTModHandler.addSmeltingRecipe(werkstoff.get(crushedPurified), werkstoff.get(nugget, 10)); + GTModHandler.addSmeltingRecipe(werkstoff.get(crushedCentrifuged), werkstoff.get(nugget, 10)); + } else { + GTModHandler.addSmeltingRecipe(werkstoff.get(crushed), werkstoff.get(ingot)); + GTModHandler.addSmeltingRecipe(werkstoff.get(crushedPurified), werkstoff.get(ingot)); + GTModHandler.addSmeltingRecipe(werkstoff.get(crushedCentrifuged), werkstoff.get(ingot)); + } + GTModHandler.addSmeltingRecipe(werkstoff.get(dustImpure), werkstoff.get(ingot)); + GTModHandler.addSmeltingRecipe(werkstoff.get(dustPure), werkstoff.get(ingot)); + GTModHandler.addSmeltingRecipe(werkstoff.get(dust), werkstoff.get(ingot)); + } + + GTModHandler + .addCraftingRecipe(werkstoff.get(dustImpure), new Object[] { "h ", "W ", 'W', werkstoff.get(crushed) }); + GTModHandler.addCraftingRecipe( + werkstoff.get(dustPure), + new Object[] { "h ", "W ", 'W', werkstoff.get(crushedPurified) }); + GTModHandler.addCraftingRecipe( + werkstoff.get(dust), + new Object[] { "h ", "W ", 'W', werkstoff.get(crushedCentrifuged) }); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(crushed)) + .itemOutputs(werkstoff.get(dustImpure)) + .duration(10 * TICKS) + .eut(16) + .addTo(hammerRecipes); + + RA.stdBuilder() + .itemInputs(werkstoff.get(crushed)) + .itemOutputs(werkstoff.get(dustImpure), werkstoff.getOreByProduct(0, dust)) + .outputChances(100_00, 10_00) + .eut(2) + .duration(20 * SECONDS) + .addTo(maceratorRecipes); + + RA.stdBuilder() + .itemInputs(werkstoff.get(crushed)) + .itemOutputs( + werkstoff.get(crushedPurified), + werkstoff.getOreByProduct(0, dust), + GTOreDictUnificator.get(dust, Materials.Stone, 1L)) + .outputChances(100_00, 11_11, 100_00) + .fluidInputs(GTModHandler.getWater(1000)) + .duration(25 * SECONDS) + .eut(16) + .addTo(oreWasherRecipes); + + RA.stdBuilder() + .itemInputs(werkstoff.get(crushed)) + .itemOutputs( + werkstoff.get(crushedPurified), + werkstoff.getOreByProduct(0, dust), + GTOreDictUnificator.get(dust, Materials.Stone, 1L)) + .outputChances(100_00, 11_11, 100_00) + .fluidInputs(GTModHandler.getDistilledWater(200)) + .duration(15 * SECONDS) + .eut(16) + .addTo(oreWasherRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(crushed)) + .itemOutputs( + werkstoff.get(crushedCentrifuged), + werkstoff.getOreByProduct(1, dust), + GTOreDictUnificator.get(dust, Materials.Stone, 1L)) + .outputChances(100_00, 11_11, 100_00) + .duration(25 * SECONDS) + .eut(48) + .addTo(thermalCentrifugeRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(crushedPurified)) + .itemOutputs(werkstoff.get(dustPure)) + .duration(10 * TICKS) + .eut(16) + .addTo(hammerRecipes); + + RA.stdBuilder() + .itemInputs(werkstoff.get(crushedPurified)) + .itemOutputs(werkstoff.get(dustPure), werkstoff.getOreByProduct(1, dust)) + .outputChances(100_00, 10_00) + .eut(2) + .duration(20 * SECONDS) + .addTo(maceratorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(crushedPurified)) + .itemOutputs(werkstoff.get(crushedCentrifuged), werkstoff.getOreByProduct(1, dust)) + .outputChances(100_00, 11_11) + .duration(25 * SECONDS) + .eut(48) + .addTo(thermalCentrifugeRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(crushedCentrifuged)) + .itemOutputs(werkstoff.get(dust)) + .duration(10 * TICKS) + .eut(16) + .addTo(hammerRecipes); + + RA.stdBuilder() + .itemInputs(werkstoff.get(crushedCentrifuged)) + .itemOutputs(werkstoff.get(dust), werkstoff.getOreByProduct(2, dust)) + .outputChances(100_00, 10_00) + .eut(2) + .duration(20 * SECONDS) + .addTo(maceratorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(dustImpure)) + .itemOutputs(werkstoff.get(dust), werkstoff.getOreByProduct(0, dust)) + .outputChances(100_00, 11_11) + .duration( + Math.max( + 1L, + werkstoff.getStats() + .getMass() * 8L)) + .eut(5) + .addTo(centrifugeRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(dustPure)) + .itemOutputs(werkstoff.get(dust), werkstoff.getOreByProduct(1, dust)) + .outputChances(100_00, 11_11) + .duration( + Math.max( + 1L, + werkstoff.getStats() + .getMass() * 8L)) + .eut(5) + .addTo(centrifugeRecipes); + + if (werkstoff.contains(SubTag.CRYSTALLISABLE)) { + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(dustPure)) + .itemOutputs(werkstoff.get(gem)) + .outputChances(9000) + .fluidInputs(Materials.Water.getFluid(200L)) + .duration(1 * MINUTES + 40 * SECONDS) + .eut(24) + .addTo(autoclaveRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(dustImpure)) + .itemOutputs(werkstoff.get(gem)) + .outputChances(9000) + .fluidInputs(Materials.Water.getFluid(200L)) + .duration(1 * MINUTES + 40 * SECONDS) + .eut(24) + .addTo(autoclaveRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(dustPure)) + .itemOutputs(werkstoff.get(gem)) + .outputChances(9500) + .fluidInputs(GTModHandler.getDistilledWater(200L)) + .duration(1 * MINUTES + 15 * SECONDS) + .eut(24) + .addTo(autoclaveRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(dustImpure)) + .itemOutputs(werkstoff.get(gem)) + .outputChances(9500) + .fluidInputs(GTModHandler.getDistilledWater(200L)) + .duration(1 * MINUTES + 15 * SECONDS) + .eut(24) + .addTo(autoclaveRecipes); + + } + if (werkstoff.contains(SubTag.WASHING_MERCURY)) { + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(crushed)) + .itemOutputs( + werkstoff.get(crushedPurified), + werkstoff.getOreByProduct(1, dust), + GTOreDictUnificator.get(dust, Materials.Stone, 1L)) + .outputChances(10000, 7000, 4000) + .fluidInputs(Materials.Mercury.getFluid(1000L)) + .duration(40 * SECONDS) + .eut(8) + .addTo(chemicalBathRecipes); + + } + if (werkstoff.contains(SubTag.WASHING_SODIUMPERSULFATE)) { + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(crushed)) + .itemOutputs( + werkstoff.get(crushedPurified), + werkstoff.getOreByProduct(1, dust), + GTOreDictUnificator.get(dust, Materials.Stone, 1L)) + .outputChances(10000, 7000, 4000) + .fluidInputs(Materials.SodiumPersulfate.getFluid(100L)) + .duration(40 * SECONDS) + .eut(8) + .addTo(chemicalBathRecipes); + + } + if (werkstoff.contains(SubTag.ELECTROMAGNETIC_SEPERATION_GOLD)) { + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(dustPure)) + .itemOutputs( + werkstoff.get(dust), + GTOreDictUnificator.get(dustSmall, Materials.Gold, 1L), + GTOreDictUnificator.get(nugget, Materials.Gold, 1L)) + .outputChances(10000, 4000, 2000) + .duration(20 * SECONDS) + .eut(24) + .addTo(electroMagneticSeparatorRecipes); + + } else if (werkstoff.contains(SubTag.ELECTROMAGNETIC_SEPERATION_IRON)) { + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(dustPure)) + .itemOutputs( + werkstoff.get(dust), + GTOreDictUnificator.get(dustSmall, Materials.Iron, 1L), + GTOreDictUnificator.get(nugget, Materials.Iron, 1L)) + .outputChances(10000, 4000, 2000) + .duration(20 * SECONDS) + .eut(24) + .addTo(electroMagneticSeparatorRecipes); + + } else if (werkstoff.contains(SubTag.ELECTROMAGNETIC_SEPERATION_NEODYMIUM)) { + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(dustPure)) + .itemOutputs( + werkstoff.get(dust), + GTOreDictUnificator.get(dustSmall, Materials.Neodymium, 1L), + GTOreDictUnificator.get(nugget, Materials.Neodymium, 1L)) + .outputChances(10000, 4000, 2000) + .duration(20 * SECONDS) + .eut(24) + .addTo(electroMagneticSeparatorRecipes); + + } + } +} diff --git a/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/DustLoader.java b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/DustLoader.java new file mode 100644 index 0000000000..53da59aceb --- /dev/null +++ b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/DustLoader.java @@ -0,0 +1,528 @@ +/* + * 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.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.OrePrefixes.block; +import static gregtech.api.enums.OrePrefixes.cell; +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.dustSmall; +import static gregtech.api.enums.OrePrefixes.dustTiny; +import static gregtech.api.enums.OrePrefixes.gem; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.enums.OrePrefixes.ingotHot; +import static gregtech.api.enums.OrePrefixes.nugget; +import static gregtech.api.recipe.RecipeMaps.blastFurnaceRecipes; +import static gregtech.api.recipe.RecipeMaps.maceratorRecipes; +import static gregtech.api.recipe.RecipeMaps.packagerRecipes; +import static gregtech.api.recipe.RecipeMaps.primitiveBlastRecipes; +import static gregtech.api.recipe.RecipeMaps.vacuumFreezerRecipes; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; +import static gregtech.api.util.GTRecipeConstants.ADDITIVE_AMOUNT; +import static gregtech.api.util.GTRecipeConstants.COIL_HEAT; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import bartworks.system.material.Werkstoff; +import bartworks.system.material.WerkstoffLoader; +import bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; +import bartworks.util.Pair; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TextureSet; +import gregtech.api.enums.TierEU; +import gregtech.api.interfaces.ISubTagContainer; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTRecipeConstants; +import gregtech.api.util.GTUtility; + +public class DustLoader implements IWerkstoffRunnable { + + @Override + @SuppressWarnings("unchecked") + public void run(Werkstoff werkstoff) { + if (werkstoff.hasItemType(dust)) { + List<FluidStack> flOutputs = new ArrayList<>(); + List<ItemStack> stOutputs = new ArrayList<>(); + HashMap<ISubTagContainer, Pair<Integer, Integer>> tracker = new HashMap<>(); + int cells = 0; + + if (werkstoff.getGenerationFeatures() + .hasMixerRecipes() + || werkstoff.getStats() + .isElektrolysis() + || werkstoff.getStats() + .isCentrifuge() + || werkstoff.getGenerationFeatures() + .hasChemicalRecipes()) { + for (Pair<ISubTagContainer, Integer> container : werkstoff.getContents() + .getValue() + .toArray(new Pair[0])) { + final ISubTagContainer key = container.getKey(); + final int value = container.getValue(); + if (key instanceof Materials materialKey) { + if ((materialKey.getGas(0) != null || materialKey.getFluid(0) != null + || materialKey.mIconSet == TextureSet.SET_FLUID) && materialKey.getDust(0) == null) { + FluidStack tmpFl = materialKey.getGas(1000L * value); + if (tmpFl == null || tmpFl.getFluid() == null) { + tmpFl = materialKey.getFluid(1000L * value); + } + flOutputs.add(tmpFl); + if (flOutputs.size() > 1) { + if (!tracker.containsKey(key)) { + stOutputs.add(materialKey.getCells(value)); + tracker.put(key, new Pair<>(value, stOutputs.size() - 1)); + } else { + stOutputs.add( + materialKey.getCells( + tracker.get(key) + .getKey() + value)); + stOutputs.remove( + tracker.get(key) + .getValue() + 1); + } + cells += value; + } + } else { + if (materialKey.getDust(value) == null) { + if (materialKey.getCells(value) == null + || materialKey.getMolten(0) == null && materialKey.getSolid(0) == null) continue; + FluidStack tmpFl = materialKey.getMolten(1000L * value); + if (tmpFl == null || tmpFl.getFluid() == null) { + tmpFl = materialKey.getSolid(1000L * value); + } + flOutputs.add(tmpFl); + if (flOutputs.size() > 1) { + if (!tracker.containsKey(key)) { + stOutputs.add(materialKey.getCells(value)); + tracker.put(key, new Pair<>(value, stOutputs.size() - 1)); + } else { + stOutputs.add( + materialKey.getCells( + tracker.get(key) + .getKey() + value)); + stOutputs.remove( + tracker.get(key) + .getValue() + 1); + } + cells += value; + } + } + if (!tracker.containsKey(key)) { + stOutputs.add(materialKey.getDust(value)); + tracker.put(key, new Pair<>(value, stOutputs.size() - 1)); + } else { + stOutputs.add( + materialKey.getDust( + tracker.get(key) + .getKey() + value)); + stOutputs.remove( + tracker.get(key) + .getValue() + 1); + } + } + } else if (key instanceof Werkstoff werkstoffKey) { + if (werkstoffKey.getStats() + .isGas() || werkstoffKey.hasItemType(cell)) { + FluidStack tmpFl = werkstoffKey.getFluidOrGas(1000 * value); + if (tmpFl == null || tmpFl.getFluid() == null) { + tmpFl = werkstoffKey.getFluidOrGas(1000 * value); + } + flOutputs.add(tmpFl); + if (flOutputs.size() > 1) { + if (!tracker.containsKey(key)) { + stOutputs.add(werkstoffKey.get(cell, value)); + tracker.put(key, new Pair<>(value, stOutputs.size() - 1)); + } else { + stOutputs.add( + werkstoffKey.get( + cell, + tracker.get(key) + .getKey() + value)); + stOutputs.remove( + tracker.get(key) + .getValue() + 1); + } + cells += value; + } + } else { + if (!werkstoffKey.hasItemType(dust)) continue; + if (!tracker.containsKey(key)) { + stOutputs.add(werkstoffKey.get(dust, value)); + tracker.put(key, new Pair<>(value, stOutputs.size() - 1)); + } else { + stOutputs.add( + werkstoffKey.get( + dust, + tracker.get(key) + .getKey() + value)); + stOutputs.remove( + tracker.get(key) + .getValue() + 1); + } + } + } + } + ItemStack input = werkstoff.get(dust); + input.stackSize = werkstoff.getContents() + .getKey(); + if (werkstoff.getStats() + .isElektrolysis()) { + GTRecipe tRecipe = new GTRecipe( + true, + new ItemStack[] { input, cells > 0 ? Materials.Empty.getCells(cells) : null }, + stOutputs.toArray(new ItemStack[0]), + null, + null, + new FluidStack[] { null }, + new FluidStack[] { flOutputs.size() > 0 ? flOutputs.get(0) : null }, + (int) Math.max( + 1L, + Math.abs( + werkstoff.getStats() + .getProtons() + / werkstoff.getContents() + .getValue() + .size())), + Math.min( + 4, + werkstoff.getContents() + .getValue() + .size()) + * 30, + 0); + RecipeMaps.electrolyzerRecipes.add(tRecipe); + RecipeMaps.electrolyzerNonCellRecipes.add(tRecipe); + } + if (werkstoff.getStats() + .isCentrifuge()) { + RecipeMaps.centrifugeRecipes.add( + new GTRecipe( + true, + new ItemStack[] { input, cells > 0 ? Materials.Empty.getCells(cells) : null }, + stOutputs.toArray(new ItemStack[0]), + null, + null, + new FluidStack[] { null }, + new FluidStack[] { flOutputs.size() > 0 ? flOutputs.get(0) : null }, + (int) Math.max( + 1L, + Math.abs( + werkstoff.getStats() + .getMass() + / werkstoff.getContents() + .getValue() + .size())), + Math.min( + 4, + werkstoff.getContents() + .getValue() + .size()) + * 5, + 0)); + GTRecipe tRecipe = new GTRecipe( + false, + stOutputs.toArray(new ItemStack[0]), + new ItemStack[] { input }, + null, + null, + new FluidStack[] { flOutputs.size() > 0 ? flOutputs.get(0) : null }, + null, + (int) Math.max( + 1L, + Math.abs( + werkstoff.getStats() + .getProtons() + / werkstoff.getContents() + .getValue() + .size())), + Math.min( + 4, + werkstoff.getContents() + .getValue() + .size()) + * 30, + 0); + RecipeMaps.centrifugeNonCellRecipes.add(tRecipe); + } + if (werkstoff.getGenerationFeatures() + .hasChemicalRecipes()) { + if (cells > 0) stOutputs.add(Materials.Empty.getCells(cells)); + GTValues.RA.stdBuilder() + .itemInputs(stOutputs.toArray(new ItemStack[0])) + .itemOutputs(input) + .fluidInputs(flOutputs.toArray(new FluidStack[0])) + .duration( + (int) Math.max( + 1L, + Math.abs( + werkstoff.getStats() + .getProtons() + / werkstoff.getContents() + .getValue() + .size()))) + .eut( + Math.min( + 4, + werkstoff.getContents() + .getValue() + .size()) + * 30) + .addTo(GTRecipeConstants.UniversalChemical); + } + if (werkstoff.getGenerationFeatures() + .hasMixerRecipes()) { + if (cells > 0) stOutputs.add(Materials.Empty.getCells(cells)); + short circuitID = werkstoff.getMixCircuit(); + ItemStack circuit = circuitID == -1 ? null : GTUtility.getIntegratedCircuit(circuitID); + if (circuit != null) stOutputs.add(circuit); + RecipeMaps.mixerRecipes.add( + new GTRecipe( + true, + stOutputs.toArray(new ItemStack[0]), + new ItemStack[] { input }, + null, + null, + new FluidStack[] { flOutputs.size() > 0 ? flOutputs.get(0) : null }, + null, + (int) Math.max( + 1L, + Math.abs( + werkstoff.getStats() + .getMass() + / werkstoff.getContents() + .getValue() + .size())), + Math.min( + 4, + werkstoff.getContents() + .getValue() + .size()) + * 5, + 0)); + GTRecipe tRecipe = new GTRecipe( + false, + stOutputs.toArray(new ItemStack[0]), + new ItemStack[] { input }, + null, + null, + new FluidStack[] { flOutputs.size() > 0 ? flOutputs.get(0) : null }, + null, + (int) Math.max( + 1L, + Math.abs( + werkstoff.getStats() + .getProtons() + / werkstoff.getContents() + .getValue() + .size())), + Math.min( + 4, + werkstoff.getContents() + .getValue() + .size()) + * 30, + 0); + RecipeMaps.mixerNonCellRecipes.add(tRecipe); + } + } + + GTModHandler.addCraftingRecipe( + werkstoff.get(dust), + new Object[] { "TTT", "TTT", "TTT", 'T', werkstoff.get(dustTiny) }); + GTModHandler.addCraftingRecipe( + werkstoff.get(dust), + new Object[] { "TT ", "TT ", 'T', WerkstoffLoader.getCorrespondingItemStack(dustSmall, werkstoff) }); + GTModHandler.addCraftingRecipe( + WerkstoffLoader.getCorrespondingItemStack(dustSmall, werkstoff, 4), + new Object[] { " T ", 'T', werkstoff.get(dust) }); + GTModHandler.addCraftingRecipe( + WerkstoffLoader.getCorrespondingItemStack(dustTiny, werkstoff, 9), + new Object[] { "T ", 'T', werkstoff.get(dust) }); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(dustTiny, 9), ItemList.Schematic_Dust.get(0L)) + .itemOutputs(werkstoff.get(dust)) + .duration(5 * SECONDS) + .eut(4) + .addTo(packagerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(dustSmall, 4), ItemList.Schematic_Dust.get(0L)) + .itemOutputs(werkstoff.get(dust)) + .duration(5 * SECONDS) + .eut(4) + .addTo(packagerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(dustTiny, 9), ItemList.Schematic_3by3.get(0L)) + .itemOutputs(werkstoff.get(dust)) + .duration(5 * SECONDS) + .eut(4) + .addTo(packagerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(dustSmall, 4), ItemList.Schematic_2by2.get(0L)) + .itemOutputs(werkstoff.get(dust)) + .duration(5 * SECONDS) + .eut(4) + .addTo(packagerRecipes); + + if (werkstoff.hasItemType(ingot) && !werkstoff.getStats() + .isBlastFurnace()) { + GTModHandler.addSmeltingRecipe(werkstoff.get(dust), werkstoff.get(ingot)); + GTModHandler.addSmeltingRecipe(werkstoff.get(dustTiny), werkstoff.get(nugget)); + } else if (werkstoff.hasItemType(ingot) && werkstoff.getStats() + .isBlastFurnace() + && werkstoff.getStats() + .getMeltingPoint() != 0) { + if (werkstoff.contains(WerkstoffLoader.ANAEROBE_SMELTING)) { + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(dust), GTUtility.getIntegratedCircuit(11)) + .itemOutputs( + werkstoff.getStats() + .getMeltingPoint() < 1750 ? werkstoff.get(ingot) : werkstoff.get(ingotHot)) + .fluidInputs(Materials.Nitrogen.getGas(1000)) + .duration( + Math.max( + werkstoff.getStats() + .getMass() / 40L, + 1L) + * werkstoff.getStats() + .getMeltingPoint()) + .eut( + werkstoff.getStats() + .getMeltingVoltage()) + .metadata( + COIL_HEAT, + werkstoff.getStats() + .getMeltingPoint()) + .addTo(blastFurnaceRecipes); + + } else if (werkstoff.contains(WerkstoffLoader.NOBLE_GAS_SMELTING)) { + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(dust), GTUtility.getIntegratedCircuit(11)) + .itemOutputs( + werkstoff.getStats() + .getMeltingPoint() < 1750 ? werkstoff.get(ingot) : werkstoff.get(ingotHot)) + .fluidInputs(Materials.Argon.getGas(1000)) + .duration( + Math.max( + werkstoff.getStats() + .getMass() / 40L, + 1L) + * werkstoff.getStats() + .getMeltingPoint()) + .eut( + werkstoff.getStats() + .getMeltingVoltage()) + .metadata( + COIL_HEAT, + werkstoff.getStats() + .getMeltingPoint()) + .addTo(blastFurnaceRecipes); + + } else { + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(dust), GTUtility.getIntegratedCircuit(1)) + .itemOutputs( + werkstoff.getStats() + .getMeltingPoint() < 1750 ? werkstoff.get(ingot) : werkstoff.get(ingotHot)) + .duration( + Math.max( + werkstoff.getStats() + .getMass() / 40L, + 1L) + * werkstoff.getStats() + .getMeltingPoint()) + .eut( + werkstoff.getStats() + .getMeltingVoltage()) + .metadata( + COIL_HEAT, + werkstoff.getStats() + .getMeltingPoint()) + .addTo(blastFurnaceRecipes); + + if (werkstoff.getStats() + .getMeltingPoint() <= 1000) { + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(dust)) + .itemOutputs(werkstoff.get(ingot)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() / 40L, + 1L) * werkstoff.getStats() + .getMeltingPoint()) + .eut(0) + .metadata(ADDITIVE_AMOUNT, 9) + .addTo(primitiveBlastRecipes); + } + } + } + + if (werkstoff.getStats() + .isBlastFurnace() + && werkstoff.getStats() + .getMeltingPoint() > 1750) { + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(ingotHot)) + .itemOutputs(werkstoff.get(ingot)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 3L, + 1L)) + .eut(TierEU.RECIPE_MV) + .addTo(vacuumFreezerRecipes); + } + + if (werkstoff.hasItemType(ingot)) { + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot)) + .itemOutputs(werkstoff.get(dust)) + .duration(20 * SECONDS) + .eut(2) + .addTo(maceratorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(nugget)) + .itemOutputs(werkstoff.get(dustTiny)) + .duration(20 * SECONDS) + .eut(2) + .addTo(maceratorRecipes); + + } + if (werkstoff.hasItemType(ingot) || werkstoff.hasItemType(gem)) { + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(block)) + .itemOutputs(werkstoff.get(dust, 9)) + .duration(20 * SECONDS) + .eut(2) + .addTo(maceratorRecipes); + + } + } + } +} diff --git a/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/GemLoader.java b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/GemLoader.java new file mode 100644 index 0000000000..cc21110a14 --- /dev/null +++ b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/GemLoader.java @@ -0,0 +1,294 @@ +/* + * 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.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.OrePrefixes.block; +import static gregtech.api.enums.OrePrefixes.crushedPurified; +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.dustSmall; +import static gregtech.api.enums.OrePrefixes.dustTiny; +import static gregtech.api.enums.OrePrefixes.gem; +import static gregtech.api.enums.OrePrefixes.gemChipped; +import static gregtech.api.enums.OrePrefixes.gemExquisite; +import static gregtech.api.enums.OrePrefixes.gemFlawed; +import static gregtech.api.enums.OrePrefixes.gemFlawless; +import static gregtech.api.enums.OrePrefixes.lens; +import static gregtech.api.enums.OrePrefixes.ore; +import static gregtech.api.enums.OrePrefixes.plate; +import static gregtech.api.recipe.RecipeMaps.compressorRecipes; +import static gregtech.api.recipe.RecipeMaps.hammerRecipes; +import static gregtech.api.recipe.RecipeMaps.implosionRecipes; +import static gregtech.api.recipe.RecipeMaps.laserEngraverRecipes; +import static gregtech.api.recipe.RecipeMaps.latheRecipes; +import static gregtech.api.recipe.RecipeMaps.maceratorRecipes; +import static gregtech.api.recipe.RecipeMaps.sifterRecipes; +import static gregtech.api.util.GTRecipeBuilder.MINUTES; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; +import static gregtech.api.util.GTRecipeBuilder.TICKS; +import static gregtech.api.util.GTRecipeConstants.ADDITIVE_AMOUNT; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +import bartworks.system.material.Werkstoff; +import bartworks.system.material.WerkstoffLoader; +import bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; +import bartworks.util.BWColorUtil; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.Materials; +import gregtech.api.enums.Textures; +import gregtech.api.enums.TierEU; +import gregtech.api.interfaces.ITexture; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.common.covers.CoverLens; + +public class GemLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + if (werkstoff.hasItemType(gem)) { + if (werkstoff.getGenerationFeatures() + .hasSifterRecipes() || werkstoff.hasItemType(ore) && werkstoff.hasItemType(dust)) { + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(gem, 9)) + .itemOutputs(werkstoff.get(block)) + .duration(15 * SECONDS) + .eut(2) + .addTo(compressorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(block)) + .itemOutputs(werkstoff.get(gem, 9)) + .duration(5 * SECONDS) + .eut(24) + .addTo(hammerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(crushedPurified)) + .itemOutputs( + werkstoff.get(gemExquisite), + werkstoff.get(gemFlawless), + werkstoff.get(gem), + werkstoff.get(gemFlawed), + werkstoff.get(gemChipped), + werkstoff.get(dust)) + .outputChances(200, 1000, 2500, 2000, 4000, 5000) + .duration(40 * SECONDS) + .eut(16) + .addTo(sifterRecipes); + + } + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(gemExquisite)) + .itemOutputs(werkstoff.get(dust, 4)) + .duration(20 * SECONDS) + .eut(2) + .addTo(maceratorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(gemFlawless)) + .itemOutputs(werkstoff.get(dust, 2)) + .duration(20 * SECONDS) + .eut(2) + .addTo(maceratorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(gem)) + .itemOutputs(werkstoff.get(dust)) + .duration(20 * SECONDS) + .eut(2) + .addTo(maceratorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(gemFlawed)) + .itemOutputs(werkstoff.get(dustSmall, 2)) + .duration(20 * SECONDS) + .eut(2) + .addTo(maceratorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(gemChipped)) + .itemOutputs(werkstoff.get(dustSmall)) + .duration(20 * SECONDS) + .eut(2) + .addTo(maceratorRecipes); + + GTModHandler.addCraftingRecipe( + werkstoff.get(gemFlawless, 2), + 0, + new Object[] { "h ", "W ", 'W', werkstoff.get(gemExquisite) }); + GTModHandler.addCraftingRecipe( + werkstoff.get(gem, 2), + 0, + new Object[] { "h ", "W ", 'W', werkstoff.get(gemFlawless) }); + GTModHandler.addCraftingRecipe( + werkstoff.get(gemFlawed, 2), + 0, + new Object[] { "h ", "W ", 'W', werkstoff.get(gem) }); + GTModHandler.addCraftingRecipe( + werkstoff.get(gemChipped, 2), + 0, + new Object[] { "h ", "W ", 'W', werkstoff.get(gemFlawed) }); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(gemExquisite)) + .itemOutputs(werkstoff.get(gemFlawless, 2)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(16) + .addTo(hammerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(gemFlawless)) + .itemOutputs(werkstoff.get(gem, 2)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(16) + .addTo(hammerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(gem)) + .itemOutputs(werkstoff.get(gemFlawed, 2)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(16) + .addTo(hammerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(gemFlawed)) + .itemOutputs(werkstoff.get(gemChipped, 2)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(16) + .addTo(hammerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(gemChipped)) + .itemOutputs(werkstoff.get(dustTiny)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(16) + .addTo(hammerRecipes); + + if (!werkstoff.contains(WerkstoffLoader.NO_BLAST)) { + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(gemFlawless, 3)) + .itemOutputs(werkstoff.get(gemExquisite), GTOreDictUnificator.get(dustTiny, Materials.DarkAsh, 2)) + .duration(20 * TICKS) + .eut(TierEU.RECIPE_LV) + .metadata(ADDITIVE_AMOUNT, 8) + .addTo(implosionRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(gem, 3)) + .itemOutputs(werkstoff.get(gemFlawless), GTOreDictUnificator.get(dustTiny, Materials.DarkAsh, 2)) + .duration(20 * TICKS) + .eut(TierEU.RECIPE_LV) + .metadata(ADDITIVE_AMOUNT, 8) + .addTo(implosionRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(gemFlawed, 3)) + .itemOutputs(werkstoff.get(gem), GTOreDictUnificator.get(dustTiny, Materials.DarkAsh, 2)) + .duration(20 * TICKS) + .eut(TierEU.RECIPE_LV) + .metadata(ADDITIVE_AMOUNT, 8) + .addTo(implosionRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(gemChipped, 3)) + .itemOutputs(werkstoff.get(gemFlawed), GTOreDictUnificator.get(dustTiny, Materials.DarkAsh, 2)) + .duration(20 * TICKS) + .eut(TierEU.RECIPE_LV) + .metadata(ADDITIVE_AMOUNT, 8) + .addTo(implosionRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(dust, 4)) + .itemOutputs(werkstoff.get(gem, 3), GTOreDictUnificator.get(dustTiny, Materials.DarkAsh, 8)) + .duration(20 * TICKS) + .eut(TierEU.RECIPE_LV) + .metadata(ADDITIVE_AMOUNT, 24) + .addTo(implosionRecipes); + } + + if (werkstoff.hasItemType(plate)) { + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(plate)) + .itemOutputs(werkstoff.get(lens), werkstoff.get(dustSmall)) + .duration(60 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(latheRecipes); + + } + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(gemExquisite)) + .itemOutputs(werkstoff.get(lens), werkstoff.get(dust, 2)) + .duration(2 * MINUTES) + .eut(TierEU.RECIPE_LV) + .addTo(latheRecipes); + + final ITexture texture = TextureFactory.of( + Textures.BlockIcons.MACHINE_CASINGS[2][0], + TextureFactory.of(Textures.BlockIcons.OVERLAY_LENS, werkstoff.getRGBA(), false)); + GregTechAPI.registerCover( + werkstoff.get(lens), + texture, + new CoverLens(BWColorUtil.getDyeFromColor(werkstoff.getRGBA()).mIndex, texture)); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(lens)) + .itemOutputs(werkstoff.get(dustSmall, 3)) + .duration(20 * SECONDS) + .eut(2) + .addTo(maceratorRecipes); + + for (ItemStack is : OreDictionary + .getOres("craftingLens" + BWColorUtil.getDyeFromColor(werkstoff.getRGBA()).mName.replace(" ", ""))) { + is.stackSize = 0; + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(gemChipped, 3), is) + .itemOutputs(werkstoff.get(gemFlawed, 1)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(laserEngraverRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(gemFlawed, 3), is) + .itemOutputs(werkstoff.get(gem, 1)) + .duration(30 * SECONDS) + .eut(TierEU.RECIPE_MV) + .addTo(laserEngraverRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(gem, 3), is) + .itemOutputs(werkstoff.get(gemFlawless, 1)) + .duration(60 * SECONDS) + .eut(TierEU.RECIPE_HV) + .addTo(laserEngraverRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(gemFlawless, 3), is) + .itemOutputs(werkstoff.get(gemExquisite, 1)) + .duration(2 * MINUTES) + .eut(TierEU.RECIPE_EV) + .addTo(laserEngraverRecipes); + + } + } + } +} diff --git a/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/MetalLoader.java b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/MetalLoader.java new file mode 100644 index 0000000000..53c25b4ab0 --- /dev/null +++ b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/MetalLoader.java @@ -0,0 +1,65 @@ +/* + * 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.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.OrePrefixes.block; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.recipe.RecipeMaps.compressorRecipes; +import static gregtech.api.recipe.RecipeMaps.extruderRecipes; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; + +import bartworks.system.material.Werkstoff; +import bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.ItemList; +import gregtech.api.recipe.RecipeCategories; +import gregtech.api.recipe.RecipeMaps; + +public class MetalLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + if (werkstoff.hasItemType(ingot)) { + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot, 9)) + .itemOutputs(werkstoff.get(block)) + .duration(15 * SECONDS) + .eut(2) + .addTo(compressorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot, 9), ItemList.Shape_Extruder_Block.get(0)) + .itemOutputs(werkstoff.get(block)) + .duration( + (int) werkstoff.getStats() + .getMass()) + .eut( + 8 * werkstoff.getStats() + .getMeltingPoint() >= 2800 ? 60 : 15) + .addTo(extruderRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot, 9), ItemList.Shape_Mold_Block.get(0L)) + .itemOutputs(werkstoff.get(block)) + .duration( + (int) (werkstoff.getStats() + .getMass() / 2)) + .eut( + 4 * werkstoff.getStats() + .getMeltingPoint() >= 2800 ? 60 : 15) + .recipeCategory(RecipeCategories.alloySmelterMolding) + .addTo(RecipeMaps.alloySmelterRecipes); + } + } +} diff --git a/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/MoltenCellLoader.java b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/MoltenCellLoader.java new file mode 100644 index 0000000000..8d639574cb --- /dev/null +++ b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/MoltenCellLoader.java @@ -0,0 +1,376 @@ +/* + * 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.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.Mods.Forestry; +import static gregtech.api.enums.OrePrefixes.block; +import static gregtech.api.enums.OrePrefixes.bolt; +import static gregtech.api.enums.OrePrefixes.capsuleMolten; +import static gregtech.api.enums.OrePrefixes.cellMolten; +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.dustSmall; +import static gregtech.api.enums.OrePrefixes.dustTiny; +import static gregtech.api.enums.OrePrefixes.gearGt; +import static gregtech.api.enums.OrePrefixes.gearGtSmall; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.enums.OrePrefixes.nugget; +import static gregtech.api.enums.OrePrefixes.plate; +import static gregtech.api.enums.OrePrefixes.plateDouble; +import static gregtech.api.enums.OrePrefixes.ring; +import static gregtech.api.enums.OrePrefixes.rotor; +import static gregtech.api.enums.OrePrefixes.screw; +import static gregtech.api.enums.OrePrefixes.stick; +import static gregtech.api.enums.OrePrefixes.stickLong; +import static gregtech.api.recipe.RecipeMaps.fluidCannerRecipes; +import static gregtech.api.recipe.RecipeMaps.fluidExtractionRecipes; +import static gregtech.api.recipe.RecipeMaps.fluidSolidifierRecipes; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; +import static gregtech.api.util.GTRecipeBuilder.TICKS; + +import java.util.Objects; + +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; + +import bartworks.system.material.Werkstoff; +import bartworks.system.material.WerkstoffLoader; +import bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.recipe.RecipeCategories; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTUtility; + +public class MoltenCellLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + if (!werkstoff.hasItemType(cellMolten)) { + return; + } + + if (!werkstoff.hasItemType(ingot)) { + if (!werkstoff.hasItemType(dust)) { + return; + } + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(dust)) + .fluidOutputs(werkstoff.getMolten(144)) + .duration(15 * SECONDS) + .eut(2) + .recipeCategory(RecipeCategories.fluidExtractorRecycling) + .addTo(fluidExtractionRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(dustSmall)) + .fluidOutputs(werkstoff.getMolten(36)) + .duration(15 * SECONDS) + .eut(2) + .recipeCategory(RecipeCategories.fluidExtractorRecycling) + .addTo(fluidExtractionRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(dustTiny)) + .fluidOutputs(werkstoff.getMolten(16)) + .duration(15 * SECONDS) + .eut(2) + .recipeCategory(RecipeCategories.fluidExtractorRecycling) + .addTo(fluidExtractionRecipes); + + } else { + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot)) + .fluidOutputs(werkstoff.getMolten(144)) + .duration(15 * SECONDS) + .eut(2) + .recipeCategory(RecipeCategories.fluidExtractorRecycling) + .addTo(fluidExtractionRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(nugget)) + .fluidOutputs(werkstoff.getMolten(16)) + .duration(15 * SECONDS) + .eut(2) + .recipeCategory(RecipeCategories.fluidExtractorRecycling) + .addTo(fluidExtractionRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Shape_Mold_Ingot.get(0)) + .itemOutputs(werkstoff.get(ingot)) + .fluidInputs(werkstoff.getMolten(144)) + .duration( + (int) werkstoff.getStats() + .getMass()) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .addTo(fluidSolidifierRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Shape_Mold_Nugget.get(0)) + .itemOutputs(werkstoff.get(nugget)) + .fluidInputs(werkstoff.getMolten(16)) + .duration( + (int) ((double) werkstoff.getStats() + .getMass() / 9D)) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .addTo(fluidSolidifierRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Shape_Mold_Block.get(0)) + .itemOutputs(werkstoff.get(block)) + .fluidInputs(werkstoff.getMolten(1296)) + .duration( + (int) werkstoff.getStats() + .getMass() * 9) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .addTo(fluidSolidifierRecipes); + + if (!werkstoff.hasItemType(plate)) { + return; + } + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(stickLong)) + .fluidOutputs(werkstoff.getMolten(144)) + .duration(15 * SECONDS) + .eut(2) + .recipeCategory(RecipeCategories.fluidExtractorRecycling) + .addTo(fluidExtractionRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(plate)) + .fluidOutputs(werkstoff.getMolten(144)) + .duration(15 * SECONDS) + .eut(2) + .recipeCategory(RecipeCategories.fluidExtractorRecycling) + .addTo(fluidExtractionRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(stick)) + .fluidOutputs(werkstoff.getMolten(72)) + .duration(15 * SECONDS) + .eut(2) + .recipeCategory(RecipeCategories.fluidExtractorRecycling) + .addTo(fluidExtractionRecipes); + } + + if (werkstoff.getGenerationFeatures() + .hasMetalCraftingSolidifierRecipes()) { + + if (!werkstoff.hasItemType(plate)) { + return; + } + + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Shape_Mold_Rod_Long.get(0)) + .itemOutputs(werkstoff.get(stickLong)) + .fluidInputs(werkstoff.getMolten(144)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass(), + 1L)) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .addTo(fluidSolidifierRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Shape_Mold_Rod.get(0)) + .itemOutputs(werkstoff.get(stick)) + .fluidInputs(werkstoff.getMolten(72)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() / 2, + 1L)) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .addTo(fluidSolidifierRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Shape_Mold_Plate.get(0)) + .itemOutputs(werkstoff.get(plate)) + .fluidInputs(werkstoff.getMolten(144)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass(), + 1L)) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .addTo(fluidSolidifierRecipes); + + } + + if (werkstoff.getGenerationFeatures() + .hasMetaSolidifierRecipes()) { + if (!werkstoff.hasItemType(screw)) { + return; + } + + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Shape_Mold_Screw.get(0)) + .itemOutputs(werkstoff.get(screw)) + .fluidInputs(werkstoff.getMolten(18)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() / 8, + 1L)) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .addTo(fluidSolidifierRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Shape_Mold_Gear.get(0)) + .itemOutputs(werkstoff.get(gearGt)) + .fluidInputs(werkstoff.getMolten(576)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() / 4, + 1L)) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .addTo(fluidSolidifierRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Shape_Mold_Gear_Small.get(0)) + .itemOutputs(werkstoff.get(gearGtSmall)) + .fluidInputs(werkstoff.getMolten(144)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass(), + 1L)) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .addTo(fluidSolidifierRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Shape_Mold_Bolt.get(0)) + .itemOutputs(werkstoff.get(bolt)) + .fluidInputs(werkstoff.getMolten(18)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() / 8, + 1L)) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .addTo(fluidSolidifierRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Shape_Mold_Ring.get(0)) + .itemOutputs(werkstoff.get(ring)) + .fluidInputs(werkstoff.getMolten(36)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() / 4, + 1L)) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .addTo(fluidSolidifierRecipes); + + // No Spring Molds + + if (WerkstoffLoader.rotorMold == null) { + return; + } + + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Shape_Mold_Rotor.get(0)) + .itemOutputs(werkstoff.get(rotor)) + .fluidInputs(werkstoff.getMolten(612)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 4.25, + 1L)) + .eut( + werkstoff.getStats() + .getMass() > 128 ? 64 : 30) + .addTo(fluidSolidifierRecipes); + + } + + if (werkstoff.getGenerationFeatures() + .hasMultipleMetalSolidifierRecipes() && !werkstoff.hasItemType(plateDouble)) { + // No multiple plate molds + return; + } + + // Tank "Recipe" + final FluidContainerRegistry.FluidContainerData data = new FluidContainerRegistry.FluidContainerData( + new FluidStack(Objects.requireNonNull(WerkstoffLoader.molten.get(werkstoff)), 144), + werkstoff.get(cellMolten), + Materials.Empty.getCells(1)); + FluidContainerRegistry + .registerFluidContainer(werkstoff.getMolten(144), werkstoff.get(cellMolten), Materials.Empty.getCells(1)); + GTUtility.addFluidContainerData(data); + + GTValues.RA.stdBuilder() + .itemInputs(Materials.Empty.getCells(1)) + .itemOutputs(werkstoff.get(cellMolten)) + .fluidInputs(new FluidStack(Objects.requireNonNull(WerkstoffLoader.molten.get(werkstoff)), 144)) + .duration(2 * TICKS) + .eut(2) + .addTo(fluidCannerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(cellMolten)) + .itemOutputs(Materials.Empty.getCells(1)) + .fluidOutputs(new FluidStack(Objects.requireNonNull(WerkstoffLoader.molten.get(werkstoff)), 144)) + .duration(2 * TICKS) + .eut(2) + .addTo(fluidCannerRecipes); + + if (!Forestry.isModLoaded()) return; + + final FluidContainerRegistry.FluidContainerData emptyData = new FluidContainerRegistry.FluidContainerData( + new FluidStack(Objects.requireNonNull(WerkstoffLoader.molten.get(werkstoff)), 144), + werkstoff.get(capsuleMolten), + GTModHandler.getModItem(Forestry.ID, "refractoryEmpty", 1)); + FluidContainerRegistry.registerFluidContainer( + werkstoff.getMolten(144), + werkstoff.get(capsuleMolten), + GTModHandler.getModItem(Forestry.ID, "refractoryEmpty", 1)); + GTUtility.addFluidContainerData(emptyData); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(capsuleMolten)) + .fluidOutputs(new FluidStack(Objects.requireNonNull(WerkstoffLoader.molten.get(werkstoff)), 144)) + .duration(2 * TICKS) + .eut(2) + .addTo(fluidCannerRecipes); + + } +} diff --git a/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/MultipleMetalLoader.java b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/MultipleMetalLoader.java new file mode 100644 index 0000000000..25e49b0666 --- /dev/null +++ b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/MultipleMetalLoader.java @@ -0,0 +1,68 @@ +/* + * 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.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.enums.OrePrefixes.plateDense; +import static gregtech.api.enums.OrePrefixes.plateDouble; +import static gregtech.api.recipe.RecipeMaps.maceratorRecipes; +import static gregtech.api.util.GTRecipeBuilder.TICKS; + +import net.minecraft.item.ItemStack; + +import bartworks.system.material.Werkstoff; +import bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.GTValues; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; + +public class MultipleMetalLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + if (werkstoff.hasItemType(plateDense)) { + RecipeMaps.benderRecipes.add( + new GTRecipe( + true, + new ItemStack[] { werkstoff.get(ingot, 2), GTUtility.getIntegratedCircuit(2) }, + new ItemStack[] { werkstoff.get(plateDouble) }, + null, + null, + null, + null, + (int) Math.max( + werkstoff.getStats() + .getMass() * 2, + 1L), + 60, + 0)); + GregTechAPI.registerCover( + werkstoff.get(plateDouble), + TextureFactory.of(werkstoff.getTexSet().mTextures[72], werkstoff.getRGBA(), false), + null); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(plateDouble)) + .itemOutputs(werkstoff.get(dust, 2)) + .duration(2 * TICKS) + .eut(8) + .addTo(maceratorRecipes); + + } + } +} diff --git a/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/OreLoader.java b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/OreLoader.java new file mode 100644 index 0000000000..cd5effd0f0 --- /dev/null +++ b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/OreLoader.java @@ -0,0 +1,65 @@ +/* + * 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.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.GTValues.RA; +import static gregtech.api.enums.OrePrefixes.crushed; +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.gem; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.enums.OrePrefixes.ore; +import static gregtech.api.recipe.RecipeMaps.hammerRecipes; +import static gregtech.api.recipe.RecipeMaps.maceratorRecipes; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; +import static gregtech.api.util.GTRecipeBuilder.TICKS; + +import bartworks.system.material.Werkstoff; +import bartworks.system.material.WerkstoffLoader; +import bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; +import gregtech.api.enums.Materials; +import gregtech.api.enums.SubTag; +import gregtech.api.util.GTModHandler; + +public class OreLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + if (werkstoff.hasItemType(ore) && werkstoff.hasItemType(ingot) + && !werkstoff.getStats() + .isBlastFurnace()) + GTModHandler + .addSmeltingRecipe(WerkstoffLoader.getCorrespondingItemStack(ore, werkstoff), werkstoff.get(ingot)); + + if (werkstoff.hasItemType(ore)) { + + RA.stdBuilder() + .itemInputs(werkstoff.get(ore)) + .itemOutputs(werkstoff.hasItemType(gem) ? werkstoff.get(gem) : werkstoff.get(crushed)) + .duration(16 * TICKS) + .eut(10) + .addTo(hammerRecipes); + + RA.stdBuilder() + .itemInputs(werkstoff.get(ore)) + .itemOutputs( + werkstoff.get(crushed, 2), + werkstoff.contains(SubTag.CRYSTAL) ? werkstoff.get(gem) : werkstoff.getOreByProduct(0, dust), + Materials.Stone.getDust(1)) + .outputChances(100_00, 10_00, 50_00) + .eut(2) + .duration(20 * SECONDS) + .addTo(maceratorRecipes); + } + } +} diff --git a/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/RawOreLoader.java b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/RawOreLoader.java new file mode 100644 index 0000000000..8c9c3c1f5f --- /dev/null +++ b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/RawOreLoader.java @@ -0,0 +1,65 @@ +/* + * 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.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.GTValues.RA; +import static gregtech.api.enums.OrePrefixes.crushed; +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.gem; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.enums.OrePrefixes.rawOre; +import static gregtech.api.recipe.RecipeMaps.hammerRecipes; +import static gregtech.api.recipe.RecipeMaps.maceratorRecipes; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; +import static gregtech.api.util.GTRecipeBuilder.TICKS; + +import bartworks.system.material.Werkstoff; +import bartworks.system.material.WerkstoffLoader; +import bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; +import gregtech.api.enums.Materials; +import gregtech.api.enums.SubTag; +import gregtech.api.util.GTModHandler; + +public class RawOreLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + if (werkstoff.hasItemType(rawOre) && werkstoff.hasItemType(ingot) + && !werkstoff.getStats() + .isBlastFurnace()) + GTModHandler + .addSmeltingRecipe(WerkstoffLoader.getCorrespondingItemStack(rawOre, werkstoff), werkstoff.get(ingot)); + + if (werkstoff.hasItemType(rawOre)) { + + RA.stdBuilder() + .itemInputs(werkstoff.get(rawOre)) + .itemOutputs(werkstoff.hasItemType(gem) ? werkstoff.get(gem) : werkstoff.get(crushed)) + .duration(16 * TICKS) + .eut(10) + .addTo(hammerRecipes); + + RA.stdBuilder() + .itemInputs(werkstoff.get(rawOre)) + .itemOutputs( + werkstoff.get(crushed, 2), + werkstoff.contains(SubTag.CRYSTAL) ? werkstoff.get(gem) : werkstoff.getOreByProduct(0, dust), + Materials.Stone.getDust(1)) + .outputChances(100_00, werkstoff.getNoOfByProducts() > 0 ? 5_00 : 10_00, 50_00) + .eut(2) + .duration(20 * SECONDS) + .addTo(maceratorRecipes); + } + } +} diff --git a/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/SimpleMetalLoader.java b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/SimpleMetalLoader.java new file mode 100644 index 0000000000..1fa51359d9 --- /dev/null +++ b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/SimpleMetalLoader.java @@ -0,0 +1,249 @@ +/* + * 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.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.OrePrefixes.block; +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.dustSmall; +import static gregtech.api.enums.OrePrefixes.foil; +import static gregtech.api.enums.OrePrefixes.gem; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.enums.OrePrefixes.plate; +import static gregtech.api.enums.OrePrefixes.stick; +import static gregtech.api.enums.OrePrefixes.stickLong; +import static gregtech.api.recipe.RecipeMaps.benderRecipes; +import static gregtech.api.recipe.RecipeMaps.extruderRecipes; +import static gregtech.api.recipe.RecipeMaps.hammerRecipes; +import static gregtech.api.recipe.RecipeMaps.latheRecipes; +import static gregtech.api.recipe.RecipeMaps.maceratorRecipes; +import static gregtech.api.util.GTRecipeBuilder.TICKS; + +import net.minecraft.item.ItemStack; + +import bartworks.API.SideReference; +import bartworks.client.textures.PrefixTextureLinker; +import bartworks.system.material.Werkstoff; +import bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.TextureSet; +import gregtech.api.interfaces.ITexture; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.common.GTProxy; + +public class SimpleMetalLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + if (werkstoff.hasItemType(plate)) { + if (werkstoff.hasItemType(gem)) { + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(gem)) + .itemOutputs(werkstoff.get(stick), werkstoff.get(dustSmall, 2)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 5L, + 1L)) + .eut(16) + .addTo(latheRecipes); + + GTModHandler.addCraftingRecipe( + werkstoff.get(stick, 2), + GTProxy.tBits, + new Object[] { "s", "X", 'X', werkstoff.get(stickLong) }); + GTModHandler.addCraftingRecipe( + werkstoff.get(stick), + GTProxy.tBits, + new Object[] { "f ", " X", 'X', werkstoff.get(gem) }); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(stick, 2)) + .itemOutputs(werkstoff.get(stickLong)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass(), + 1L)) + .eut(16) + .addTo(hammerRecipes); + + TextureSet texSet = werkstoff.getTexSet(); + ITexture texture = SideReference.Side.Client ? TextureFactory.of( + texSet.mTextures[PrefixTextureLinker.blockTexMap.getOrDefault(texSet, block.mTextureIndex)], + werkstoff.getRGBA(), + false) : TextureFactory.of(texSet.mTextures[block.mTextureIndex], werkstoff.getRGBA(), false); + GregTechAPI.registerCover(werkstoff.get(plate), texture, null); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(plate)) + .itemOutputs(werkstoff.get(dust)) + .duration(2 * TICKS) + .eut(8) + .addTo(maceratorRecipes); + + return; + } + + GTModHandler.addCraftingRecipe( + werkstoff.get(stick, 2), + GTProxy.tBits, + new Object[] { "s", "X", 'X', werkstoff.get(stickLong) }); + GTModHandler.addCraftingRecipe( + werkstoff.get(stick), + GTProxy.tBits, + new Object[] { "f ", " X", 'X', werkstoff.get(ingot) }); + GTModHandler.addCraftingRecipe( + werkstoff.get(plate), + GTProxy.tBits, + new Object[] { "h", "X", "X", 'X', werkstoff.get(ingot) }); + GTModHandler.addCraftingRecipe( + werkstoff.get(foil, 2), + GTProxy.tBits, + new Object[] { "hX", 'X', werkstoff.get(plate) }); + + benderRecipes.add( + new GTRecipe( + true, + new ItemStack[] { werkstoff.get(ingot), GTUtility.getIntegratedCircuit(1) }, + new ItemStack[] { werkstoff.get(plate) }, + null, + null, + null, + null, + (int) Math.max( + werkstoff.getStats() + .getMass(), + 1L), + 24, + 0)); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot, 3)) + .itemOutputs(werkstoff.get(plate, 2)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass(), + 1L)) + .eut(16) + .addTo(hammerRecipes); + + GregTechAPI.registerCover( + werkstoff.get(plate), + TextureFactory.of(werkstoff.getTexSet().mTextures[71], werkstoff.getRGBA(), false), + null); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot)) + .itemOutputs(werkstoff.get(stick), werkstoff.get(dustSmall, 2)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 5L, + 1L)) + .eut(16) + .addTo(latheRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(plate), GTUtility.getIntegratedCircuit(1)) + .itemOutputs(werkstoff.get(foil, 4)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 1L, + 1L)) + .eut(24) + .addTo(benderRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot), GTUtility.getIntegratedCircuit(10)) + .itemOutputs(werkstoff.get(foil, 4)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 2L, + 1L)) + .eut(24) + .addTo(benderRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(stick, 2)) + .itemOutputs(werkstoff.get(stickLong)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass(), + 1L)) + .eut(16) + .addTo(hammerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot), ItemList.Shape_Extruder_Plate.get(0)) + .itemOutputs(werkstoff.get(plate)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 2L, + 1L)) + .eut(45) + .addTo(extruderRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot), ItemList.Shape_Extruder_Rod.get(0)) + .itemOutputs(werkstoff.get(stick, 2)) + .duration( + (int) Math.max( + werkstoff.getStats() + .getMass() * 2L, + 1L)) + .eut(45) + .addTo(extruderRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot)) + .itemOutputs(werkstoff.get(dust)) + .duration(2 * TICKS) + .eut(8) + .addTo(maceratorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(plate)) + .itemOutputs(werkstoff.get(dust)) + .duration(2 * TICKS) + .eut(8) + .addTo(maceratorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(stickLong)) + .itemOutputs(werkstoff.get(dust)) + .duration(2 * TICKS) + .eut(8) + .addTo(maceratorRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(stick)) + .itemOutputs(werkstoff.get(dustSmall, 2)) + .duration(2 * TICKS) + .eut(8) + .addTo(maceratorRecipes); + + } + } +} diff --git a/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/ToolLoader.java b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/ToolLoader.java new file mode 100644 index 0000000000..4110ec25eb --- /dev/null +++ b/src/main/java/bartworks/system/material/werkstoff_loaders/recipe/ToolLoader.java @@ -0,0 +1,600 @@ +/* + * 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.system.material.werkstoff_loaders.recipe; + +import static gregtech.api.enums.OrePrefixes.bolt; +import static gregtech.api.enums.OrePrefixes.cellMolten; +import static gregtech.api.enums.OrePrefixes.gearGtSmall; +import static gregtech.api.enums.OrePrefixes.gem; +import static gregtech.api.enums.OrePrefixes.ingot; +import static gregtech.api.enums.OrePrefixes.plate; +import static gregtech.api.enums.OrePrefixes.plateDouble; +import static gregtech.api.enums.OrePrefixes.ring; +import static gregtech.api.enums.OrePrefixes.screw; +import static gregtech.api.enums.OrePrefixes.stick; +import static gregtech.api.enums.OrePrefixes.stickLong; +import static gregtech.api.enums.OrePrefixes.toolHeadHammer; +import static gregtech.api.enums.OrePrefixes.toolHeadSaw; +import static gregtech.api.enums.OrePrefixes.toolHeadWrench; +import static gregtech.api.enums.OrePrefixes.turbineBlade; +import static gregtech.api.recipe.RecipeMaps.assemblerRecipes; +import static gregtech.api.recipe.RecipeMaps.extruderRecipes; +import static gregtech.api.recipe.RecipeMaps.fluidSolidifierRecipes; +import static gregtech.api.recipe.RecipeMaps.formingPressRecipes; +import static gregtech.api.util.GTRecipeBuilder.MINUTES; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; + +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; + +import bartworks.system.material.Werkstoff; +import bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.TierEU; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.common.GTProxy; +import gregtech.common.items.IDMetaTool01; +import gregtech.common.items.MetaGeneratedTool01; + +public class ToolLoader implements IWerkstoffRunnable { + + // GTNH-Specific + public static final short SCREWDRIVER_MV = 152; + public static final short SCREWDRIVER_HV = 154; + public static final short SOLDERING_IRON_MV = 162; + public static final short SOLDERING_IRON_HV = 164; + + public void run(Werkstoff werkstoff) { + if (werkstoff.getBridgeMaterial().mDurability == 0) return; + + if (werkstoff.hasItemType(gem)) { + if (!werkstoff.getGenerationFeatures() + .isExtension()) + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.HARDHAMMER.ID, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial().mHandleMaterial, + null), + GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "XX ", "XXS", "XX ", 'X', gem.get(werkstoff.getBridgeMaterial()), 'S', + stick.get(werkstoff.getBridgeMaterial().mHandleMaterial) }); + GTModHandler.addCraftingRecipe( + GTOreDictUnificator.get(toolHeadSaw, werkstoff.getBridgeMaterial(), 1L), + GTProxy.tBits, + new Object[] { "GGf", 'G', gem.get(werkstoff.getBridgeMaterial()) }); + } + + if (!werkstoff.hasItemType(plate)) return; + + // Disable recipe gen with handle Material for GT Materials + if (!werkstoff.getGenerationFeatures() + .isExtension()) { + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.SCREWDRIVER.ID, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial().mHandleMaterial, + null), + GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GTModHandler.RecipeBits.BUFFERED, + new Object[] { " fS", " Sh", "W ", 'S', stick.get(werkstoff.getBridgeMaterial()), 'W', + stick.get(werkstoff.getBridgeMaterial().mHandleMaterial) }); + GTModHandler.addCraftingRecipe( + GTOreDictUnificator.get(toolHeadWrench, werkstoff.getBridgeMaterial(), 1L), + GTProxy.tBits, + new Object[] { "hXW", "XRX", "WXd", 'X', plate.get(werkstoff.getBridgeMaterial()), 'S', + plate.get(werkstoff.getBridgeMaterial().mHandleMaterial), 'R', + ring.get(werkstoff.getBridgeMaterial().mHandleMaterial), 'W', + screw.get(werkstoff.getBridgeMaterial().mHandleMaterial) }); + GTModHandler.addShapelessCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.HARDHAMMER.ID, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial().mHandleMaterial, + null), + GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GTModHandler.RecipeBits.BUFFERED, + new Object[] { toolHeadHammer.get(werkstoff.getBridgeMaterial()), + stick.get(werkstoff.getBridgeMaterial().mHandleMaterial) }); + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.FILE.ID, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial().mHandleMaterial, + null), + GTModHandler.RecipeBits.MIRRORED | GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "P", "P", "S", 'P', plate.get(werkstoff.getBridgeMaterial()), 'S', + stick.get(werkstoff.getBridgeMaterial().mHandleMaterial) }); + GTModHandler.addShapelessCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.SAW.ID, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial().mHandleMaterial, + null), + new Object[] { toolHeadSaw.get(werkstoff.getBridgeMaterial()), + stick.get(werkstoff.getBridgeMaterial().mHandleMaterial) }); + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.SOLDERING_IRON_LV.ID, + 1, + werkstoff.getBridgeMaterial(), + Materials.Rubber, + new long[] { 100000L, 32L, 1L, -1L }), + GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "LBf", "Sd ", "P ", 'B', bolt.get(werkstoff.getBridgeMaterial()), 'P', + plate.get(Materials.AnyRubber), 'S', stick.get(werkstoff.getBridgeMaterial().mHandleMaterial), 'L', + ItemList.Battery_RE_LV_Lithium.get(1L) }); + + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + SOLDERING_IRON_MV, + 1, + werkstoff.getBridgeMaterial(), + Materials.Rubber, + new long[] { 400000L, 128L, 2L, -1L }), + GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "LBf", "Sd ", "P ", 'B', bolt.get(werkstoff.getBridgeMaterial()), 'P', + plate.get(Materials.AnyRubber), 'S', stick.get(werkstoff.getBridgeMaterial().mHandleMaterial), 'L', + ItemList.Battery_RE_MV_Lithium.get(1L) }); + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + SOLDERING_IRON_HV, + 1, + werkstoff.getBridgeMaterial(), + Materials.StyreneButadieneRubber, + new long[] { 1600000L, 512L, 3L, -1L }), + GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "LBf", "Sd ", "P ", 'B', bolt.get(werkstoff.getBridgeMaterial()), 'P', + plate.get(Materials.StyreneButadieneRubber), 'S', + stick.get(werkstoff.getBridgeMaterial().mHandleMaterial), 'L', + ItemList.Battery_RE_HV_Lithium.get(1L) }); + + if (!werkstoff.hasItemType(gem)) { + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.HARDHAMMER.ID, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial().mHandleMaterial, + null), + GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "XX ", "XXS", "XX ", 'X', ingot.get(werkstoff.getBridgeMaterial()), 'S', + stick.get(werkstoff.getBridgeMaterial().mHandleMaterial) }); + } + } + + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.PLUNGER.ID, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial(), + null), + GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "xRR", " SR", "S f", 'S', stick.get(werkstoff.getBridgeMaterial()), 'R', + plate.get(Materials.AnyRubber) }); + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.WRENCH.ID, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial(), + null), + GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "IhI", "III", " I ", 'I', ingot.get(werkstoff.getBridgeMaterial()) }); + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.CROWBAR.ID, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial(), + null), + GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "hDS", "DSD", "SDf", 'S', stick.get(werkstoff.getBridgeMaterial()), 'D', Dyes.dyeBlue }); + + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.WIRECUTTER.ID, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial(), + null), + GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "PfP", "hPd", "STS", 'S', stick.get(werkstoff.getBridgeMaterial()), 'P', + plate.get(werkstoff.getBridgeMaterial()), 'T', screw.get(werkstoff.getBridgeMaterial()) }); + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.SCOOP.ID, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial(), + null), + GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "SWS", "SSS", "xSh", 'S', stick.get(werkstoff.getBridgeMaterial()), 'W', + new ItemStack(Blocks.wool, 1, 32767) }); + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.BRANCHCUTTER.ID, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial(), + null), + GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "PfP", "PdP", "STS", 'S', stick.get(werkstoff.getBridgeMaterial()), 'P', + plate.get(werkstoff.getBridgeMaterial()), 'T', screw.get(werkstoff.getBridgeMaterial()) }); + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.KNIFE.ID, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial(), + null), + GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "fPh", " S ", 'S', stick.get(werkstoff.getBridgeMaterial()), 'P', + plate.get(werkstoff.getBridgeMaterial()) }); + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.BUTCHERYKNIFE.ID, + 1, + werkstoff.getBridgeMaterial(), + werkstoff.getBridgeMaterial(), + null), + GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "PPf", "PP ", "Sh ", 'S', stick.get(werkstoff.getBridgeMaterial()), 'P', + plate.get(werkstoff.getBridgeMaterial()) }); + + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.WRENCH_LV.ID, + 1, + werkstoff.getBridgeMaterial(), + Materials.Steel, + new long[] { 100000L, 32L, 1L, -1L }), + GTModHandler.RecipeBits.DISMANTLEABLE | GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "SXd", "GMG", "PBP", 'X', toolHeadWrench.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_LV.get(1L), 'S', screw.get(Materials.Steel), 'P', plate.get(Materials.Steel), + 'G', gearGtSmall.get(Materials.Steel), 'B', ItemList.Battery_RE_LV_Lithium.get(1L) }); + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.WRENCH_LV.ID, + 1, + werkstoff.getBridgeMaterial(), + Materials.Steel, + new long[] { 75000L, 32L, 1L, -1L }), + GTModHandler.RecipeBits.DISMANTLEABLE | GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "SXd", "GMG", "PBP", 'X', toolHeadWrench.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_LV.get(1L), 'S', screw.get(Materials.Steel), 'P', plate.get(Materials.Steel), + 'G', gearGtSmall.get(Materials.Steel), 'B', ItemList.Battery_RE_LV_Cadmium.get(1L) }); + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.WRENCH_LV.ID, + 1, + werkstoff.getBridgeMaterial(), + Materials.Steel, + new long[] { 50000L, 32L, 1L, -1L }), + GTModHandler.RecipeBits.DISMANTLEABLE | GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "SXd", "GMG", "PBP", 'X', toolHeadWrench.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_LV.get(1L), 'S', screw.get(Materials.Steel), 'P', plate.get(Materials.Steel), + 'G', gearGtSmall.get(Materials.Steel), 'B', ItemList.Battery_RE_LV_Sodium.get(1L) }); + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.WRENCH_MV.ID, + 1, + werkstoff.getBridgeMaterial(), + Materials.Aluminium, + new long[] { 400000L, 128L, 2L, -1L }), + GTModHandler.RecipeBits.DISMANTLEABLE | GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "SXd", "GMG", "PBP", 'X', toolHeadWrench.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_MV.get(1L), 'S', screw.get(Materials.Aluminium), 'P', + plate.get(Materials.Aluminium), 'G', gearGtSmall.get(Materials.Aluminium), 'B', + ItemList.Battery_RE_MV_Lithium.get(1L) }); + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.WRENCH_MV.ID, + 1, + werkstoff.getBridgeMaterial(), + Materials.Aluminium, + new long[] { 300000L, 128L, 2L, -1L }), + GTModHandler.RecipeBits.DISMANTLEABLE | GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "SXd", "GMG", "PBP", 'X', toolHeadWrench.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_MV.get(1L), 'S', screw.get(Materials.Aluminium), 'P', + plate.get(Materials.Aluminium), 'G', gearGtSmall.get(Materials.Aluminium), 'B', + ItemList.Battery_RE_MV_Cadmium.get(1L) }); + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.WRENCH_MV.ID, + 1, + werkstoff.getBridgeMaterial(), + Materials.Aluminium, + new long[] { 200000L, 128L, 2L, -1L }), + GTModHandler.RecipeBits.DISMANTLEABLE | GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "SXd", "GMG", "PBP", 'X', toolHeadWrench.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_MV.get(1L), 'S', screw.get(Materials.Aluminium), 'P', + plate.get(Materials.Aluminium), 'G', gearGtSmall.get(Materials.Aluminium), 'B', + ItemList.Battery_RE_MV_Sodium.get(1L) }); + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.WRENCH_HV.ID, + 1, + werkstoff.getBridgeMaterial(), + Materials.StainlessSteel, + new long[] { 1600000L, 512L, 3L, -1L }), + GTModHandler.RecipeBits.DISMANTLEABLE | GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "SXd", "GMG", "PBP", 'X', toolHeadWrench.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_HV.get(1L), 'S', screw.get(Materials.StainlessSteel), 'P', + plate.get(Materials.StainlessSteel), 'G', gearGtSmall.get(Materials.StainlessSteel), 'B', + ItemList.Battery_RE_HV_Lithium.get(1L) }); + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.WRENCH_HV.ID, + 1, + werkstoff.getBridgeMaterial(), + Materials.StainlessSteel, + new long[] { 1200000L, 512L, 3L, -1L }), + GTModHandler.RecipeBits.DISMANTLEABLE | GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "SXd", "GMG", "PBP", 'X', toolHeadWrench.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_HV.get(1L), 'S', screw.get(Materials.StainlessSteel), 'P', + plate.get(Materials.StainlessSteel), 'G', gearGtSmall.get(Materials.StainlessSteel), 'B', + ItemList.Battery_RE_HV_Cadmium.get(1L) }); + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.WRENCH_HV.ID, + 1, + werkstoff.getBridgeMaterial(), + Materials.StainlessSteel, + new long[] { 800000L, 512L, 3L, -1L }), + GTModHandler.RecipeBits.DISMANTLEABLE | GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "SXd", "GMG", "PBP", 'X', toolHeadWrench.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_HV.get(1L), 'S', screw.get(Materials.StainlessSteel), 'P', + plate.get(Materials.StainlessSteel), 'G', gearGtSmall.get(Materials.StainlessSteel), 'B', + ItemList.Battery_RE_HV_Sodium.get(1L) }); + + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.SCREWDRIVER_LV.ID, + 1, + werkstoff.getBridgeMaterial(), + Materials.Steel, + new long[] { 100000L, 32L, 1L, -1L }), + GTModHandler.RecipeBits.DISMANTLEABLE | GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "PdX", "MGS", "GBP", 'X', stickLong.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_LV.get(1L), 'S', screw.get(Materials.Steel), 'P', plate.get(Materials.Steel), + 'G', gearGtSmall.get(Materials.Steel), 'B', ItemList.Battery_RE_LV_Lithium.get(1L) }); + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.SCREWDRIVER_LV.ID, + 1, + werkstoff.getBridgeMaterial(), + Materials.Steel, + new long[] { 75000L, 32L, 1L, -1L }), + GTModHandler.RecipeBits.DISMANTLEABLE | GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "PdX", "MGS", "GBP", 'X', stickLong.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_LV.get(1L), 'S', screw.get(Materials.Steel), 'P', plate.get(Materials.Steel), + 'G', gearGtSmall.get(Materials.Steel), 'B', ItemList.Battery_RE_LV_Cadmium.get(1L) }); + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.SCREWDRIVER_LV.ID, + 1, + werkstoff.getBridgeMaterial(), + Materials.Steel, + new long[] { 50000L, 32L, 1L, -1L }), + GTModHandler.RecipeBits.DISMANTLEABLE | GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "PdX", "MGS", "GBP", 'X', stickLong.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_LV.get(1L), 'S', screw.get(Materials.Steel), 'P', plate.get(Materials.Steel), + 'G', gearGtSmall.get(Materials.Steel), 'B', ItemList.Battery_RE_LV_Sodium.get(1L) }); + + GTModHandler.addCraftingRecipe( + GTOreDictUnificator.get(toolHeadHammer, werkstoff.getBridgeMaterial(), 1L), + GTProxy.tBits, + new Object[] { "II ", "IIh", "II ", 'P', plate.get(werkstoff.getBridgeMaterial()), 'I', + ingot.get(werkstoff.getBridgeMaterial()) }); + if (werkstoff.hasItemType(plateDouble) && werkstoff.hasItemType(cellMolten)) { + GTModHandler.addCraftingRecipe( + GTOreDictUnificator.get(turbineBlade, werkstoff.getBridgeMaterial(), 1L), + GTProxy.tBits, + new Object[] { "fPd", "SPS", " P ", 'P', plateDouble.get(werkstoff.getBridgeMaterial()), 'S', + screw.get(werkstoff.getBridgeMaterial()) }); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(ingot, 6), ItemList.Shape_Extruder_Turbine_Blade.get(0)) + .itemOutputs(werkstoff.get(turbineBlade, 1)) + .duration( + (int) werkstoff.getStats() + .getMass() / 2 * 20) + .eut(TierEU.RECIPE_MV) + .addTo(extruderRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(ItemList.Shape_Mold_Turbine_Blade.get(0)) + .itemOutputs(werkstoff.get(turbineBlade, 1)) + .fluidInputs(werkstoff.getMolten(864)) + .duration( + (int) werkstoff.getStats() + .getMass() * 20) + .eut(TierEU.RECIPE_MV) + .addTo(fluidSolidifierRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(plateDouble, 3), werkstoff.get(screw, 2)) + .itemOutputs(werkstoff.get(turbineBlade, 1)) + .duration( + (werkstoff.getStats() + .getMass() / 4) * SECONDS) + .eut(TierEU.RECIPE_LV) + .addTo(formingPressRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(turbineBlade, 4), GTOreDictUnificator.get(stickLong, Materials.Magnalium, 1)) + .itemOutputs( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.TURBINE_SMALL.ID, + 1, + werkstoff.getBridgeMaterial(), + Materials.Magnalium, + null)) + .duration(8 * SECONDS) + .eut(100) + .addTo(assemblerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(turbineBlade, 8), GTOreDictUnificator.get(stickLong, Materials.Titanium, 1)) + .itemOutputs( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.TURBINE.ID, + 1, + werkstoff.getBridgeMaterial(), + Materials.Titanium, + null)) + .duration(16 * SECONDS) + .eut(400) + .addTo(assemblerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs( + werkstoff.get(turbineBlade, 12), + GTOreDictUnificator.get(stickLong, Materials.TungstenSteel, 1)) + .itemOutputs( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.TURBINE_LARGE.ID, + 1, + werkstoff.getBridgeMaterial(), + Materials.TungstenSteel, + null)) + .duration(32 * SECONDS) + .eut(1600) + .addTo(assemblerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(werkstoff.get(turbineBlade, 16), GTOreDictUnificator.get(stickLong, Materials.Americium, 1)) + .itemOutputs( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + IDMetaTool01.TURBINE_HUGE.ID, + 1, + werkstoff.getBridgeMaterial(), + Materials.Americium, + null)) + .duration(1 * MINUTES + 4 * SECONDS) + .eut(6400) + .addTo(assemblerRecipes); + } + + if (!werkstoff.hasItemType(gem)) { + GTModHandler.addCraftingRecipe( + GTOreDictUnificator.get(toolHeadSaw, werkstoff.getBridgeMaterial(), 1L), + GTProxy.tBits, + new Object[] { "PP ", "fh ", 'P', plate.get(werkstoff.getBridgeMaterial()), 'I', + ingot.get(werkstoff.getBridgeMaterial()) }); + } + + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + SCREWDRIVER_MV, + 1, + werkstoff.getBridgeMaterial(), + Materials.Aluminium, + new long[] { 400000L, 128L, 2L, -1L }), + GTModHandler.RecipeBits.DISMANTLEABLE | GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "PdX", "MGS", "GBP", 'X', stickLong.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_MV.get(1L), 'S', screw.get(Materials.Aluminium), 'P', + plate.get(Materials.Aluminium), 'G', gearGtSmall.get(Materials.Titanium), 'B', + ItemList.Battery_RE_MV_Lithium.get(1L) }); + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + SCREWDRIVER_MV, + 1, + werkstoff.getBridgeMaterial(), + Materials.Aluminium, + new long[] { 300000L, 128L, 2L, -1L }), + GTModHandler.RecipeBits.DISMANTLEABLE | GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "PdX", "MGS", "GBP", 'X', stickLong.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_MV.get(1L), 'S', screw.get(Materials.Aluminium), 'P', + plate.get(Materials.Aluminium), 'G', gearGtSmall.get(Materials.Titanium), 'B', + ItemList.Battery_RE_MV_Cadmium.get(1L) }); + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + SCREWDRIVER_MV, + 1, + werkstoff.getBridgeMaterial(), + Materials.Aluminium, + new long[] { 200000L, 128L, 2L, -1L }), + GTModHandler.RecipeBits.DISMANTLEABLE | GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "PdX", "MGS", "GBP", 'X', stickLong.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_MV.get(1L), 'S', screw.get(Materials.Aluminium), 'P', + plate.get(Materials.Aluminium), 'G', gearGtSmall.get(Materials.Titanium), 'B', + ItemList.Battery_RE_MV_Sodium.get(1L) }); + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + SCREWDRIVER_HV, + 1, + werkstoff.getBridgeMaterial(), + Materials.StainlessSteel, + new long[] { 1600000L, 512L, 3L, -1L }), + GTModHandler.RecipeBits.DISMANTLEABLE | GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "PdX", "MGS", "GBP", 'X', stickLong.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_HV.get(1L), 'S', screw.get(Materials.StainlessSteel), 'P', + plate.get(Materials.StainlessSteel), 'G', gearGtSmall.get(Materials.StainlessSteel), 'B', + ItemList.Battery_RE_HV_Lithium.get(1L) }); + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + SCREWDRIVER_HV, + 1, + werkstoff.getBridgeMaterial(), + Materials.StainlessSteel, + new long[] { 1200000L, 512L, 3L, -1L }), + GTModHandler.RecipeBits.DISMANTLEABLE | GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "PdX", "MGS", "GBP", 'X', stickLong.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_HV.get(1L), 'S', screw.get(Materials.StainlessSteel), 'P', + plate.get(Materials.StainlessSteel), 'G', gearGtSmall.get(Materials.StainlessSteel), 'B', + ItemList.Battery_RE_HV_Cadmium.get(1L) }); + GTModHandler.addCraftingRecipe( + MetaGeneratedTool01.INSTANCE.getToolWithStats( + SCREWDRIVER_HV, + 1, + werkstoff.getBridgeMaterial(), + Materials.StainlessSteel, + new long[] { 800000L, 512L, 3L, -1L }), + GTModHandler.RecipeBits.DISMANTLEABLE | GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS + | GTModHandler.RecipeBits.BUFFERED, + new Object[] { "PdX", "MGS", "GBP", 'X', stickLong.get(werkstoff.getBridgeMaterial()), 'M', + ItemList.Electric_Motor_HV.get(1L), 'S', screw.get(Materials.StainlessSteel), 'P', + plate.get(Materials.StainlessSteel), 'G', gearGtSmall.get(Materials.StainlessSteel), 'B', + ItemList.Battery_RE_HV_Sodium.get(1L) }); + } +} diff --git a/src/main/java/bartworks/system/material/werkstoff_loaders/registration/AssociationLoader.java b/src/main/java/bartworks/system/material/werkstoff_loaders/registration/AssociationLoader.java new file mode 100644 index 0000000000..3cf224e777 --- /dev/null +++ b/src/main/java/bartworks/system/material/werkstoff_loaders/registration/AssociationLoader.java @@ -0,0 +1,41 @@ +/* + * 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.system.material.werkstoff_loaders.registration; + +import net.minecraft.item.ItemStack; + +import bartworks.system.material.Werkstoff; +import bartworks.system.material.WerkstoffLoader; +import bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GTOreDictUnificator; + +public class AssociationLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + for (OrePrefixes prefixes : OrePrefixes.values()) { + if (!werkstoff.hasItemType(prefixes)) continue; + + Materials werkstoffBridgeMaterial = werkstoff.getBridgeMaterial(); + ItemStack stack = WerkstoffLoader.getCorrespondingItemStackUnsafe(prefixes, werkstoff, 1); + + if (stack != null && stack.getItem() != null) { + GTOreDictUnificator.addAssociation(prefixes, werkstoffBridgeMaterial, stack, false); + GTOreDictUnificator.set(prefixes, werkstoffBridgeMaterial, stack, true, true); + } + } + } +} diff --git a/src/main/java/bartworks/system/material/werkstoff_loaders/registration/BridgeMaterialsLoader.java b/src/main/java/bartworks/system/material/werkstoff_loaders/registration/BridgeMaterialsLoader.java new file mode 100644 index 0000000000..2bf712ed7a --- /dev/null +++ b/src/main/java/bartworks/system/material/werkstoff_loaders/registration/BridgeMaterialsLoader.java @@ -0,0 +1,171 @@ +/* + * 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.system.material.werkstoff_loaders.registration; + +import static gregtech.api.enums.Mods.Thaumcraft; +import static gregtech.api.enums.OrePrefixes.cell; +import static gregtech.api.enums.OrePrefixes.cellMolten; +import static gregtech.api.enums.OrePrefixes.dust; +import static gregtech.api.enums.OrePrefixes.values; + +import java.util.ArrayList; + +import bartworks.system.material.Werkstoff; +import bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; +import gregtech.api.enchants.EnchantmentRadioactivity; +import gregtech.api.enums.Element; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SubTag; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTOreDictUnificator; + +public class BridgeMaterialsLoader implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + // int aMetaItemSubID, TextureSet aIconSet, float aToolSpeed, int aDurability, int aToolQuality, int aTypes, int + // aR, int aG, int aB, int aA, String aName, String aDefaultLocalName, int aFuelType, int aFuelPower, int + // aMeltingPoint, int aBlastFurnaceTemp, boolean aBlastFurnaceRequired, boolean aTransparent, int aOreValue, int + // aDensityMultiplier, int aDensityDivider, Dyes aColor, String aConfigSection, boolean aCustomOre, String + // aCustomID + Materials werkstoffBridgeMaterial = werkstoff.getBridgeMaterial() != null ? werkstoff.getBridgeMaterial() + : Materials.get(werkstoff.getVarName()) != Materials._NULL ? Materials.get(werkstoff.getVarName()) + : new Materials( + -1, + werkstoff.getTexSet(), + werkstoff.getToolSpeed(), + werkstoff.getDurability(), + werkstoff.getToolQuality(), + 0, + werkstoff.getRGBA()[0], + werkstoff.getRGBA()[1], + werkstoff.getRGBA()[2], + werkstoff.getRGBA()[3], + werkstoff.getVarName(), + werkstoff.getDefaultName(), + 0, + 0, + werkstoff.getStats() + .getMeltingPoint(), + werkstoff.getStats() + .getMeltingPoint(), + werkstoff.getStats() + .isBlastFurnace(), + false, + 0, + 1, + 1, + null); + for (OrePrefixes prefixes : values()) { + if (prefixes != cell || !Werkstoff.Types.ELEMENT.equals(werkstoff.getType())) { + if (prefixes == dust && Werkstoff.Types.ELEMENT.equals(werkstoff.getType()) + && Werkstoff.Types.ELEMENT.equals(werkstoff.getType())) { + boolean ElementSet = false; + for (Element e : Element.values()) { + if (e.toString() + .equals(werkstoff.getToolTip())) { + if (!e.mLinkedMaterials.isEmpty()) break; + werkstoffBridgeMaterial = werkstoff.getBridgeMaterial() != null + ? werkstoff.getBridgeMaterial() + : Materials.get(werkstoff.getVarName()) != Materials._NULL + ? Materials.get(werkstoff.getVarName()) + : new Materials( + -1, + werkstoff.getTexSet(), + werkstoff.getToolSpeed(), + werkstoff.getDurability(), + werkstoff.getToolQuality(), + 0, + werkstoff.getRGBA()[0], + werkstoff.getRGBA()[1], + werkstoff.getRGBA()[2], + werkstoff.getRGBA()[3], + werkstoff.getVarName(), + werkstoff.getDefaultName(), + 0, + 0, + werkstoff.getStats() + .getMeltingPoint(), + werkstoff.getStats() + .getMeltingPoint(), + werkstoff.getStats() + .isBlastFurnace(), + false, + 0, + 1, + 1, + null); + werkstoffBridgeMaterial.mElement = e; + e.mLinkedMaterials = new ArrayList<>(); + e.mLinkedMaterials.add(werkstoffBridgeMaterial); + if (werkstoff.hasItemType(dust)) { + GTOreDictUnificator + .addAssociation(dust, werkstoffBridgeMaterial, werkstoff.get(dust), false); + GTOreDictUnificator.set(dust, werkstoffBridgeMaterial, werkstoff.get(dust), true, true); + } + ElementSet = true; + break; + } + } + if (!ElementSet) { + continue; + } + } + + if (werkstoff.hasItemType(cell)) { + werkstoffBridgeMaterial.setHasCorrespondingFluid(true); + werkstoffBridgeMaterial.setHasCorrespondingGas(true); + werkstoffBridgeMaterial.mFluid = werkstoff.getFluidOrGas(1) + .getFluid(); + werkstoffBridgeMaterial.mGas = werkstoff.getFluidOrGas(1) + .getFluid(); + } + + if (werkstoff.hasItemType(cellMolten)) { + werkstoffBridgeMaterial.mStandardMoltenFluid = werkstoff.getMolten(1) + .getFluid(); + } + werkstoffBridgeMaterial.mName = werkstoff.getVarName(); + werkstoffBridgeMaterial.mDefaultLocalName = werkstoff.getDefaultName(); + werkstoffBridgeMaterial.mChemicalFormula = werkstoff.getToolTip(); + if ("null".equals(werkstoffBridgeMaterial.mLocalizedName)) + // only reload from lang file if not localized already + werkstoffBridgeMaterial.mLocalizedName = GTLanguageManager.addStringLocalization( + "Material." + werkstoffBridgeMaterial.mName.toLowerCase(), + werkstoffBridgeMaterial.mDefaultLocalName); + if (Thaumcraft.isModLoaded()) { + werkstoffBridgeMaterial.mAspects = werkstoff.getGTWrappedTCAspects(); + } + werkstoffBridgeMaterial.mMaterialInto = werkstoffBridgeMaterial; + werkstoffBridgeMaterial.mHandleMaterial = werkstoff.contains(SubTag.BURNING) ? Materials.Blaze + : werkstoff.contains(SubTag.MAGICAL) ? Materials.Thaumium + : werkstoffBridgeMaterial.mDurability > 5120 ? Materials.TungstenSteel + : werkstoffBridgeMaterial.mDurability > 1280 ? Materials.Steel : Materials.Wood; + if (werkstoff.getStats() + .isRadioactive()) { + werkstoffBridgeMaterial.setEnchantmentForArmors( + EnchantmentRadioactivity.INSTANCE, + werkstoff.getStats() + .getEnchantmentlvl()); + werkstoffBridgeMaterial.setEnchantmentForTools( + EnchantmentRadioactivity.INSTANCE, + werkstoff.getStats() + .getEnchantmentlvl()); + } + werkstoff.setBridgeMaterial(werkstoffBridgeMaterial); + } + } + } +} diff --git a/src/main/java/bartworks/system/material/werkstoff_loaders/registration/CasingRegistrator.java b/src/main/java/bartworks/system/material/werkstoff_loaders/registration/CasingRegistrator.java new file mode 100644 index 0000000000..87d89f29af --- /dev/null +++ b/src/main/java/bartworks/system/material/werkstoff_loaders/registration/CasingRegistrator.java @@ -0,0 +1,39 @@ +/* + * 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.system.material.werkstoff_loaders.registration; + +import net.minecraft.item.ItemStack; + +import bartworks.system.material.Werkstoff; +import bartworks.system.material.WerkstoffLoader; +import bartworks.system.material.werkstoff_loaders.IWerkstoffRunnable; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GTOreDictUnificator; + +public class CasingRegistrator implements IWerkstoffRunnable { + + @Override + public void run(Werkstoff werkstoff) { + GTOreDictUnificator.addAssociation( + OrePrefixes.blockCasing, + werkstoff.getBridgeMaterial(), + new ItemStack(WerkstoffLoader.BWBlockCasings, 1, werkstoff.getmID()), + false); + GTOreDictUnificator.addAssociation( + OrePrefixes.blockCasingAdvanced, + werkstoff.getBridgeMaterial(), + new ItemStack(WerkstoffLoader.BWBlockCasingsAdvanced, 1, werkstoff.getmID()), + false); + } +} diff --git a/src/main/java/bartworks/system/oredict/OreDictAdder.java b/src/main/java/bartworks/system/oredict/OreDictAdder.java new file mode 100644 index 0000000000..7c07dbb274 --- /dev/null +++ b/src/main/java/bartworks/system/oredict/OreDictAdder.java @@ -0,0 +1,42 @@ +/* + * 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.system.oredict; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import net.minecraft.item.ItemStack; + +import bartworks.util.Pair; +import gregtech.api.util.GTOreDictUnificator; + +public class OreDictAdder { + + private static final ConcurrentHashMap<String, ItemStack> toAddMap = new ConcurrentHashMap<>(); + + public static synchronized void addToMap(Pair<String, ItemStack> element) { + OreDictAdder.toAddMap.put(element.getKey(), element.getValue()); + } + + @SafeVarargs + public static synchronized void addToMap(Pair<String, ItemStack>... elements) { + for (Pair<String, ItemStack> p : elements) OreDictAdder.toAddMap.put(p.getKey(), p.getValue()); + } + + public static void addToOreDict() { + for (Map.Entry<String, ItemStack> entry : OreDictAdder.toAddMap.entrySet()) { + GTOreDictUnificator.registerOre(entry.getKey(), entry.getValue()); + } + } +} diff --git a/src/main/java/bartworks/system/oredict/OreDictHandler.java b/src/main/java/bartworks/system/oredict/OreDictHandler.java new file mode 100644 index 0000000000..5faa23f0b2 --- /dev/null +++ b/src/main/java/bartworks/system/oredict/OreDictHandler.java @@ -0,0 +1,94 @@ +/* + * 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.system.oredict; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +import bartworks.MainMod; +import bartworks.util.Pair; +import bwcrossmod.BartWorksCrossmod; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GTOreDictUnificator; + +public class OreDictHandler { + + private static final HashMap<String, Pair<Integer, Short>> cache = new HashMap<>(); + private static final HashSet<Pair<Integer, Short>> cacheNonBW = new HashSet<>(); + + public static HashMap<String, Pair<Integer, Short>> getCache() { + return OreDictHandler.cache; + } + + public static HashSet<Pair<Integer, Short>> getNonBWCache() { + return OreDictHandler.cacheNonBW; + } + + public static void adaptCacheForWorld() { + Set<String> used = new HashSet<>(OreDictHandler.cache.keySet()); + OreDictHandler.cache.clear(); + OreDictHandler.cacheNonBW.clear(); + for (String s : used) { + if (!OreDictionary.getOres(s) + .isEmpty()) { + ItemStack tmpstack = OreDictionary.getOres(s) + .get(0) + .copy(); + Pair<Integer, Short> p = new Pair<>( + Item.getIdFromItem(tmpstack.getItem()), + (short) tmpstack.getItemDamage()); + OreDictHandler.cache.put(s, p); + for (ItemStack tmp : OreDictionary.getOres(s)) { + Pair<Integer, Short> p2 = new Pair<>( + Item.getIdFromItem(tmp.getItem()), + (short) tmp.getItemDamage()); + GameRegistry.UniqueIdentifier UI = GameRegistry.findUniqueIdentifierFor(tmp.getItem()); + if (UI == null) UI = GameRegistry.findUniqueIdentifierFor(Block.getBlockFromItem(tmp.getItem())); + if (!MainMod.MOD_ID.equals(UI.modId) && !BartWorksCrossmod.MOD_ID.equals(UI.modId) + && !"BWCore".equals(UI.modId)) { + OreDictHandler.cacheNonBW.add(p2); + } + } + } + } + } + + public static ItemStack getItemStack(String elementName, OrePrefixes prefixes, int amount) { + if (OreDictHandler.cache.get(prefixes + elementName.replace(" ", "")) != null) { + Pair<Integer, Short> p = OreDictHandler.cache.get(prefixes + elementName.replace(" ", "")); + return new ItemStack(Item.getItemById(p.getKey()), amount, p.getValue()); + } + if (!OreDictionary.getOres(prefixes + elementName.replace(" ", "")) + .isEmpty()) { + ItemStack tmp = GTOreDictUnificator.get( + OreDictionary.getOres(prefixes + elementName.replace(" ", "")) + .get(0) + .copy()) + .copy(); + OreDictHandler.cache.put( + prefixes + elementName.replace(" ", ""), + new Pair<>(Item.getIdFromItem(tmp.getItem()), (short) tmp.getItemDamage())); + tmp.stackSize = amount; + return tmp; + } + return null; + } +} diff --git a/src/main/java/bartworks/system/oregen/BWOreLayer.java b/src/main/java/bartworks/system/oregen/BWOreLayer.java new file mode 100644 index 0000000000..5f9688e68c --- /dev/null +++ b/src/main/java/bartworks/system/oregen/BWOreLayer.java @@ -0,0 +1,273 @@ +/* + * 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.system.oregen; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; + +import com.google.common.collect.ArrayListMultimap; + +import bartworks.MainMod; +import bartworks.system.material.BWMetaGeneratedOres; +import bartworks.system.material.BWMetaGeneratedSmallOres; +import bartworks.system.material.BWTileEntityMetaGeneratedOre; +import bartworks.system.material.Werkstoff; +import bartworks.system.material.WerkstoffLoader; +import bartworks.util.MurmurHash3; +import bartworks.util.Pair; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.ISubTagContainer; +import gregtech.api.world.GTWorldgen; +import gregtech.common.blocks.TileEntityOres; + +/** + * Original GT File Stripped and adjusted to work with this mod + */ +public abstract class BWOreLayer extends GTWorldgen { + + public static final List<BWOreLayer> sList = new ArrayList<>(); + public static final ArrayListMultimap<Short, BWOreLayer> NEIMAP = ArrayListMultimap.create(); + private static final boolean logOregenRoss128 = false; + public static int sWeight; + public byte bwOres; + public int mMinY, mWeight, mDensity, mSize, mMaxY, mPrimaryMeta, mSecondaryMeta, mBetweenMeta, mSporadicMeta; + + public abstract Block getDefaultBlockToReplace(); + + public abstract int[] getDefaultDamageToReplace(); + + public abstract String getDimName(); + + public BWOreLayer(String aName, boolean aDefault, int aMinY, int aMaxY, int aWeight, int aDensity, int aSize, + ISubTagContainer top, ISubTagContainer bottom, ISubTagContainer between, ISubTagContainer sprinkled) { + super(aName, BWOreLayer.sList, aDefault); + this.mMinY = (short) aMinY; + this.mMaxY = (short) aMaxY; + this.mWeight = (short) aWeight; + this.mDensity = (short) aDensity; + this.mSize = (short) Math.max(1, aSize); + + if (this.mEnabled) BWOreLayer.sWeight += this.mWeight; + + if (top instanceof Werkstoff) this.bwOres = (byte) (this.bwOres | 0b1000); + if (bottom instanceof Werkstoff) this.bwOres = (byte) (this.bwOres | 0b0100); + if (between instanceof Werkstoff) this.bwOres = (byte) (this.bwOres | 0b0010); + if (sprinkled instanceof Werkstoff) this.bwOres = (byte) (this.bwOres | 0b0001); + + short aPrimary = top instanceof Materials ? (short) ((Materials) top).mMetaItemSubID + : top instanceof Werkstoff ? ((Werkstoff) top).getmID() : 0; + short aSecondary = bottom instanceof Materials ? (short) ((Materials) bottom).mMetaItemSubID + : bottom instanceof Werkstoff ? ((Werkstoff) bottom).getmID() : 0; + short aBetween = between instanceof Materials ? (short) ((Materials) between).mMetaItemSubID + : between instanceof Werkstoff ? ((Werkstoff) between).getmID() : 0; + short aSporadic = sprinkled instanceof Materials ? (short) ((Materials) sprinkled).mMetaItemSubID + : sprinkled instanceof Werkstoff ? ((Werkstoff) sprinkled).getmID() : 0; + this.mPrimaryMeta = aPrimary; + this.mSecondaryMeta = aSecondary; + this.mBetweenMeta = aBetween; + this.mSporadicMeta = aSporadic; + NEIMAP.put((short) this.mPrimaryMeta, this); + NEIMAP.put((short) this.mSecondaryMeta, this); + NEIMAP.put((short) this.mBetweenMeta, this); + NEIMAP.put((short) this.mSporadicMeta, this); + } + + public List<ItemStack> getStacks() { + ArrayList<ItemStack> ret = new ArrayList<>(); + ret.add( + (this.bwOres & 0b1000) != 0 ? new ItemStack(WerkstoffLoader.BWOres, 1, this.mPrimaryMeta) + : new ItemStack(GregTechAPI.sBlockOres1, 1, this.mPrimaryMeta)); + ret.add( + (this.bwOres & 0b0100) != 0 ? new ItemStack(WerkstoffLoader.BWOres, 1, this.mSecondaryMeta) + : new ItemStack(GregTechAPI.sBlockOres1, 1, this.mSecondaryMeta)); + ret.add( + (this.bwOres & 0b0010) != 0 ? new ItemStack(WerkstoffLoader.BWOres, 1, this.mBetweenMeta) + : new ItemStack(GregTechAPI.sBlockOres1, 1, this.mBetweenMeta)); + ret.add( + (this.bwOres & 0b0001) != 0 ? new ItemStack(WerkstoffLoader.BWOres, 1, this.mSporadicMeta) + : new ItemStack(GregTechAPI.sBlockOres1, 1, this.mSporadicMeta)); + return ret; + } + + public List<Pair<Integer, Boolean>> getStacksRawData() { + ArrayList<Pair<Integer, Boolean>> ret = new ArrayList<>(); + ret.add(new Pair<>(this.mPrimaryMeta, (this.bwOres & 0b1000) != 0)); + ret.add(new Pair<>(this.mSecondaryMeta, (this.bwOres & 0b0100) != 0)); + ret.add(new Pair<>(this.mBetweenMeta, (this.bwOres & 0b0010) != 0)); + ret.add(new Pair<>(this.mSporadicMeta, (this.bwOres & 0b0001) != 0)); + return ret; + } + + @Override + public boolean executeWorldgen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, + int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { + { + int tMinY = this.mMinY + aRandom.nextInt(this.mMaxY - this.mMinY - 5); + int cX = aChunkX - aRandom.nextInt(this.mSize); + int eX = aChunkX + 16 + aRandom.nextInt(this.mSize); + + boolean wasPlaced = false; + + for (int tX = cX; tX <= eX; ++tX) { + int cZ = aChunkZ - aRandom.nextInt(this.mSize); + int eZ = aChunkZ + 16 + aRandom.nextInt(this.mSize); + + for (int tZ = cZ; tZ <= eZ; ++tZ) { + int i; + if (this.mSecondaryMeta > 0) { + for (i = tMinY - 1; i < tMinY + 2; ++i) { + if (this.shouldPlace(aRandom, cX, eX, tX, cZ, eZ, tZ)) { + wasPlaced = this.setOreBlock(aWorld, tX, i, tZ, this.mSecondaryMeta, false); + } + } + } + + if (this.mBetweenMeta > 0 && this.shouldPlace(aRandom, cX, eX, tX, cZ, eZ, tZ)) { + wasPlaced = this + .setOreBlock(aWorld, tX, tMinY + 2 + aRandom.nextInt(2), tZ, this.mBetweenMeta, false); + } + + if (this.mPrimaryMeta > 0) { + for (i = tMinY + 3; i < tMinY + 6; ++i) { + if (this.shouldPlace(aRandom, cX, eX, tX, cZ, eZ, tZ)) { + wasPlaced = this.setOreBlock(aWorld, tX, i, tZ, this.mPrimaryMeta, false); + } + } + } + + if (this.mSporadicMeta > 0 && this.shouldPlace(aRandom, cX, eX, tX, cZ, eZ, tZ)) { + wasPlaced = this + .setOreBlock(aWorld, tX, tMinY - 1 + aRandom.nextInt(7), tZ, this.mSporadicMeta, false); + } + } + } + + if (BWOreLayer.logOregenRoss128) { + MainMod.LOGGER.info("Generated Orevein: " + this.mWorldGenName + " " + aChunkX + " " + aChunkZ); + } + + return wasPlaced; + } + } + + private boolean shouldPlace(Random aRandom, int cX, int eX, int tX, int cZ, int eZ, int tZ) { + if (aRandom.nextInt( + Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0 + || aRandom.nextInt( + Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0) + return true; + return false; + } + + public boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData, boolean isSmallOre) { + // security stuff to prevent crashes with 2 TileEntites on the same Spot + TileEntity te = aWorld.getTileEntity(aX, aY, aZ); + if (te instanceof BWTileEntityMetaGeneratedOre || te instanceof TileEntityOres) return true; + + if (aMetaData == this.mSporadicMeta && (this.bwOres & 0b0001) != 0 + || aMetaData == this.mBetweenMeta && (this.bwOres & 0b0010) != 0 + || aMetaData == this.mPrimaryMeta && (this.bwOres & 0b1000) != 0 + || aMetaData == this.mSecondaryMeta && (this.bwOres & 0b0100) != 0) { + return isSmallOre + ? BWMetaGeneratedSmallOres.setOreBlock( + aWorld, + aX, + aY, + aZ, + aMetaData, + false, + this.getDefaultBlockToReplace(), + this.getDefaultDamageToReplace()) + : BWMetaGeneratedOres.setOreBlock( + aWorld, + aX, + aY, + aZ, + aMetaData, + false, + this.getDefaultBlockToReplace(), + this.getDefaultDamageToReplace()); + } + + return this.setGTOreBlockSpace(aWorld, aX, aY, aZ, aMetaData, this.getDefaultBlockToReplace()); + } + + public boolean setGTOreBlockSpace(World aWorld, int aX, int aY, int aZ, int aMetaData, Block block) { + if (TileEntityOres.setOreBlock(aWorld, aX, aY, aZ, aMetaData, false, false)) return true; + aY = Math.min(aWorld.getActualHeight(), Math.max(aY, 1)); + Block tBlock = aWorld.getBlock(aX, aY, aZ); + Block tOreBlock = GregTechAPI.sBlockOres1; + if (aMetaData < 0 || tBlock == Blocks.air) { + return false; + } else { + if (!tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, block)) { + return false; + } + aMetaData += 5000; + aWorld.setBlock(aX, aY, aZ, tOreBlock, aMetaData, 0); + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof TileEntityOres ore) { + ore.mMetaData = (short) aMetaData; + } + return true; + } + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof BWOreLayer that)) return false; + + if (this.bwOres != that.bwOres || this.mMinY != that.mMinY + || this.mWeight != that.mWeight + || this.mDensity != that.mDensity) return false; + if (this.mSize != that.mSize) return false; + if (this.mMaxY != that.mMaxY) return false; + if (this.mPrimaryMeta != that.mPrimaryMeta) return false; + if (this.mSecondaryMeta != that.mSecondaryMeta) return false; + if (this.mBetweenMeta != that.mBetweenMeta) return false; + return this.mSporadicMeta == that.mSporadicMeta; + } + + @Override + public int hashCode() { + return MurmurHash3.murmurhash3_x86_32( + ByteBuffer.allocate(37) + .put(this.bwOres) + .putInt(this.mMinY) + .putInt(this.mWeight) + .putInt(this.mDensity) + .putInt(this.mSize) + .putInt(this.mMaxY) + .putInt(this.mPrimaryMeta) + .putInt(this.mSecondaryMeta) + .putInt(this.mBetweenMeta) + .putInt(this.mSporadicMeta) + .array(), + 0, + 37, + 31); + } +} diff --git a/src/main/java/bartworks/system/oregen/BWWordGenerator.java b/src/main/java/bartworks/system/oregen/BWWordGenerator.java new file mode 100644 index 0000000000..10a3c862af --- /dev/null +++ b/src/main/java/bartworks/system/oregen/BWWordGenerator.java @@ -0,0 +1,140 @@ +/* + * 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.system.oregen; + +import java.util.HashSet; +import java.util.Random; + +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.World; +import net.minecraft.world.WorldProvider; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunkProvider; + +import cpw.mods.fml.common.IWorldGenerator; +import gregtech.api.objects.XSTR; +import gregtech.api.util.GTLog; + +/** + * Original GT File Stripped and adjusted to work with this mod + */ +public class BWWordGenerator implements IWorldGenerator { + + public BWWordGenerator() { + // GT_NH Override... wont be actually registered to force its generation directly in the ChunkProvider + // GameRegistry.registerWorldGenerator(this, 1073741823); + } + + public synchronized void generate(Random aRandom, int aX, int aZ, World aWorld, IChunkProvider aChunkGenerator, + IChunkProvider aChunkProvider) { + new BWWordGenerator.WorldGenContainer( + aX * 16, + aZ * 16, + aWorld.provider, + aWorld, + aChunkGenerator, + aChunkProvider).run(); + } + + public static class WorldGenContainer implements Runnable { + + public static HashSet<ChunkCoordIntPair> mGenerated = new HashSet<>(2000); + public final WorldProvider mWorldProvider; + public final World mWorld; + public final IChunkProvider mChunkGenerator; + public final IChunkProvider mChunkProvider; + public int mX; + public int mZ; + + public WorldGenContainer(int aX, int aZ, WorldProvider aWorldProvider, World aWorld, + IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { + this.mX = aX; + this.mZ = aZ; + this.mWorldProvider = aWorldProvider; + this.mWorld = aWorld; + this.mChunkGenerator = aChunkGenerator; + this.mChunkProvider = aChunkProvider; + } + + // returns a coordinate of a center chunk of 3x3 square; the argument belongs to this square + public int getVeinCenterCoordinate(int c) { + c += c < 0 ? 1 : 3; + return c - c % 3 - 2; + } + + public boolean surroundingChunksLoaded(int xCenter, int zCenter) { + return this.mWorld.checkChunksExist(xCenter - 16, 0, zCenter - 16, xCenter + 16, 0, zCenter + 16); + } + + public XSTR getRandom(int xChunk, int zChunk) { + long worldSeed = this.mWorld.getSeed(); + XSTR fmlRandom = new XSTR(worldSeed); + long xSeed = fmlRandom.nextLong() >> 2 + 1L; + long zSeed = fmlRandom.nextLong() >> 2 + 1L; + long chunkSeed = xSeed * xChunk + zSeed * zChunk ^ worldSeed; + fmlRandom.setSeed(chunkSeed); + return new XSTR(fmlRandom.nextInt()); + } + + public void run() { + int xCenter = this.getVeinCenterCoordinate(this.mX >> 4); + int zCenter = this.getVeinCenterCoordinate(this.mZ >> 4); + Random random = this.getRandom(xCenter, zCenter); + xCenter <<= 4; + zCenter <<= 4; + ChunkCoordIntPair centerChunk = new ChunkCoordIntPair(xCenter, zCenter); + if (!BWWordGenerator.WorldGenContainer.mGenerated.contains(centerChunk) + && this.surroundingChunksLoaded(xCenter, zCenter)) { + BWWordGenerator.WorldGenContainer.mGenerated.add(centerChunk); + if (BWOreLayer.sWeight > 0 && BWOreLayer.sList.size() > 0) { + boolean temp = true; + int tRandomWeight; + for (int i = 0; i < 256 && temp; i++) { + tRandomWeight = random.nextInt(BWOreLayer.sWeight); + for (BWOreLayer tWorldGen : BWOreLayer.sList) { + if (!tWorldGen.isGenerationAllowed(this.mWorld, mWorldProvider.getClass())) continue; + tRandomWeight -= tWorldGen.mWeight; + if (tRandomWeight <= 0) { + try { + boolean placed; + int attempts = 0; + do { + placed = tWorldGen.executeWorldgen( + this.mWorld, + random, + "", + this.mWorldProvider.dimensionId, + xCenter, + zCenter, + this.mChunkGenerator, + this.mChunkProvider); + ++attempts; + } while (!placed && attempts < 25); + temp = false; + break; + } catch (Throwable e) { + e.printStackTrace(GTLog.err); + } + } + } + } + } + } + Chunk tChunk = this.mWorld.getChunkFromBlockCoords(this.mX, this.mZ); + if (tChunk != null) { + tChunk.isModified = true; + } + } + } +} diff --git a/src/main/java/bartworks/system/oregen/BWWorldGenRoss128b.java b/src/main/java/bartworks/system/oregen/BWWorldGenRoss128b.java new file mode 100644 index 0000000000..0af1a4a993 --- /dev/null +++ b/src/main/java/bartworks/system/oregen/BWWorldGenRoss128b.java @@ -0,0 +1,174 @@ +/* + * 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.system.oregen; + +import static gregtech.api.enums.Materials.Bismuth; +import static gregtech.api.enums.Materials.Coal; +import static gregtech.api.enums.Materials.Diamond; +import static gregtech.api.enums.Materials.Graphite; +import static gregtech.api.enums.Materials.Lepidolite; +import static gregtech.api.enums.Materials.Scheelite; +import static gregtech.api.enums.Materials.Spodumene; +import static gregtech.api.enums.Materials.Stibnite; +import static gregtech.api.enums.Materials.Tetrahedrite; +import static gregtech.api.enums.Materials.Uraninite; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.util.StatCollector; + +import bartworks.common.configs.ConfigHandler; +import bartworks.system.material.WerkstoffLoader; +import gregtech.api.interfaces.ISubTagContainer; + +public class BWWorldGenRoss128b extends BWOreLayer { + + @Override + public Block getDefaultBlockToReplace() { + return Blocks.stone; + } + + @Override + public int[] getDefaultDamageToReplace() { + return new int[] { 0 }; + } + + @Override + public String getDimName() { + return StatCollector.translateToLocal("planet.Ross128b"); + } + + public BWWorldGenRoss128b(String aName, boolean aDefault, int aMinY, int aMaxY, int aWeight, int aDensity, + int aSize, ISubTagContainer top, ISubTagContainer bottom, ISubTagContainer between, + ISubTagContainer sprinkled) { + super(aName, aDefault, aMinY, aMaxY, aWeight, aDensity, aSize, top, bottom, between, sprinkled); + } + + public static void initOres() { + new BWWorldGenRoss128b( + "ore.mix.ross128.Thorianit", + true, + 30, + 60, + 17, + 1, + 16, + WerkstoffLoader.Thorianit, + Uraninite, + Lepidolite, + Spodumene); + new BWWorldGenRoss128b("ore.mix.ross128.carbon", true, 5, 25, 5, 4, 12, Graphite, Diamond, Coal, Graphite); + new BWWorldGenRoss128b( + "ore.mix.ross128.bismuth", + true, + 5, + 80, + 30, + 1, + 16, + WerkstoffLoader.Bismuthinit, + Stibnite, + Bismuth, + WerkstoffLoader.Bismutite); + new BWWorldGenRoss128b( + "ore.mix.ross128.TurmalinAlkali", + true, + 5, + 80, + 15, + 4, + 48, + WerkstoffLoader.Olenit, + WerkstoffLoader.FluorBuergerit, + WerkstoffLoader.ChromoAluminoPovondrait, + WerkstoffLoader.VanadioOxyDravit); + new BWWorldGenRoss128b( + "ore.mix.ross128.Roquesit", + true, + 30, + 50, + 3, + 1, + 12, + WerkstoffLoader.Arsenopyrite, + WerkstoffLoader.Ferberite, + WerkstoffLoader.Loellingit, + WerkstoffLoader.Roquesit); + new BWWorldGenRoss128b( + "ore.mix.ross128.Tungstate", + true, + 5, + 40, + 10, + 4, + 14, + WerkstoffLoader.Ferberite, + WerkstoffLoader.Huebnerit, + WerkstoffLoader.Loellingit, + Scheelite); + new BWWorldGenRoss128b( + "ore.mix.ross128.CopperSulfits", + true, + 40, + 70, + 80, + 3, + 24, + WerkstoffLoader.Djurleit, + WerkstoffLoader.Bornite, + WerkstoffLoader.Wittichenit, + Tetrahedrite); + new BWWorldGenRoss128b( + "ore.mix.ross128.Forsterit", + true, + 20, + 90, + 50, + 2, + 32, + WerkstoffLoader.Forsterit, + WerkstoffLoader.Fayalit, + WerkstoffLoader.DescloiziteCUVO4, + WerkstoffLoader.DescloiziteZNVO4); + new BWWorldGenRoss128b( + "ore.mix.ross128.Hedenbergit", + true, + 20, + 90, + 50, + 2, + 32, + WerkstoffLoader.Hedenbergit, + WerkstoffLoader.Fayalit, + WerkstoffLoader.DescloiziteCUVO4, + WerkstoffLoader.DescloiziteZNVO4); + new BWWorldGenRoss128b( + "ore.mix.ross128.RedZircon", + true, + 10, + 80, + 40, + 3, + 24, + WerkstoffLoader.Fayalit, + WerkstoffLoader.FuchsitAL, + WerkstoffLoader.RedZircon, + WerkstoffLoader.FuchsitCR); + } + + @Override + public boolean isGenerationAllowed(String aDimName, int aDimensionType, int aAllowedDimensionType) { + return aDimensionType == ConfigHandler.ross128BID; + } +} diff --git a/src/main/java/bartworks/system/oregen/BWWorldGenRoss128ba.java b/src/main/java/bartworks/system/oregen/BWWorldGenRoss128ba.java new file mode 100644 index 0000000000..3a032af822 --- /dev/null +++ b/src/main/java/bartworks/system/oregen/BWWorldGenRoss128ba.java @@ -0,0 +1,162 @@ +/* + * 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.system.oregen; + +import static gregtech.api.enums.Materials.Amethyst; +import static gregtech.api.enums.Materials.Barite; +import static gregtech.api.enums.Materials.Galena; +import static gregtech.api.enums.Materials.NaquadahEnriched; +import static gregtech.api.enums.Materials.Olivine; +import static gregtech.api.enums.Materials.Scheelite; +import static gregtech.api.enums.Materials.Sphalerite; +import static gregtech.api.enums.Materials.Tetrahedrite; + +import net.minecraft.block.Block; +import net.minecraft.util.StatCollector; + +import bartworks.common.configs.ConfigHandler; +import bartworks.system.material.WerkstoffLoader; +import gregtech.api.interfaces.ISubTagContainer; + +public class BWWorldGenRoss128ba extends BWOreLayer { + + public BWWorldGenRoss128ba(String aName, boolean aDefault, int aMinY, int aMaxY, int aWeight, int aDensity, + int aSize, ISubTagContainer top, ISubTagContainer bottom, ISubTagContainer between, + ISubTagContainer sprinkled) { + super(aName, aDefault, aMinY, aMaxY, aWeight, aDensity, aSize, top, bottom, between, sprinkled); + } + + @Override + public Block getDefaultBlockToReplace() { + return Block.getBlockFromName("GalacticraftCore:tile.moonBlock"); + } + + @Override + public int[] getDefaultDamageToReplace() { + int[] ret = new int[12]; + for (int i = 0; i < 12; i++) { + if (i != 5 && i != 3) ret[i] = i; + } + return ret; + } + + @Override + public String getDimName() { + return StatCollector.translateToLocal("moon.Ross128ba"); + } + + public static void init_Ores() { + new BWWorldGenRoss128ba( + "ore.mix.ross128ba.tib", + true, + 30, + 60, + 6, + 1, + 16, + WerkstoffLoader.Tiberium, + WerkstoffLoader.Tiberium, + NaquadahEnriched, + NaquadahEnriched); + new BWWorldGenRoss128ba( + "ore.mix.ross128ba.Tungstate", + true, + 5, + 40, + 60, + 4, + 14, + WerkstoffLoader.Ferberite, + WerkstoffLoader.Huebnerit, + WerkstoffLoader.Loellingit, + Scheelite); + new BWWorldGenRoss128ba( + "ore.mix.ross128ba.bart", + true, + 30, + 60, + 1, + 1, + 1, + WerkstoffLoader.BArTiMaEuSNeK, + WerkstoffLoader.BArTiMaEuSNeK, + WerkstoffLoader.BArTiMaEuSNeK, + WerkstoffLoader.BArTiMaEuSNeK); + new BWWorldGenRoss128ba( + "ore.mix.ross128ba.TurmalinAlkali", + true, + 5, + 80, + 60, + 4, + 48, + WerkstoffLoader.Olenit, + WerkstoffLoader.FluorBuergerit, + WerkstoffLoader.ChromoAluminoPovondrait, + WerkstoffLoader.VanadioOxyDravit); + new BWWorldGenRoss128ba( + "ore.mix.ross128ba.Amethyst", + true, + 5, + 80, + 35, + 2, + 8, + Amethyst, + Olivine, + WerkstoffLoader.Prasiolite, + WerkstoffLoader.Hedenbergit); + new BWWorldGenRoss128ba( + "ore.mix.ross128ba.CopperSulfits", + true, + 40, + 70, + 80, + 3, + 24, + WerkstoffLoader.Djurleit, + WerkstoffLoader.Bornite, + WerkstoffLoader.Wittichenit, + Tetrahedrite); + new BWWorldGenRoss128ba( + "ore.mix.ross128ba.RedZircon", + true, + 10, + 80, + 40, + 3, + 24, + WerkstoffLoader.Fayalit, + WerkstoffLoader.FuchsitAL, + WerkstoffLoader.RedZircon, + WerkstoffLoader.FuchsitCR); + new BWWorldGenRoss128ba( + "ore.mix.ross128ba.Fluorspar", + true, + 10, + 80, + 35, + 4, + 8, + Galena, + Sphalerite, + WerkstoffLoader.Fluorspar, + Barite); + } + + @Override + public boolean isGenerationAllowed(String aDimName, int aDimensionType, int aAllowedDimensionType) { + return aDimensionType == ConfigHandler.ross128BAID; + } +} diff --git a/src/main/java/bartworks/system/worldgen/BWWorldGenUtil.java b/src/main/java/bartworks/system/worldgen/BWWorldGenUtil.java new file mode 100644 index 0000000000..db32462ca4 --- /dev/null +++ b/src/main/java/bartworks/system/worldgen/BWWorldGenUtil.java @@ -0,0 +1,48 @@ +/* + * 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.system.worldgen; + +import java.util.Random; + +import net.minecraft.block.Block; + +import bartworks.common.configs.ConfigHandler; +import gregtech.api.GregTechAPI; + +public class BWWorldGenUtil { + + private BWWorldGenUtil() {} + + public static final Block GT_TILES = GregTechAPI.sBlockMachines; + + public static short getGenerator(Random rand, int tier) { + int meta = ConfigHandler.metasForTiers[0][tier][rand.nextInt(ConfigHandler.metasForTiers[0][tier].length)]; + return GregTechAPI.METATILEENTITIES[meta] != null ? (short) meta : BWWorldGenUtil.getGenerator(rand, tier); + } + + public static short getBuffer(Random rand, int tier) { + int meta = ConfigHandler.metasForTiers[1][tier][rand.nextInt(ConfigHandler.metasForTiers[1][tier].length)]; + return GregTechAPI.METATILEENTITIES[meta] != null ? (short) meta : BWWorldGenUtil.getBuffer(rand, tier); + } + + public static short getCable(Random rand, int tier) { + int meta = ConfigHandler.metasForTiers[2][tier][rand.nextInt(ConfigHandler.metasForTiers[2][tier].length)]; + return GregTechAPI.METATILEENTITIES[meta] != null ? (short) meta : BWWorldGenUtil.getCable(rand, tier); + } + + public static short getMachine(Random rand, int tier) { + int meta = ConfigHandler.metasForTiers[3][tier][rand.nextInt(ConfigHandler.metasForTiers[3][tier].length)]; + return GregTechAPI.METATILEENTITIES[meta] != null ? (short) meta : BWWorldGenUtil.getMachine(rand, tier); + } +} diff --git a/src/main/java/bartworks/system/worldgen/MapGenRuins.java b/src/main/java/bartworks/system/worldgen/MapGenRuins.java new file mode 100644 index 0000000000..a5668fb7ed --- /dev/null +++ b/src/main/java/bartworks/system/worldgen/MapGenRuins.java @@ -0,0 +1,501 @@ +/* + * 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.system.worldgen; + +import static bartworks.common.configs.ConfigHandler.maxTierRoss; +import static net.minecraftforge.common.ChestGenHooks.PYRAMID_JUNGLE_CHEST; + +import java.security.SecureRandom; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.inventory.IInventory; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenerator; +import net.minecraftforge.common.ChestGenHooks; +import net.minecraftforge.common.util.ForgeDirection; + +import bartworks.util.Pair; +import gregtech.api.GregTechAPI; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.BaseMetaPipeEntity; +import gregtech.api.metatileentity.BaseMetaTileEntity; +import gregtech.api.metatileentity.MetaPipeEntity; +import gregtech.api.objects.XSTR; +import gregtech.api.threads.RunnableMachineUpdate; + +public abstract class MapGenRuins extends WorldGenerator { + + @SuppressWarnings("unchecked") + protected Pair<Block, Integer>[][] ToBuildWith = new Pair[4][0]; + + @Override + public boolean generate(World p_76484_1_, Random p_76484_2_, int p_76484_3_, int p_76484_4_, int p_76484_5_) { + return false; + } + + @SuppressWarnings("unchecked") + protected void setFloorBlocks(int[] metas, Block... blocks) { + this.ToBuildWith[0] = new Pair[metas.length]; + for (int i = 0; i < metas.length; i++) { + this.ToBuildWith[0][i] = new Pair<>(blocks[i % blocks.length], metas[i]); + } + } + + @SuppressWarnings("unchecked") + protected void setWallBlocks(int[] metas, Block... blocks) { + this.ToBuildWith[1] = new Pair[metas.length]; + for (int i = 0; i < metas.length; i++) { + this.ToBuildWith[1][i] = new Pair<>(blocks[i % blocks.length], metas[i]); + } + } + + @SuppressWarnings("unchecked") + protected void setRoofBlocks(int[] metas, Block... blocks) { + this.ToBuildWith[2] = new Pair[metas.length]; + for (int i = 0; i < metas.length; i++) { + this.ToBuildWith[2][i] = new Pair<>(blocks[i % blocks.length], metas[i]); + } + } + + @SuppressWarnings("unchecked") + protected void setMiscBlocks(int[] metas, Block... blocks) { + this.ToBuildWith[3] = new Pair[metas.length]; + for (int i = 0; i < metas.length; i++) { + this.ToBuildWith[3][i] = new Pair<>(blocks[i % blocks.length], metas[i]); + } + } + + int[] statBlocks = new int[4]; + + protected void setRandomBlockWAirChance(World worldObj, int x, int y, int z, Random rand, int airchance, + Pair<Block, Integer>... blocks) { + if (rand.nextInt(100) > airchance) this.setRandomBlock(worldObj, x, y, z, rand, blocks); + else this.setBlock(worldObj, x, y, z, Blocks.air, 0); + } + + protected void setRandomBlock(World worldObj, int x, int y, int z, Random rand, Pair<Block, Integer>... blocks) { + Block toSet = blocks[rand.nextInt(blocks.length)].getKey(); + int meta = blocks[rand.nextInt(blocks.length)].getValue(); + this.setBlock(worldObj, x, y, z, toSet, meta); + } + + protected void setBlock(World worldObj, int x, int y, int z, Block block, int meta) { + this.setBlockAndNotifyAdequately(worldObj, x, y, z, block, meta); + } + + protected void setBlock(World worldObj, int x, int y, int z, Pair<Block, Integer> pair) { + this.setBlockAndNotifyAdequately(worldObj, x, y, z, pair.getKey(), pair.getValue()); + } + + private TileEntity setGTMachineBlock(World worldObj, int x, int y, int z, int meta) { + boolean isEnabled = true; + try { + isEnabled = RunnableMachineUpdate.isEnabled(); + } catch (Throwable ignored) { + isEnabled = false; + } + if (isEnabled) + throw new IllegalStateException("Machine Block Runnable needs to be disabled while creating world!"); + this.setBlockAndNotifyAdequately( + worldObj, + x, + y, + z, + BWWorldGenUtil.GT_TILES, + GregTechAPI.METATILEENTITIES[meta].getTileEntityBaseType()); + TileEntity tile = worldObj.getTileEntity(x, y, z); + ((IGregTechTileEntity) tile).setInitialValuesAsNBT(null, (short) meta); + return tile; + } + + protected TileEntity reSetGTTileEntity(IGregTechTileEntity bte, World worldObj, int x, int y, int z, int meta) { + worldObj.removeTileEntity(x, y, z); + this.setBlock(worldObj, x, y, z, Blocks.air, 0); + return this.setGTMachineBlock(worldObj, x, y, z, meta); + } + + protected void setGTMachineBlockWChance(World worldObj, int x, int y, int z, Random rand, int airchance, int meta) { + if (rand.nextInt(100) > airchance) { + this.setGTMachineBlock(worldObj, x, y, z, meta); + } else this.setBlock(worldObj, x, y, z, Blocks.air, 0); + } + + protected void setGTCablekWChance(World worldObj, int x, int y, int z, Random rand, int airchance, int meta) { + if (rand.nextInt(100) > airchance) { + this.setGTCable(worldObj, x, y, z, meta); + } else this.setBlock(worldObj, x, y, z, Blocks.air, 0); + } + + protected void setGTMachine(World worldObj, int x, int y, int z, int meta, String ownerName, + ForgeDirection facing) { + try { + RunnableMachineUpdate.setDisabled(); + } catch (Throwable ignored) {} + this.setGTMachineBlock(worldObj, x, y, z, meta); + BaseMetaTileEntity BTE = (BaseMetaTileEntity) worldObj.getTileEntity(x, y, z); + BTE.setOwnerName(ownerName); + BTE.setFrontFacing(facing); + BTE = (BaseMetaTileEntity) worldObj.getTileEntity(x, y, z); + this.checkTile(BTE, worldObj, x, y, z, meta, ownerName, facing, 0); + try { + RunnableMachineUpdate.setEnabled(); + } catch (Throwable ignored) {} + } + + private void checkTile(BaseMetaTileEntity BTE, World worldObj, int x, int y, int z, int meta, String ownerName, + ForgeDirection facing, int depth) { + if (depth < 25) { + if (BTE.getMetaTileID() != meta || worldObj.getTileEntity(x, y, z) != BTE || BTE.isInvalid()) { + this.redoTile(BTE, worldObj, x, y, z, meta, ownerName, facing); + this.checkTile(BTE, worldObj, x, y, z, meta, ownerName, facing, depth); + depth++; + } + } else { + worldObj.removeTileEntity(x, y, z); + worldObj.setBlockToAir(x, y, z); + } + } + + private void redoTile(BaseMetaTileEntity BTE, World worldObj, int x, int y, int z, int meta, String ownerName, + ForgeDirection facing) { + this.reSetGTTileEntity(BTE, worldObj, x, y, z, meta); + BTE = (BaseMetaTileEntity) worldObj.getTileEntity(x, y, z); + BTE.setOwnerName(ownerName); + BTE.setFrontFacing(facing); + } + + protected void setGTCable(World worldObj, int x, int y, int z, int meta) { + try { + RunnableMachineUpdate.setDisabled(); + } catch (Throwable ignored) {} + BaseMetaPipeEntity BTE = (BaseMetaPipeEntity) this.setGTMachineBlock(worldObj, x, y, z, meta); + MetaPipeEntity MPE = (MetaPipeEntity) BTE.getMetaTileEntity(); + BTE.mConnections |= (byte) (1 << (byte) 4); + BTE.mConnections |= (byte) (1 << ForgeDirection.getOrientation(4) + .getOpposite() + .ordinal()); + BaseMetaTileEntity BPE = (BaseMetaTileEntity) worldObj.getTileEntity(x, y, z - 1); + if (BPE != null) { + BTE.mConnections |= (byte) (1 << (byte) 2); + } + MPE.mConnections = BTE.mConnections; + try { + RunnableMachineUpdate.setEnabled(); + } catch (Throwable ignored) {} + } + + public static class RuinsBase extends MapGenRuins { + + private static final String owner = "Ancient Cultures"; + + @Override + public boolean generate(World worldObj, Random rand1, int x, int y, int z) { + + for (int i = 0; i < rand1.nextInt(144); i++) { + rand1.nextLong(); + } + + Random rand = new XSTR(rand1.nextLong()); + SecureRandom secureRandom = new SecureRandom(); + + if (worldObj.getBlock(x, y, z) == Blocks.air) { + while (worldObj.getBlock(x, y, z) == Blocks.air) { + y--; + } + } + + this.setFloorBlocks(new int[] { 0, 0, 0 }, Blocks.brick_block, Blocks.double_stone_slab, Blocks.stonebrick); + this.setWallBlocks(new int[] { 0, 1, 2, 1, 1 }, Blocks.stonebrick); + this.setRoofBlocks(new int[] { 9 }, Blocks.log); + this.setMiscBlocks(new int[] { 1 }, Blocks.log); + this.statBlocks = new int[] { rand.nextInt(this.ToBuildWith[0].length) }; + int colored = rand.nextInt(15); + int tier = secureRandom.nextInt(maxTierRoss); + boolean useColor = rand.nextBoolean(); + byte set = 0; + byte toSet = (byte) (rand.nextInt(maxTierRoss - tier) + 1); + short cablemeta = BWWorldGenUtil.getCable(secureRandom, tier); + byte treeinaRow = 0; + boolean lastset = rand.nextBoolean(); + for (int dx = -6; dx <= 6; dx++) { + for (int dy = 0; dy <= 8; dy++) { + for (int dz = -6; dz <= 6; dz++) { + this.setBlock(worldObj, x + dx, y + dy, z + dz, Blocks.air, 0); + if (dy == 0) { + Pair<Block, Integer> floor = this.ToBuildWith[0][this.statBlocks[0]]; + this.setBlock(worldObj, x + dx, y + 0, z + dz, floor.getKey(), floor.getValue()); + } else if (dy > 0 && dy < 4) { + if (Math.abs(dx) == 5 && Math.abs(dz) == 5) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + dy, + z + dz, + rand, + 5, + this.ToBuildWith[3][0]); + } else if (dx == 0 && dz == -5 && (dy == 1 || dy == 2)) { + if (dy == 1) { + this.setBlock(worldObj, x + dx, y + 1, z + -5, Blocks.iron_door, 1); + } + if (dy == 2) { + this.setBlock(worldObj, x + dx, y + 2, z + dz, Blocks.iron_door, 8); + } + } else if (Math.abs(dx) == 5 && Math.abs(dz) < 5 || Math.abs(dz) == 5 && Math.abs(dx) < 5) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + dy, + z + dz, + rand, + 25, + this.ToBuildWith[1]); + if (dy == 2 && rand.nextInt(100) < 12) { + if (useColor) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + 2, + z + dz, + rand, + 25, + new Pair<>(Blocks.stained_glass_pane, colored)); + } + } else { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + dy, + z + dz, + rand, + 25, + new Pair<>(Blocks.glass_pane, 0)); + } + } + + if (dy == 3 && Math.abs(dx) == 6) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + 3, + z + dz, + rand, + 25, + this.ToBuildWith[2]); + } + + if (dy == 1) { + if (dx == 3 && dz == -3) { + this.setBlock(worldObj, x + 3, y + 1, z + dz, Blocks.crafting_table, 0); + } + if (dx == -3 && (dz == -3 || dz == -2)) { + this.setBlock(worldObj, x + -3, y + dy, z + dz, Blocks.chest, 5); + IInventory chest = (IInventory) worldObj.getTileEntity(x + dx, y + dy, z + dz); + if (chest != null) { + WeightedRandomChestContent.generateChestContents( + secureRandom, + ChestGenHooks.getItems(PYRAMID_JUNGLE_CHEST, rand), + chest, + ChestGenHooks.getCount(PYRAMID_JUNGLE_CHEST, rand)); + } + } + + if (dx == 4 && dz == 4) { + short meta = BWWorldGenUtil.getGenerator(secureRandom, tier); + this.setGTMachine( + worldObj, + x + dx, + y + dy, + z + dz, + meta, + owner, + tier > 0 ? ForgeDirection.WEST : ForgeDirection.UP); + } else if (dx == 3 && dz == 4) { + if (tier > 0) { + short meta = BWWorldGenUtil.getBuffer(secureRandom, tier); + this.setGTMachine( + worldObj, + x + dx, + y + dy, + z + dz, + meta, + owner, + ForgeDirection.WEST); + } else { + this.setGTCablekWChance(worldObj, x + dx, y + dy, z + dz, rand, 33, cablemeta); + } + } else if (dx < 3 && dx > -5 && dz == 4) { + this.setGTCablekWChance(worldObj, x + dx, y + dy, z + dz, rand, 33, cablemeta); + } else if (dx < 3 && dx > -5 && dz == 3 && set < toSet) { + if (!lastset || treeinaRow > 2) { + short meta = BWWorldGenUtil.getMachine(secureRandom, tier); + this.setGTMachine( + worldObj, + x + dx, + y + dy, + z + dz, + meta, + owner, + ForgeDirection.UP); + + set++; + treeinaRow = 0; + lastset = true; + } else { + lastset = rand.nextBoolean(); + if (lastset) treeinaRow++; + } + } + } + } else switch (dy) { + case 4: + if (Math.abs(dx) == 5) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + 4, + z + dz, + rand, + 25, + this.ToBuildWith[2]); + break; + } + if (Math.abs(dz) == 5 && Math.abs(dx) < 5) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + dy, + z + dz, + rand, + 25, + this.ToBuildWith[1]); + } + break; + case 5: + if (Math.abs(dx) == 4) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + 5, + z + dz, + rand, + 25, + this.ToBuildWith[2]); + break; + } + if (Math.abs(dz) == 5 && Math.abs(dx) < 4) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + dy, + z + dz, + rand, + 25, + this.ToBuildWith[1]); + } + break; + case 6: + if (Math.abs(dx) == 3) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + 6, + z + dz, + rand, + 25, + this.ToBuildWith[2]); + break; + } + if (Math.abs(dz) == 5 && Math.abs(dx) < 3) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + dy, + z + dz, + rand, + 25, + this.ToBuildWith[1]); + } + break; + case 7: + if (Math.abs(dx) == 2) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + 7, + z + dz, + rand, + 25, + this.ToBuildWith[2]); + break; + } + if (Math.abs(dz) == 5 && Math.abs(dx) < 2) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + dy, + z + dz, + rand, + 25, + this.ToBuildWith[1]); + } + break; + case 8: + if (Math.abs(dx) == 1 || Math.abs(dx) == 0) { + this.setRandomBlockWAirChance( + worldObj, + x + dx, + y + 8, + z + dz, + rand, + 25, + this.ToBuildWith[2]); + } + break; + default: + break; + } + } + } + } + tosetloop: while (set < toSet) { + int dy = 1; + int dz = 3; + for (int dx = 2; dx > -5; dx--) { + if (set >= toSet) { + break tosetloop; + } + if (!lastset || treeinaRow > 2 && worldObj.getTileEntity(x + dx, y + dy, z + dz) == null) { + short meta = BWWorldGenUtil.getMachine(secureRandom, tier); + this.setGTMachine(worldObj, x + dx, y + dy, z + dz, meta, owner, ForgeDirection.UP); + + set++; + treeinaRow = 0; + lastset = true; + } else { + lastset = rand.nextBoolean(); + if (lastset) { + treeinaRow++; + } + } + } + } + return true; + } + } +} diff --git a/src/main/java/bartworks/util/BWColorUtil.java b/src/main/java/bartworks/util/BWColorUtil.java new file mode 100644 index 0000000000..b9453b9963 --- /dev/null +++ b/src/main/java/bartworks/util/BWColorUtil.java @@ -0,0 +1,216 @@ +/* + * Copyright (c) 2018-2019 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.util; + +import java.util.Arrays; + +import gregtech.api.enums.Dyes; + +@SuppressWarnings("unused") +public class BWColorUtil { + + private BWColorUtil() {} + + public static byte getDarknessFromColor(short[] rgba, int index) { + int g = rgba[index]; + if (g >= 0 && g < 64) return 0; + if (g >= 64 && g < 160) return 1; + else if (g >= 160 && g < 223) return 2; + else if (g >= 233 && g <= 255) return 3; + return 4; + } + + public static Dyes getDyeFromColor(short[] rgba) { + rgba = correctCorlorArray(rgba); + if (isGrayScale(rgba, 2)) { + switch (getDarknessFromColor(rgba, 0)) { + case 0: + return Dyes.dyeBlack; + case 1: + return Dyes.dyeGray; + case 2: + return Dyes.dyeLightGray; + case 3: + return Dyes.dyeWhite; + } + } else { + short[] tmp = roundColor(rgba, 2); + if (isRedScale(tmp)) { + if (isPurpleScale(tmp)) { + switch (getDarknessFromColor(rgba, 0)) { + case 0: + case 1: + if (rgba[3] - 50 > rgba[0]) return Dyes.dyePurple; + else return Dyes.dyeRed; + case 2: + case 3: + if (rgba[3] - 50 > rgba[0]) return Dyes.dyeMagenta; + else if (rgba[0] > 200 && rgba[2] > 140) return Dyes.dyePink; + else if (rgba[0] > rgba[1] + rgba[1] / 10 && rgba[0] > rgba[2] + rgba[2] / 10 + && rgba[1] >> 4 == rgba[2] >> 4 + && rgba[1] + 50 > rgba[0]) { + return Dyes.dyeBrown; + } else return Dyes.dyeRed; + case 4: + return Dyes._NULL; + } + } + if (isYellowScale(tmp)) switch (getDarknessFromColor(rgba, 0)) { + case 0: + case 1: + return Dyes.dyeBrown; + case 2: + case 3: { + if (rgba[0] >> 5 > rgba[1] >> 5) return Dyes.dyeOrange; + else return Dyes.dyeYellow; + } + case 4: + return Dyes._NULL; + } + return Dyes.dyePink; + } + if (isGrenScale(tmp)) { + if (isCyanScale(tmp)) { + if (rgba[2] + 40 < rgba[1]) switch (getDarknessFromColor(rgba, 0)) { + case 0: + case 1: + return Dyes.dyeGreen; + case 2: + case 3: + return Dyes.dyeLime; + } + return Dyes.dyeCyan; + } + if (isYellowScale(tmp)) switch (getDarknessFromColor(rgba, 0)) { + case 0: + case 1: + return Dyes.dyeBrown; + case 2: + case 3: { + if (rgba[0] >> 5 > rgba[1] >> 5) return Dyes.dyeOrange; + else return Dyes.dyeYellow; + } + } + switch (getDarknessFromColor(rgba, 0)) { + case 0: + case 1: + return Dyes.dyeGreen; + case 2: + case 3: + return Dyes.dyeLime; + } + } else if (isBlueScale(tmp)) { + if (isPurpleScale(tmp)) { + switch (getDarknessFromColor(rgba, 0)) { + case 0: + case 1: + return Dyes.dyePurple; + case 2: + case 3: + return Dyes.dyeMagenta; + } + } else if (isCyanScale(tmp)) { + return Dyes.dyeCyan; + } + switch (getDarknessFromColor(rgba, 0)) { + case 0: + case 1: + return Dyes.dyeBlue; + case 2: + case 3: + return Dyes.dyeLightBlue; + } + } + } + return Dyes._NULL; + } + + public static boolean isCyanScale(short[] rgba) { + return !isRedScale(rgba); + } + + public static boolean isPurpleScale(short[] rgba) { + return !isGrenScale(rgba); + } + + public static boolean isYellowScale(short[] rgba) { + return !isBlueScale(rgba); + } + + public static boolean isBlueScale(short[] rgba) { + rgba = correctCorlorArray(rgba); + return rgba[2] * 2 >= rgba[1] + rgba[0]; + } + + public static boolean isGrenScale(short[] rgba) { + rgba = correctCorlorArray(rgba); + return rgba[1] * 2 >= rgba[0] + rgba[2]; + } + + public static boolean isRedScale(short[] rgba) { + rgba = correctCorlorArray(rgba); + return rgba[0] * 2 >= rgba[1] + rgba[2]; + } + + public static boolean isGrayScale(short[] rgba, int magin) { + rgba = correctCorlorArray(rgba); + return rgba[0] >> magin == rgba[1] >> magin && rgba[1] >> magin == rgba[2] >> magin; + } + + public static short[] roundColor(short[] rgba, int magin) { + short[] tmp = Arrays.copyOf(rgba, 4); + tmp[0] = (short) (rgba[0] >> magin); + tmp[1] = (short) (rgba[1] >> magin); + tmp[2] = (short) (rgba[2] >> magin); + return tmp; + } + + public static boolean isGrayScale(short[] rgba) { + rgba = correctCorlorArray(rgba); + return rgba[0] == rgba[1] && rgba[1] == rgba[2]; + } + + public static short[] correctCorlorArray(short[] rgba) { + if (rgba.length > 4) { + rgba = Arrays.copyOfRange(rgba, 0, 4); + } + if (rgba.length < 4) { + short[] tmp = Arrays.copyOf(rgba, 4); + Arrays.fill(tmp, rgba.length, 4, (short) 0); + rgba = tmp; + } + if (rgba[0] > 255) rgba[0] = 255; + if (rgba[1] > 255) rgba[1] = 255; + if (rgba[2] > 255) rgba[2] = 255; + if (rgba[3] > 255) rgba[3] = 255; + if (rgba[0] < 0) rgba[0] = 0; + if (rgba[1] < 0) rgba[1] = 0; + if (rgba[2] < 0) rgba[2] = 0; + if (rgba[3] < 0) rgba[3] = 0; + return rgba; + } + + public static short[] splitColorToRBGArray(int rgb) { + return new short[] { (short) (rgb >> 16 & 0xFF), (short) (rgb >> 8 & 0xFF), (short) (rgb & 0xFF) }; + } + + public static int getColorFromRGBArray(short[] color) { + return (color[0] & 0x0ff) << 16 | (color[1] & 0x0ff) << 8 | color[2] & 0x0ff; + } + + public static int getColorFromRGBArray(int[] color) { + return (color[0] & 0x0ff) << 16 | (color[1] & 0x0ff) << 8 | color[2] & 0x0ff; + } + +} diff --git a/src/main/java/bartworks/util/BWRecipes.java b/src/main/java/bartworks/util/BWRecipes.java new file mode 100644 index 0000000000..1d6cd56c00 --- /dev/null +++ b/src/main/java/bartworks/util/BWRecipes.java @@ -0,0 +1,71 @@ +/* + * 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.util; + +import gregtech.api.enums.Materials; + +public class BWRecipes { + + public static long calcDecayTicks(int x) { + long ret; + if (x == 43) ret = 5000; + else if (x == 61) ret = 4500; + else if (x <= 100) ret = MathUtils.ceilLong((8000D * Math.tanh(-x / 20D) + 8000D) * 1000D); + else ret = MathUtils.ceilLong(8000D * Math.tanh(-x / 65D) + 8000D); + return ret; + } + + public static int computeSieverts(int givenSievert, int glassTier, boolean requiresExactSieverts, boolean cleanroom, + boolean lowGravity) { + byte specialValue = 0; + if (cleanroom && lowGravity) { + specialValue = 3; + } else if (cleanroom) { + specialValue = 2; + } else if (lowGravity) { + specialValue = 1; + } + int sievertValue = 0; + if (givenSievert >= 83 || givenSievert == 61 || givenSievert == 43) sievertValue += givenSievert; + sievertValue = sievertValue << 1; + sievertValue = sievertValue | (requiresExactSieverts ? 1 : 0); + sievertValue = sievertValue << 2; + sievertValue = sievertValue | specialValue; + sievertValue = sievertValue << 4; + sievertValue = sievertValue | glassTier; + return sievertValue; + } + + public static int computeSieverts(Materials material, int glassTier, boolean requiresExactSieverts, + boolean cleanroom, boolean lowGravity) { + byte specialValue = 0; + if (cleanroom && lowGravity) { + specialValue = 3; + } else if (cleanroom) { + specialValue = 2; + } else if (lowGravity) { + specialValue = 1; + } + int aSievert = 0; + if (material.getProtons() >= 83 || material.getProtons() == 61 || material.getProtons() == 43) + aSievert += BWUtil.calculateSv(material); + aSievert = aSievert << 1; + aSievert = aSievert | (requiresExactSieverts ? 1 : 0); + aSievert = aSievert << 2; + aSievert = aSievert | specialValue; + aSievert = aSievert << 4; + aSievert = aSievert | glassTier; + return aSievert; + } +} diff --git a/src/main/java/bartworks/util/BWTooltipReference.java b/src/main/java/bartworks/util/BWTooltipReference.java new file mode 100644 index 0000000000..1c9e32e5e6 --- /dev/null +++ b/src/main/java/bartworks/util/BWTooltipReference.java @@ -0,0 +1,45 @@ +/* + * 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.util; + +import static net.minecraft.util.EnumChatFormatting.BLUE; +import static net.minecraft.util.EnumChatFormatting.DARK_BLUE; +import static net.minecraft.util.EnumChatFormatting.GRAY; +import static net.minecraft.util.EnumChatFormatting.GREEN; + +import java.util.function.Function; +import java.util.function.Supplier; + +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; + +public class BWTooltipReference { + + public static final String BW_NO_RESET = EnumChatFormatting.DARK_GREEN + "BartWorks"; + public static final String TT_NO_RESET = BLUE + "Tec" + DARK_BLUE + "Tech"; + public static final String BW = BW_NO_RESET + GRAY; + public static final String TT = TT_NO_RESET + GRAY; + + public static final Supplier<String> ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS = () -> StatCollector.translateToLocal( + "tooltip.bw.1.name") + " " + BW; + + public static final String MULTIBLOCK_ADDED_BY_BARTWORKS = BW; + public static final Function<String, String> MULTIBLOCK_ADDED_VIA_BARTWORKS = owner -> String + .format(StatCollector.translateToLocal("tooltip.bw.mb_via.name"), owner); + public static final String MULTIBLOCK_ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS = MULTIBLOCK_ADDED_VIA_BARTWORKS + .apply(GREEN + "bartimaeusnek"); + + public static final String TT_BLUEPRINT = "To see the structure, use a " + TT + " Blueprint on the Controller!"; + +} diff --git a/src/main/java/bartworks/util/BWUtil.java b/src/main/java/bartworks/util/BWUtil.java new file mode 100644 index 0000000000..5f740af40f --- /dev/null +++ b/src/main/java/bartworks/util/BWUtil.java @@ -0,0 +1,784 @@ +/* + * 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.util; + +import static gregtech.api.enums.GTValues.D1; +import static gregtech.api.enums.GTValues.E; +import static gregtech.api.enums.GTValues.M; +import static gregtech.api.enums.GTValues.VN; +import static gregtech.api.enums.GTValues.W; + +import java.lang.reflect.Array; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.function.BiConsumer; +import java.util.function.Function; +import java.util.stream.Collectors; + +import net.minecraft.block.Block; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.init.Items; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.world.World; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; +import net.minecraftforge.oredict.ShapedOreRecipe; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import com.gtnewhorizon.structurelib.StructureLibAPI; +import com.gtnewhorizon.structurelib.structure.AutoPlaceEnvironment; +import com.gtnewhorizon.structurelib.structure.IStructureElement; + +import bartworks.API.BioVatLogicAdder; +import bartworks.API.BorosilicateGlass; +import bartworks.API.GlassTier; +import bartworks.MainMod; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OreDictNames; +import gregtech.api.enums.ToolDictNames; +import gregtech.api.interfaces.IItemContainer; +import gregtech.api.objects.ItemData; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTLog; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTShapedRecipe; +import gregtech.api.util.GTUtility; + +public class BWUtil { + + @Deprecated + public static final int STANDART = 0; + @Deprecated + public static final int LOWGRAVITY = -100; + @Deprecated + public static final int CLEANROOM = -200; + + public static String translateGTItemStack(ItemStack itemStack) { + if (!GTUtility.isStackValid(itemStack)) return "Not a Valid ItemStack:" + itemStack; + String ret = GTLanguageManager.getTranslation(GTLanguageManager.getTranslateableItemStackName(itemStack)); + if (!ret.contains("%material")) return ret; + String matname = ""; + if (BWUtil.checkStackAndPrefix(itemStack)) + matname = GTOreDictUnificator.getAssociation(itemStack).mMaterial.mMaterial.mDefaultLocalName; + return ret.replace("%material", matname); + } + + public static void set2DCoordTo1DArray(int indexX, int indexY, int sizeY, Object value, Object[] array) { + int index = indexX * sizeY + indexY; + array[index] = value; + } + + public static Object get2DCoordFrom1DArray(int indexX, int indexY, int sizeY, Object[] array) { + int index = indexX * sizeY + indexY; + return array[index]; + } + + public static GTRecipe copyAndSetTierToNewRecipe(GTRecipe recipe, byte tier) { + byte oldTier = GTUtility.getTier(recipe.mEUt); + int newTime = recipe.mDuration; + int newVoltage = recipe.mEUt; + if (tier < oldTier) { + newTime <<= oldTier - tier; + newVoltage >>= 2 * (oldTier - tier); + } else { + newTime >>= tier - oldTier; + newVoltage <<= 2 * (tier - oldTier); + } + recipe.mEUt = newVoltage; + recipe.mDuration = newTime; + return recipe; + } + + public static String subscriptNumbers(String b) { + char[] chars = b.toCharArray(); + char[] nu = new char[chars.length]; + for (int i = 0; i < chars.length; i++) { + nu[i] = switch (chars[i]) { + case '0' -> '\u2080'; + case '1' -> '\u2081'; + case '2' -> '\u2082'; + case '3' -> '\u2083'; + case '4' -> '\u2084'; + case '5' -> '\u2085'; + case '6' -> '\u2086'; + case '7' -> '\u2087'; + case '8' -> '\u2088'; + case '9' -> '\u2089'; + default -> chars[i]; + }; + } + return new String(nu); + } + + public static String subscriptNumber(Number b) { + char[] chars = Long.toString(b.longValue()) + .toCharArray(); + char[] nu = new char[chars.length]; + for (int i = 0; i < chars.length; i++) { + nu[i] = switch (chars[i]) { + case '0' -> '\u2080'; + case '1' -> '\u2081'; + case '2' -> '\u2082'; + case '3' -> '\u2083'; + case '4' -> '\u2084'; + case '5' -> '\u2085'; + case '6' -> '\u2086'; + case '7' -> '\u2087'; + case '8' -> '\u2088'; + case '9' -> '\u2089'; + default -> chars[i]; + }; + } + return new String(nu); + } + + public static String superscriptNumbers(String b) { + char[] chars = b.toCharArray(); + char[] nu = new char[chars.length]; + for (int i = 0; i < chars.length; i++) { + nu[i] = switch (chars[i]) { + case '0' -> '\u2070'; + case '1' -> '\u2071'; + case '2' -> '\u00B2'; + case '3' -> '\u00B3'; + case '4' -> '\u2074'; + case '5' -> '\u2075'; + case '6' -> '\u2076'; + case '7' -> '\u2077'; + case '8' -> '\u2078'; + case '9' -> '\u2079'; + default -> chars[i]; + }; + } + return new String(nu); + } + + public static String superscriptNumber(Number b) { + char[] chars = Long.toString(b.longValue()) + .toCharArray(); + char[] nu = new char[chars.length]; + for (int i = 0; i < chars.length; i++) { + nu[i] = switch (chars[i]) { + case '0' -> '\u2070'; + case '1' -> '\u2071'; + case '2' -> '\u00B2'; + case '3' -> '\u00B3'; + case '4' -> '\u2074'; + case '5' -> '\u2075'; + case '6' -> '\u2076'; + case '7' -> '\u2077'; + case '8' -> '\u2078'; + case '9' -> '\u2079'; + default -> chars[i]; + }; + } + return new String(nu); + } + + public static byte specialToByte(int aSpecialValue) { + byte special = 0; + switch (aSpecialValue) { + case LOWGRAVITY: + special = 1; + break; + case CLEANROOM: + special = 2; + break; + case LOWGRAVITY | CLEANROOM: + special = 3; + break; + default: + break; + } + return special; + } + + public static int calculateSv(Materials materials) { + for (BioVatLogicAdder.MaterialSvPair pair : BioVatLogicAdder.RadioHatch.getMaSv()) { + if (pair.getMaterials() + .equals(materials)) return pair.getSievert(); + } + return (int) (materials.getProtons() == 43L + ? materials.equals(Materials.NaquadahEnriched) ? 140 + : materials.equals(Materials.Naquadria) ? 150 : materials.equals(Materials.Naquadah) ? 130 : 43 + : materials.getProtons()); + } + + public static ItemStack setStackSize(ItemStack stack, int size) { + if (stack != null) stack.stackSize = size; + return stack; + } + + public static boolean checkStackAndPrefix(ItemStack itemStack) { + return itemStack != null && GTOreDictUnificator.getAssociation(itemStack) != null + && GTOreDictUnificator.getAssociation(itemStack).mPrefix != null + && GTOreDictUnificator.getAssociation(itemStack).mMaterial != null + && GTOreDictUnificator.getAssociation(itemStack).mMaterial.mMaterial != null; + } + + public static int abstractHashGTRecipe(GTRecipe recipe) { + int hash = 31; + hash += recipe.mDuration / 20 * 31; + hash += GTUtility.getTier(recipe.mEUt) * 31; + hash += BWUtil.specialToByte(recipe.mSpecialValue) * 31; + hash += recipe.mInputs.length * 31; + for (ItemStack mInput : recipe.mInputs) { + if (mInput != null) { + hash += mInput.stackSize * 31; + hash += Item.getIdFromItem(mInput.getItem()) * 31; + } + } + hash += recipe.mOutputs.length * 31; + for (ItemStack mOutput : recipe.mOutputs) { + if (mOutput != null) { + hash += mOutput.stackSize * 31; + hash += Item.getIdFromItem(mOutput.getItem()) * 31; + } + } + hash += recipe.mFluidInputs.length * 31; + for (FluidStack mInput : recipe.mFluidInputs) { + if (mInput != null) { + hash += mInput.amount * 31; + hash += mInput.getFluidID() * 31; + } + } + hash += recipe.mFluidOutputs.length * 31; + for (FluidStack mOutput : recipe.mFluidOutputs) { + if (mOutput != null) { + hash += mOutput.amount * 31; + hash += mOutput.getFluidID() * 31; + } + } + return hash; + } + + @SuppressWarnings({ "unchecked" }) + public static <T> T[] copyAndRemoveNulls(T[] input, Class<T> clazz) { + List<T> ret = Arrays.stream(input) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + + if (ret.size() <= 0) return (T[]) Array.newInstance(clazz, 0); + + T[] retArr = (T[]) Array.newInstance(clazz, ret.size()); + + for (int i = 0; i < ret.size(); i++) retArr[i] = ret.get(i); + + return retArr; + } + + @Deprecated + public static int getMachineVoltageFromTier(int tier) { + return (int) (30 * Math.pow(4, tier - 1)); + } + + public static long getTierVoltage(int tier) { + return getTierVoltage((byte) tier); + } + + public static long getTierVoltage(byte tier) { + return 8L << 2 * tier; + } + + public static byte getTier(long voltage) { + if (voltage <= Integer.MAX_VALUE - 7) return GTUtility.getTier(voltage); + byte t = 0; + while (voltage > 8L) { + voltage >>= 2; + t++; + } + return t; + } + + public static String getTierName(byte tier) { + if (VN.length - 1 <= tier) return "MAX+"; + return VN[tier]; + } + + public static String getTierNameFromVoltage(long voltage) { + return getTierName(getTier(voltage)); + } + + public static boolean areStacksEqualOrNull(ItemStack aStack1, ItemStack aStack2) { + return aStack1 == null && aStack2 == null || GTUtility.areStacksEqual(aStack1, aStack2); + } + + public static boolean areStacksEqualOrEachNull(ItemStack aStack1, ItemStack aStack2) { + return aStack1 == null || aStack2 == null || GTUtility.areStacksEqual(aStack1, aStack2); + } + + public static byte getByteFromRarity(EnumRarity rarity) { + if (EnumRarity.uncommon.equals(rarity)) return 1; + if (EnumRarity.epic.equals(rarity)) return 2; + else if (EnumRarity.rare.equals(rarity)) return 3; + return 0; + } + + /** + * @deprecated Use stuff in {@link BorosilicateGlass} instead + */ + @Deprecated + public static byte getTierFromGlasMeta(int meta) { + return switch (meta) { + case 1 -> 4; + case 2, 12 -> 5; + case 3 -> 6; + case 4 -> 7; + case 5 -> 8; + case 13 -> 9; + case 14 -> 10; + default -> 3; + }; + } + + public static EnumRarity getRarityFromByte(byte b) { + return switch (b) { + case 1 -> EnumRarity.uncommon; + case 2 -> EnumRarity.rare; + case 3 -> EnumRarity.epic; + default -> EnumRarity.common; + }; + } + + public static byte getCircuitTierFromOreDictName(String name) { + return switch (name) { + case "circuitPrimitive" -> 0; + case "circuitBasic" -> 1; + case "circuitGood" -> 2; + case "circuitAdvanced" -> 3; + case "circuitData" -> 4; + case "circuitElite" -> 5; + case "circuitMaster" -> 6; + case "circuitUltimate" -> 7; + case "circuitSuperconductor" -> 8; + case "circuitInfinite" -> 9; + case "circuitBio" -> 10; + case "circuitNano", "circuitOptical" -> 11; + case "circuitPiko", "circuitExotic" -> 12; + case "circuitQuantum", "circuitCosmic" -> 13; + case "circuitTranscendent" -> 14; + default -> -1; + }; + } + + public static byte getCircuitTierFromItemStack(ItemStack stack) { + for (String oreName : getOreNames(stack)) { + byte tier = getCircuitTierFromOreDictName(oreName); + if (tier != -1) { + return tier; + } + } + return -1; + } + + public static boolean isTieredCircuit(ItemStack stack) { + return getCircuitTierFromItemStack(stack) != -1; + } + + public static List<String> getOreNames(ItemStack stack) { + List<String> ret = new ArrayList<>(); + for (int oreID : OreDictionary.getOreIDs(stack)) { + ret.add(OreDictionary.getOreName(oreID)); + } + return ret; + } + + public static <T> IStructureElement<T> ofGlassTiered(byte mintier, byte maxtier, byte notset, + BiConsumer<T, Byte> setter, Function<T, Byte> getter, int aDots) { + return new IStructureElement<>() { + + private final IStructureElement<T> placementDelegate = BorosilicateGlass + .ofBoroGlass(notset, mintier, maxtier, setter, getter); + + @Override + public boolean check(T te, World world, int x, int y, int z) { + if (world.isAirBlock(x, y, z)) return false; + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + + int glassTier = GlassTier.getGlassTier(block, meta); + + // If it is not a glass, the tier will be 0. + if (glassTier == 0 || glassTier == notset || glassTier < mintier || glassTier > maxtier) return false; + + if (getter.apply(te) == notset) setter.accept(te, (byte) glassTier); + return getter.apply(te) == glassTier; + } + + @Override + public boolean spawnHint(T te, World world, int x, int y, int z, ItemStack itemStack) { + StructureLibAPI.hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), aDots - 1); + return true; + } + + @Override + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return this.placementDelegate.placeBlock(t, world, x, y, z, trigger); + } + + @Override + public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, + AutoPlaceEnvironment env) { + return this.placementDelegate.survivalPlaceBlock(t, world, x, y, z, trigger, env); + } + }; + } + + public static <T> IStructureElement<T> ofGlassTieredMixed(byte mintier, byte maxtier, int aDots) { + return new IStructureElement<>() { + + private final IStructureElement<T> placementDelegate = BorosilicateGlass + .ofBoroGlass((byte) 0, mintier, maxtier, (v1, v2) -> {}, v1 -> (byte) 0); + + @Override + public boolean check(T te, World world, int x, int y, int z) { + if (world.isAirBlock(x, y, z)) return false; + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + int glassTier = GlassTier.getGlassTier(block, meta); + + if (glassTier == 0) return false; // Not a glass. + return glassTier >= mintier && glassTier <= maxtier; + } + + @Override + public boolean spawnHint(T te, World world, int x, int y, int z, ItemStack itemStack) { + StructureLibAPI.hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), aDots - 1); + return true; + } + + @Override + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return this.placementDelegate.placeBlock(t, world, x, y, z, trigger); + } + + @Override + public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, + AutoPlaceEnvironment env) { + return this.placementDelegate.survivalPlaceBlock(t, world, x, y, z, trigger, env); + } + }; + } + + private static Field sBufferedRecipeList; + + @SuppressWarnings("unchecked") + public static List<IRecipe> getGTBufferedRecipeList() + throws SecurityException, IllegalArgumentException, IllegalAccessException { + if (sBufferedRecipeList == null) { + sBufferedRecipeList = FieldUtils.getDeclaredField(GTModHandler.class, "sBufferRecipeList", true); + } + if (sBufferedRecipeList == null) { + sBufferedRecipeList = FieldUtils.getField(GTModHandler.class, "sBufferRecipeList", true); + } + return (List<IRecipe>) sBufferedRecipeList.get(null); + } + + public static ShapedOreRecipe createGTCraftingRecipe(ItemStack aResult, long aBitMask, Object[] aRecipe) { + return createGTCraftingRecipe( + aResult, + new Enchantment[0], + new int[0], + (aBitMask & GTModHandler.RecipeBits.MIRRORED) != 0L, + (aBitMask & GTModHandler.RecipeBits.BUFFERED) != 0L, + (aBitMask & GTModHandler.RecipeBits.KEEPNBT) != 0L, + (aBitMask & GTModHandler.RecipeBits.DISMANTLEABLE) != 0L, + (aBitMask & GTModHandler.RecipeBits.NOT_REMOVABLE) == 0L, + (aBitMask & GTModHandler.RecipeBits.REVERSIBLE) != 0L, + (aBitMask & GTModHandler.RecipeBits.DELETE_ALL_OTHER_RECIPES) != 0L, + (aBitMask & GTModHandler.RecipeBits.DELETE_ALL_OTHER_RECIPES_IF_SAME_NBT) != 0L, + (aBitMask & GTModHandler.RecipeBits.DELETE_ALL_OTHER_SHAPED_RECIPES) != 0L, + (aBitMask & GTModHandler.RecipeBits.DELETE_ALL_OTHER_NATIVE_RECIPES) != 0L, + (aBitMask & GTModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS) == 0L, + (aBitMask & GTModHandler.RecipeBits.ONLY_ADD_IF_THERE_IS_ANOTHER_RECIPE_FOR_IT) != 0L, + (aBitMask & GTModHandler.RecipeBits.ONLY_ADD_IF_RESULT_IS_NOT_NULL) != 0L, + aRecipe); + } + + public static ShapedOreRecipe createGTCraftingRecipe(ItemStack aResult, Enchantment[] aEnchantmentsAdded, + int[] aEnchantmentLevelsAdded, boolean aMirrored, boolean aBuffered, boolean aKeepNBT, boolean aDismantleable, + boolean aRemovable, boolean aReversible, boolean aRemoveAllOthersWithSameOutput, + boolean aRemoveAllOthersWithSameOutputIfTheyHaveSameNBT, boolean aRemoveAllOtherShapedsWithSameOutput, + boolean aRemoveAllOtherNativeRecipes, boolean aCheckForCollisions, + boolean aOnlyAddIfThereIsAnyRecipeOutputtingThis, boolean aOnlyAddIfResultIsNotNull, Object[] aRecipe) { + aResult = GTOreDictUnificator.get(true, aResult); + if (aOnlyAddIfResultIsNotNull && aResult == null) return null; + if (aResult != null && Items.feather.getDamage(aResult) == W) Items.feather.setDamage(aResult, 0); + if (aRecipe == null || aRecipe.length <= 0) return null; + + boolean tThereWasARecipe = false; + + for (byte i = 0; i < aRecipe.length; i++) { + if (aRecipe[i] instanceof IItemContainer itemContainer) { + aRecipe[i] = itemContainer.get(1); + continue; + } + if (aRecipe[i] instanceof Enum<?>enum_) { + aRecipe[i] = enum_.name(); + continue; + } + if (aRecipe[i] != null && !(aRecipe[i] instanceof ItemStack) + && !(aRecipe[i] instanceof ItemData) + && !(aRecipe[i] instanceof String) + && !(aRecipe[i] instanceof Character)) { + aRecipe[i] = aRecipe[i].toString(); + } + } + + try { + StringBuilder shape = new StringBuilder(E); + int idx = 0; + if (aRecipe[idx] instanceof Boolean) { + throw new IllegalArgumentException(); + } + + ArrayList<Object> tRecipeList = new ArrayList<>(Arrays.asList(aRecipe)); + + while (aRecipe[idx] instanceof String string) { + StringBuilder s = new StringBuilder(string); + idx++; + shape.append(s); + while (s.length() < 3) s.append(" "); + if (s.length() > 3) throw new IllegalArgumentException(); + + for (char c : s.toString() + .toCharArray()) { + switch (c) { + case 'b': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolBlade.name()); + break; + case 'c': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolCrowbar.name()); + break; + case 'd': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolScrewdriver.name()); + break; + case 'f': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolFile.name()); + break; + case 'h': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolHardHammer.name()); + break; + case 'i': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolSolderingIron.name()); + break; + case 'j': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolSolderingMetal.name()); + break; + case 'k': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolKnife.name()); + break; + case 'm': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolMortar.name()); + break; + case 'p': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolDrawplate.name()); + break; + case 'r': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolSoftHammer.name()); + break; + case 's': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolSaw.name()); + break; + case 'w': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolWrench.name()); + break; + case 'x': + tRecipeList.add(c); + tRecipeList.add(ToolDictNames.craftingToolWireCutter.name()); + break; + } + } + } + + aRecipe = tRecipeList.toArray(); + + if (aRecipe[idx] instanceof Boolean) { + idx++; + } + Map<Character, ItemStack> tItemStackMap = new HashMap<>(); + Map<Character, ItemData> tItemDataMap = new HashMap<>(); + tItemStackMap.put(' ', null); + + boolean tRemoveRecipe = true; + + for (; idx < aRecipe.length; idx += 2) { + if (aRecipe[idx] == null || aRecipe[idx + 1] == null) { + if (D1) { + GTLog.err.println( + "WARNING: Missing Item for shaped Recipe: " + + (aResult == null ? "null" : aResult.getDisplayName())); + for (Object tContent : aRecipe) GTLog.err.println(tContent); + } + return null; + } + Character chr = (Character) aRecipe[idx]; + Object in = aRecipe[idx + 1]; + if (in instanceof ItemStack) { + tItemStackMap.put(chr, GTUtility.copy(in)); + tItemDataMap.put(chr, GTOreDictUnificator.getItemData((ItemStack) in)); + } else if (in instanceof ItemData) { + String tString = in.toString(); + switch (tString) { + case "plankWood": + tItemDataMap.put(chr, new ItemData(Materials.Wood, M)); + break; + case "stoneNetherrack": + tItemDataMap.put(chr, new ItemData(Materials.Netherrack, M)); + break; + case "stoneObsidian": + tItemDataMap.put(chr, new ItemData(Materials.Obsidian, M)); + break; + case "stoneEndstone": + tItemDataMap.put(chr, new ItemData(Materials.Endstone, M)); + break; + default: + tItemDataMap.put(chr, (ItemData) in); + break; + } + ItemStack tStack = GTOreDictUnificator.getFirstOre(in, 1); + if (tStack == null) tRemoveRecipe = false; + else tItemStackMap.put(chr, tStack); + aRecipe[idx + 1] = in.toString(); + } else if (in instanceof String) { + if (in.equals(OreDictNames.craftingChest.toString())) + tItemDataMap.put(chr, new ItemData(Materials.Wood, M * 8)); + else if (in.equals(OreDictNames.craftingBook.toString())) + tItemDataMap.put(chr, new ItemData(Materials.Paper, M * 3)); + else if (in.equals(OreDictNames.craftingPiston.toString())) + tItemDataMap.put(chr, new ItemData(Materials.Stone, M * 4, Materials.Wood, M * 3)); + else if (in.equals(OreDictNames.craftingFurnace.toString())) + tItemDataMap.put(chr, new ItemData(Materials.Stone, M * 8)); + else if (in.equals(OreDictNames.craftingIndustrialDiamond.toString())) + tItemDataMap.put(chr, new ItemData(Materials.Diamond, M)); + else if (in.equals(OreDictNames.craftingAnvil.toString())) + tItemDataMap.put(chr, new ItemData(Materials.Iron, M * 10)); + ItemStack tStack = GTOreDictUnificator.getFirstOre(in, 1); + if (tStack == null) tRemoveRecipe = false; + else tItemStackMap.put(chr, tStack); + } else { + throw new IllegalArgumentException(); + } + } + + if (aReversible && aResult != null) { + ItemData[] tData = new ItemData[9]; + int x = -1; + for (char chr : shape.toString() + .toCharArray()) { + x++; + tData[x] = tItemDataMap.get(chr); + } + if (GTUtility.arrayContainsNonNull(tData)) + GTOreDictUnificator.addItemData(aResult, new ItemData(tData)); + } + + if (aCheckForCollisions && tRemoveRecipe) { + ItemStack[] tRecipe = new ItemStack[9]; + int x = -1; + for (char chr : shape.toString() + .toCharArray()) { + x++; + tRecipe[x] = tItemStackMap.get(chr); + if (tRecipe[x] != null && Items.feather.getDamage(tRecipe[x]) == W) + Items.feather.setDamage(tRecipe[x], 0); + } + tThereWasARecipe = GTModHandler.removeRecipe(tRecipe) != null; + } + } catch (Throwable e) { + e.printStackTrace(GTLog.err); + } + + if (aResult == null || aResult.stackSize <= 0) return null; + + if (aRemoveAllOthersWithSameOutput || aRemoveAllOthersWithSameOutputIfTheyHaveSameNBT + || aRemoveAllOtherShapedsWithSameOutput + || aRemoveAllOtherNativeRecipes) + tThereWasARecipe = GTModHandler.removeRecipeByOutput( + aResult, + !aRemoveAllOthersWithSameOutputIfTheyHaveSameNBT, + aRemoveAllOtherShapedsWithSameOutput, + aRemoveAllOtherNativeRecipes) || tThereWasARecipe; + + if (aOnlyAddIfThereIsAnyRecipeOutputtingThis && !tThereWasARecipe) { + ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance() + .getRecipeList(); + int tList_sS = tList.size(); + for (int i = 0; i < tList_sS && !tThereWasARecipe; i++) { + IRecipe tRecipe = tList.get(i); + if (GTModHandler.sSpecialRecipeClasses.contains( + tRecipe.getClass() + .getName())) + continue; + if (GTUtility.areStacksEqual(GTOreDictUnificator.get(tRecipe.getRecipeOutput()), aResult, true)) { + tList.remove(i); + i--; + tList_sS = tList.size(); + tThereWasARecipe = true; + } + } + } + + if (Items.feather.getDamage(aResult) == W || Items.feather.getDamage(aResult) < 0) + Items.feather.setDamage(aResult, 0); + + GTUtility.updateItemStack(aResult); + + return new GTShapedRecipe( + GTUtility.copy(aResult), + aDismantleable, + aRemovable, + aKeepNBT, + aEnchantmentsAdded, + aEnchantmentLevelsAdded, + aRecipe).setMirrored(aMirrored); + } + + public static void shortSleep(long nanos) { + try { + long start = System.nanoTime(); + long end; + do { + end = System.nanoTime(); + } while (start + nanos >= end); + } catch (Exception e) { + MainMod.LOGGER.catching(e); + } + } +} diff --git a/src/main/java/bartworks/util/BioCulture.java b/src/main/java/bartworks/util/BioCulture.java new file mode 100644 index 0000000000..3e4f64fd77 --- /dev/null +++ b/src/main/java/bartworks/util/BioCulture.java @@ -0,0 +1,253 @@ +/* + * 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.util; + +import java.awt.Color; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Objects; + +import net.minecraft.item.EnumRarity; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; + +import gregtech.api.interfaces.IColorModulationContainer; +import gregtech.api.util.GTLanguageManager; + +public class BioCulture extends BioData implements IColorModulationContainer { + + public static final ArrayList<BioCulture> BIO_CULTURE_ARRAY_LIST = new ArrayList<>(); + public static final BioCulture NULLCULTURE = BioCulture + .createAndRegisterBioCulture(Color.BLUE, "", BioPlasmid.NULLPLASMID, BioDNA.NULLDNA, false); // fallback + // NULL + // culture, + // also Blue =) + + public String getLocalisedName() { + return GTLanguageManager.getTranslation(this.getName()); + } + + public void setLocalisedName(String localisedName) { + GTLanguageManager.addStringLocalization(this.getName(), localisedName); + } + + Color color; + BioPlasmid plasmid; + BioDNA dDNA; + boolean bBreedable; + Fluid mFluid; + + protected BioCulture(Color color, String name, int ID, BioPlasmid plasmid, BioDNA dDNA, EnumRarity rarity, + boolean bBreedable) { + super(name, ID, rarity); + this.color = color; + this.plasmid = plasmid; + this.dDNA = dDNA; + this.bBreedable = bBreedable; + } + + protected BioCulture(Color color, String name, int ID, BioPlasmid plasmid, BioDNA dDNA) { + super(name, ID, dDNA.getRarity()); + this.color = color; + this.plasmid = plasmid; + this.dDNA = dDNA; + } + + public static BioCulture createAndRegisterBioCulture(Color color, String name, BioPlasmid plasmid, BioDNA dna, + EnumRarity rarity, boolean breedable) { + BioCulture ret = new BioCulture(color, name, BIO_CULTURE_ARRAY_LIST.size(), plasmid, dna, rarity, breedable); + BIO_CULTURE_ARRAY_LIST.add(ret); + return ret; + } + + public static BioCulture createAndRegisterBioCulture(Color color, String name, BioPlasmid plasmid, BioDNA dna, + boolean breedable) { + BioCulture ret = new BioCulture( + color, + name, + BIO_CULTURE_ARRAY_LIST.size(), + plasmid, + dna, + dna.getRarity(), + breedable); + BIO_CULTURE_ARRAY_LIST.add(ret); + return ret; + } + + public static NBTTagCompound getNBTTagFromCulture(BioCulture bioCulture) { + if (bioCulture == null) return new NBTTagCompound(); + NBTTagCompound ret = new NBTTagCompound(); + ret.setString("Name", bioCulture.name); + // ret.setInteger("ID", bioCulture.ID); + ret.setIntArray( + "Color", + new int[] { bioCulture.color.getRed(), bioCulture.color.getGreen(), bioCulture.color.getBlue() }); + ret.setTag("Plasmid", BioData.getNBTTagFromBioData(BioData.convertBioPlasmidToBioData(bioCulture.plasmid))); + ret.setTag("DNA", BioData.getNBTTagFromBioData(BioData.convertBioDNAToBioData(bioCulture.dDNA))); + ret.setBoolean("Breedable", bioCulture.bBreedable); + ret.setByte("Rarety", BWUtil.getByteFromRarity(bioCulture.rarity)); + if (bioCulture.bBreedable) ret.setString( + "Fluid", + bioCulture.getFluid() + .getName()); + return ret; + } + + public static BioCulture getBioCultureFromNBTTag(NBTTagCompound tag) { + if (tag == null || tag.getIntArray("Color").length == 0) return null; + BioCulture ret = getBioCulture(tag.getString("Name")); + + if (ret == null) ret = createAndRegisterBioCulture( + new Color(tag.getIntArray("Color")[0], tag.getIntArray("Color")[1], tag.getIntArray("Color")[2]), + tag.getString("Name"), + BioPlasmid.convertDataToPlasmid(getBioDataFromNBTTag(tag.getCompoundTag("Plasmid"))), + BioDNA.convertDataToDNA(getBioDataFromNBTTag(tag.getCompoundTag("DNA"))), + BWUtil.getRarityFromByte(tag.getByte("Rarety")), + tag.getBoolean("Breedable")); + if (ret.bBreedable) ret.setFluid(FluidRegistry.getFluid(tag.getString("Fluid"))); + if (ret.getFluidNotSet()) // should never happen, but better safe than sorry + ret.setbBreedable(false); + return ret; + } + + public static BioCulture getBioCulture(String Name) { + if (Name == null || Name.isEmpty()) return null; + for (BioCulture b : BIO_CULTURE_ARRAY_LIST) if (b.name.equals(Name)) return b; + return null; + } + + public static BioCulture getBioCulture(BioDNA DNA) { + for (BioCulture b : BIO_CULTURE_ARRAY_LIST) if (b.getdDNA() + .equals(DNA)) return b; + return null; + } + + public Fluid getFluid() { + if (this.mFluid == null) + throw new IllegalStateException("Fluid has not been set yet! The issuring Culture is: " + this.name); + return this.mFluid; + } + + public void setFluid(Fluid mFluid) { + this.mFluid = mFluid; + } + + public boolean getFluidNotSet() { + return this.mFluid == null && this.isBreedable(); + } + + public boolean isBreedable() { + return this.bBreedable; + } + + public void setbBreedable(boolean bBreedable) { + this.bBreedable = bBreedable; + } + + public int getColorRGB() { + return BWColorUtil + .getColorFromRGBArray(new int[] { this.color.getRed(), this.color.getGreen(), this.color.getBlue() }); + } + + public Color getColor() { + return this.color; + } + + public void setColor(Color color) { + this.color = color; + } + + public BioPlasmid getPlasmid() { + return this.plasmid; + } + + public BioCulture setPlasmid(BioPlasmid plasmid) { + return this.checkForExisting( + new BioCulture(this.color, this.name, this.ID, plasmid, this.dDNA, this.rarity, this.bBreedable)); + } + + private BioCulture checkForExisting(BioCulture culture) { + if (culture == null) return null; + for (BioCulture bc : BioCulture.BIO_CULTURE_ARRAY_LIST) if (culture.getdDNA() + .equals(bc.getdDNA()) + && culture.getPlasmid() + .equals(bc.getPlasmid())) + return bc; + return culture; + } + + public BioCulture setPlasmidUnsafe(BioPlasmid plasmid) { + this.plasmid = plasmid; + return this; + } + + public BioDNA getdDNA() { + return this.dDNA; + } + + public BioCulture setdDNA(BioDNA dDNA) { + return this.checkForExisting( + new BioCulture(this.color, this.name, this.ID, this.plasmid, dDNA, this.rarity, this.bBreedable)); + } + + public BioCulture setdDNAUnsafe(BioDNA dDNA) { + this.dDNA = dDNA; + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass() || !super.equals(o)) return false; + BioCulture culture = (BioCulture) o; + return this.isBreedable() == culture.isBreedable() && Objects.equals(this.getColor(), culture.getColor()) + && Objects.equals(this.getPlasmid(), culture.getPlasmid()) + && Objects.equals(this.getdDNA(), culture.getdDNA()) + && Objects.equals(this.mFluid, culture.mFluid); + } + + @Override + public int hashCode() { + return MurmurHash3.murmurhash3_x86_32( + ByteBuffer.allocate(17) + .putInt( + MurmurHash3.murmurhash3_x86_32( + this.getName(), + 0, + this.getName() + .length(), + 31)) + .putInt(this.getColorRGB()) + .putInt(this.getPlasmid().ID) + .putInt(this.getdDNA().ID) + .put((byte) (this.isBreedable() ? 1 : 0)) + .array(), + 0, + 17, + 31); + } + + @Override + public short[] getRGBA() { + return new short[] { (short) this.getColor() + .getRed(), + (short) this.getColor() + .getGreen(), + (short) this.getColor() + .getBlue(), + (short) this.getColor() + .getAlpha() }; + } +} diff --git a/src/main/java/bartworks/util/BioDNA.java b/src/main/java/bartworks/util/BioDNA.java new file mode 100644 index 0000000000..6233218e67 --- /dev/null +++ b/src/main/java/bartworks/util/BioDNA.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2018-2019 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.util; + +import net.minecraft.item.EnumRarity; + +public class BioDNA extends BioData { + + public static final BioDNA NULLDNA = createAndRegisterBioDNA("", EnumRarity.epic); + + protected BioDNA(String name, int ID, EnumRarity rarity) { + super(name, ID, rarity); + } + + protected BioDNA(BioData bioData) { + super(bioData); + this.name = bioData.name; + this.ID = bioData.ID; + this.rarity = bioData.rarity; + } + + public static BioDNA convertDataToDNA(BioData bioData) { + return new BioDNA(bioData); + } + + public static BioDNA createAndRegisterBioDNA(String aName, EnumRarity rarity) { + BioData ret = BioData.createAndRegisterBioData(aName, rarity); + return new BioDNA(ret); + } + + public static BioDNA createAndRegisterBioDNA(String aName, EnumRarity rarity, int chance, int tier) { + BioData ret = BioData.createAndRegisterBioData(aName, rarity, chance, tier); + return new BioDNA(ret); + } + + @Override + public String toString() { + return "BioDNA{" + "name='" + this.name + '\'' + ", ID=" + this.ID + '}'; + } +} diff --git a/src/main/java/bartworks/util/BioData.java b/src/main/java/bartworks/util/BioData.java new file mode 100644 index 0000000000..6622476ca5 --- /dev/null +++ b/src/main/java/bartworks/util/BioData.java @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2018-2019 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.util; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Objects; + +import net.minecraft.item.EnumRarity; +import net.minecraft.nbt.NBTTagCompound; + +public class BioData { + + public static final ArrayList<BioData> BIO_DATA_ARRAY_LIST = new ArrayList<>(); + + protected String name; + protected int ID; + protected EnumRarity rarity; + protected int chance; + protected int tier; + + protected BioData(String name, int ID, EnumRarity rarity, int chance, int tier) { + this.name = name; + this.ID = ID; + this.rarity = rarity; + this.chance = chance; + this.tier = tier; + } + + protected BioData(String name, int ID, EnumRarity rarity) { + this.name = name; + this.ID = ID; + this.rarity = rarity; + this.chance = 7500; + this.tier = 0; + } + + protected BioData(BioData bioData) { + this.rarity = bioData.rarity; + this.name = bioData.name; + this.ID = bioData.ID; + this.chance = bioData.chance; + this.tier = bioData.tier; + } + + public static BioData convertBioPlasmidToBioData(BioPlasmid bioPlasmid) { + return new BioData(bioPlasmid.name, bioPlasmid.ID, bioPlasmid.rarity, bioPlasmid.chance, bioPlasmid.tier); + } + + public static BioData convertBioDNAToBioData(BioDNA bioDNA) { + return new BioData(bioDNA.name, bioDNA.ID, bioDNA.rarity, bioDNA.chance, bioDNA.tier); + } + + public static BioData createAndRegisterBioData(String aName, EnumRarity rarity, int chance, int tier) { + BioData ret = new BioData(aName, BIO_DATA_ARRAY_LIST.size(), rarity, chance, tier); + BIO_DATA_ARRAY_LIST.add(ret); + return ret; + } + + public static BioData createAndRegisterBioData(String aName, EnumRarity rarity) { + BioData ret = new BioData(aName, BIO_DATA_ARRAY_LIST.size(), rarity); + BIO_DATA_ARRAY_LIST.add(ret); + return ret; + } + + public static NBTTagCompound getNBTTagFromBioData(BioData bioData) { + NBTTagCompound ret = new NBTTagCompound(); + ret.setByte("Rarity", BWUtil.getByteFromRarity(bioData.rarity)); + ret.setString("Name", bioData.name); + // ret.setInteger("ID", bioData.ID); buggy when load Order changes + ret.setInteger("Chance", bioData.chance); + ret.setInteger("Tier", bioData.tier); + return ret; + } + + public static BioData getBioDataFromNBTTag(NBTTagCompound tag) { + if (tag == null) return null; + return getBioDataFromName(tag.getString("Name")); + } + + public static BioData getBioDataFromName(String Name) { + for (BioData bd : BIO_DATA_ARRAY_LIST) if (bd.name.equals(Name)) return bd; + return null; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + BioData bioData = (BioData) o; + return this.getID() == bioData.getID() + || this.getChance() == bioData.getChance() && this.getTier() == bioData.getTier() + && Objects.equals(this.getName(), bioData.getName()) + && this.getRarity() == bioData.getRarity(); + } + + @Override + public int hashCode() { + return MurmurHash3.murmurhash3_x86_32( + ByteBuffer.allocate(13) + .putInt( + MurmurHash3.murmurhash3_x86_32( + this.getName(), + 0, + this.getName() + .length(), + 31)) + .put(BWUtil.getByteFromRarity(this.getRarity())) + .putInt(this.getChance()) + .putInt(this.getTier()) + .array(), + 0, + 13, + 31); + } + + public int getTier() { + return this.tier; + } + + public void setTier(int tier) { + this.tier = tier; + } + + @Override + public String toString() { + return "BioData{" + "name='" + this.name + '\'' + ", ID=" + this.ID + '}'; + } + + public EnumRarity getRarity() { + return this.rarity; + } + + public void setRarity(EnumRarity rarity) { + this.rarity = rarity; + } + + public int getChance() { + return this.chance; + } + + public void setChance(int chance) { + this.chance = chance; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * DO NOT USE GET ID TO GET THE OBJECT! THIS SHOULD ONLY BE USED FOR COMPARISON! + * + * @return the position in the loading list + */ + public int getID() { + return this.ID; + } +} diff --git a/src/main/java/bartworks/util/BioPlasmid.java b/src/main/java/bartworks/util/BioPlasmid.java new file mode 100644 index 0000000000..0ab26b3d3c --- /dev/null +++ b/src/main/java/bartworks/util/BioPlasmid.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2018-2019 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.util; + +import net.minecraft.item.EnumRarity; + +public class BioPlasmid extends BioData { + + public static final BioPlasmid NULLPLASMID = convertDataToPlasmid(BioData.convertBioDNAToBioData(BioDNA.NULLDNA)); + + private BioPlasmid(String name, int ID, EnumRarity rarity) { + super(name, ID, rarity); + } + + protected BioPlasmid(BioData bioData) { + super(bioData); + this.name = bioData.name; + this.ID = bioData.ID; + this.rarity = bioData.rarity; + } + + public static BioPlasmid convertDataToPlasmid(BioData bioData) { + return new BioPlasmid(bioData); + } + + public static BioPlasmid createAndRegisterBioPlasmid(String aName, EnumRarity rarity) { + BioData ret = BioData.createAndRegisterBioData(aName, rarity); + return new BioPlasmid(ret); + } + + public static BioPlasmid createAndRegisterBioPlasmid(String aName, EnumRarity rarity, int chance, int tier) { + BioData ret = BioData.createAndRegisterBioData(aName, rarity, chance, tier); + return new BioPlasmid(ret); + } + + @Override + public String toString() { + return "BioPlasmid{" + "name='" + this.name + '\'' + ", ID=" + this.ID + '}'; + } +} diff --git a/src/main/java/bartworks/util/CachedReflectionUtils.java b/src/main/java/bartworks/util/CachedReflectionUtils.java new file mode 100644 index 0000000000..a02b644b4a --- /dev/null +++ b/src/main/java/bartworks/util/CachedReflectionUtils.java @@ -0,0 +1,31 @@ +package bartworks.util; + +import java.lang.reflect.Field; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.commons.lang3.reflect.FieldUtils; + +public class CachedReflectionUtils { + + private static final ClassValue<Map<String, Field>> fields = new ConcurrentMapClassValue(); + private static final ClassValue<Map<String, Field>> declaredFields = new ConcurrentMapClassValue(); + + public static Field getField(final Class<?> cls, final String fieldName) { + return fields.get(cls) + .computeIfAbsent(fieldName, f -> FieldUtils.getField(cls, f, true)); + } + + public static Field getDeclaredField(final Class<?> cls, final String fieldName) { + return declaredFields.get(cls) + .computeIfAbsent(fieldName, f -> FieldUtils.getDeclaredField(cls, f, true)); + } + + private static class ConcurrentMapClassValue extends ClassValue<Map<String, Field>> { + + @Override + protected Map<String, Field> computeValue(Class<?> type) { + return new ConcurrentHashMap<>(); + } + } +} diff --git a/src/main/java/bartworks/util/ConnectedBlocksChecker.java b/src/main/java/bartworks/util/ConnectedBlocksChecker.java new file mode 100644 index 0000000000..e89d2b7df7 --- /dev/null +++ b/src/main/java/bartworks/util/ConnectedBlocksChecker.java @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2018-2019 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.util; + +import java.util.HashSet; + +import net.minecraft.block.Block; +import net.minecraft.world.World; +import net.minecraftforge.common.DimensionManager; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +public class ConnectedBlocksChecker { + + public final HashSet<Coords> hashset = new HashSet<>(2048); + + public static byte check_sourroundings(Coords C, Block b) { + byte ret = 0; + World w = DimensionManager.getWorld(C.wID); + int x = C.x, y = C.y, z = C.z; + + if (w.getBlock(x + 1, y, z) + .equals(b)) ret = (byte) (ret | 0b000100); + + if (w.getBlock(x - 1, y, z) + .equals(b)) ret = (byte) (ret | 0b001000); + + if (w.getBlock(x, y, z + 1) + .equals(b)) ret = (byte) (ret | 0b010000); + + if (w.getBlock(x, y, z - 1) + .equals(b)) ret = (byte) (ret | 0b100000); + + if (w.getBlock(x, y + 1, z) + .equals(b)) ret = (byte) (ret | 0b000001); + + if (w.getBlock(x, y - 1, z) + .equals(b)) ret = (byte) (ret | 0b000010); + + return ret; + } + + public int get_connected(World w, int x, int y, int z, Block b) { + int ret = 0; + + int wID = w.provider.dimensionId; + + byte sides = this.check_sourroundings(w, x, y, z, b); + + if ((sides | 0b111011) == 0b111111 && !this.hashset.contains(new Coords(x + 1, y, z, wID))) { + ret++; + ret += this.get_connected(w, x + 1, y, z, b); + } + + if ((sides | 0b110111) == 0b111111 && !this.hashset.contains(new Coords(x - 1, y, z, wID))) { + ret++; + ret += this.get_connected(w, x - 1, y, z, b); + } + + if ((sides | 0b101111) == 0b111111 && !this.hashset.contains(new Coords(x, y, z + 1, wID))) { + ret++; + ret += this.get_connected(w, x, y, z + 1, b); + } + + if ((sides | 0b011111) == 0b111111 && !this.hashset.contains(new Coords(x, y, z - 1, wID))) { + ret++; + ret += this.get_connected(w, x, y, z - 1, b); + } + + if ((sides | 0b111110) == 0b111111 && !this.hashset.contains(new Coords(x, y + 1, z, wID))) { + ret++; + ret += this.get_connected(w, x, y + 1, z, b); + } + + if ((sides | 0b111101) == 0b111111 && !this.hashset.contains(new Coords(x, y - 1, z, wID))) { + ret++; + ret += this.get_connected(w, x, y - 1, z, b); + } + + return ret; + } + + public byte check_sourroundings(World w, int x, int y, int z, Block b) { + + byte ret = 0; + int wID = w.provider.dimensionId; + + if (this.hashset.contains(new Coords(x, y, z, wID))) return ret; + + this.hashset.add(new Coords(x, y, z, wID)); + + if (w.getBlock(x + 1, y, z) + .equals(b)) ret = (byte) (ret | 0b000100); + + if (w.getBlock(x - 1, y, z) + .equals(b)) ret = (byte) (ret | 0b001000); + + if (w.getBlock(x, y, z + 1) + .equals(b)) ret = (byte) (ret | 0b010000); + + if (w.getBlock(x, y, z - 1) + .equals(b)) ret = (byte) (ret | 0b100000); + + if (w.getBlock(x, y + 1, z) + .equals(b)) ret = (byte) (ret | 0b000001); + + if (w.getBlock(x, y - 1, z) + .equals(b)) ret = (byte) (ret | 0b000010); + + return ret; + } + + public boolean get_meta_of_sideblocks(World w, int n, int[] xyz, boolean GT) { + + int wID = w.provider.dimensionId; + Coords Controller = new Coords(xyz[0], xyz[1], xyz[2], wID); + + for (Coords C : this.hashset) { + if (GT) { + if (!new Coords(C.x, C.y + 1, C.z, wID).equals(Controller) + && w.getTileEntity(C.x, C.y + 1, C.z) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; + } + if (!new Coords(C.x, C.y - 1, C.z, wID).equals(Controller) + && w.getTileEntity(C.x, C.y - 1, C.z) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; + } + if (!new Coords(C.x + 1, C.y, C.z, wID).equals(Controller) + && w.getTileEntity(C.x + 1, C.y, C.z) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; + } + if (!new Coords(C.x - 1, C.y, C.z, wID).equals(Controller) + && w.getTileEntity(C.x - 1, C.y, C.z) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; + } + if (!new Coords(C.x, C.y, C.z + 1, wID).equals(Controller) + && w.getTileEntity(C.x, C.y, C.z + 1) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; + } + if (!new Coords(C.x, C.y, C.z - 1, wID).equals(Controller) + && w.getTileEntity(C.x, C.y, C.z - 1) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; + } + } else { + if (n == w.getBlockMetadata(C.x, C.y + 1, C.z) && !new Coords(C.x, C.y + 1, C.z, wID).equals(Controller) + || n == w.getBlockMetadata(C.x, C.y - 1, C.z) + && !new Coords(C.x, C.y - 1, C.z, wID).equals(Controller)) { + return true; + } + if (n == w.getBlockMetadata(C.x + 1, C.y, C.z) + && !new Coords(C.x + 1, C.y, C.z, wID).equals(Controller)) { + return true; + } + if (n == w.getBlockMetadata(C.x - 1, C.y, C.z) + && !new Coords(C.x - 1, C.y, C.z, wID).equals(Controller)) { + return true; + } + if (n == w.getBlockMetadata(C.x, C.y, C.z + 1) + && !new Coords(C.x, C.y, C.z + 1, wID).equals(Controller)) { + return true; + } + if (n == w.getBlockMetadata(C.x, C.y, C.z - 1) + && !new Coords(C.x, C.y, C.z - 1, wID).equals(Controller)) { + return true; + } + } + } + return false; + } +} diff --git a/src/main/java/bartworks/util/ConnectedBlocksCheckerIteration.java b/src/main/java/bartworks/util/ConnectedBlocksCheckerIteration.java new file mode 100644 index 0000000000..a0c9d95b70 --- /dev/null +++ b/src/main/java/bartworks/util/ConnectedBlocksCheckerIteration.java @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2018-2019 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.util; + +import java.util.HashSet; +import java.util.LinkedList; +import java.util.Queue; + +import net.minecraft.block.Block; +import net.minecraft.world.World; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +/** + * This implementation is for some reason slower than the Recursive Check.... For ~3400 blocks this takes 8ms, the + * Recursive Check 5ms. + */ +public class ConnectedBlocksCheckerIteration { + + public final HashSet<Coords> hashset = new HashSet<>(2048); + public final HashSet<Coords> checked = new HashSet<>(4096); + private final Queue<Coords> kwoe = new LinkedList<>(); + + public long get_connected(World w, int x, int y, int z, Block b) { + this.kwoe.add(new Coords(x, y, z, w.provider.dimensionId)); + this.hashset.add(new Coords(x, y, z, w.provider.dimensionId)); + while (!this.kwoe.isEmpty()) { + Coords tocheck = this.kwoe.poll(); + int wID = w.provider.dimensionId; + this.checked.add(tocheck); + Coords c; + if (!this.checked.contains(c = new Coords(tocheck.x + 1, tocheck.y, tocheck.z, wID)) + && w.getBlock(tocheck.x + 1, tocheck.y, tocheck.z) + .equals(b)) { + this.kwoe.add(c); + this.hashset.add(c); + } + if (!this.checked.contains(c = new Coords(tocheck.x - 1, tocheck.y, tocheck.z, wID)) + && w.getBlock(tocheck.x - 1, tocheck.y, tocheck.z) + .equals(b)) { + this.kwoe.add(c); + this.hashset.add(c); + } + if (!this.checked.contains(c = new Coords(tocheck.x, tocheck.y, tocheck.z + 1, wID)) + && w.getBlock(tocheck.x, tocheck.y, tocheck.z + 1) + .equals(b)) { + this.kwoe.add(c); + this.hashset.add(c); + } + if (!this.checked.contains(c = new Coords(tocheck.x, tocheck.y, tocheck.z - 1, wID)) + && w.getBlock(tocheck.x, tocheck.y, tocheck.z - 1) + .equals(b)) { + this.kwoe.add(c); + this.hashset.add(c); + } + if (!this.checked.contains(c = new Coords(tocheck.x, tocheck.y + 1, tocheck.z, wID)) + && w.getBlock(tocheck.x, tocheck.y + 1, tocheck.z) + .equals(b)) { + this.kwoe.add(c); + this.hashset.add(c); + } + if (!this.checked.contains(c = new Coords(tocheck.x, tocheck.y - 1, tocheck.z, wID)) + && w.getBlock(tocheck.x, tocheck.y - 1, tocheck.z) + .equals(b)) { + this.kwoe.add(c); + this.hashset.add(c); + } + } + return this.hashset.size(); + } + + public boolean get_meta_of_sideblocks(World w, int n, int[] xyz, boolean GT) { + + int wID = w.provider.dimensionId; + Coords Controller = new Coords(xyz[0], xyz[1], xyz[2], wID); + + for (Coords C : this.hashset) { + if (GT) { + if (!new Coords(C.x, C.y + 1, C.z, wID).equals(Controller) + && w.getTileEntity(C.x, C.y + 1, C.z) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; + } + if (!new Coords(C.x, C.y - 1, C.z, wID).equals(Controller) + && w.getTileEntity(C.x, C.y - 1, C.z) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; + } + if (!new Coords(C.x + 1, C.y, C.z, wID).equals(Controller) + && w.getTileEntity(C.x + 1, C.y, C.z) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; + } + if (!new Coords(C.x - 1, C.y, C.z, wID).equals(Controller) + && w.getTileEntity(C.x - 1, C.y, C.z) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; + } + if (!new Coords(C.x, C.y, C.z + 1, wID).equals(Controller) + && w.getTileEntity(C.x, C.y, C.z + 1) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; + } + if (!new Coords(C.x, C.y, C.z - 1, wID).equals(Controller) + && w.getTileEntity(C.x, C.y, C.z - 1) instanceof IGregTechTileEntity gtTE + && gtTE.getMetaTileID() == n) { + return true; + } + } else { + if (n == w.getBlockMetadata(C.x, C.y + 1, C.z) && !new Coords(C.x, C.y + 1, C.z, wID).equals(Controller) + || n == w.getBlockMetadata(C.x, C.y - 1, C.z) + && !new Coords(C.x, C.y - 1, C.z, wID).equals(Controller)) { + return true; + } + if (n == w.getBlockMetadata(C.x + 1, C.y, C.z) + && !new Coords(C.x + 1, C.y, C.z, wID).equals(Controller)) { + return true; + } + if (n == w.getBlockMetadata(C.x - 1, C.y, C.z) + && !new Coords(C.x - 1, C.y, C.z, wID).equals(Controller)) { + return true; + } + if (n == w.getBlockMetadata(C.x, C.y, C.z + 1) + && !new Coords(C.x, C.y, C.z + 1, wID).equals(Controller)) { + return true; + } + if (n == w.getBlockMetadata(C.x, C.y, C.z - 1) + && !new Coords(C.x, C.y, C.z - 1, wID).equals(Controller)) { + return true; + } + } + } + return false; + } +} diff --git a/src/main/java/bartworks/util/Coords.java b/src/main/java/bartworks/util/Coords.java new file mode 100644 index 0000000000..7458c6f4e6 --- /dev/null +++ b/src/main/java/bartworks/util/Coords.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2018-2019 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.util; + +import net.minecraftforge.common.util.ForgeDirection; + +public class Coords { + + public int x, z, wID; + public short y; + + public Coords(int x, int y, int z, int wID) { + this(x, y, z); + this.wID = wID; + } + + public Coords(int x, int y, int z) { + this.x = x; + this.y = (short) y; + this.z = z; + this.wID = 0; + } + + public Coords getCoordsFromSide(ForgeDirection direction) { + return switch (direction) { + case UP -> new Coords(this.x, this.y + 1, this.z, this.wID); + case DOWN -> new Coords(this.x, this.y - 1, this.z, this.wID); + case WEST -> new Coords(this.x - 1, this.y, this.z, this.wID); + case EAST -> new Coords(this.x + 1, this.y, this.z, this.wID); + case NORTH -> new Coords(this.x, this.y, this.z - 1, this.wID); + case SOUTH -> new Coords(this.x, this.y, this.z + 1, this.wID); + default -> throw new UnsupportedOperationException("This is impossible."); + }; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + Coords coords = (Coords) o; + return this.x == coords.x && this.y == coords.y && this.z == coords.z && this.wID == coords.wID; + } + + @Override + public int hashCode() { + byte[] data = new byte[14]; + data[0] = (byte) (this.x & 0xff); + data[1] = (byte) (this.x >> 4 & 0xff); + data[2] = (byte) (this.x >> 8 & 0xff); + data[3] = (byte) (this.x >> 12 & 0xff); + data[4] = (byte) (this.y & 0xff); + data[5] = (byte) (this.y >> 4 & 0xff); + data[6] = (byte) (this.z & 0xff); + data[7] = (byte) (this.z >> 4 & 0xff); + data[8] = (byte) (this.z >> 8 & 0xff); + data[9] = (byte) (this.z >> 12 & 0xff); + data[10] = (byte) (this.wID & 0xff); + data[11] = (byte) (this.wID >> 4 & 0xff); + data[12] = (byte) (this.wID >> 8 & 0xff); + data[13] = (byte) (this.wID >> 12 & 0xff); + return MurmurHash3.murmurhash3_x86_32(data, 0, 14, 31); + } + + @Override + public String toString() { + return this.x + "," + this.y + "," + this.z + "," + this.wID; + } +} diff --git a/src/main/java/bartworks/util/EnumUtils.java b/src/main/java/bartworks/util/EnumUtils.java new file mode 100644 index 0000000000..e443e38d65 --- /dev/null +++ b/src/main/java/bartworks/util/EnumUtils.java @@ -0,0 +1,50 @@ +/* + * 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.util; + +import net.minecraftforge.common.util.EnumHelper; + +import gregtech.api.enums.Element; +import gregtech.api.enums.OrePrefixes; + +public class EnumUtils { + + private EnumUtils() {} + + public static OrePrefixes addNewOrePrefix(String enumName, String aRegularLocalName, String aLocalizedMaterialPre, + String aLocalizedMaterialPost, boolean aIsUnificatable, boolean aIsMaterialBased, boolean aIsSelfReferencing, + boolean aIsContainer, boolean aDontUnificateActively, boolean aIsUsedForBlocks, boolean aAllowNormalRecycling, + boolean aGenerateDefaultItem, boolean aIsEnchantable, boolean aIsUsedForOreProcessing, + int aMaterialGenerationBits, long aMaterialAmount, int aDefaultStackSize, int aTextureindex) { + return EnumHelper.addEnum( + OrePrefixes.class, + enumName, + new Class<?>[] { String.class, String.class, String.class, boolean.class, boolean.class, boolean.class, + boolean.class, boolean.class, boolean.class, boolean.class, boolean.class, boolean.class, boolean.class, + int.class, long.class, int.class, int.class }, + new Object[] { aRegularLocalName, aLocalizedMaterialPre, aLocalizedMaterialPost, aIsUnificatable, + aIsMaterialBased, aIsSelfReferencing, aIsContainer, aDontUnificateActively, aIsUsedForBlocks, + aAllowNormalRecycling, aGenerateDefaultItem, aIsEnchantable, aIsUsedForOreProcessing, + aMaterialGenerationBits, aMaterialAmount, aDefaultStackSize, aTextureindex }); + } + + public static Element createNewElement(String enumName, long aProtons, long aNeutrons, long aAdditionalMass, + long aHalfLifeSeconds, String aDecayTo, String aName, boolean aIsIsotope) { + return EnumHelper.addEnum( + Element.class, + enumName, + new Class[] { long.class, long.class, long.class, long.class, String.class, String.class, boolean.class }, + new Object[] { aProtons, aNeutrons, aAdditionalMass, aHalfLifeSeconds, aDecayTo, aName, aIsIsotope }); + } +} diff --git a/src/main/java/bartworks/util/MathUtils.java b/src/main/java/bartworks/util/MathUtils.java new file mode 100644 index 0000000000..5c677dd437 --- /dev/null +++ b/src/main/java/bartworks/util/MathUtils.java @@ -0,0 +1,116 @@ +/* + * 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.util; + +/* + * Faster implementations for Math stuff + */ +@SuppressWarnings("unused") +public class MathUtils { + + public static long floorLong(double x) { + if (Double.isInfinite(x) || Double.isNaN(x)) return (long) x; + long xi = (long) x; + return x < xi ? xi - 1 : xi; + } + + public static long ceilLong(double x) { + if (Double.isInfinite(x) || Double.isNaN(x)) return (long) x; + long xi = (long) x; + return x > xi ? xi + 1 : xi; + } + + public static int floorInt(double x) { + if (Double.isInfinite(x) || Double.isNaN(x)) return (int) x; + int xi = (int) x; + return x < xi ? xi - 1 : xi; + } + + public static int ceilInt(float x) { + if (Float.isInfinite(x) || Float.isNaN(x)) return (int) x; + int xi = (int) x; + return x > xi ? xi + 1 : xi; + } + + public static int ceilInt(double x) { + if (Double.isInfinite(x) || Double.isNaN(x)) return (int) x; + int xi = (int) x; + return x > xi ? xi + 1 : xi; + } + + public static double floor(double x) { + if (Double.isInfinite(x) || Double.isNaN(x)) return x; + int xi = (int) x; + return x < xi ? xi - 1 : xi; + } + + public static double ceil(double x) { + if (Double.isInfinite(x) || Double.isNaN(x)) return x; + int xi = (int) x; + return x > xi ? xi + 1 : xi; + } + + public static byte clamp(byte amount, byte min, byte max) { + byte inner = amount <= max ? amount : max; + return min >= inner ? min : inner; + } + + public static short clamp(short amount, short min, short max) { + short inner = amount <= max ? amount : max; + return min >= inner ? min : inner; + } + + public static int clamp(int amount, int min, int max) { + return Math.max(min, Math.min(amount, max)); + } + + public static long clamp(long amount, long min, long max) { + return Math.max(min, Math.min(amount, max)); + } + + public static float clamp(float amount, float min, float max) { + return Math.max(min, Math.min(amount, max)); + } + + public static double clamp(double amount, double min, double max) { + return Math.max(min, Math.min(amount, max)); + } + + public static <T extends Comparable<T>> T clamp(T val, T min, T max) { + return val.compareTo(min) < 0 ? min : val.compareTo(max) > 0 ? max : val; + } + + public static int wrap(int input, int bound) { + return (input % bound + bound) % bound; + } + + public static long wrap(long input, long bound) { + return (input % bound + bound) % bound; + } + + public static double wrap(double input, double bound) { + return (input % bound + bound) % bound; + } + + public static float wrap(float input, float bound) { + return (input % bound + bound) % bound; + } + + public static float tanh(float x) { + float x2 = x * x; + float a = x * (135135.0f + x2 * (17325.0f + x2 * (378.0f + x2))); + float b = 135135.0f + x2 * (62370.0f + x2 * (3150.0f + x2 * 28.0f)); + return clamp(a / b, -1, 1); + } +} diff --git a/src/main/java/bartworks/util/MurmurHash3.java b/src/main/java/bartworks/util/MurmurHash3.java new file mode 100644 index 0000000000..825c83cca2 --- /dev/null +++ b/src/main/java/bartworks/util/MurmurHash3.java @@ -0,0 +1,306 @@ +/* + * The MurmurHash3 algorithm was created by Austin Appleby and placed in the public domain. This java port was authored + * by Yonik Seeley and also placed into the public domain. The author hereby disclaims copyright to this source code. + * <p> This produces exactly the same hash values as the final C++ version of MurmurHash3 and is thus suitable for + * producing the same hash values across platforms. <p> The 32 bit x86 version of this hash should be the fastest + * variant for relatively short keys like ids. murmurhash3_x64_128 is a good choice for longer strings or if you need + * more than 32 bits of hash. <p> Note - The x86 and x64 versions do _not_ produce the same results, as the algorithms + * are optimized for their respective platforms. <p> See http://github.com/yonik/java_util for future updates to this + * file. Special Thanks to Austin Appleby and Yonik Seeley for placing this in the public domain and therefore allowing + * me to use it! + */ +package bartworks.util; + +public final class MurmurHash3 { + + public static int fmix32(int h) { + h ^= h >>> 16; + h *= 0x85ebca6b; + h ^= h >>> 13; + h *= 0xc2b2ae35; + h ^= h >>> 16; + return h; + } + + public static long fmix64(long k) { + k ^= k >>> 33; + k *= 0xff51afd7ed558ccdL; + k ^= k >>> 33; + k *= 0xc4ceb9fe1a85ec53L; + k ^= k >>> 33; + return k; + } + + /** + * Gets a long from a byte buffer in little endian byte order. + */ + public static long getLongLittleEndian(byte[] buf, int offset) { + return (long) buf[offset + 7] << 56 // no mask needed + | (buf[offset + 6] & 0xffL) << 48 + | (buf[offset + 5] & 0xffL) << 40 + | (buf[offset + 4] & 0xffL) << 32 + | (buf[offset + 3] & 0xffL) << 24 + | (buf[offset + 2] & 0xffL) << 16 + | (buf[offset + 1] & 0xffL) << 8 + | buf[offset] & 0xffL; // no shift needed + } + + /** + * Returns the MurmurHash3_x86_32 hash. + */ + public static int murmurhash3_x86_32(byte[] data, int offset, int len, int seed) { + + final int c1 = 0xcc9e2d51; + final int c2 = 0x1b873593; + + int h1 = seed; + int roundedEnd = offset + (len & 0xfffffffc); // round down to 4 byte block + + for (int i = offset; i < roundedEnd; i += 4) { + // little endian load order + int k1 = data[i] & 0xff | (data[i + 1] & 0xff) << 8 | (data[i + 2] & 0xff) << 16 | data[i + 3] << 24; + k1 *= c1; + k1 = k1 << 15 | k1 >>> 17; // ROTL32(k1,15); + k1 *= c2; + + h1 ^= k1; + h1 = h1 << 13 | h1 >>> 19; // ROTL32(h1,13); + h1 = h1 * 5 + 0xe6546b64; + } + + // tail + int k1 = 0; + + switch (len & 0x03) { + case 3: + k1 = (data[roundedEnd + 2] & 0xff) << 16; + // fallthrough + case 2: + k1 |= (data[roundedEnd + 1] & 0xff) << 8; + // fallthrough + case 1: + k1 |= data[roundedEnd] & 0xff; + k1 *= c1; + k1 = k1 << 15 | k1 >>> 17; // ROTL32(k1,15); + k1 *= c2; + h1 ^= k1; + } + + // finalization + h1 ^= len; + + // fmix(h1); + h1 ^= h1 >>> 16; + h1 *= 0x85ebca6b; + h1 ^= h1 >>> 13; + h1 *= 0xc2b2ae35; + h1 ^= h1 >>> 16; + + return h1; + } + + /** + * Returns the MurmurHash3_x86_32 hash of the UTF-8 bytes of the String without actually encoding the string to a + * temporary buffer. This is more than 2x faster than hashing the result of String.getBytes(). + */ + public static int murmurhash3_x86_32(CharSequence data, int offset, int len, int seed) { + + final int c1 = 0xcc9e2d51; + final int c2 = 0x1b873593; + + int h1 = seed; + + int pos = offset; + int end = offset + len; + int k1 = 0; + int k2 = 0; + int shift = 0; + int bits = 0; + int nBytes = 0; // length in UTF8 bytes + + while (pos < end) { + int code = data.charAt(pos); + pos++; + if (code < 0x80) { + k2 = code; + bits = 8; + + /*** + * // optimized ascii implementation (currently slower!!! code size?) if (shift == 24) { k1 = k1 | (code + * << 24); + * + * k1 *= c1; k1 = (k1 << 15) | (k1 >>> 17); // ROTL32(k1,15); k1 *= c2; + * + * h1 ^= k1; h1 = (h1 << 13) | (h1 >>> 19); // ROTL32(h1,13); h1 = h1*5+0xe6546b64; + * + * shift = 0; nBytes += 4; k1 = 0; } else { k1 |= code << shift; shift += 8; } continue; + ***/ + } else if (code < 0x800) { + k2 = 0xC0 | code >> 6 | (0x80 | code & 0x3F) << 8; + bits = 16; + } else if (code < 0xD800 || code > 0xDFFF || pos >= end) { + // we check for pos>=end to encode an unpaired surrogate as 3 bytes. + k2 = 0xE0 | code >> 12 | (0x80 | code >> 6 & 0x3F) << 8 | (0x80 | code & 0x3F) << 16; + bits = 24; + } else { + // surrogate pair + // int utf32 = pos < end ? (int) data.charAt(pos++) : 0; + int utf32 = data.charAt(pos++); + utf32 = (code - 0xD7C0 << 10) + (utf32 & 0x3FF); + k2 = 0xff & (0xF0 | utf32 >> 18) | (0x80 | utf32 >> 12 & 0x3F) << 8 + | (0x80 | utf32 >> 6 & 0x3F) << 16 + | (0x80 | utf32 & 0x3F) << 24; + bits = 32; + } + + k1 |= k2 << shift; + + shift += bits; + if (shift >= 32) { + // mix after we have a complete word + + k1 *= c1; + k1 = k1 << 15 | k1 >>> 17; // ROTL32(k1,15); + k1 *= c2; + + h1 ^= k1; + h1 = h1 << 13 | h1 >>> 19; // ROTL32(h1,13); + h1 = h1 * 5 + 0xe6546b64; + + shift -= 32; + // unfortunately, java won't let you shift 32 bits off, so we need to check for 0 + if (shift != 0) { + k1 = k2 >>> bits - shift; // bits used == bits - newshift + } else { + k1 = 0; + } + nBytes += 4; + } + } // inner + + // handle tail + if (shift > 0) { + nBytes += shift >> 3; + k1 *= c1; + k1 = k1 << 15 | k1 >>> 17; // ROTL32(k1,15); + k1 *= c2; + h1 ^= k1; + } + + // finalization + h1 ^= nBytes; + + // fmix(h1); + h1 ^= h1 >>> 16; + h1 *= 0x85ebca6b; + h1 ^= h1 >>> 13; + h1 *= 0xc2b2ae35; + h1 ^= h1 >>> 16; + + return h1; + } + + /** + * Returns the MurmurHash3_x64_128 hash, placing the result in "out". + */ + public static void murmurhash3_x64_128(byte[] key, int offset, int len, int seed, LongPair out) { + // The original algorithm does have a 32 bit unsigned seed. + // We have to mask to match the behavior of the unsigned types and prevent sign extension. + long h1 = seed & 0x00000000FFFFFFFFL; + long h2 = seed & 0x00000000FFFFFFFFL; + + final long c1 = 0x87c37b91114253d5L; + final long c2 = 0x4cf5ad432745937fL; + + int roundedEnd = offset + (len & 0xFFFFFFF0); // round down to 16 byte block + for (int i = offset; i < roundedEnd; i += 16) { + long k1 = getLongLittleEndian(key, i); + long k2 = getLongLittleEndian(key, i + 8); + k1 *= c1; + k1 = Long.rotateLeft(k1, 31); + k1 *= c2; + h1 ^= k1; + h1 = Long.rotateLeft(h1, 27); + h1 += h2; + h1 = h1 * 5 + 0x52dce729; + k2 *= c2; + k2 = Long.rotateLeft(k2, 33); + k2 *= c1; + h2 ^= k2; + h2 = Long.rotateLeft(h2, 31); + h2 += h1; + h2 = h2 * 5 + 0x38495ab5; + } + + long k1 = 0; + long k2 = 0; + + switch (len & 15) { + case 15: + k2 = (key[roundedEnd + 14] & 0xffL) << 48; + case 14: + k2 |= (key[roundedEnd + 13] & 0xffL) << 40; + case 13: + k2 |= (key[roundedEnd + 12] & 0xffL) << 32; + case 12: + k2 |= (key[roundedEnd + 11] & 0xffL) << 24; + case 11: + k2 |= (key[roundedEnd + 10] & 0xffL) << 16; + case 10: + k2 |= (key[roundedEnd + 9] & 0xffL) << 8; + case 9: + k2 |= key[roundedEnd + 8] & 0xffL; + k2 *= c2; + k2 = Long.rotateLeft(k2, 33); + k2 *= c1; + h2 ^= k2; + case 8: + k1 = (long) key[roundedEnd + 7] << 56; + case 7: + k1 |= (key[roundedEnd + 6] & 0xffL) << 48; + case 6: + k1 |= (key[roundedEnd + 5] & 0xffL) << 40; + case 5: + k1 |= (key[roundedEnd + 4] & 0xffL) << 32; + case 4: + k1 |= (key[roundedEnd + 3] & 0xffL) << 24; + case 3: + k1 |= (key[roundedEnd + 2] & 0xffL) << 16; + case 2: + k1 |= (key[roundedEnd + 1] & 0xffL) << 8; + case 1: + k1 |= key[roundedEnd] & 0xffL; + k1 *= c1; + k1 = Long.rotateLeft(k1, 31); + k1 *= c2; + h1 ^= k1; + } + + // ---------- + // finalization + + h1 ^= len; + h2 ^= len; + + h1 += h2; + h2 += h1; + + h1 = fmix64(h1); + h2 = fmix64(h2); + + h1 += h2; + h2 += h1; + + out.val1 = h1; + out.val2 = h2; + } + + /** + * 128 bits of state + */ + public static final class LongPair { + + public long val1; + public long val2; + } +} diff --git a/src/main/java/bartworks/util/NoiseUtil/BartsNoise.java b/src/main/java/bartworks/util/NoiseUtil/BartsNoise.java new file mode 100644 index 0000000000..2130f27ccd --- /dev/null +++ b/src/main/java/bartworks/util/NoiseUtil/BartsNoise.java @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2018-2019 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.util.NoiseUtil; + +import java.util.Random; + +import bartworks.API.INoiseGen; +import bartworks.util.MathUtils; +import gregtech.api.objects.XSTR; + +public class BartsNoise implements INoiseGen { + + public void setUsePhase(boolean usePhase) { + this.usePhase = usePhase; + } + + public void setRandom(Random random) { + this.random = random; + } + + boolean usePhase; + int octaves; + double frequency; + double amplitude; + long seed; + Random random; + + public enum NoiseColor { + + Red(-1), + Pink(-0.5), + White(0), + Blue(0.5), + Violet(1); + + NoiseColor(double num) { + this.ampl = num; + } + + double ampl; + + public BartsNoise getColoredNoise() { + BartsNoise noise = new BartsNoise(); + noise.setAmplitude(this.ampl); + return noise; + } + } + + public BartsNoise(int octaves, double frequency, double amplitude, long seed) { + this.octaves = octaves; + this.frequency = frequency; + this.amplitude = amplitude; + this.seed = seed; + this.random = new XSTR(seed); + } + + public BartsNoise() { + this.seed = new XSTR().nextLong(); + this.random = new XSTR(this.seed); + this.octaves = 1; + this.frequency = this.random.nextGaussian(); + this.amplitude = this.random.nextGaussian(); + } + + public BartsNoise(long seed) { + this.seed = seed; + this.random = new XSTR(seed); + this.octaves = 1; + this.frequency = this.random.nextGaussian(); + this.amplitude = this.random.nextGaussian(); + } + + public BartsNoise copy() { + return new BartsNoise(this.octaves, this.frequency, this.amplitude, this.seed); + } + + public BartsNoise copy(long seed) { + return new BartsNoise(this.octaves, this.frequency, this.amplitude, seed); + } + + public double getCosNoise(double x, double y) { + double pr = x * this.frequency; + double r1 = Math.cos(pr); + if (r1 < 0) r1 = Math.abs(r1); + double result = Math.pow(r1, this.amplitude); + double pr2 = y * this.frequency; + double r2 = Math.cos(pr2); + if (r2 < 0) r2 = Math.abs(r2); + double result2 = Math.pow(r2, this.amplitude); + result *= result2; + if (result == Double.POSITIVE_INFINITY) result = Double.MAX_VALUE; + if (result == Double.NEGATIVE_INFINITY) result = Double.MIN_VALUE; + return MathUtils.wrap(result, 1D); + } + + double getNonOctavedNoise(double x, double y) { + double phase = SimplexNoise + .noise(Math.pow(x * this.frequency, this.amplitude), Math.pow(y * this.frequency, this.amplitude)); + return MathUtils.wrap(phase, 1); + } + + public double getNeighbouringNoise(int x, int y) { + return (this.getNoiseSingle(x - 1, y - 1) + this.getNoiseSingle(x, y - 1) + + this.getNoiseSingle(x - 1, y) + + this.getNoiseSingle(x + 1, y) + + this.getNoiseSingle(x, y + 1) + + this.getNoiseSingle(x + 1, y + 1) + + this.getNoiseSingle(x - 1, y + 1) + + this.getNoiseSingle(x + 1, y - 1)) / 8; + } + + public double getNoiseSingle(int x, int y) { + double result = 0; + for (double i = 1; i <= this.octaves; i++) { + result += 1d / i * this.getNonOctavedNoise(i * x, i * y); + } + return result; + } + + @Override + public double getNoise(int x, int y) { + double result = 0; + for (double i = 1; i <= this.octaves; i++) { + result += 1d / i * this.getNonOctavedNoise(i * x, y); + } + // result = (this.getNeighbouringNoise(x,y)+result)/2; + return MathUtils.wrap(result, 1D); + } + + @Override + public double[][] getNoiseForRegion(int xStart, int zStart, int xEnd, int zEnd) { + // double[][] results = new double[Math.abs(xEnd)-Math.abs(xStart)][Math.abs(zEnd)-Math.abs(zStart)]; + // for (int i = xStart; i < xEnd; i++) { + // for (int j = zStart; j < zEnd; j++) { + // results + // } + // } + return new double[0][0]; + } + + @Override + public void setAmplitude(double amplitude) { + this.amplitude = amplitude; + } + + @Override + public void setOctaves(int octaves) { + this.octaves = octaves; + } + + @Override + public void setFrequency(double freq) { + this.frequency = freq; + } + + @Override + public void setSeed(long seed) { + this.seed = seed; + } +} diff --git a/src/main/java/bartworks/util/NoiseUtil/SimplexNoise.java b/src/main/java/bartworks/util/NoiseUtil/SimplexNoise.java new file mode 100644 index 0000000000..ea2e571910 --- /dev/null +++ b/src/main/java/bartworks/util/NoiseUtil/SimplexNoise.java @@ -0,0 +1,396 @@ +package bartworks.util.NoiseUtil; +/* + * A speed-improved simplex noise algorithm for 2D, 3D and 4D in Java. Based on example code by Stefan Gustavson + * (stegu@itn.liu.se). Optimisations by Peter Eastman (peastman@drizzle.stanford.edu). Better rank ordering method by + * Stefan Gustavson in 2012. This could be speeded up even further, but it's useful as it is. Version 2012-03-09 This + * code was placed in the public domain by its original author, Stefan Gustavson. You may use it as you see fit, but + * attribution is appreciated. + */ + +import bartworks.util.MathUtils; + +public class SimplexNoise { // Simplex noise in 2D, 3D and 4D + + private static Grad[] grad3 = { new Grad(1, 1, 0), new Grad(-1, 1, 0), new Grad(1, -1, 0), new Grad(-1, -1, 0), + new Grad(1, 0, 1), new Grad(-1, 0, 1), new Grad(1, 0, -1), new Grad(-1, 0, -1), new Grad(0, 1, 1), + new Grad(0, -1, 1), new Grad(0, 1, -1), new Grad(0, -1, -1) }; + + private static Grad[] grad4 = { new Grad(0, 1, 1, 1), new Grad(0, 1, 1, -1), new Grad(0, 1, -1, 1), + new Grad(0, 1, -1, -1), new Grad(0, -1, 1, 1), new Grad(0, -1, 1, -1), new Grad(0, -1, -1, 1), + new Grad(0, -1, -1, -1), new Grad(1, 0, 1, 1), new Grad(1, 0, 1, -1), new Grad(1, 0, -1, 1), + new Grad(1, 0, -1, -1), new Grad(-1, 0, 1, 1), new Grad(-1, 0, 1, -1), new Grad(-1, 0, -1, 1), + new Grad(-1, 0, -1, -1), new Grad(1, 1, 0, 1), new Grad(1, 1, 0, -1), new Grad(1, -1, 0, 1), + new Grad(1, -1, 0, -1), new Grad(-1, 1, 0, 1), new Grad(-1, 1, 0, -1), new Grad(-1, -1, 0, 1), + new Grad(-1, -1, 0, -1), new Grad(1, 1, 1, 0), new Grad(1, 1, -1, 0), new Grad(1, -1, 1, 0), + new Grad(1, -1, -1, 0), new Grad(-1, 1, 1, 0), new Grad(-1, 1, -1, 0), new Grad(-1, -1, 1, 0), + new Grad(-1, -1, -1, 0) }; + + private static short[] p = { 151, 160, 137, 91, 90, 15, 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, + 30, 69, 142, 8, 99, 37, 240, 21, 10, 23, 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, + 35, 11, 32, 57, 177, 33, 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, + 27, 166, 77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41, 55, 46, 245, 40, 244, 102, + 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, 89, 18, 169, 200, 196, 135, 130, 116, 188, + 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123, 5, 202, 38, 147, 118, 126, 255, 82, + 85, 212, 207, 206, 59, 227, 47, 16, 58, 17, 182, 189, 28, 42, 223, 183, 170, 213, 119, 248, 152, 2, 44, 154, + 163, 70, 221, 153, 101, 155, 167, 43, 172, 9, 129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, + 112, 104, 218, 246, 97, 228, 251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, 249, + 14, 239, 107, 49, 192, 214, 31, 181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254, 138, + 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180 }; + // To remove the need for index wrapping, double the permutation table length + private static short[] perm = new short[512]; + private static short[] permMod12 = new short[512]; + + static { + for (int i = 0; i < 512; i++) { + perm[i] = p[i & 255]; + permMod12[i] = (short) (perm[i] % 12); + } + } + + // Skewing and unskewing factors for 2, 3, and 4 dimensions + private static final double F2 = 0.5 * (Math.sqrt(3.0) - 1.0); + private static final double G2 = (3.0 - Math.sqrt(3.0)) / 6.0; + private static final double F3 = 1.0 / 3.0; + private static final double G3 = 1.0 / 6.0; + private static final double F4 = (Math.sqrt(5.0) - 1.0) / 4.0; + private static final double G4 = (5.0 - Math.sqrt(5.0)) / 20.0; + + // This method is a *lot* faster than using (int)Math.floor(x) + private static int fastfloor(double x) { + return MathUtils.floorInt(x); + } + + private static double dot(Grad g, double x, double y) { + return g.x * x + g.y * y; + } + + private static double dot(Grad g, double x, double y, double z) { + return g.x * x + g.y * y + g.z * z; + } + + private static double dot(Grad g, double x, double y, double z, double w) { + return g.x * x + g.y * y + g.z * z + g.w * w; + } + + // 2D simplex noise + public static double noise(double xin, double yin) { + double n0, n1, n2; // Noise contributions from the three corners + // Skew the input space to determine which simplex cell we're in + double s = (xin + yin) * F2; // Hairy factor for 2D + int i = fastfloor(xin + s); + int j = fastfloor(yin + s); + double t = (i + j) * G2; + double X0 = i - t; // Unskew the cell origin back to (x,y) space + double Y0 = j - t; + double x0 = xin - X0; // The x,y distances from the cell origin + double y0 = yin - Y0; + // For the 2D case, the simplex shape is an equilateral triangle. + // Determine which simplex we are in. + int i1, j1; // Offsets for second (middle) corner of simplex in (i,j) coords + if (x0 > y0) { + i1 = 1; + j1 = 0; + } // lower triangle, XY order: (0,0)->(1,0)->(1,1) + else { + i1 = 0; + j1 = 1; + } // upper triangle, YX order: (0,0)->(0,1)->(1,1) + // A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and + // a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where + // c = (3-sqrt(3))/6 + double x1 = x0 - i1 + G2; // Offsets for middle corner in (x,y) unskewed coords + double y1 = y0 - j1 + G2; + double x2 = x0 - 1.0 + 2.0 * G2; // Offsets for last corner in (x,y) unskewed coords + double y2 = y0 - 1.0 + 2.0 * G2; + // Work out the hashed gradient indices of the three simplex corners + int ii = i & 255; + int jj = j & 255; + int gi0 = permMod12[ii + perm[jj]]; + int gi1 = permMod12[ii + i1 + perm[jj + j1]]; + int gi2 = permMod12[ii + 1 + perm[jj + 1]]; + // Calculate the contribution from the three corners + double t0 = 0.5 - x0 * x0 - y0 * y0; + if (t0 < 0) n0 = 0.0; + else { + t0 *= t0; + n0 = t0 * t0 * dot(grad3[gi0], x0, y0); // (x,y) of grad3 used for 2D gradient + } + double t1 = 0.5 - x1 * x1 - y1 * y1; + if (t1 < 0) n1 = 0.0; + else { + t1 *= t1; + n1 = t1 * t1 * dot(grad3[gi1], x1, y1); + } + double t2 = 0.5 - x2 * x2 - y2 * y2; + if (t2 < 0) n2 = 0.0; + else { + t2 *= t2; + n2 = t2 * t2 * dot(grad3[gi2], x2, y2); + } + // Add contributions from each corner to get the final noise value. + // The result is scaled to return values in the interval [-1,1]. + return 70.0 * (n0 + n1 + n2); + } + + // 3D simplex noise + public static double noise(double xin, double yin, double zin) { + double n0, n1, n2, n3; // Noise contributions from the four corners + // Skew the input space to determine which simplex cell we're in + double s = (xin + yin + zin) * F3; // Very nice and simple skew factor for 3D + int i = fastfloor(xin + s); + int j = fastfloor(yin + s); + int k = fastfloor(zin + s); + double t = (i + j + k) * G3; + double X0 = i - t; // Unskew the cell origin back to (x,y,z) space + double Y0 = j - t; + double Z0 = k - t; + double x0 = xin - X0; // The x,y,z distances from the cell origin + double y0 = yin - Y0; + double z0 = zin - Z0; + // For the 3D case, the simplex shape is a slightly irregular tetrahedron. + // Determine which simplex we are in. + int i1, j1, k1; // Offsets for second corner of simplex in (i,j,k) coords + int i2, j2, k2; // Offsets for third corner of simplex in (i,j,k) coords + if (x0 >= y0) { + if (y0 >= z0) { + i1 = 1; + j1 = 0; + k1 = 0; + i2 = 1; + j2 = 1; + k2 = 0; + } // X Y Z order + else { + if (x0 >= z0) { + i1 = 1; + j1 = 0; + k1 = 0; + } // X Z Y order + else { + i1 = 0; + j1 = 0; + k1 = 1; + } + i2 = 1; + j2 = 0; + k2 = 1; + } // Z X Y order + } else if (y0 < z0) { + i1 = 0; + j1 = 0; + k1 = 1; + i2 = 0; + j2 = 1; + k2 = 1; + } // Z Y X order + else if (x0 < z0) { + i1 = 0; + j1 = 1; + k1 = 0; + i2 = 0; + j2 = 1; + k2 = 1; + } // Y Z X order + else { + i1 = 0; + j1 = 1; + k1 = 0; + i2 = 1; + j2 = 1; + k2 = 0; + } // Y X Z order + // A step of (1,0,0) in (i,j,k) means a step of (1-c,-c,-c) in (x,y,z), + // a step of (0,1,0) in (i,j,k) means a step of (-c,1-c,-c) in (x,y,z), and + // a step of (0,0,1) in (i,j,k) means a step of (-c,-c,1-c) in (x,y,z), where + // c = 1/6. + double x1 = x0 - i1 + G3; // Offsets for second corner in (x,y,z) coords + double y1 = y0 - j1 + G3; + double z1 = z0 - k1 + G3; + double x2 = x0 - i2 + 2.0 * G3; // Offsets for third corner in (x,y,z) coords + double y2 = y0 - j2 + 2.0 * G3; + double z2 = z0 - k2 + 2.0 * G3; + double x3 = x0 - 1.0 + 3.0 * G3; // Offsets for last corner in (x,y,z) coords + double y3 = y0 - 1.0 + 3.0 * G3; + double z3 = z0 - 1.0 + 3.0 * G3; + // Work out the hashed gradient indices of the four simplex corners + int ii = i & 255; + int jj = j & 255; + int kk = k & 255; + int gi0 = permMod12[ii + perm[jj + perm[kk]]]; + int gi1 = permMod12[ii + i1 + perm[jj + j1 + perm[kk + k1]]]; + int gi2 = permMod12[ii + i2 + perm[jj + j2 + perm[kk + k2]]]; + int gi3 = permMod12[ii + 1 + perm[jj + 1 + perm[kk + 1]]]; + // Calculate the contribution from the four corners + double t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0; + if (t0 < 0) n0 = 0.0; + else { + t0 *= t0; + n0 = t0 * t0 * dot(grad3[gi0], x0, y0, z0); + } + double t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1; + if (t1 < 0) n1 = 0.0; + else { + t1 *= t1; + n1 = t1 * t1 * dot(grad3[gi1], x1, y1, z1); + } + double t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2; + if (t2 < 0) n2 = 0.0; + else { + t2 *= t2; + n2 = t2 * t2 * dot(grad3[gi2], x2, y2, z2); + } + double t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3; + if (t3 < 0) n3 = 0.0; + else { + t3 *= t3; + n3 = t3 * t3 * dot(grad3[gi3], x3, y3, z3); + } + // Add contributions from each corner to get the final noise value. + // The result is scaled to stay just inside [-1,1] + return 32.0 * (n0 + n1 + n2 + n3); + } + + // 4D simplex noise, better simplex rank ordering method 2012-03-09 + public static double noise(double x, double y, double z, double w) { + + double n0, n1, n2, n3, n4; // Noise contributions from the five corners + // Skew the (x,y,z,w) space to determine which cell of 24 simplices we're in + double s = (x + y + z + w) * F4; // Factor for 4D skewing + int i = fastfloor(x + s); + int j = fastfloor(y + s); + int k = fastfloor(z + s); + int l = fastfloor(w + s); + double t = (i + j + k + l) * G4; // Factor for 4D unskewing + double X0 = i - t; // Unskew the cell origin back to (x,y,z,w) space + double Y0 = j - t; + double Z0 = k - t; + double W0 = l - t; + double x0 = x - X0; // The x,y,z,w distances from the cell origin + double y0 = y - Y0; + double z0 = z - Z0; + double w0 = w - W0; + // For the 4D case, the simplex is a 4D shape I won't even try to describe. + // To find out which of the 24 possible simplices we're in, we need to + // determine the magnitude ordering of x0, y0, z0 and w0. + // Six pair-wise comparisons are performed between each possible pair + // of the four coordinates, and the results are used to rank the numbers. + int rankx = 0; + int ranky = 0; + int rankz = 0; + int rankw = 0; + if (x0 > y0) rankx++; + else ranky++; + if (x0 > z0) rankx++; + else rankz++; + if (x0 > w0) rankx++; + else rankw++; + if (y0 > z0) ranky++; + else rankz++; + if (y0 > w0) ranky++; + else rankw++; + if (z0 > w0) rankz++; + else rankw++; + int i1, j1, k1, l1; // The integer offsets for the second simplex corner + int i2, j2, k2, l2; // The integer offsets for the third simplex corner + int i3, j3, k3, l3; // The integer offsets for the fourth simplex corner + // simplex[c] is a 4-vector with the numbers 0, 1, 2 and 3 in some order. + // Many values of c will never occur, since e.g. x>y>z>w makes x<z, y<w and x<w + // impossible. Only the 24 indices which have non-zero entries make any sense. + // We use a thresholding to set the coordinates in turn from the largest magnitude. + // Rank 3 denotes the largest coordinate. + i1 = rankx >= 3 ? 1 : 0; + j1 = ranky >= 3 ? 1 : 0; + k1 = rankz >= 3 ? 1 : 0; + l1 = rankw >= 3 ? 1 : 0; + // Rank 2 denotes the second largest coordinate. + i2 = rankx >= 2 ? 1 : 0; + j2 = ranky >= 2 ? 1 : 0; + k2 = rankz >= 2 ? 1 : 0; + l2 = rankw >= 2 ? 1 : 0; + // Rank 1 denotes the second smallest coordinate. + i3 = rankx >= 1 ? 1 : 0; + j3 = ranky >= 1 ? 1 : 0; + k3 = rankz >= 1 ? 1 : 0; + l3 = rankw >= 1 ? 1 : 0; + // The fifth corner has all coordinate offsets = 1, so no need to compute that. + double x1 = x0 - i1 + G4; // Offsets for second corner in (x,y,z,w) coords + double y1 = y0 - j1 + G4; + double z1 = z0 - k1 + G4; + double w1 = w0 - l1 + G4; + double x2 = x0 - i2 + 2.0 * G4; // Offsets for third corner in (x,y,z,w) coords + double y2 = y0 - j2 + 2.0 * G4; + double z2 = z0 - k2 + 2.0 * G4; + double w2 = w0 - l2 + 2.0 * G4; + double x3 = x0 - i3 + 3.0 * G4; // Offsets for fourth corner in (x,y,z,w) coords + double y3 = y0 - j3 + 3.0 * G4; + double z3 = z0 - k3 + 3.0 * G4; + double w3 = w0 - l3 + 3.0 * G4; + double x4 = x0 - 1.0 + 4.0 * G4; // Offsets for last corner in (x,y,z,w) coords + double y4 = y0 - 1.0 + 4.0 * G4; + double z4 = z0 - 1.0 + 4.0 * G4; + double w4 = w0 - 1.0 + 4.0 * G4; + // Work out the hashed gradient indices of the five simplex corners + int ii = i & 255; + int jj = j & 255; + int kk = k & 255; + int ll = l & 255; + int gi0 = perm[ii + perm[jj + perm[kk + perm[ll]]]] % 32; + int gi1 = perm[ii + i1 + perm[jj + j1 + perm[kk + k1 + perm[ll + l1]]]] % 32; + int gi2 = perm[ii + i2 + perm[jj + j2 + perm[kk + k2 + perm[ll + l2]]]] % 32; + int gi3 = perm[ii + i3 + perm[jj + j3 + perm[kk + k3 + perm[ll + l3]]]] % 32; + int gi4 = perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]] % 32; + // Calculate the contribution from the five corners + double t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0 - w0 * w0; + if (t0 < 0) n0 = 0.0; + else { + t0 *= t0; + n0 = t0 * t0 * dot(grad4[gi0], x0, y0, z0, w0); + } + double t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1 - w1 * w1; + if (t1 < 0) n1 = 0.0; + else { + t1 *= t1; + n1 = t1 * t1 * dot(grad4[gi1], x1, y1, z1, w1); + } + double t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2 - w2 * w2; + if (t2 < 0) n2 = 0.0; + else { + t2 *= t2; + n2 = t2 * t2 * dot(grad4[gi2], x2, y2, z2, w2); + } + double t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3 - w3 * w3; + if (t3 < 0) n3 = 0.0; + else { + t3 *= t3; + n3 = t3 * t3 * dot(grad4[gi3], x3, y3, z3, w3); + } + double t4 = 0.6 - x4 * x4 - y4 * y4 - z4 * z4 - w4 * w4; + if (t4 < 0) n4 = 0.0; + else { + t4 *= t4; + n4 = t4 * t4 * dot(grad4[gi4], x4, y4, z4, w4); + } + // Sum up and scale the result to cover the range [-1,1] + return 27.0 * (n0 + n1 + n2 + n3 + n4); + } + + // Inner class to speed upp gradient computations + // (array access is a lot slower than member access) + private static class Grad { + + double x, y, z, w; + + Grad(double x, double y, double z) { + this.x = x; + this.y = y; + this.z = z; + } + + Grad(double x, double y, double z, double w) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + } +} diff --git a/src/main/java/bartworks/util/NonNullWrappedHashMap.java b/src/main/java/bartworks/util/NonNullWrappedHashMap.java new file mode 100644 index 0000000000..a11cb6a6af --- /dev/null +++ b/src/main/java/bartworks/util/NonNullWrappedHashMap.java @@ -0,0 +1,56 @@ +/* + * 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.util; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +public class NonNullWrappedHashMap<K, V> extends HashMap<K, V> { + + private static final long serialVersionUID = 46345163103910175L; + private V defaultValue; + + public NonNullWrappedHashMap(int initialCapacity, float loadFactor, V defaultValue) { + super(initialCapacity, loadFactor); + this.defaultValue = Objects.requireNonNull(defaultValue); + } + + public NonNullWrappedHashMap(int initialCapacity, V defaultValue) { + super(initialCapacity); + this.defaultValue = Objects.requireNonNull(defaultValue); + } + + public NonNullWrappedHashMap(V defaultValue) { + this.defaultValue = Objects.requireNonNull(defaultValue); + } + + public NonNullWrappedHashMap(Map<? extends K, ? extends V> m, V defaultValue) { + super(m); + this.defaultValue = Objects.requireNonNull(defaultValue); + } + + @Override + public V get(Object key) { + return this.getOrDefault(key, this.defaultValue); + } + + @Override + public V getOrDefault(Object key, V defaultValue) { + return Objects.requireNonNull( + Optional.ofNullable(super.getOrDefault(key, defaultValue)) + .orElse(this.defaultValue)); + } +} diff --git a/src/main/java/bartworks/util/NonNullWrappedHashSet.java b/src/main/java/bartworks/util/NonNullWrappedHashSet.java new file mode 100644 index 0000000000..c9ad90a616 --- /dev/null +++ b/src/main/java/bartworks/util/NonNullWrappedHashSet.java @@ -0,0 +1,51 @@ +/* + * 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.util; + +import java.util.Collection; +import java.util.HashSet; + +public class NonNullWrappedHashSet<E> extends HashSet<E> { + + private static final long serialVersionUID = 8377161849188229010L; + + public NonNullWrappedHashSet() {} + + public NonNullWrappedHashSet(Collection<? extends E> c) { + this.addAll(c); + } + + public NonNullWrappedHashSet(int initialCapacity, float loadFactor) { + super(initialCapacity, loadFactor); + } + + public NonNullWrappedHashSet(int initialCapacity) { + super(initialCapacity); + } + + @Override + public boolean add(E e) { + if (e != null) return super.add(e); + return false; + } + + @Override + public boolean addAll(Collection<? extends E> c) { + boolean wasChanged = false; + for (E element : c) { + if (element != null) wasChanged |= this.add(element); + } + return wasChanged; + } +} diff --git a/src/main/java/bartworks/util/Pair.java b/src/main/java/bartworks/util/Pair.java new file mode 100644 index 0000000000..1361460e31 --- /dev/null +++ b/src/main/java/bartworks/util/Pair.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2018-2019 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.util; + +import java.nio.ByteBuffer; +import java.util.Arrays; +import java.util.Map; + +@SuppressWarnings("unchecked") +public class Pair<A, B> implements Map.Entry<A, B> { + + Object[] pair = new Object[2]; + + public Pair(Object[] pair) { + this.pair = pair; + } + + public Pair(A k, B v) { + this.pair[0] = k; + this.pair[1] = v; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Pair)) return false; + + Pair<?, ?> pair1 = (Pair<?, ?>) o; + + // Probably incorrect - comparing Object[] arrays with Arrays.equals + return Arrays.equals(this.pair, pair1.pair); + } + + @Override + public int hashCode() { + return MurmurHash3.murmurhash3_x86_32( + ByteBuffer.allocate(8) + .putInt(this.pair[0].hashCode()) + .putInt(this.pair[1].hashCode()) + .array(), + 0, + 8, + 31); + } + + @Override + public A getKey() { + return (A) this.pair[0]; + } + + @Override + public B getValue() { + return (B) this.pair[1]; + } + + @Override + public B setValue(Object value) { + this.pair[1] = value; + return (B) this.pair[1]; + } + + public Pair<A, B> copyWithNewValue(B value) { + return new Pair<>((A) this.pair[0], value); + } + + public Pair<A, B> replaceValue(B value) { + this.setValue(value); + return this; + } +} diff --git a/src/main/java/bartworks/util/ResultWrongSievert.java b/src/main/java/bartworks/util/ResultWrongSievert.java new file mode 100644 index 0000000000..fd1f7ce25b --- /dev/null +++ b/src/main/java/bartworks/util/ResultWrongSievert.java @@ -0,0 +1,97 @@ +package bartworks.util; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.PacketBuffer; +import net.minecraft.util.StatCollector; + +import org.jetbrains.annotations.NotNull; + +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.util.GTUtility; + +public class ResultWrongSievert implements CheckRecipeResult { + + public enum NeededSievertType { + EXACTLY, + MINIMUM + } + + private NeededSievertType type; + private int required; + + public ResultWrongSievert(int required, NeededSievertType type) { + this.required = required; + this.type = type; + } + + public @NotNull String getID() { + return "wrong_sievert"; + } + + @Override + public boolean wasSuccessful() { + return false; + } + + @Override + public @NotNull String getDisplayString() { + return switch (this.type) { + case EXACTLY -> StatCollector.translateToLocalFormatted( + "GT5U.gui.text.wrong_sievert_exactly", + GTUtility.formatNumbers(this.required)); + case MINIMUM -> StatCollector + .translateToLocalFormatted("GT5U.gui.text.wrong_sievert_min", GTUtility.formatNumbers(this.required)); + }; + } + + @Override + public @NotNull NBTTagCompound writeToNBT(@NotNull NBTTagCompound tag) { + tag.setInteger("required", required); + tag.setInteger("type", type.ordinal()); + return tag; + } + + @Override + public void readFromNBT(@NotNull NBTTagCompound tag) { + required = tag.getInteger("required"); + } + + @Override + public @NotNull CheckRecipeResult newInstance() { + return new ResultWrongSievert(0, NeededSievertType.EXACTLY); + } + + @Override + public void encode(@NotNull PacketBuffer buffer) { + buffer.writeVarIntToBuffer(this.required); + buffer.writeVarIntToBuffer(this.type.ordinal()); + } + + @Override + public void decode(PacketBuffer buffer) { + this.required = buffer.readVarIntFromBuffer(); + this.type = NeededSievertType.values()[buffer.readVarIntFromBuffer()]; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + ResultWrongSievert that = (ResultWrongSievert) o; + return this.required == that.required; + } + + /** + * Cannot process recipe because the machine doesn't have the minimum amount of sievert + */ + public static CheckRecipeResult insufficientSievert(int required) { + return new ResultWrongSievert(required, NeededSievertType.MINIMUM); + } + + /** + * Cannot process recipe because the machine doesn't have the exact amount of sievert + */ + public static CheckRecipeResult wrongSievert(int required) { + return new ResultWrongSievert(required, NeededSievertType.EXACTLY); + } +} diff --git a/src/main/java/bartworks/util/StreamUtils.java b/src/main/java/bartworks/util/StreamUtils.java new file mode 100644 index 0000000000..d26d2eb40d --- /dev/null +++ b/src/main/java/bartworks/util/StreamUtils.java @@ -0,0 +1,38 @@ +/* + * 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.util; + +import java.util.Optional; +import java.util.function.Predicate; + +import gregtech.api.recipe.RecipeMap; +import gregtech.api.util.GTRecipe; + +public class StreamUtils { + + private StreamUtils() {} + + public static Predicate<RecipeMap<?>> filterVisualMaps() { + return recipeMap -> { + Optional<GTRecipe> op = recipeMap.getAllRecipes() + .stream() + .findAny(); + return op.isPresent() && !op.get().mFakeRecipe; + }; + } + + public static boolean filterVisualMaps(RecipeMap<?> recipeMap) { + return filterVisualMaps().test(recipeMap); + } +} diff --git a/src/main/java/bartworks/util/accessprioritylist/AccessPriorityList.java b/src/main/java/bartworks/util/accessprioritylist/AccessPriorityList.java new file mode 100644 index 0000000000..7a41b712b5 --- /dev/null +++ b/src/main/java/bartworks/util/accessprioritylist/AccessPriorityList.java @@ -0,0 +1,388 @@ +/* + * Copyright (c) 2018-2019 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.util.accessprioritylist; + +import java.util.Collection; +import java.util.Deque; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.Set; +import java.util.Spliterator; + +import org.apache.commons.lang3.NotImplementedException; + +public class AccessPriorityList<E> implements List<E>, Deque<E>, Set<E> { + + transient int size = 0; + transient AccessPriorityListNode<E> head; + transient AccessPriorityListNode<E> tail; + + public static <E> AccessPriorityList<E> create() { + return new AccessPriorityList<>(); + } + + public AccessPriorityList() {} + + @Override + public void addFirst(E t) { + final AccessPriorityListNode<E> first = this.head; + final AccessPriorityListNode<E> newNode = new AccessPriorityListNode<>(null, t, first); + this.head = newNode; + if (first == null) this.tail = newNode; + else first.setBefore(newNode); + this.size++; + } + + @Override + public void addLast(E t) { + final AccessPriorityListNode<E> last = this.tail; + final AccessPriorityListNode<E> newNode = new AccessPriorityListNode<>(last, t, null); + this.tail = newNode; + if (last == null) this.head = newNode; + else last.setNext(newNode); + this.size++; + } + + @Override + public boolean offerFirst(E e) { + throw new NotImplementedException(""); + } + + @Override + public boolean offerLast(E e) { + throw new NotImplementedException(""); + } + + @Override + public E removeFirst() { + E first = this.head.getELEMENT(); + AccessPriorityListNode<E> node = this.head; + this.head = node.getNext(); + this.head.setBefore(null); + node.destroy(); + node = null; + this.size--; + return first; + } + + @Override + public E removeLast() { + E last = this.tail.getELEMENT(); + AccessPriorityListNode<E> node = this.tail; + this.tail = node.getBefore(); + this.tail.setNext(null); + node.destroy(); + node = null; + this.size--; + return last; + } + + @Override + public E pollFirst() { + throw new NotImplementedException(""); + } + + @Override + public E pollLast() { + throw new NotImplementedException(""); + } + + @Override + public E getFirst() { + return this.peekFirst(); + } + + @Override + public E getLast() { + return this.peekLast(); + } + + @Override + public E peekFirst() { + return this.head != null ? this.head.getELEMENT() : null; + } + + @Override + public E peekLast() { + return this.tail != null ? this.tail.getELEMENT() : null; + } + + @Override + public boolean removeFirstOccurrence(Object o) { + throw new NotImplementedException(""); + } + + @Override + public boolean removeLastOccurrence(Object o) { + throw new NotImplementedException(""); + } + + @Override + public int size() { + return this.size; + } + + @Override + public boolean isEmpty() { + return this.size == 0; + } + + @Override + public boolean contains(Object o) { + throw new NotImplementedException(""); + } + + @Override + public Iterator<E> iterator() { + return new AccessPriorityListIterators.AccessPriorityListIterator<>(this.head); + } + + public Iterator<AccessPriorityListNode<E>> nodeIterator() { + return new AccessPriorityListIterators.AccessPriorityListNodeIterator<>(this.head); + } + + @Override + public Iterator<E> descendingIterator() { + return new AccessPriorityListIterators.AccessPriorityListReverseIterator<>(this.tail); + } + + @Override + public Object[] toArray() { + Object[] ret = new Object[this.size]; + int index = 0; + for (Iterator<E> it = this.iterator(); it.hasNext(); index++) ret[index] = it.next(); + return ret; + } + + @Override + public <T> T[] toArray(T[] a) { + T[] ret = (T[]) new Object[this.size]; + int index = 0; + for (Iterator<T> it = (Iterator<T>) this.iterator(); it.hasNext(); index++) ret[index] = it.next(); + return ret; + } + + @Override + public boolean add(E e) { + this.addLast(e); + return true; + } + + private void moveNodeUp(AccessPriorityListNode<E> node) { + if (node == this.head || node.getBefore() == null) return; + final AccessPriorityListNode<E> before = node.getBefore(); + final AccessPriorityListNode<E> beforeBefore = before.getBefore(); + final AccessPriorityListNode<E> next = node.getNext(); + + // <0,1,2> <1,2,3> N<2,3,4> <3,4,5> + + node.setBefore(beforeBefore); + // <0,1,2> <1,2,3> N<0,3,4> <3,4,5> + + if (beforeBefore != null) beforeBefore.setNext(node); + else this.head = node; + // <0,1,3> <1,2,3> N<0,3,4> <3,4,5> + + before.setBefore(node); + // <0,1,3> <3,2,3> N<0,3,4> <3,4,5> + + before.setNext(next); + // <0,1,3> <3,2,4> N<0,3,4> <3,4,5> + + if (next != null) next.setBefore(before); + else this.tail = before; + // <0,1,3> N<0,3,4> <3,2,4> <2,4,5> + + node.setNext(before); + // <0,1,3> N<0,3,2> <3,2,4> <2,4,5> + } + + AccessPriorityListNode<E> getNode(int index) { + if (index <= this.size / 2) { + AccessPriorityListNode<E> x = this.head; + for (int i = 0; i < index; i++) x = x.getNext(); + return x; + } + AccessPriorityListNode<E> x = this.tail; + for (int i = this.size - 1; i > index; i--) x = x.getBefore(); + return x; + } + + @Override + public boolean offer(E e) { + throw new NotImplementedException(""); + } + + private boolean isValidIndex(int index) { + if (index >= 0 && index < this.size) return true; + throw new ArrayIndexOutOfBoundsException("NOT A VAILD INDEX!"); + } + + @Override + public E remove() { + throw new NotImplementedException(""); + } + + @Override + public E poll() { + return this.removeFirst(); + } + + @Override + public E element() { + throw new NotImplementedException(""); + } + + @Override + public E peek() { + return this.getFirst(); + } + + @Override + public void push(E e) { + this.addFirst(e); + } + + @Override + public E pop() { + return this.removeFirst(); + } + + @Override + public boolean remove(Object o) { + throw new NotImplementedException(""); + } + + @Override + public boolean containsAll(Collection<?> c) { + throw new NotImplementedException(""); + } + + @Override + public boolean addAll(Collection<? extends E> c) { + if (c == null) return false; + c.forEach(this::addLast); + return true; + } + + @Override + public boolean addAll(int index, Collection<? extends E> c) { + throw new NotImplementedException(""); + } + + @Override + public boolean removeAll(Collection<?> c) { + throw new NotImplementedException(""); + } + + @Override + public boolean retainAll(Collection<?> c) { + throw new NotImplementedException(""); + } + + @Override + public void clear() { + if (this.tail != null) { + AccessPriorityListNode<E> node = this.tail; + while (node.getBefore() != null) { + node.setNext(null); + node.setPriority(0L); + node = node.getBefore(); + node.getNext() + .setBefore(null); + } + this.size = 0; + this.head = null; + this.tail = null; + } + } + + public void addPrioToNode(AccessPriorityListNode<E> node) { + this.addPrioToNode(node, 1L); + } + + public void addPrioToNode(AccessPriorityListNode<E> node, long prio) { + long current = node.getPriority(); + if (current == Long.MAX_VALUE || current > 0 && prio > 0 && prio + current < 0) + node.setPriority(Long.MAX_VALUE); + else node.setPriority(current + prio); + while (node.getBefore() != null && node.getPriority() >= node.getBefore() + .getPriority()) { + this.moveNodeUp(node); + } + } + + public void addPrioToNode(int index, long prio) { + if (!this.isValidIndex(index)) return; + AccessPriorityListNode<E> node = this.getNode(index); + this.addPrioToNode(node, prio); + } + + public void addPrioToNode(int index) { + this.addPrioToNode(index, 1L); + } + + @Override + public E get(int index) { + if (!this.isValidIndex(index)) return null; + AccessPriorityListNode<E> node = this.getNode(index); + return node.getELEMENT(); + } + + @Override + public E set(int index, E element) { + throw new NotImplementedException(""); + } + + @Override + public void add(int index, E element) { + throw new NotImplementedException(""); + } + + @Override + public E remove(int index) { + throw new NotImplementedException(""); + } + + @Override + public int indexOf(Object o) { + throw new NotImplementedException(""); + } + + @Override + public int lastIndexOf(Object o) { + throw new NotImplementedException(""); + } + + @Override + public ListIterator<E> listIterator() { + return new AccessPriorityListIterators.AccessPriorityListListIterator<>(this.head, this.tail, false); + } + + @Override + public ListIterator<E> listIterator(int index) { + return new AccessPriorityListIterators.AccessPriorityListListIterator<>(this, index); + } + + @Override + public List<E> subList(int fromIndex, int toIndex) { + throw new NotImplementedException(""); + } + + @Override + public Spliterator<E> spliterator() { + throw new NotImplementedException(""); + } +} diff --git a/src/main/java/bartworks/util/accessprioritylist/AccessPriorityListIterators.java b/src/main/java/bartworks/util/accessprioritylist/AccessPriorityListIterators.java new file mode 100644 index 0000000000..ebdda6b302 --- /dev/null +++ b/src/main/java/bartworks/util/accessprioritylist/AccessPriorityListIterators.java @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2018-2019 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.util.accessprioritylist; + +import java.util.Iterator; +import java.util.ListIterator; + +import org.apache.commons.lang3.NotImplementedException; + +public class AccessPriorityListIterators { + + public static class AccessPriorityListListIterator<E> implements ListIterator<E> { + + final AccessPriorityListNode<E> head; + final AccessPriorityListNode<E> tail; + AccessPriorityListNode<E> current; + int counter = 0; + boolean reverse; + + public AccessPriorityListListIterator(AccessPriorityListNode<E> head, AccessPriorityListNode<E> tail, + boolean reverse) { + this.head = head; + this.tail = tail; + this.current = reverse ? tail : head; + this.reverse = reverse; + } + + public AccessPriorityListListIterator(AccessPriorityList<E> list, int index) { + this.head = list.head; + this.tail = list.tail; + this.current = list.getNode(index); + this.counter = index; + } + + @Override + public boolean hasNext() { + return this.reverse ? this.head != this.current : this.tail != this.current; + } + + @Override + public E next() { + this.counter++; + E ret = this.current.getELEMENT(); + this.current = this.current.getNext(); + return ret; + } + + @Override + public boolean hasPrevious() { + return !this.reverse ? this.head != this.current : this.tail != this.current; + } + + @Override + public E previous() { + this.counter--; + E ret = this.current.getELEMENT(); + this.current = this.current.getBefore(); + return ret; + } + + @Override + public int nextIndex() { + return this.counter + 1; + } + + @Override + public int previousIndex() { + return this.counter - 1; + } + + @Override + public void remove() { + throw new NotImplementedException("Not Implemented"); + } + + @Override + public void set(E e) { + throw new NotImplementedException("Not Implemented"); + } + + @Override + public void add(E e) { + throw new NotImplementedException("Not Implemented"); + } + } + + public static class AccessPriorityListIterator<E> implements Iterator<E> { + + final AccessPriorityListNode<E> head; + AccessPriorityListNode<E> current; + + public AccessPriorityListIterator(AccessPriorityListNode<E> head) { + this.head = this.current = head; + } + + @Override + public boolean hasNext() { + return this.current != null; + } + + @Override + public E next() { + E ret = this.current.getELEMENT(); + this.current = this.current.getNext(); + return ret; + } + } + + public static class AccessPriorityListReverseIterator<E> implements Iterator<E> { + + final AccessPriorityListNode<E> tail; + AccessPriorityListNode<E> current; + + public AccessPriorityListReverseIterator(AccessPriorityListNode<E> tail) { + this.tail = this.current = tail; + } + + @Override + public boolean hasNext() { + return this.current != null; + } + + @Override + public E next() { + E ret = this.current.getELEMENT(); + this.current = this.current.getBefore(); + return ret; + } + } + + public static class AccessPriorityListNodeIterator<E> implements Iterator<AccessPriorityListNode<E>> { + + final AccessPriorityListNode<E> head; + AccessPriorityListNode<E> current; + + public AccessPriorityListNodeIterator(AccessPriorityListNode<E> head) { + this.head = this.current = head; + } + + @Override + public boolean hasNext() { + return this.current != null; + } + + @Override + public AccessPriorityListNode<E> next() { + AccessPriorityListNode<E> ret = this.current; + this.current = this.current.getNext(); + return ret; + } + } +} diff --git a/src/main/java/bartworks/util/accessprioritylist/AccessPriorityListNode.java b/src/main/java/bartworks/util/accessprioritylist/AccessPriorityListNode.java new file mode 100644 index 0000000000..12788c82c8 --- /dev/null +++ b/src/main/java/bartworks/util/accessprioritylist/AccessPriorityListNode.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2018-2019 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.util.accessprioritylist; + +public class AccessPriorityListNode<E> { + + public static final AccessPriorityListNode<?> EMPTY_NODE = new AccessPriorityListNode<>(null); + + private final E ELEMENT; + private long priority = Long.MIN_VALUE; + private AccessPriorityListNode<E> next; + private AccessPriorityListNode<E> before; + + public AccessPriorityListNode(E element) { + this.ELEMENT = element; + } + + public AccessPriorityListNode(AccessPriorityListNode<E> before, E element, AccessPriorityListNode<E> next) { + this.ELEMENT = element; + this.connect(next, before); + } + + public void connect(AccessPriorityListNode<E> next, AccessPriorityListNode<E> before) { + this.setNext(next); + this.setBefore(before); + } + + public E getELEMENT() { + return this.ELEMENT; + } + + public long getPriority() { + return this.priority; + } + + public void setPriority(long priority) { + this.priority = priority; + } + + public AccessPriorityListNode<E> getNext() { + return this.next; + } + + public void setNext(AccessPriorityListNode<E> next) { + this.next = next; + } + + public AccessPriorityListNode<E> getBefore() { + return this.before; + } + + public void setBefore(AccessPriorityListNode<E> before) { + this.before = before; + } + + void destroy() { + this.before = null; + this.next = null; + this.priority = 0L; + } +} diff --git a/src/main/java/bartworks/util/flowerset/FlowerSet.java b/src/main/java/bartworks/util/flowerset/FlowerSet.java new file mode 100644 index 0000000000..99954d1860 --- /dev/null +++ b/src/main/java/bartworks/util/flowerset/FlowerSet.java @@ -0,0 +1,146 @@ +/* + * 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.util.flowerset; + +import java.util.Collection; +import java.util.Iterator; +import java.util.Set; +import java.util.function.Function; + +public class FlowerSet<T> implements Set<T> { + + public FlowerSet(int petals, Function<FlowerNode<T>, Integer> comparerison) { + this.petals = petals; + this.comparerison = comparerison; + } + + final int petals; + final Function<FlowerNode<T>, Integer> comparerison; + + public static <U> FlowerSet<U> createBase64(Function<FlowerNode<U>, Integer> comparerison) { + return new FlowerSet<>(64, comparerison); + } + + public static <U> FlowerSet<U> createHexflower(Function<FlowerNode<U>, Integer> comparerison) { + return new FlowerSet<>(16, comparerison); + } + + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator<T> iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public <T1> T1[] toArray(T1[] a) { + return null; + } + + @Override + public boolean add(T t) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection<?> c) { + return false; + } + + @Override + public boolean addAll(Collection<? extends T> c) { + return false; + } + + @Override + public boolean retainAll(Collection<?> c) { + return false; + } + + @Override + public boolean removeAll(Collection<?> c) { + return false; + } + + @Override + public void clear() {} + + static class FlowerNode<V> { + + private final FlowerSet<V> map; + final V value; + final FlowerNode<V>[] links; + + @SuppressWarnings("unchecked") + public FlowerNode(V value, FlowerSet<V> map) { + this.value = value; + this.map = map; + this.links = new FlowerNode[map.petals]; + } + + private static final int DEPTH = 20480; + + public void TryToSetSingleNode(FlowerNode<V> node, FlowerNode<V> toset, int place, int depth) { + if (depth > DEPTH) throw new IllegalStateException("Recursive Call went too deep."); + if (node.links[place] == null) node.links[place] = toset; + else { + this.TryToSetSingleNode(node.links[place], toset, place, depth); + depth++; + } + } + + public void TryToSetSingleNode(FlowerNode<V> node, FlowerNode<V> toset, int place) { + if (node.links[place] == null) node.links[place] = toset; + else this.TryToSetSingleNode(node.links[place], toset, place, 0); + } + + @SafeVarargs + public final void SetUpLinks(FlowerNode<V>... links) { + for (FlowerNode<V> node : links) { + int place = this.map.comparerison.apply(node); + this.TryToSetSingleNode(this, node, place); + } + } + } + + static class Functions { + + public static <V> Function<FlowerNode<V>, Integer> HashBasedFunction() { + return function -> function.hashCode() % function.map.petals; + } + } +} diff --git a/src/main/java/bartworks/util/log/DebugLog.java b/src/main/java/bartworks/util/log/DebugLog.java new file mode 100644 index 0000000000..76d6a70ea7 --- /dev/null +++ b/src/main/java/bartworks/util/log/DebugLog.java @@ -0,0 +1,65 @@ +/* + * 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.util.log; + +import java.io.File; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.logging.FileHandler; +import java.util.logging.Formatter; +import java.util.logging.LogRecord; +import java.util.logging.Logger; + +import cpw.mods.fml.common.event.FMLPreInitializationEvent; + +public class DebugLog { + + private static boolean init; + static FileHandler fh; + private static Logger utilLog; + + public static void initDebugLog(FMLPreInitializationEvent event) throws IOException { + if (DebugLog.init) return; + DebugLog.fh = new FileHandler( + new File( + new File( + event.getModConfigurationDirectory() + .getParentFile(), + "logs"), + "BWLog.log").toString()); + DebugLog.utilLog = Logger.getLogger("DebugLog"); + DebugLog.utilLog.setUseParentHandlers(false); + DebugLog.utilLog.addHandler(DebugLog.fh); + Formatter formatter = new Formatter() { + + @Override + public String format(LogRecord record) { + SimpleDateFormat logTime = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + Calendar cal = new GregorianCalendar(); + cal.setTimeInMillis(record.getMillis()); + return "Level: " + record + .getLevel() + " at " + logTime.format(cal.getTime()) + " " + record.getMessage() + "\n"; + } + }; + DebugLog.fh.setFormatter(formatter); + DebugLog.init = true; + } + + public static void log(String record) { + if (!DebugLog.init) return; + DebugLog.utilLog.info(record); + } +} |