aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/common')
-rw-r--r--src/main/java/gregtech/common/blocks/GT_Block_Casings5.java71
-rw-r--r--src/main/java/gregtech/common/blocks/GT_Item_Casings5.java39
-rw-r--r--src/main/java/gregtech/common/blocks/GT_Item_Machines.java6
-rw-r--r--src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java9
-rw-r--r--src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java2
-rw-r--r--src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java1
-rw-r--r--src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_Regulator.java1
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java446
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AbstractMultiFurnace.java98
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java505
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java298
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java350
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java365
13 files changed, 1312 insertions, 879 deletions
diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java
index 995de490e8..1ccd1f7164 100644
--- a/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java
+++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java
@@ -2,14 +2,21 @@ package gregtech.common.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
+import gregtech.api.enums.HeatingCoilLevel;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Textures;
+import gregtech.api.interfaces.IHeatingCoil;
import gregtech.api.objects.GT_CopiedBlockTexture;
import gregtech.api.util.GT_LanguageManager;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
-public class GT_Block_Casings5 extends GT_Block_Casings_Abstract {
+import java.util.function.Consumer;
+
+import static gregtech.api.enums.HeatingCoilLevel.*;
+
+public class GT_Block_Casings5 extends GT_Block_Casings_Abstract implements IHeatingCoil {
+
public GT_Block_Casings5() {
super(GT_Item_Casings5.class, "gt.blockcasings5", GT_Material_Casings.INSTANCE);
for (byte i = 0; i < 16; i = (byte) (i + 1)) {
@@ -24,6 +31,8 @@ public class GT_Block_Casings5 extends GT_Block_Casings_Abstract {
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Naquadah Alloy Coil Block");
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Electrum Flux Coil Block");
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Awakened Draconium Coil Block");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "HSS-S Coil Block");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Trinium Coil Block");
ItemList.Casing_Coil_Cupronickel.set(new ItemStack(this, 1, 0));
ItemList.Casing_Coil_Kanthal.set(new ItemStack(this, 1, 1));
@@ -34,7 +43,10 @@ public class GT_Block_Casings5 extends GT_Block_Casings_Abstract {
ItemList.Casing_Coil_NaquadahAlloy.set(new ItemStack(this, 1, 6));
ItemList.Casing_Coil_ElectrumFlux.set(new ItemStack(this, 1, 7));
ItemList.Casing_Coil_AwakenedDraconium.set(new ItemStack(this, 1, 8));
+ ItemList.Casing_Coil_HSSS.set(new ItemStack(this, 1, 9));
+ ItemList.Casing_Coil_Trinium.set(new ItemStack(this, 1, 10));
}
+
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int aSide, int aMeta) {
@@ -57,7 +69,62 @@ public class GT_Block_Casings5 extends GT_Block_Casings_Abstract {
return Textures.BlockIcons.MACHINE_COIL_ELECTRUMFLUX.getIcon();
case 8:
return Textures.BlockIcons.MACHINE_COIL_AWAKENEDDRACONIUM.getIcon();
+ case 9:
+ return Textures.BlockIcons.MACHINE_COIL_HSSS.getIcon();
+ case 10:
+ return Textures.BlockIcons.MACHINE_COIL_TRINIUM.getIcon();
}
return Textures.BlockIcons.MACHINE_COIL_CUPRONICKEL.getIcon();
}
-}
+
+ /*--------------- COIL CHECK IMPL. ------------*/
+
+ public static HeatingCoilLevel getCoilHeatFromDamage(int meta) {
+ switch (meta) {
+ case 0:
+ return LV;
+ case 1:
+ return MV;
+ case 2:
+ return HV;
+ case 3:
+ return EV;
+ case 4:
+ return IV;
+ case 5:
+ return ZPM;
+ case 6:
+ return UV;
+ case 7:
+ return UEV;
+ case 8:
+ return UIV;
+ case 9:
+ return LuV;
+ case 10:
+ return UHV;
+ default:
+ return None;
+ }
+ }
+
+ @Override
+ public HeatingCoilLevel getCoilHeat(int meta) {
+ getOnCoilCheck().accept(this);
+ return getCoilHeatFromDamage(meta);
+ }
+
+ /*--------------- CALLBACK ------------*/
+
+ private Consumer<IHeatingCoil> callback = coil -> {};
+
+ @Override
+ public void setOnCoilCheck(Consumer<IHeatingCoil> callback) {
+ this.callback = callback;
+ }
+
+ @Override
+ public Consumer<IHeatingCoil> getOnCoilCheck() {
+ return this.callback;
+ }
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings5.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings5.java
index 38ad1a668c..f3e58d2acc 100644
--- a/src/main/java/gregtech/common/blocks/GT_Item_Casings5.java
+++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings5.java
@@ -2,6 +2,8 @@ package gregtech.common.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
+import gregtech.api.enums.HeatingCoilLevel;
+import gregtech.api.util.GT_LanguageManager;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@@ -12,37 +14,18 @@ public class GT_Item_Casings5 extends GT_Item_Casings_Abstract {
public GT_Item_Casings5(Block par1) {
super(par1);
}
+
+ protected static final String mCoilHeatTooltip = GT_LanguageManager.addStringLocalization("gt.coilheattooltip", "Base Heating Capacity = ");
+ protected static final String mCoilUnitTooltip = GT_LanguageManager.addStringLocalization("gt.coilunittooltip", " Kelvin");
+ protected static final String mCoilTierTooltip = GT_LanguageManager.addStringLocalization("gt.coiltiertooltip", "Coil Tier = ");
+
@Override
@SideOnly(Side.CLIENT)
+ @SuppressWarnings("unchecked")
public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) {
super.addInformation(aStack, aPlayer, aList, aF3_H);
- switch (getDamage(aStack)) {
- case 0:
- aList.add(this.mCoil01Tooltip);
- break;
- case 1:
- aList.add(this.mCoil02Tooltip);
- break;
- case 2:
- aList.add(this.mCoil03Tooltip);
- break;
- case 3:
- aList.add(this.mCoil04Tooltip);
- break;
- case 4:
- aList.add(this.mCoil05Tooltip);
- break;
- case 5:
- aList.add(this.mCoil06Tooltip);
- break;
- case 6:
- aList.add(this.mCoil07Tooltip);
- break;
- case 7:
- aList.add(this.mCoil08Tooltip);
- break;
- case 8:
- aList.add(this.mCoil09Tooltip);
- }
+ HeatingCoilLevel coilLevel = GT_Block_Casings5.getCoilHeatFromDamage(aStack.getItemDamage());
+ aList.add(mCoilHeatTooltip + coilLevel.getHeat() + mCoilUnitTooltip);
+ aList.add(mCoilTierTooltip + coilLevel.getTierName());
}
}
diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java
index 0b3cc6182a..917f31f9ce 100644
--- a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java
+++ b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java
@@ -64,10 +64,12 @@ public class GT_Item_Machines extends ItemBlock {
}
if (tTileEntity.getEUCapacity() > 0L) {
if (tTileEntity.getInputVoltage() > 0L) {
- aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_IN", "Voltage IN: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + tTileEntity.getInputVoltage() + " (" + GT_Values.VN[GT_Utility.getTier(tTileEntity.getInputVoltage())] + ")" + EnumChatFormatting.GRAY);
+ int inputTier = GT_Utility.getTier(tTileEntity.getInputVoltage());
+ aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_IN", "Voltage IN: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + tTileEntity.getInputVoltage() + " (" + GT_Values.TIER_COLORS[inputTier] + GT_Values.VN[inputTier] + EnumChatFormatting.GREEN +")" + EnumChatFormatting.GRAY);
}
if (tTileEntity.getOutputVoltage() > 0L) {
- aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_OUT", "Voltage OUT: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + tTileEntity.getOutputVoltage() + " (" + GT_Values.VN[GT_Utility.getTier(tTileEntity.getOutputVoltage())] + ")" + EnumChatFormatting.GRAY);
+ int outputTier = GT_Utility.getTier(tTileEntity.getOutputVoltage());
+ aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_OUT", "Voltage OUT: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + tTileEntity.getOutputVoltage() + " (" + GT_Values.TIER_COLORS[outputTier] + GT_Values.VN[outputTier] + EnumChatFormatting.GREEN + ")" + EnumChatFormatting.GRAY);
}
if (tTileEntity.getOutputAmperage() > 1L) {
aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_AMOUNT", "Amperage: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.YELLOW + tTileEntity.getOutputAmperage() + EnumChatFormatting.GRAY);
diff --git a/src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java b/src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java
index 39c87669f1..f8784d570f 100644
--- a/src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java
+++ b/src/main/java/gregtech/common/covers/GT_Cover_FluidRegulator.java
@@ -50,14 +50,7 @@ public class GT_Cover_FluidRegulator extends GT_CoverBehavior {
tLiquid = tLiquid.copy();
tLiquid.amount = tTank2.fill(directionTo, tLiquid, false);
if (tLiquid.amount > 0) {
- if (aTileEntity.getUniversalEnergyCapacity() >= Math.min(1, tLiquid.amount / 10)) {
- if (aTileEntity.isUniversalEnergyStored(Math.min(1, tLiquid.amount / 10))) {
- aTileEntity.decreaseStoredEnergyUnits(Math.min(1, tLiquid.amount / 10), true);
- tTank2.fill(directionTo, tTank1.drain(directionFrom, tLiquid.amount, true), true);
- }
- } else {
- tTank2.fill(directionTo, tTank1.drain(directionFrom, tLiquid.amount, true), true);
- }
+ tTank2.fill(directionTo, tTank1.drain(directionFrom, tLiquid.amount, true), true);
}
}
}
diff --git a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java
index 6605d4fc35..4e80b7b779 100644
--- a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java
+++ b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ChestBuffer.java
@@ -19,7 +19,7 @@ import java.util.Comparator;
public class GT_MetaTileEntity_ChestBuffer
extends GT_MetaTileEntity_Buffer {
- private static final int[] tickRate = {400, 200, 100, 20, 4, 1, 1, 1,1,1};
+ private static final int[] tickRate = {400, 200, 100, 20, 4, 1, 1, 1, 1, 1, 1, 1, 1};
public GT_MetaTileEntity_ChestBuffer(int aID, String aName, String aNameRegional, int aTier) {
diff --git a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java
index 5fa3bc8c82..37d8585310 100644
--- a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java
+++ b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java
@@ -143,7 +143,6 @@ public class GT_MetaTileEntity_ItemDistributor extends GT_MetaTileEntity_Buffer
}
if (movedItems > 0 || aBaseMetaTileEntity.hasInventoryBeenModified()) {
mSuccess = 50;
- aBaseMetaTileEntity.decreaseStoredEnergyUnits(Math.abs(movedItems), true);
}
fillStacksIntoFirstSlots();
}
diff --git a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_Regulator.java b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_Regulator.java
index b5a33bfb81..746e182066 100644
--- a/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_Regulator.java
+++ b/src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_Regulator.java
@@ -95,7 +95,6 @@ public class GT_MetaTileEntity_Regulator
tCosts = GT_Utility.moveOneItemStackIntoSlot(getBaseMetaTileEntity(), getBaseMetaTileEntity().getTileEntityAtSide(getBaseMetaTileEntity().getBackFacing()), getBaseMetaTileEntity().getBackFacing(), this.mTargetSlots[i], Arrays.asList(new ItemStack[]{this.mInventory[(i + 9)]}), false, (byte) this.mInventory[(i + 9)].stackSize, (byte) this.mInventory[(i + 9)].stackSize, (byte) 64, (byte) 1) * 3;
if (tCosts > 0) {
this.mSuccess = 50;
- getBaseMetaTileEntity().decreaseStoredEnergyUnits(tCosts, true);
break;
}
}
diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java
index ce1812a9cf..92ed054b05 100644
--- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java
+++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java
@@ -1,15 +1,34 @@
package gregtech.common.tileentities.machines.basic;
-import gregtech.api.enums.GT_Values;
+import com.google.common.collect.ArrayListMultimap;
+import gregtech.api.GregTech_API;
+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.items.GT_MetaGenerated_Tool;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock;
+import gregtech.api.objects.GT_ItemStack;
import gregtech.api.objects.GT_RenderedTexture;
+import gregtech.api.objects.ItemData;
+import gregtech.api.util.GT_OreDictUnificator;
+import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
+import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
+import net.minecraftforge.oredict.OreDictionary;
+
+import java.util.*;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
public class GT_MetaTileEntity_Disassembler
extends GT_MetaTileEntity_BasicMachine {
@@ -29,79 +48,380 @@ public class GT_MetaTileEntity_Disassembler
return new GT_MetaTileEntity_Disassembler(this.mName, this.mTier, this.mDescriptionArray, this.mTextures, this.mGUIName, this.mNEIName);
}
+ private static final ItemStack[][] alwaysReplace = new ItemStack[][]{
+ {
+ //ItemStack to look for
+ new ItemStack(Blocks.trapped_chest, 1, OreDictionary.WILDCARD_VALUE)
+ },
+ {
+ //ItemStack to replace
+ new ItemStack(Blocks.chest)
+ }
+ };
+
+ private static final Object[][] OreDictionaryOverride = new Object[][]{
+ {
+ //String to look for
+ "plankWood",
+ "stoneCobble",
+ "gemDiamond",
+ "logWood",
+ "stickWood",
+ "treeSapling"
+ },
+ {
+ //ItemStack to replace
+ new ItemStack(Blocks.planks),
+ new ItemStack(Blocks.cobblestone),
+ new ItemStack(Items.diamond),
+ new ItemStack(Blocks.log),
+ new ItemStack(Items.stick),
+ new ItemStack(Blocks.sapling)
+ }
+ };
+
+ public static ArrayListMultimap<GT_ItemStack, ItemStack> getOutputHardOverrides() {
+ return outputHardOverrides;
+ }
+
+ private static final ArrayListMultimap<GT_ItemStack, ItemStack> outputHardOverrides;
+
+ static {
+ outputHardOverrides = ArrayListMultimap.create();
+ outputHardOverrides.put(new GT_ItemStack(new ItemStack(Blocks.torch,6)), new ItemStack(Items.stick));
+ }
+
public int checkRecipe() {
- //if ((getInputAt(0) != null) && (isOutputEmpty())) {
- // if(GT_Utility.areStacksEqual(getInputAt(0), new ItemStack(Items.egg))){
- // getInputAt(0).stackSize -= 1;
- // this.mEUt = (16 * (1 << this.mTier - 1) * (1 << this.mTier - 1));
- // this.mMaxProgresstime = 2400;
- // this.mMaxProgresstime = this.mMaxProgresstime >> (mTier);
- //if (getBaseMetaTileEntity().getRandomNumber(100) < (this.mTier+1)) {
- // this.mOutputItems[0] = ItemList.Circuit_Chip_Stemcell.get(1, new Object[0]);
- //}
- //return 2;
- //}
- NBTTagCompound tNBT = getInputAt(0).getTagCompound();
- if (tNBT != null) {
- tNBT = tNBT.getCompoundTag("GT.CraftingComponents");
- if (tNBT != null) {
- boolean isAnyOutput=false;
- calculateOverclockedNessDisassembler(16);
- this.mMaxProgresstime = 80;
- //In case recipe is too OP for that machine
- if (mEUt == Integer.MAX_VALUE - 1)//&& mMaxProgresstime==Integer.MAX_VALUE-1
- return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS;
- for (int i = 0; i < this.mOutputItems.length; i++) {
- if (getBaseMetaTileEntity().getRandomNumber(100) < 50 + 10 * this.mTier) {
- this.mOutputItems[i] = GT_Utility.loadItem(tNBT, "Ingredient." + i);
- if (this.mOutputItems[i] != null) {
- this.mMaxProgresstime *= 1.7F;
- isAnyOutput=true;
- }
- }
- }
- if(!isAnyOutput)
- return DID_NOT_FIND_RECIPE;
- for(int i=mTier-5;i>0;i--){
- this.mMaxProgresstime>>=1;
- if(this.mMaxProgresstime==0)
- this.mEUt = this.mEUt>>1;
- }
- if(this.mEUt==0)
- mEUt = 1;
- if(this.mMaxProgresstime==0)
- this.mMaxProgresstime = 1;
- getInputAt(0).stackSize -= 1;
- return FOUND_AND_SUCCESSFULLY_USED_RECIPE;
- }
+ ItemStack is = getInputAt(0);
+ if (GT_Utility.isStackInvalid(is))
+ return DID_NOT_FIND_RECIPE;
+ if (is.getItem() instanceof GT_MetaGenerated_Tool)
+ return DID_NOT_FIND_RECIPE;
+ ItemStack comp = new ItemStack(GregTech_API.sBlockMachines);
+ if (is.getItem() == comp.getItem()) {
+ IMetaTileEntity iMetaTileEntity = GregTech_API.METATILEENTITIES[is.getItemDamage()];
+ if (iMetaTileEntity instanceof GT_MetaTileEntity_TieredMachineBlock &&
+ ((GT_MetaTileEntity_TieredMachineBlock) iMetaTileEntity).mTier > this.mTier)
+ return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS;
+ }
+ Set<GT_ItemStack> stacks = outputHardOverrides.keySet();
+ for (GT_ItemStack stack : stacks) {
+ ItemStack in = is.copy();
+ in.stackSize = 1;
+ if (stack.isStackEqual(in) && stack.mStackSize <= is.stackSize) {
+ return setOutputsAndTime(outputHardOverrides.get(stack).toArray(new ItemStack[0]), stack.mStackSize)
+ ? FOUND_AND_SUCCESSFULLY_USED_RECIPE
+ : DID_NOT_FIND_RECIPE;
}
+ }
+ return process()
+ ? FOUND_AND_SUCCESSFULLY_USED_RECIPE
+ : DID_NOT_FIND_RECIPE;
+ }
+
+ private boolean process(){
+
+ GT_Recipe gt_recipe = GT_Recipe.GT_Recipe_Map.sDisassemblerRecipes.findRecipe(this.getBaseMetaTileEntity(), true, this.mEUt, null, this.getAllInputs());
+ if (gt_recipe != null) {
+ gt_recipe.isRecipeInputEqual(true, null, this.getRealInventory());
+ return setOutputsAndTime(gt_recipe.mOutputs, gt_recipe.mInputs[0].stackSize);
+ }
+
+ Collection<DissassembleReference> recipes = this.findRecipeFromMachine();
+ if (recipes.isEmpty())
+ return false;
- return DID_NOT_FIND_RECIPE;
+ DissassembleReference recipe = ensureDowncasting(recipes);
+
+ for (int i = 0; i < recipe.inputs.length; i++)
+ if (GT_Utility.isStackInvalid(recipe.inputs[i]) || recipe.inputs[i].stackSize < 1)
+ recipe.inputs[i] = null;
+
+ recipe.inputs = GT_Utility.getArrayListWithoutNulls(recipe.inputs).toArray(new ItemStack[0]);
+
+ return setOutputsAndTime(recipe.inputs, recipe.stackSize);
}
- private void calculateOverclockedNessDisassembler(int aEUt) {
- if(mTier==0){
- mEUt=aEUt>>2;
- }else{
- //Long EUt calculation
- long xEUt=aEUt;
- //Isnt too low EUt check?
- long tempEUt = xEUt<GT_Values.V[1] ? GT_Values.V[1] : xEUt;
+ private boolean setOutputsAndTime(ItemStack[] inputs, int stackSize){
+ if (this.getInputAt(0).stackSize >= stackSize)
+ this.getInputAt(0).stackSize -= stackSize;
+ else
+ return false;
+
+ System.arraycopy(inputs, 0, this.mOutputItems, 0, inputs.length);
+ this.calculateOverclockedNess(30,600);
+
+ return true;
+ }
+
+ private static DissassembleReference ensureDowncasting(Collection<DissassembleReference> recipes) {
+ ItemStack[] inputs = recipes.stream()
+ .findFirst()
+ .orElseThrow(NullPointerException::new)
+ .inputs;
+
+ ItemStack[] output = new ItemStack[inputs.length];
+ List<GT_Recipe> recipesColl = null;
+ if (recipes.size() > 1)
+ recipesColl = recipes.stream()
+ .skip(1)
+ .map(x -> x.recipe)
+ .collect(Collectors.toList());
+
+ handleRecipeTransformation(inputs, output, recipesColl);
- while (tempEUt <= GT_Values.V[mTier -1] * (long)mAmperage) {
- tempEUt<<=2;//this actually controls overclocking
- xEUt<<=2;//this is effect of overclocking
+ return new DissassembleReference(recipes.stream().mapToInt(x -> x.stackSize).min().orElseThrow(NumberFormatException::new), output, null);
+ }
+
+ private static void handleRecipeTransformation(ItemStack[] inputs, ItemStack[] output, List<GT_Recipe> recipesColl) {
+ for (int i = 0, inputsLength = inputs.length; i < inputsLength; i++) {
+ Set<ItemStack[]> inputsStacks = null;
+ if (recipesColl != null)
+ inputsStacks = recipesColl.stream()
+ .map(x -> x.mInputs)
+ .collect(Collectors.toSet());
+ ItemStack input = inputs[i];
+ ItemData data = GT_OreDictUnificator.getItemData(input);
+ if (data == null || data.mMaterial == null || data.mMaterial.mMaterial == null || data.mPrefix == null) {
+ output[i] = input;
+ continue;
}
- if(xEUt>Integer.MAX_VALUE-1){
- mEUt = Integer.MAX_VALUE-1;
- }else{
- mEUt = (int)xEUt;
+ handleReplacement(inputsStacks, data, output, input, i);
+ }
+ addOthersAndHandleAlwaysReplace(inputs, output);
+ }
+
+ /**
+ * Public Interface for ReverseRecipes, do not call inside of this class.
+ * @param inputs
+ * @param output
+ * @param inputsStacks
+ */
+ public static void handleRecipeTransformation(ItemStack[] inputs, ItemStack[] output, Set<ItemStack[]> inputsStacks) {
+ for (int i = 0, inputsLength = inputs.length; i < inputsLength; i++) {
+ ItemStack input = inputs[i];
+ ItemData data = GT_OreDictUnificator.getItemData(input);
+ if (data == null || data.mMaterial == null || data.mMaterial.mMaterial == null || data.mPrefix == null) {
+ output[i] = input;
+ continue;
}
+ handleReplacement(inputsStacks, data, output, input, i);
}
+ addOthersAndHandleAlwaysReplace(inputs, output);
+ }
+
+ private static void addOthersAndHandleAlwaysReplace(ItemStack[] inputs, ItemStack[] output){
+ for (int i = 0; i < inputs.length; i++) {
+ //Adds rest of Items
+ if (output[i] == null)
+ output[i] = inputs[i];
+
+ //Math.min the recipe output if Items are the same
+ if (GT_Utility.areStacksEqual(output[i], inputs[i]))
+ output[i].stackSize = Math.min(output[i].stackSize, inputs[i].stackSize);
+
+ //Handles replacement Overrides
+ ItemStack[] itemStacks = GT_MetaTileEntity_Disassembler.alwaysReplace[0];
+ for (int j = 0; j < itemStacks.length; j++) {
+ ItemStack x = itemStacks[j];
+ if (GT_Utility.areStacksEqual(x, output[i], true)) {
+ output[i] = GT_MetaTileEntity_Disassembler.alwaysReplace[1][j];
+ break;
+ }
+ }
+
+ //Unification
+ output[i] = handleUnification(output[i]);
+ }
+ }
+
+ private static ItemStack handleUnification(ItemStack stack) {
+ for (int oreID : OreDictionary.getOreIDs(stack)) {
+ for (int i = 0; i < OreDictionaryOverride[0].length; i++)
+ if (OreDictionary.getOreName(oreID).equals(OreDictionaryOverride[0][i])){
+ ItemStack ret = ((ItemStack) OreDictionaryOverride[1][i]).copy();
+ ret.stackSize = stack.stackSize;
+ return ret;
+ }
+ }
+ return GT_OreDictUnificator.get(stack);
+ }
+
+ private static void handleReplacement(Set<ItemStack[]> inputsStacks, ItemData data, ItemStack[] output, ItemStack input, int i){
+ AtomicReference<Materials> toRpl = new AtomicReference<>();
+ Materials first = data.mMaterial.mMaterial;
+ if (inputsStacks != null) {
+ handleInputStacks(inputsStacks, toRpl, data, first, i);
+ }
+ if (toRpl.get() == null) {
+ //Remove Magnetic and Annealed Modifiers
+ handleBetterMaterialsVersions(data, toRpl);
+ }
+ if (toRpl.get() != null) {
+ output[i] = GT_OreDictUnificator.get(data.mPrefix, toRpl.get(), input.stackSize);
+ return;
+ }
+ if (data.mPrefix == OrePrefixes.circuit) {
+ handleCircuits(first, output, input, i);
+ }
+ }
+
+ private static void handleInputStacks(Set<ItemStack[]> inputsStacks, AtomicReference<Materials> toRpl, ItemData data, Materials first, int i){
+ final int finalIndex = i;
+ inputsStacks.forEach(stackArray -> {
+ ItemData dataAgainst = GT_OreDictUnificator.getItemData(stackArray[finalIndex]);
+ if (
+ dataAgainst == null ||
+ dataAgainst.mMaterial == null ||
+ dataAgainst.mMaterial.mMaterial == null ||
+ dataAgainst.mPrefix == null ||
+ dataAgainst.mPrefix != data.mPrefix
+ ) {
+ return;
+ }
+ handleDifferentMaterialsOnRecipes(first, dataAgainst.mMaterial.mMaterial, toRpl);
+ handleAnyMaterials(first,toRpl);
+ });
+ }
+
+ private static void handleAnyMaterials(Materials first, AtomicReference<Materials> toRpl){
+ if (first.mOreReRegistrations.stream().anyMatch(y -> y.equals(Materials.AnyIron)))
+ toRpl.set(Materials.Iron);
+ else if (first.mOreReRegistrations.stream().anyMatch(y -> y.equals(Materials.AnyCopper)))
+ toRpl.set(Materials.Copper);
+ else if (first.mOreReRegistrations.stream().anyMatch(y -> y.equals(Materials.AnyRubber)))
+ toRpl.set(Materials.Rubber);
+ else if (first.mOreReRegistrations.stream().anyMatch(y -> y.equals(Materials.AnyBronze)))
+ toRpl.set(Materials.Bronze);
+ else if (first.mOreReRegistrations.stream().anyMatch(y -> y.equals(Materials.AnySyntheticRubber)))
+ toRpl.set(Materials.Rubber);
+ }
+
+ private static void handleDifferentMaterialsOnRecipes(Materials first, Materials second, AtomicReference<Materials> toRpl){
+ if (!first.equals(second))
+ if (first.equals(Materials.Aluminium) && second.equals(Materials.Iron))
+ toRpl.set(second);
+ else if (first.equals(Materials.Steel) && second.equals(Materials.Iron))
+ toRpl.set(second);
+ else if (first.equals(Materials.WroughtIron) && second.equals(Materials.Iron))
+ toRpl.set(second);
+ else if (first.equals(Materials.Aluminium) && second.equals(Materials.WroughtIron))
+ toRpl.set(Materials.Iron);
+ else if (first.equals(Materials.Aluminium) && second.equals(Materials.Steel))
+ toRpl.set(second);
+ else if (first.equals(Materials.Polytetrafluoroethylene) && second.equals(Materials.Plastic))
+ toRpl.set(second);
+ else if (first.equals(Materials.Polybenzimidazole) && second.equals(Materials.Plastic))
+ toRpl.set(second);
+ else if (first.equals(Materials.Polystyrene) && second.equals(Materials.Plastic))
+ toRpl.set(second);
+ else if (first.equals(Materials.Silicone) && second.equals(Materials.Plastic))
+ toRpl.set(second);
+ else if (first.equals(Materials.NetherQuartz) || first.equals(Materials.CertusQuartz) && second.equals(Materials.Quartzite))
+ toRpl.set(second);
+ else if (first.equals(Materials.Plastic) && second.equals(Materials.Wood))
+ toRpl.set(second);
+ else if (first.equals(Materials.Diamond) && second.equals(Materials.Glass))
+ toRpl.set(second);
+ }
+
+ private static void handleBetterMaterialsVersions(ItemData data, AtomicReference<Materials> toRpl){
+ if (Materials.SteelMagnetic.equals(data.mMaterial.mMaterial)) {
+ toRpl.set(Materials.Steel);
+ } else if (Materials.IronMagnetic.equals(data.mMaterial.mMaterial)) {
+ toRpl.set(Materials.Iron);
+ } else if (Materials.NeodymiumMagnetic.equals(data.mMaterial.mMaterial)) {
+ toRpl.set(Materials.Neodymium);
+ } else if (Materials.SamariumMagnetic.equals(data.mMaterial.mMaterial)) {
+ toRpl.set(Materials.Samarium);
+ } else if (Materials.AnnealedCopper.equals(data.mMaterial.mMaterial)) {
+ toRpl.set(Materials.Copper);
+ }
+ }
+
+ @SuppressWarnings("deprecation")
+ private static void handleCircuits(Materials first, ItemStack[] output, ItemStack input, int i){
+ if (first.equals(Materials.Primitive))
+ output[i] = ItemList.NandChip.get(input.stackSize);
+ else if (first.equals(Materials.Basic))
+ output[i] = ItemList.Circuit_Microprocessor.get(input.stackSize);
+ else if (first.equals(Materials.Good))
+ output[i] = ItemList.Circuit_Good.get(input.stackSize);
+ else if (first.equals(Materials.Advanced))
+ output[i] = ItemList.Circuit_Advanced.get(input.stackSize);
+ else if (first.equals(Materials.Data))
+ output[i] = ItemList.Circuit_Data.get(input.stackSize);
+ else if (first.equals(Materials.Master))
+ output[i] = ItemList.Circuit_Master.get(input.stackSize);
+ else if (first.equals(Materials.Ultimate))
+ output[i] = ItemList.Circuit_Quantummainframe.get(input.stackSize);
+ else if (first.equals(Materials.Superconductor))
+ output[i] = ItemList.Circuit_Crystalmainframe.get(input.stackSize);
+ else if (first.equals(Materials.Infinite))
+ output[i] = ItemList.Circuit_Wetwaremainframe.get(input.stackSize);
+ else if (first.equals(Materials.Bio))
+ output[i] = ItemList.Circuit_Biomainframe.get(input.stackSize);
+ }
+
+ static class DissassembleReference {
+ final int stackSize;
+ ItemStack[] inputs;
+ final GT_Recipe recipe;
+
+ public DissassembleReference(int stackSize, ItemStack[] inputs, GT_Recipe recipe) {
+ this.stackSize = stackSize;
+ this.inputs = inputs;
+ this.recipe = recipe;
+ }
+ }
+
+ private Collection<DissassembleReference> findRecipeFromMachine() {
+ ItemStack is = getInputAt(0);
+ if (GT_Utility.isStackInvalid(is))
+ return Collections.emptySet();
+
+ AtomicInteger stacksize = new AtomicInteger();
+ //Check Recipe Maps for creation of Item
+ List<DissassembleReference> possibleRecipes = GT_Recipe.GT_Recipe_Map.sAssemblerRecipes.mRecipeList.stream()
+ .filter(x -> Arrays.stream(x.mOutputs)
+ .anyMatch(y ->
+ {
+ ItemStack out = is.copy();
+ out.stackSize = y.stackSize;
+ boolean isDone = GT_Utility.areStacksEqual(y, out, true) && y.stackSize <= is.stackSize;
+ if (isDone)
+ stacksize.set(y.stackSize);
+ return isDone;
+ })
+ )
+ .map(x -> new DissassembleReference(stacksize.get(), x.mInputs, x))
+ .collect(Collectors.toList());
+
+ //Is there only one way to create it?
+ if (possibleRecipes.size() == 1)
+ return possibleRecipes;
+
+ //There are Multiple Ways -> Get recipe with cheapest inputs