Merge pull request #526 from perkinslr/experimental
Make processing array handle multiple input stacks at a time
This commit is contained in:
commit
7a9c3857e2
2 changed files with 70 additions and 47 deletions
|
@ -317,57 +317,102 @@ public class GT_Recipe {
|
||||||
|
|
||||||
public boolean isRecipeInputEqual(boolean aDecreaseStacksizeBySuccess, boolean aDontCheckStackSizes, FluidStack[] aFluidInputs, ItemStack... aInputs) {
|
public boolean isRecipeInputEqual(boolean aDecreaseStacksizeBySuccess, boolean aDontCheckStackSizes, FluidStack[] aFluidInputs, ItemStack... aInputs) {
|
||||||
if (mFluidInputs.length > 0 && aFluidInputs == null) return false;
|
if (mFluidInputs.length > 0 && aFluidInputs == null) return false;
|
||||||
|
int amt;
|
||||||
for (FluidStack tFluid : mFluidInputs)
|
for (FluidStack tFluid : mFluidInputs)
|
||||||
if (tFluid != null) {
|
if (tFluid != null) {
|
||||||
boolean temp = true;
|
boolean temp = true;
|
||||||
|
amt = tFluid.amount;
|
||||||
for (FluidStack aFluid : aFluidInputs)
|
for (FluidStack aFluid : aFluidInputs)
|
||||||
if (aFluid != null && aFluid.isFluidEqual(tFluid) && (aDontCheckStackSizes || aFluid.amount >= tFluid.amount)) {
|
if (aFluid != null && aFluid.isFluidEqual(tFluid)){
|
||||||
temp = false;
|
if (aDontCheckStackSizes ){
|
||||||
break;
|
temp = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
amt -= aFluid.amount;
|
||||||
|
if (amt<1){
|
||||||
|
temp = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (temp) return false;
|
if (temp) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mInputs.length > 0 && aInputs == null) return false;
|
if (mInputs.length > 0 && aInputs == null) return false;
|
||||||
|
|
||||||
for (ItemStack tStack : mInputs)
|
for (ItemStack tStack : mInputs) {
|
||||||
if (tStack != null) {
|
if (tStack != null) {
|
||||||
|
amt = tStack.stackSize;
|
||||||
boolean temp = true;
|
boolean temp = true;
|
||||||
for (ItemStack aStack : aInputs)
|
for (ItemStack aStack : aInputs) {
|
||||||
if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true)) && (aDontCheckStackSizes || aStack.stackSize >= tStack.stackSize)) {
|
if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) {
|
||||||
temp = false;
|
if (aDontCheckStackSizes) {
|
||||||
break;
|
temp = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
amt -= aStack.stackSize;
|
||||||
|
if (amt < 1) {
|
||||||
|
temp = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (temp) return false;
|
if (temp) return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (aDecreaseStacksizeBySuccess) {
|
if (aDecreaseStacksizeBySuccess) {
|
||||||
if (aFluidInputs != null) {
|
if (aFluidInputs != null) {
|
||||||
for (FluidStack tFluid : mFluidInputs)
|
for (FluidStack tFluid : mFluidInputs) {
|
||||||
if (tFluid != null) {
|
if (tFluid != null) {
|
||||||
for (FluidStack aFluid : aFluidInputs)
|
amt = tFluid.amount;
|
||||||
if (aFluid != null && aFluid.isFluidEqual(tFluid) && (aDontCheckStackSizes || aFluid.amount >= tFluid.amount)) {
|
for (FluidStack aFluid : aFluidInputs) {
|
||||||
aFluid.amount -= tFluid.amount;
|
if (aFluid != null && aFluid.isFluidEqual(tFluid)) {
|
||||||
break;
|
if (aDontCheckStackSizes) {
|
||||||
|
aFluid.amount -= amt;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (aFluid.amount < amt) {
|
||||||
|
amt -= aFluid.amount;
|
||||||
|
aFluid.amount = 0;
|
||||||
|
} else {
|
||||||
|
aFluid.amount -= amt;
|
||||||
|
amt = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aInputs != null) {
|
if (aInputs != null) {
|
||||||
for (ItemStack tStack : mInputs)
|
for (ItemStack tStack : mInputs) {
|
||||||
if (tStack != null) {
|
if (tStack != null) {
|
||||||
for (ItemStack aStack : aInputs)
|
amt = tStack.stackSize;
|
||||||
if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true)) && (aDontCheckStackSizes || aStack.stackSize >= tStack.stackSize)) {
|
for (ItemStack aStack : aInputs) {
|
||||||
aStack.stackSize -= tStack.stackSize;
|
if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) {
|
||||||
break;
|
if (aDontCheckStackSizes){
|
||||||
|
aStack.stackSize -= amt;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (aStack.stackSize < amt){
|
||||||
|
amt -= aStack.stackSize;
|
||||||
|
aStack.stackSize = 0;
|
||||||
|
}else{
|
||||||
|
aStack.stackSize -= amt;
|
||||||
|
amt = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class GT_Recipe_Map {
|
public static class GT_Recipe_Map {
|
||||||
/**
|
/**
|
||||||
* Contains all Recipe Maps
|
* Contains all Recipe Maps
|
||||||
|
@ -1272,4 +1317,4 @@ public class GT_Recipe {
|
||||||
return super.containsInput(aFluid) || Dyes.isAnyFluidDye(aFluid);
|
return super.containsInput(aFluid) || Dyes.isAnyFluidDye(aFluid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,34 +168,12 @@ public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_MultiBl
|
||||||
if (mInventory[1].getUnlocalizedName().endsWith("5")) {
|
if (mInventory[1].getUnlocalizedName().endsWith("5")) {
|
||||||
tTier = 5;
|
tTier = 5;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < tInputList.size() - 1; i++) {
|
|
||||||
for (int j = i + 1; j < tInputList.size(); j++) {
|
ItemStack[] tInputs = (ItemStack[]) tInputList.toArray(new ItemStack[tInputList.size()]);
|
||||||
if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) {
|
|
||||||
if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) {
|
|
||||||
tInputList.remove(j--);
|
|
||||||
} else {
|
|
||||||
tInputList.remove(i--);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2);
|
|
||||||
|
|
||||||
ArrayList<FluidStack> tFluidList = getStoredFluids();
|
ArrayList<FluidStack> tFluidList = getStoredFluids();
|
||||||
for (int i = 0; i < tFluidList.size() - 1; i++) {
|
|
||||||
for (int j = i + 1; j < tFluidList.size(); j++) {
|
FluidStack[] tFluids = (FluidStack[]) tFluidList.toArray(new FluidStack[tFluidList.size()]);
|
||||||
if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) {
|
|
||||||
if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) {
|
|
||||||
tFluidList.remove(j--);
|
|
||||||
} else {
|
|
||||||
tFluidList.remove(i--);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1);
|
|
||||||
if (tInputList.size() > 0 || tFluids.length > 0) {
|
if (tInputList.size() > 0 || tFluids.length > 0) {
|
||||||
GT_Recipe tRecipe = map.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs);
|
GT_Recipe tRecipe = map.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs);
|
||||||
if (tRecipe != null) {
|
if (tRecipe != null) {
|
||||||
|
@ -328,4 +306,4 @@ public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_MultiBl
|
||||||
public boolean explodesOnComponentBreak(ItemStack aStack) {
|
public boolean explodesOnComponentBreak(ItemStack aStack) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue