From f5f9d29c848705effe4414c2ed39ce118430476c Mon Sep 17 00:00:00 2001 From: Technus Date: Mon, 1 Apr 2019 17:23:00 +0200 Subject: Make use of scanner recipe map since i also inject my own recipes... --- .../machines/basic/GT_MetaTileEntity_Scanner.java | 286 +++++++++++---------- 1 file changed, 147 insertions(+), 139 deletions(-) (limited to 'src/main/java/gregtech/common/tileentities/machines') diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java index 8e244ff502..ea7897eaca 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java @@ -29,6 +29,8 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; +import static gregtech.api.util.GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes; + public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine { @@ -64,7 +66,7 @@ public class GT_MetaTileEntity_Scanner NBTTagCompound tNBT = new NBTTagCompound(); ((IIndividual) tIndividual).writeToNBT(tNBT); this.mOutputItems[0].setTagCompound(tNBT); - calculateOverclockedNess(2,500); + calculateOverclockedNess(2, 500); //In case recipe is too OP for that machine if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; @@ -89,7 +91,7 @@ public class GT_MetaTileEntity_Scanner } if (tNBT.getByte("scan") < 4) { tNBT.setByte("scan", (byte) 4); - calculateOverclockedNess(8,160); + calculateOverclockedNess(8, 160); //In case recipe is too OP for that machine if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; @@ -104,9 +106,9 @@ public class GT_MetaTileEntity_Scanner } if (ItemList.Tool_DataOrb.isStackEqual(getSpecialSlot(), false, true)) { if (ItemList.Tool_DataOrb.isStackEqual(aStack, false, true)) { - aStack.stackSize -= 1; + aStack.stackSize -= 1; this.mOutputItems[0] = GT_Utility.copyAmount(1L, new Object[]{getSpecialSlot()}); - calculateOverclockedNess(30,512); + calculateOverclockedNess(30, 512); //In case recipe is too OP for that machine if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; @@ -120,7 +122,7 @@ public class GT_MetaTileEntity_Scanner this.mOutputItems[0] = ItemList.Tool_DataOrb.get(1L, new Object[0]); Behaviour_DataOrb.setDataTitle(this.mOutputItems[0], "Elemental-Scan"); Behaviour_DataOrb.setDataName(this.mOutputItems[0], tData.mMaterial.mMaterial.mElement.name()); - calculateOverclockedNess(30,GT_Utility.safeInt(tData.mMaterial.mMaterial.getMass() * 8192L)); + calculateOverclockedNess(30, GT_Utility.safeInt(tData.mMaterial.mMaterial.getMass() * 8192L)); //In case recipe is too OP for that machine if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; @@ -131,7 +133,7 @@ public class GT_MetaTileEntity_Scanner if (ItemList.Tool_DataStick.isStackEqual(aStack, false, true)) { aStack.stackSize -= 1; this.mOutputItems[0] = GT_Utility.copyAmount(1L, new Object[]{getSpecialSlot()}); - calculateOverclockedNess(30,128); + calculateOverclockedNess(30, 128); //In case recipe is too OP for that machine if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; @@ -143,7 +145,7 @@ public class GT_MetaTileEntity_Scanner this.mOutputItems[0] = GT_Utility.copyAmount(1L, new Object[]{getSpecialSlot()}); this.mOutputItems[0].setTagCompound(aStack.getTagCompound()); - calculateOverclockedNess(30,128); + calculateOverclockedNess(30, 128); //In case recipe is too OP for that machine if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; @@ -155,44 +157,40 @@ public class GT_MetaTileEntity_Scanner this.mOutputItems[0] = GT_Utility.copyAmount(1L, new Object[]{getSpecialSlot()}); this.mOutputItems[0].setTagCompound(GT_Utility.getNBTContainingShort(new NBTTagCompound(), "map_id", (short) aStack.getItemDamage())); - calculateOverclockedNess(30,128); + calculateOverclockedNess(30, 128); //In case recipe is too OP for that machine if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; return 2; } - - if ((aStack.getItem().getUnlocalizedName().contains("Schematic")||aStack.getItem().getUnlocalizedName().contains("schematic"))&&!aStack.getItem().getUnlocalizedName().contains("Schematics")){ - String sTier =""; - - if (aStack.getItem().getIdFromItem(aStack.getItem()) == GT_ModHandler.getModItem("GalacticraftCore", "item.schematic", 1L, 0).getItem().getIdFromItem(GT_ModHandler.getModItem("GalacticraftCore", "item.schematic", 1L, 0).getItem())) { - if (aStack.getItemDamage()==0 && aStack.toString().equals(GT_ModHandler.getModItem("GalacticraftCore", "item.schematic", 1L, 0).copy().toString())) - sTier = "100"; - else if (aStack.getItemDamage()==1 && aStack.toString().equals(GT_ModHandler.getModItem("GalacticraftCore", "item.schematic", 1L, 1).copy().toString())) - sTier = "2"; - } - - else if (aStack.getItem().getIdFromItem(aStack.getItem()) == GT_ModHandler.getModItem("GalacticraftMars", "item.schematic", 1L, 0).getItem().getIdFromItem(GT_ModHandler.getModItem("GalacticraftMars", "item.schematic", 1L, 0).getItem())) { - if(aStack.getItemDamage()==0 && aStack.toString().equals(GT_ModHandler.getModItem("GalacticraftMars", "item.schematic", 1L, 0).copy().toString())) - sTier = "3"; - else if(aStack.getItemDamage()==1 && aStack.toString().equals(GT_ModHandler.getModItem("GalacticraftMars", "item.schematic", 1L, 1).copy().toString())) - sTier = "101"; - else if(aStack.getItemDamage()==2 && aStack.toString().equals(GT_ModHandler.getModItem("GalacticraftMars", "item.schematic", 1L, 2).copy().toString())) - sTier = "102"; - } - - else if (aStack.getUnlocalizedName().matches(".*\\d+.*")) - sTier = aStack.getUnlocalizedName().split("(?<=\\D)(?=\\d)")[1].substring(0, 1); - else - sTier = "1"; - - getSpecialSlot().stackSize -= 1; + + if ((aStack.getItem().getUnlocalizedName().contains("Schematic") || aStack.getItem().getUnlocalizedName().contains("schematic")) && !aStack.getItem().getUnlocalizedName().contains("Schematics")) { + String sTier = ""; + + if (aStack.getItem().getIdFromItem(aStack.getItem()) == GT_ModHandler.getModItem("GalacticraftCore", "item.schematic", 1L, 0).getItem().getIdFromItem(GT_ModHandler.getModItem("GalacticraftCore", "item.schematic", 1L, 0).getItem())) { + if (aStack.getItemDamage() == 0 && aStack.toString().equals(GT_ModHandler.getModItem("GalacticraftCore", "item.schematic", 1L, 0).copy().toString())) + sTier = "100"; + else if (aStack.getItemDamage() == 1 && aStack.toString().equals(GT_ModHandler.getModItem("GalacticraftCore", "item.schematic", 1L, 1).copy().toString())) + sTier = "2"; + } else if (aStack.getItem().getIdFromItem(aStack.getItem()) == GT_ModHandler.getModItem("GalacticraftMars", "item.schematic", 1L, 0).getItem().getIdFromItem(GT_ModHandler.getModItem("GalacticraftMars", "item.schematic", 1L, 0).getItem())) { + if (aStack.getItemDamage() == 0 && aStack.toString().equals(GT_ModHandler.getModItem("GalacticraftMars", "item.schematic", 1L, 0).copy().toString())) + sTier = "3"; + else if (aStack.getItemDamage() == 1 && aStack.toString().equals(GT_ModHandler.getModItem("GalacticraftMars", "item.schematic", 1L, 1).copy().toString())) + sTier = "101"; + else if (aStack.getItemDamage() == 2 && aStack.toString().equals(GT_ModHandler.getModItem("GalacticraftMars", "item.schematic", 1L, 2).copy().toString())) + sTier = "102"; + } else if (aStack.getUnlocalizedName().matches(".*\\d+.*")) + sTier = aStack.getUnlocalizedName().split("(?<=\\D)(?=\\d)")[1].substring(0, 1); + else + sTier = "1"; + + getSpecialSlot().stackSize -= 1; aStack.stackSize -= 1; - - this.mOutputItems[0] = GT_Utility.copyAmount(1L, new Object[]{getSpecialSlot()}); - this.mOutputItems[0].setTagCompound(GT_Utility.getNBTContainingShort(new NBTTagCompound(), "rocket_tier", Short.parseShort(sTier) )); - - calculateOverclockedNess(480,36000); + + this.mOutputItems[0] = GT_Utility.copyAmount(1L, new Object[]{getSpecialSlot()}); + this.mOutputItems[0].setTagCompound(GT_Utility.getNBTContainingShort(new NBTTagCompound(), "rocket_tier", Short.parseShort(sTier))); + + calculateOverclockedNess(480, 36000); //In case recipe is too OP for that machine if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; @@ -207,7 +205,7 @@ public class GT_MetaTileEntity_Scanner aStack.stackSize -= 1; this.mOutputItems[0] = GT_Utility.copyAmount(1L, new Object[]{aStack}); - calculateOverclockedNess(30,1000); + calculateOverclockedNess(30, 1000); //In case recipe is too OP for that machine if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; @@ -215,105 +213,115 @@ public class GT_MetaTileEntity_Scanner } } - if(ItemList.Tool_DataStick.isStackEqual(getSpecialSlot(), false, true)&& aStack !=null){ - for(GT_Recipe.GT_Recipe_AssemblyLine tRecipe:GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes){ - if(GT_Utility.areStacksEqual(tRecipe.mResearchItem, aStack, true)){ - - String s = tRecipe.mOutput.getDisplayName(); - if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { - s = GT_Assemblyline_Server.lServerNames.get(tRecipe.mOutput.getDisplayName()); - if (s==null) - s=tRecipe.mOutput.getDisplayName(); - } - this.mOutputItems[0] = GT_Utility.copyAmount(1L, new Object[]{getSpecialSlot()}); - //remove possible old NBTTagCompound - this.mOutputItems[0].setTagCompound(new NBTTagCompound()); - GT_Utility.ItemNBT.setBookTitle(this.mOutputItems[0], s+" Construction Data"); - - NBTTagCompound tNBT = this.mOutputItems[0].getTagCompound(); - if (tNBT == null) { - tNBT = new NBTTagCompound(); - } - - tNBT.setTag("output", tRecipe.mOutput.writeToNBT(new NBTTagCompound())); - tNBT.setInteger("time", tRecipe.mDuration); - tNBT.setInteger("eu", tRecipe.mEUt); - for(int i = 0 ; i < tRecipe.mInputs.length ; i++){ - tNBT.setTag(""+i, tRecipe.mInputs[i].writeToNBT(new NBTTagCompound())); - } - for(int i = 0 ; i < tRecipe.mOreDictAlt.length ; i++){ - if (tRecipe.mOreDictAlt[i] != null && tRecipe.mOreDictAlt[i].length > 0) { - tNBT.setInteger("a" + i, tRecipe.mOreDictAlt[i].length); - for (int j = 0; j < tRecipe.mOreDictAlt[i].length; j++) { - tNBT.setTag("a" + i + ":" + j, tRecipe.mOreDictAlt[i][j].writeToNBT(new NBTTagCompound())); - } - } - } - for(int i = 0 ; i < tRecipe.mFluidInputs.length ; i++){ - tNBT.setTag("f"+i, tRecipe.mFluidInputs[i].writeToNBT(new NBTTagCompound())); - } - tNBT.setString("author", "Assembling Line Recipe Generator"); - NBTTagList tNBTList = new NBTTagList(); - s=tRecipe.mOutput.getDisplayName(); - if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { - s = GT_Assemblyline_Server.lServerNames.get(tRecipe.mOutput.getDisplayName()); - if (s==null) - s=tRecipe.mOutput.getDisplayName(); - } - tNBTList.appendTag(new NBTTagString("Construction plan for "+tRecipe.mOutput.stackSize+" "+s+". Needed EU/t: "+tRecipe.mEUt+" Production time: "+(tRecipe.mDuration/20))); - for(int i=0;i 0) tNBTList.appendTag(new NBTTagString(tBuilder.toString())); - } else if(tRecipe.mInputs[i]!=null){ - s=tRecipe.mInputs[i].getDisplayName(); - if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { - s = GT_Assemblyline_Server.lServerNames.get(tRecipe.mInputs[i].getDisplayName()); - if (s==null) - s=tRecipe.mInputs[i].getDisplayName(); - } - tNBTList.appendTag(new NBTTagString("Input Bus "+(i+1)+": "+tRecipe.mInputs[i].stackSize+" "+s)); - } - } - for(int i=0;i 0) { + tNBT.setInteger("a" + i, tRecipe.mOreDictAlt[i].length); + for (int j = 0; j < tRecipe.mOreDictAlt[i].length; j++) { + tNBT.setTag("a" + i + ":" + j, tRecipe.mOreDictAlt[i][j].writeToNBT(new NBTTagCompound())); + } + } + } + for (int i = 0; i < tRecipe.mFluidInputs.length; i++) { + tNBT.setTag("f" + i, tRecipe.mFluidInputs[i].writeToNBT(new NBTTagCompound())); + } + tNBT.setString("author", "Assembling Line Recipe Generator"); + NBTTagList tNBTList = new NBTTagList(); + s = tRecipe.mOutput.getDisplayName(); + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { + s = GT_Assemblyline_Server.lServerNames.get(tRecipe.mOutput.getDisplayName()); + if (s == null) + s = tRecipe.mOutput.getDisplayName(); + } + tNBTList.appendTag(new NBTTagString("Construction plan for " + tRecipe.mOutput.stackSize + " " + s + ". Needed EU/t: " + tRecipe.mEUt + " Production time: " + (tRecipe.mDuration / 20))); + for (int i = 0; i < tRecipe.mInputs.length; i++) { + if (tRecipe.mOreDictAlt[i] != null) { + int count = 0; + StringBuilder tBuilder = new StringBuilder("Input Bus " + (i + 1) + ": "); + for (ItemStack tStack : tRecipe.mOreDictAlt[i]) { + if (tStack != null) { + s = tStack.getDisplayName(); + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { + s = GT_Assemblyline_Server.lServerNames.get(tStack.getDisplayName()); + if (s == null) + s = tStack.getDisplayName(); + } + + + tBuilder.append((count == 0 ? "" : "\nOr ") + tStack.stackSize + " " + s); + count++; + } + } + if (count > 0) tNBTList.appendTag(new NBTTagString(tBuilder.toString())); + } else if (tRecipe.mInputs[i] != null) { + s = tRecipe.mInputs[i].getDisplayName(); + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { + s = GT_Assemblyline_Server.lServerNames.get(tRecipe.mInputs[i].getDisplayName()); + if (s == null) + s = tRecipe.mInputs[i].getDisplayName(); + } + tNBTList.appendTag(new NBTTagString("Input Bus " + (i + 1) + ": " + tRecipe.mInputs[i].stackSize + " " + s)); + } + } + for (int i = 0; i < tRecipe.mFluidInputs.length; i++) { + if (tRecipe.mFluidInputs[i] != null) { + s = tRecipe.mFluidInputs[i].getLocalizedName(); + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { + s = GT_Assemblyline_Server.lServerNames.get(tRecipe.mFluidInputs[i].getLocalizedName()); + if (s == null) + s = tRecipe.mFluidInputs[i].getLocalizedName(); + } + tNBTList.appendTag(new NBTTagString("Input Hatch " + (i + 1) + ": " + tRecipe.mFluidInputs[i].amount + "L " + s)); + } + } + tNBT.setTag("pages", tNBTList); + + this.mOutputItems[0].setTagCompound(tNBT); + + aStack.stackSize -= 1; + calculateOverclockedNess(30, tRecipe.mResearchTime); + //In case recipe is too OP for that machine + if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + getSpecialSlot().stackSize -= 1; + return 2; + } } - tNBT.setTag("pages", tNBTList); - - this.mOutputItems[0].setTagCompound(tNBT); - - aStack.stackSize -= 1; - calculateOverclockedNess(30,tRecipe.mResearchTime); - //In case recipe is too OP for that machine - if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) - return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; - getSpecialSlot().stackSize -= 1; - return 2; - } - } } } @@ -332,7 +340,7 @@ public class GT_MetaTileEntity_Scanner public GT_Recipe.GT_Recipe_Map getRecipeList() { - return GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes; + return sScannerFakeRecipes; } public int getCapacity() { -- cgit