diff --git a/build.gradle b/build.gradle index a8b7532de..393099040 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ -//version: 1684218858 +//version: 1685785062 /* DO NOT CHANGE THIS FILE! Also, you may replace this file at any time if there is an update available. @@ -1276,12 +1276,14 @@ tasks.register('faq') { description = 'Prints frequently asked questions about building a project' doLast { - print("If your build fails to fetch dependencies, they might have been deleted and replaced by newer " + - "versions.\nCheck if the versions you try to fetch are still on the distributing sites.\n" + - "The links can be found in repositories.gradle and build.gradle:repositories, " + - "not build.gradle:buildscript.repositories - this one is for gradle plugin metadata.\n\n" + + print("If your build fails to fetch dependencies, run './gradlew updateDependencies'. " + + "Or you can manually check if the versions are still on the distributing sites - " + + "the links can be found in repositories.gradle and build.gradle:repositories, " + + "but not build.gradle:buildscript.repositories - those ones are for gradle plugin metadata.\n\n" + "If your build fails to recognize the syntax of new Java versions, enable Jabel in your " + - "gradle.properties. See how it's done in GTNH ExampleMod/gradle.properties.") + "gradle.properties. See how it's done in GTNH ExampleMod/gradle.properties. " + + "However, keep in mind that Jabel enables only syntax features, but not APIs that were introduced in " + + "Java 9 or later.") } } diff --git a/dependencies.gradle b/dependencies.gradle index b7d738861..1b95793bc 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -1,14 +1,14 @@ // Add your dependencies here dependencies { - api('com.github.GTNewHorizons:GT5-Unofficial:5.09.43.57-pre:dev') - api("com.github.GTNewHorizons:TecTech:5.2.18:dev") + api('com.github.GTNewHorizons:GT5-Unofficial:5.09.43.122:dev') + api("com.github.GTNewHorizons:TecTech:5.2.34:dev") api("com.github.GTNewHorizons:GalacticGregGT5:1.0.9:dev") { exclude group:"com.github.GTNewHorizons", module:"bartworks" } - api("com.github.GTNewHorizons:Avaritia:1.42:dev") - implementation("com.github.GTNewHorizons:TinkersConstruct:1.9.35-GTNH:dev") + api("com.github.GTNewHorizons:Avaritia:1.45:dev") + implementation("com.github.GTNewHorizons:TinkersConstruct:1.9.38-GTNH:dev") compileOnly("TGregworks:TGregworks:1.7.10-GTNH-1.0.24:deobf") {transitive = false} - compileOnly("com.github.GTNewHorizons:OpenComputers:1.9.5-GTNH:api") {transitive = false} + compileOnly("com.github.GTNewHorizons:OpenComputers:1.9.12-GTNH:api") {transitive = false} } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java index 116fd7f1e..9fc49a371 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java @@ -45,13 +45,10 @@ import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.common.widget.DrawableWidget; -import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.gui.modularui.GT_UITextures; -import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; -import gregtech.api.objects.GT_ItemStack; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; @@ -812,85 +809,7 @@ public SpecialObjectSensitiveMap(Collection aRecipeList, String aUnlo aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); - } - - /** - * finds a Recipe matching the aFluid, aSpecial and ItemStack Inputs. - * - * @param aTileEntity an Object representing the current coordinates of the executing - * Block/Entity/Whatever. This may be null, especially during Startup. - * @param aRecipe in case this is != null it will try to use this Recipe first when looking things - * up. - * @param aNotUnificated if this is T the Recipe searcher will unificate the ItemStack Inputs - * @param aDontCheckStackSizes if set to false will only return recipes that can be executed at least once with - * the provided input - * @param aVoltage Voltage of the Machine or Long.MAX_VALUE if it has no Voltage - * @param aFluids the Fluid Inputs - * @param aSpecialSlot the content of the Special Slot, the regular Manager doesn't do anything with - * this, but some custom ones do. Like this one. - * @param aInputs the Item Inputs - * @return the Recipe it has found or null for no matching Recipe - */ - public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, - boolean aDontCheckStackSizes, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, - ItemStack... aInputs) { - // No Recipes? Well, nothing to be found then. - if (mRecipeList.isEmpty()) return null; - - // Some Recipe Classes require a certain amount of Inputs of certain kinds. Like "at least 1 Fluid + 1 - // Stack" or "at least 2 Stacks" before they start searching for Recipes. - // This improves Performance massively, especially if people leave things like Circuits, Molds or Shapes in - // their Machines to select Sub Recipes. - if (GregTech_API.sPostloadFinished) { - if (mMinimalInputFluids > 0) { - if (aFluids == null) return null; - int tAmount = 0; - for (FluidStack aFluid : aFluids) if (aFluid != null) tAmount++; - if (tAmount < mMinimalInputFluids) return null; - } - if (mMinimalInputItems > 0) { - if (aInputs == null) return null; - int tAmount = 0; - for (ItemStack aInput : aInputs) if (aInput != null) tAmount++; - if (tAmount < mMinimalInputItems) return null; - } - } - - // Unification happens here in case the Input isn't already unificated. - if (aNotUnificated) aInputs = GT_OreDictUnificator.getStackArray(true, (Object) aInputs); - - // Check the Recipe which has been used last time in order to not have to search for it again, if possible. - if (aRecipe != null) if (!aRecipe.mFakeRecipe && aRecipe.mCanBeBuffered - && aRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs) - && BW_Util.areStacksEqualOrNull((ItemStack) aRecipe.mSpecialItems, aSpecialSlot)) - return aRecipe.mEnabled && aVoltage * mAmperage >= aRecipe.mEUt ? aRecipe : null; - - // Now look for the Recipes inside the Item HashMaps, but only when the Recipes usually have Items. - if (mUsualInputCount > 0 && aInputs != null) for (ItemStack tStack : aInputs) if (tStack != null) { - Collection tRecipes = mRecipeItemMap.get(new GT_ItemStack(tStack)); - if (tRecipes != null) for (GT_Recipe tRecipe : tRecipes) if (!tRecipe.mFakeRecipe - && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs) - && BW_Util.areStacksEqualOrNull((ItemStack) tRecipe.mSpecialItems, aSpecialSlot)) - return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; - tRecipes = mRecipeItemMap.get(new GT_ItemStack(GT_Utility.copyMetaData(GT_Values.W, tStack))); - if (tRecipes != null) for (GT_Recipe tRecipe : tRecipes) if (!tRecipe.mFakeRecipe - && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs) - && BW_Util.areStacksEqualOrNull((ItemStack) tRecipe.mSpecialItems, aSpecialSlot)) - return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; - } - - // If the minimal Amount of Items for the Recipe is 0, then it could be a Fluid-Only Recipe, so check that - // Map too. - if (mMinimalInputItems == 0 && aFluids != null) for (FluidStack aFluid : aFluids) if (aFluid != null) { - Collection tRecipes = mRecipeFluidMap.get(aFluid.getFluid()); - if (tRecipes != null) for (GT_Recipe tRecipe : tRecipes) if (!tRecipe.mFakeRecipe - && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs) - && BW_Util.areStacksEqualOrNull((ItemStack) tRecipe.mSpecialItems, aSpecialSlot)) - return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; - } - - // And nothing has been found. - return null; + setSpecialSlotSensitive(true); } } diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/emt/recipe/TCRecipeHandler.java b/src/main/java/com/github/bartimaeusnek/crossmod/emt/recipe/TCRecipeHandler.java deleted file mode 100644 index 124b41cd2..000000000 --- a/src/main/java/com/github/bartimaeusnek/crossmod/emt/recipe/TCRecipeHandler.java +++ /dev/null @@ -1,312 +0,0 @@ -/* - * 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 com.github.bartimaeusnek.crossmod.emt.recipe; - -import static com.github.bartimaeusnek.crossmod.thaumcraft.util.ThaumcraftHandler.AspectAdder; - -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; - -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.oredict.OreDictionary; - -import com.github.bartimaeusnek.bartworks.util.BWRecipes; -import com.github.bartimaeusnek.bartworks.util.BW_Util; -import com.github.bartimaeusnek.crossmod.thaumcraft.util.ThaumcraftHandler; -import com.google.common.collect.ArrayListMultimap; - -import gregtech.api.GregTech_API; -import gregtech.api.enums.GT_Values; -import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; - -@SuppressWarnings("ALL") -public class TCRecipeHandler { - - public static final GT_Recipe.GT_Recipe_Map alchemicalConstructHandler = new TCRecipeHandler.TCRecipeMap( - new HashSet<>(15000), - "bwcm.recipe.alchemicalConstruct", - "Industrical Alchemical Construct", - null, - "gregtech:textures/gui/basicmachines/Default", - 2, - 1, - 2, - 0, - 1, - "", - 1, - "", - true, - true); - static Class aCrucibleRecipeClass; - static Class aThaumcraftAPI; - static Field craftingRecipes; - static Field aCrucibleRecipeField; - static Field aCrucibleRecipeCatalyst; - static Field aspects; - static Field key; - - static { - try { - aCrucibleRecipeClass = Class.forName("thaumcraft.api.crafting.CrucibleRecipe"); - aThaumcraftAPI = Class.forName("thaumcraft.api.ThaumcraftApi"); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } - try { - aspects = aCrucibleRecipeClass.getField("aspects"); - - key = aCrucibleRecipeClass.getField("key"); - - aCrucibleRecipeField = aCrucibleRecipeClass.getDeclaredField("recipeOutput"); - aCrucibleRecipeField.setAccessible(true); - - aCrucibleRecipeCatalyst = aCrucibleRecipeClass.getField("catalyst"); - - craftingRecipes = aThaumcraftAPI.getDeclaredField("craftingRecipes"); - craftingRecipes.setAccessible(true); - } catch (NoSuchFieldException e) { - e.printStackTrace(); - } - } - - public static void init() throws IllegalAccessException, InvocationTargetException { - ArrayList tcCraftingList = (ArrayList) craftingRecipes.get(null); - HashSet crucibleRecipes = new HashSet(); - for (Object o : tcCraftingList) { - if (TCRecipeHandler.aCrucibleRecipeClass.isInstance(o)) crucibleRecipes.add(o); - } - TCRecipeHandler.convertCrucibleRecipesToGTRecipes(crucibleRecipes); - } - - public static void convertCrucibleRecipesToGTRecipes(HashSet crucibleRecipes) - throws IllegalAccessException, InvocationTargetException { - HashSet ret = new HashSet<>(); - ArrayListMultimap itemToCircuitConfigMap = ArrayListMultimap.create(); - ArrayListMultimap itemToAspectsMap = ArrayListMultimap.create(); - ArrayListMultimap itemToOutputMap = ArrayListMultimap.create(); - ArrayListMultimap itemToResearchMap = ArrayListMultimap.create(); - - for (Object o : crucibleRecipes) { - - String key = (String) TCRecipeHandler.key.get(o); - ItemStack out = (ItemStack) TCRecipeHandler.aCrucibleRecipeField.get(o); - Object aspects = TCRecipeHandler.aspects.get(o); - Object cat = TCRecipeHandler.aCrucibleRecipeCatalyst.get(o); - - if (cat instanceof ItemStack) { - itemToAspectsMap.put((ItemStack) cat, aspects); - itemToOutputMap.put((ItemStack) cat, out); - itemToResearchMap.put((ItemStack) cat, key); - } else if (cat instanceof String) { - for (ItemStack stack : OreDictionary.getOres((String) cat)) { - itemToAspectsMap.put(stack, aspects); - itemToOutputMap.put(stack, out); - itemToResearchMap.put(stack, key); - } - } else if (cat instanceof ArrayList && ((ArrayList) cat).size() > 0) { - for (ItemStack stack : ((ArrayList) cat)) { - itemToAspectsMap.put(stack, aspects); - itemToOutputMap.put(stack, out); - itemToResearchMap.put(stack, key); - } - } - } - for (ItemStack o : itemToAspectsMap.keySet()) { - if (o.getItemDamage() == Short.MAX_VALUE) itemToCircuitConfigMap.put(o, 24); - else for (int j = 1; j <= itemToAspectsMap.get(o).size(); j++) { - itemToCircuitConfigMap.put(o, j % 24); - } - - for (int j = 0; j < itemToAspectsMap.get(o).size(); j++) { - ret.add( - addRecipes( - itemToResearchMap.get(o).get(j), - itemToOutputMap.get(o).get(j), - itemToAspectsMap.get(o).get(j), - o, - itemToCircuitConfigMap.get(o).get(j))); - } - } - - for (GT_Recipe recipe : ret) { - TCRecipeHandler.alchemicalConstructHandler.add(recipe); - } - } - - public static GT_Recipe addRecipes(String key, ItemStack out, Object aspects, ItemStack cat, int config) - throws InvocationTargetException, IllegalAccessException { - - NBTTagCompound toWrite = new NBTTagCompound(); - ThaumcraftHandler.AspectAdder.writeAspectListToNBT.invoke(aspects, toWrite); - ItemStack fake = new ItemStack(Items.feather); - fake.setTagCompound(toWrite); - fake.setStackDisplayName(key); - GT_Recipe recipe = new BWRecipes.DynamicGTRecipe( - false, - new ItemStack[] { cat, GT_Utility.getIntegratedCircuit(config) }, - new ItemStack[] { out }, - fake, - null, - null, - null, - 60, - 480, - 0); - return recipe; - } - - static class TCRecipeMap extends GT_Recipe.GT_Recipe_Map { - - public TCRecipeMap(Collection aRecipeList, String aUnlocalizedName, String aLocalName, - String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, - int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, - int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, - boolean aNEIAllowed) { - super( - aRecipeList, - aUnlocalizedName, - aLocalName, - aNEIName, - aNEIGUIPath, - aUsualInputCount, - aUsualOutputCount, - aMinimalInputItems, - aMinimalInputFluids, - aAmperage, - aNEISpecialValuePre, - aNEISpecialValueMultiplier, - aNEISpecialValuePost, - aShowVoltageAmperageInNEI, - aNEIAllowed); - } - - @Override - public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, - boolean aDontCheckStackSizes, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, - ItemStack... aInputs) { - // No Recipes? Well, nothing to be found then. - if (mRecipeList.isEmpty()) return null; - - // Some Recipe Classes require a certain amount of Inputs of certain kinds. Like "at least 1 Fluid + 1 - // Stack" or "at least 2 Stacks" before they start searching for Recipes. - // This improves Performance massively, especially if people leave things like Circuits, Molds or Shapes in - // their Machines to select Sub Recipes. - if (GregTech_API.sPostloadFinished) { - if (this.mMinimalInputItems > 0) { - if (aInputs == null) return null; - int tAmount = 0; - for (ItemStack aInput : aInputs) if (aInput != null) tAmount++; - if (tAmount < this.mMinimalInputItems) return null; - } - } - - // Unification happens here in case the Input isn't already unificated. - if (aNotUnificated) aInputs = GT_OreDictUnificator.getStackArray(true, (Object[]) aInputs); - - // // Check the Recipe which has been used last time in order to not have to search for it again, - // if possible. - // if (aRecipe != null) - // if (!aRecipe.mFakeRecipe && aRecipe.mCanBeBuffered && aRecipe.isRecipeInputEqual(false, - // aDontCheckStackSizes, aFluids, aInputs)) { - // NBTTagCompound toCheckNBT = aSpecialSlot.getTagCompound(); - // NBTTagCompound givenNBT = ((ItemStack)aRecipe.mSpecialItems).getTagCompound(); - // Object aAspectListToCheck = null; - // Object aGivenAspectList = null; - // try { - // aAspectListToCheck = AspectAdder.mAspectListClass.newInstance(); - // aGivenAspectList = AspectAdder.mAspectListClass.newInstance(); - // AspectAdder.readAspectListFromNBT.invoke(aAspectListToCheck,toCheckNBT); - // AspectAdder.readAspectListFromNBT.invoke(aGivenAspectList,givenNBT); - // if - // (!TCRecipeHandler.TCRecipeMap.containsAspects(aAspectListToCheck,aGivenAspectList)) - // return null; - // } catch (InstantiationException | IllegalAccessException | InvocationTargetException - // e) { - // e.printStackTrace(); - // return null; - // } - // return aRecipe.mEnabled && aVoltage * mAmperage >= aRecipe.mEUt ? aRecipe : null; - // } - - // Now look for the Recipes inside the Item HashMaps, but only when the Recipes usually have Items. - if (this.mUsualInputCount > 0 && aInputs != null) for (ItemStack tStack : aInputs) if (tStack != null) { - Collection tRecipes = mRecipeItemMap.get(new GT_ItemStack(tStack)); - if (tRecipes != null) for (GT_Recipe tRecipe : tRecipes) if (!tRecipe.mFakeRecipe - && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs)) { - NBTTagCompound toCheckNBT = aSpecialSlot.getTagCompound(); - NBTTagCompound givenNBT = ((ItemStack) aRecipe.mSpecialItems).getTagCompound(); - Object aAspectListToCheck = null; - Object aGivenAspectList = null; - try { - aAspectListToCheck = AspectAdder.mAspectListClass.newInstance(); - aGivenAspectList = AspectAdder.mAspectListClass.newInstance(); - AspectAdder.readAspectListFromNBT.invoke(aAspectListToCheck, toCheckNBT); - AspectAdder.readAspectListFromNBT.invoke(aGivenAspectList, givenNBT); - if (!TCRecipeHandler.TCRecipeMap.containsAspects(aAspectListToCheck, aGivenAspectList)) - continue; - } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { - e.printStackTrace(); - return null; - } - return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; - } - tRecipes = mRecipeItemMap.get(new GT_ItemStack(GT_Utility.copyMetaData(GT_Values.W, tStack))); - if (tRecipes != null) for (GT_Recipe tRecipe : tRecipes) if (!tRecipe.mFakeRecipe - && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs) - && BW_Util.areStacksEqualOrNull((ItemStack) tRecipe.mSpecialItems, aSpecialSlot)) { - NBTTagCompound toCheckNBT = aSpecialSlot.getTagCompound(); - NBTTagCompound givenNBT = ((ItemStack) aRecipe.mSpecialItems).getTagCompound(); - Object aAspectListToCheck = null; - Object aGivenAspectList = null; - try { - aAspectListToCheck = AspectAdder.mAspectListClass.newInstance(); - aGivenAspectList = AspectAdder.mAspectListClass.newInstance(); - AspectAdder.readAspectListFromNBT.invoke(aAspectListToCheck, toCheckNBT); - AspectAdder.readAspectListFromNBT.invoke(aGivenAspectList, givenNBT); - if (!TCRecipeHandler.TCRecipeMap.containsAspects(aAspectListToCheck, aGivenAspectList)) - continue; - } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { - e.printStackTrace(); - return null; - } - return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; - } - } - // And nothing has been found. - return null; - } - - private static boolean containsAspects(Object aAspectListToCheck, Object aGivenAspectList) - throws InvocationTargetException, IllegalAccessException { - Object[] aspects = (Object[]) ThaumcraftHandler.AspectAdder.getAspects.invoke(aGivenAspectList); - for (int i = 0; i < aspects.length; i++) { - if ((int) ThaumcraftHandler.AspectAdder.getAmount.invoke(aAspectListToCheck, aspects[i]) - < (int) ThaumcraftHandler.AspectAdder.getAmount.invoke(aGivenAspectList, aspects[i])) - return false; - } - return true; - } - } -} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/emt/tileentities/multi/GT_Industrial_Alchemic_Construct.java b/src/main/java/com/github/bartimaeusnek/crossmod/emt/tileentities/multi/GT_Industrial_Alchemic_Construct.java deleted file mode 100644 index 25fe6af63..000000000 --- a/src/main/java/com/github/bartimaeusnek/crossmod/emt/tileentities/multi/GT_Industrial_Alchemic_Construct.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * 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 com.github.bartimaeusnek.crossmod.emt.tileentities.multi; - -import static gregtech.api.enums.GT_Values.V; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; - -import com.github.bartimaeusnek.crossmod.emt.recipe.TCRecipeHandler; -import com.github.bartimaeusnek.crossmod.emt.util.EMTHandler; -import com.github.bartimaeusnek.crossmod.thaumcraft.util.ThaumcraftHandler; - -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; - -@SuppressWarnings("ALL") -public class GT_Industrial_Alchemic_Construct extends GT_MetaTileEntity_MultiBlockBase { - - private List mEssentiaHatches = new ArrayList<>(); - - public boolean addInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity.getClass().isInstance(EMTHandler.aEssentiaInputHatch)) - return this.addEssetiaHatchToList(aTileEntity, aBaseCasingIndex); - return super.addInputToMachineList(aTileEntity, aBaseCasingIndex); - } - - private boolean addEssetiaHatchToList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) { - return false; - } else if (aTileEntity.getClass().isInstance(EMTHandler.aEssentiaInputHatch)) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return this.mEssentiaHatches.add(aMetaTileEntity); - } else { - return false; - } - } - } - - public GT_Industrial_Alchemic_Construct(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - private GT_Industrial_Alchemic_Construct(String aName) { - super(aName); - } - - @Override - public boolean isCorrectMachinePart(ItemStack itemStack) { - return true; - } - - @Override - public boolean checkRecipe(ItemStack itemStack) { - ItemStack stack = new ItemStack(Items.feather); - String owner = this.getBaseMetaTileEntity().getOwnerName(); - Object allAspects = null; - try { - allAspects = ThaumcraftHandler.AspectAdder.mAspectListClass.newInstance(); - for (Object o : this.mEssentiaHatches) { - Object aspectList = EMTHandler.aAspectField.get(o); - ThaumcraftHandler.AspectAdder.add.invoke(allAspects, aspectList); - } - NBTTagCompound toWrite = (NBTTagCompound) ThaumcraftHandler.AspectAdder.writeAspectListToNBT - .invoke(allAspects, new NBTTagCompound()); - stack.setTagCompound(toWrite); - } catch (IllegalAccessException | InstantiationException | InvocationTargetException e) { - e.printStackTrace(); - return false; - } - ItemStack[] tInputs = this.getStoredInputs().toArray(new ItemStack[0]); - ItemStack outputItems = null; - - long tVoltage = this.getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, Math.min(GT_Utility.getTier(tVoltage), V.length - 1)); - GT_Recipe tRecipe = TCRecipeHandler.alchemicalConstructHandler - .findRecipe(this.getBaseMetaTileEntity(), null, false, false, V[tTier], null, stack, tInputs); - ItemStack helper = (ItemStack) tRecipe.mSpecialItems; - NBTTagCompound tagCompound = helper.getTagCompound(); - String research = tagCompound.getCompoundTag("display").getString("Name"); - Object aspectList = null; - try { - aspectList = ThaumcraftHandler.AspectAdder.mAspectListClass.newInstance(); - ThaumcraftHandler.AspectAdder.readAspectListFromNBT.invoke(aspectList, tagCompound); - } catch (IllegalAccessException | InvocationTargetException | InstantiationException e) { - e.printStackTrace(); - return false; - } - boolean complete = false; - try { - complete = (boolean) ThaumcraftHandler.AspectAdder.isResearchComplete.invoke(null, owner, research); - } catch (IllegalAccessException | InvocationTargetException e) { - e.printStackTrace(); - } - if (!complete) return false; - if (!tRecipe.isRecipeInputEqual(true, new FluidStack[0], tInputs)) return false; - LinkedHashMap list = null; - LinkedHashMap needed = null; - try { - list = (LinkedHashMap) ThaumcraftHandler.AspectAdder.linkedAspektList.get(allAspects); - needed = (LinkedHashMap) ThaumcraftHandler.AspectAdder.linkedAspektList.get(aspectList); - } catch (IllegalAccessException e) { - e.printStackTrace(); - return false; - } - assert list != null; - assert needed != null; - for (Map.Entry toTake : needed.entrySet()) { - list.replace(toTake.getKey(), list.get(toTake.getKey()) - toTake.getValue()); - } - this.addOutput(tRecipe.mOutputs[0]); - this.updateSlots(); - return true; - } - - @Override - public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - return false; - } - - @Override - public int getMaxEfficiency(ItemStack itemStack) { - return 0; - } - - @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 GT_Industrial_Alchemic_Construct(mName); - } - - @Override - public String[] getDescription() { - return new String[0]; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity iGregTechTileEntity, ForgeDirection side, ForgeDirection facing, - int colorIndex, boolean b3, boolean b4) { - return new ITexture[0]; - } -} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/emt/util/EMTHandler.java b/src/main/java/com/github/bartimaeusnek/crossmod/emt/util/EMTHandler.java deleted file mode 100644 index afc42577f..000000000 --- a/src/main/java/com/github/bartimaeusnek/crossmod/emt/util/EMTHandler.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 com.github.bartimaeusnek.crossmod.emt.util; - -import java.lang.reflect.Field; - -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; - -@SuppressWarnings("unchecked") -public class EMTHandler { - - public static Class aEssentiaInputHatch; - public static Field aAspectField; - - static { - try { - aEssentiaInputHatch = (Class) Class - .forName("emt.gthandler.common.implementations.EssentiaHatch"); - aAspectField = aEssentiaInputHatch.getDeclaredField("current"); - aAspectField.setAccessible(true); - } catch (ClassNotFoundException | NoSuchFieldException e) { - e.printStackTrace(); - } - } -}