Finish Assemblyline recipe check (Blood Asp)

This commit is contained in:
Dream-Master 2016-06-30 22:28:48 +02:00
parent 6daf342c2f
commit c3fcd31146
3 changed files with 70 additions and 69 deletions

View file

@ -771,25 +771,16 @@ public class GT_RecipeAdder
} }
@Override @Override
public boolean addAssemblylineRecipe(ItemStack aResearchItem, int aResearchTime, ItemStack[] aInputs, FluidStack[] aFluidInputs, ItemStack aOutput1, int aDuration, int aEUt) { public boolean addAssemblylineRecipe(ItemStack aResearchItem, int aResearchTime, ItemStack[] aInputs, FluidStack[] aFluidInputs, ItemStack aOutput, int aDuration, int aEUt) {
if ((aResearchItem==null)||(aResearchTime<=0)||(aInputs == null) || (aOutput1 == null) || aInputs.length>15 || aInputs.length<4) { if ((aResearchItem==null)||(aResearchTime<=0)||(aInputs == null) || (aOutput == null) || aInputs.length>15 || aInputs.length<4) {
return false; return false;
} }
if ((aDuration = GregTech_API.sRecipeFile.get("assemblingline", aOutput1, aDuration)) <= 0) { if ((aDuration = GregTech_API.sRecipeFile.get("assemblingline", aOutput, aDuration)) <= 0) {
return false; return false;
} }
// String tRecipe = ""; GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{aResearchItem}, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Research result", new Object[0])}, null, null, aResearchTime, 30, 0);
// for(ItemStack sStack: aInputs){
// tRecipe += sStack.getItem().getItemStackDisplayName(sStack)+" x"+sStack.stackSize+"; ";
// }
//
// for(FluidStack sStack: aFluidInputs){
// tRecipe += sStack.getLocalizedName()+" "+sStack.amount+"L; ";
// }
//
GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.addFakeRecipe(false, new ItemStack[]{aResearchItem}, new ItemStack[]{aOutput1}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Research result", new Object[0])}, null, null, aResearchTime, 30, 0);
GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes.add(new GT_Recipe_AssemblyLine( aResearchItem, aResearchTime, aInputs, aFluidInputs, aOutput1, aDuration, aEUt)); GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes.add(new GT_Recipe_AssemblyLine( aResearchItem, aResearchTime, aInputs, aFluidInputs, aOutput, aDuration, aEUt));
return true; return true;
} }

View file

@ -162,16 +162,16 @@ public class GT_MetaTileEntity_Scanner
if (tNBT == null) { if (tNBT == null) {
tNBT = new NBTTagCompound(); tNBT = new NBTTagCompound();
} }
tNBT.setTag("output", new NBTTagCompound()); tNBT.setTag("output", tRecipe.mOutput.writeToNBT(new NBTTagCompound()));
tNBT.setInteger("time", tRecipe.mDuration); tNBT.setInteger("time", tRecipe.mDuration);
tNBT.setInteger("eu", tRecipe.mEUt); tNBT.setInteger("eu", tRecipe.mEUt);
for(int i = 0 ; i < tRecipe.mInputs.length ; i++){ for(int i = 0 ; i < tRecipe.mInputs.length ; i++){
tNBT.setTag(""+i, new NBTTagCompound()); tNBT.setTag(""+i, tRecipe.mInputs[i].writeToNBT(new NBTTagCompound()));
} }
for(int i = 0 ; i < tRecipe.mFluidInputs.length ; i++){ for(int i = 0 ; i < tRecipe.mFluidInputs.length ; i++){
tNBT.setTag("f"+i, new NBTTagCompound()); tNBT.setTag("f"+i, tRecipe.mFluidInputs[i].writeToNBT(new NBTTagCompound()));
} }
this.mOutputItems[0].setTagCompound(tNBT); this.mOutputItems[0].setTagCompound(tNBT);

View file

@ -1,6 +1,7 @@
package gregtech.common.tileentities.machines.multi; package gregtech.common.tileentities.machines.multi;
import gregtech.api.GregTech_API; import gregtech.api.GregTech_API;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Textures; import gregtech.api.enums.Textures;
import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.gui.GT_GUIContainer_MultiMachine;
import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.ITexture;
@ -13,6 +14,7 @@ import gregtech.api.util.GT_Utility;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
@ -55,7 +57,7 @@ public class GT_MetaTileEntity_AssemblyLine
} }
public GT_Recipe.GT_Recipe_Map getRecipeMap() { public GT_Recipe.GT_Recipe_Map getRecipeMap() {
return GT_Recipe.GT_Recipe_Map.sImplosionRecipes; return null;
} }
public boolean isCorrectMachinePart(ItemStack aStack) { public boolean isCorrectMachinePart(ItemStack aStack) {
@ -67,63 +69,71 @@ public class GT_MetaTileEntity_AssemblyLine
} }
public boolean checkRecipe(ItemStack aStack) { public boolean checkRecipe(ItemStack aStack) {
ArrayList<ItemStack> tInputList = getStoredInputs(); if(!GT_Utility.isStackValid(mInventory[1]) && !ItemList.Tool_DataStick.isStackEqual(mInventory[1], false, true))return false;
for (int i = 0; i < tInputList.size() - 1; i++) { NBTTagCompound tTag = mInventory[1].getTagCompound();
for (int j = i + 1; j < tInputList.size(); j++) { if(tTag==null)return false;
if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { ItemStack tStack[] = new ItemStack[15];
if (((ItemStack) tInputList.get(i)).stackSize >= ((ItemStack) tInputList.get(j)).stackSize) { for(int i = 0;i<15;i++){
tInputList.remove(j--); if(tTag.hasKey(""+i)){
} else { tStack[i] = GT_Utility.loadItem(tTag, ""+i);
tInputList.remove(i--); if(tStack[i]!=null){
break; if(mInputBusses.get(i)==null)return false;
} if(GT_Utility.areStacksEqual(tStack[i],mInputBusses.get(i).getBaseMetaTileEntity().getStackInSlot(0),true) && tStack[i].stackSize <= mInputBusses.get(i).getBaseMetaTileEntity().getStackInSlot(0).stackSize){
}else{return false;}
}}
}
FluidStack[] tFluids = new FluidStack[4];
for(int i = 0;i<4;i++){
if(tTag.hasKey("f"+i)){
tFluids[i] = GT_Utility.loadFluid(tTag, "f"+i);
if(tFluids[i]!=null){
if(mInputHatches.get(i)==null)return false;
if(mInputHatches.get(i).mFluid!=null && GT_Utility.areFluidsEqual(mInputHatches.get(i).mFluid, tFluids[i], true) && mInputHatches.get(i).mFluid.amount>=tFluids[i].amount){
}else{return false;}
}
}
}
if(tTag.hasKey("output")){
mOutputItems = new ItemStack[]{GT_Utility.loadItem(tTag, "output")};
if(mOutputItems==null||mOutputItems[0]==null||!GT_Utility.isStackValid(mOutputItems[0]))return false;
}else{return false;}
if(tTag.hasKey("time")){
mMaxProgresstime = tTag.getInteger("time");
if(mMaxProgresstime<=0)return false;
}else{return false;}
if(tTag.hasKey("eu")){
mEUt = tTag.getInteger("eu");
}else{return false;}
for(int i = 0;i<15;i++){
if(tStack[i]!=null){
mInputBusses.get(i).getBaseMetaTileEntity().getStackInSlot(0).stackSize -= tStack[i].stackSize;
if(mInputBusses.get(i).getBaseMetaTileEntity().getStackInSlot(0).stackSize <= 0){
} }
} }
} }
ItemStack[] tInputs = (ItemStack[]) Arrays.copyOfRange(tInputList.toArray(new ItemStack[tInputList.size()]), 0, 2);
ArrayList<FluidStack> tFluidList = getStoredFluids(); for(int i = 0;i<4;i++){
for (int i = 0; i < tFluidList.size() - 1; i++) { if(tFluids[i]!=null){
for (int j = i + 1; j < tFluidList.size(); j++) { mInputHatches.get(i).mFluid.amount -= tFluids[i].amount;
if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(i), (FluidStack) tFluidList.get(j))) { if(mInputHatches.get(i).mFluid.amount<=0){
if (((FluidStack) tFluidList.get(i)).amount >= ((FluidStack) tFluidList.get(j)).amount) { mInputHatches.get(i).mFluid = null;
tFluidList.remove(j--);
} else {
tFluidList.remove(i--);
break;
}
} }
} }
} }
FluidStack[] tFluids = (FluidStack[]) Arrays.copyOfRange(tFluidList.toArray(new FluidStack[tInputList.size()]), 0, 1); byte tTier = (byte) Math.max(1, GT_Utility.getTier(getMaxInputVoltage()));
if (tInputList.size() > 0) { this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
long tVoltage = getMaxInputVoltage(); this.mEfficiencyIncrease = 10000;
byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); if (mEUt <= 16) {
GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sAssemblylineRecipes.findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); this.mEUt = (mEUt * (1 << tTier - 1) * (1 << tTier - 1));
if ((tRecipe != null) && (tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) { this.mMaxProgresstime = (mMaxProgresstime / (1 << tTier - 1));
this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); } else {
this.mEfficiencyIncrease = 10000; while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) {
if (tRecipe.mEUt <= 16) { this.mEUt *= 4;
this.mEUt = (tRecipe.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); this.mMaxProgresstime /= 2;
this.mMaxProgresstime = (tRecipe.mDuration / (1 << tTier - 1));
} else {
this.mEUt = tRecipe.mEUt;
this.mMaxProgresstime = tRecipe.mDuration;
while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) {
this.mEUt *= 4;
this.mMaxProgresstime /= 2;
}
}
if (this.mEUt > 0) {
this.mEUt = (-this.mEUt);
}
this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
this.mOutputItems = new ItemStack[]{tRecipe.getOutput(0), tRecipe.getOutput(1)};
updateSlots();
return true;
} }
} }
return false; this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
return true;
} }
public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) {
@ -213,7 +223,7 @@ public class GT_MetaTileEntity_AssemblyLine
} }
public int getPollutionPerTick(ItemStack aStack) { public int getPollutionPerTick(ItemStack aStack) {
return 1000; return 0;
} }
public int getDamageToComponent(ItemStack aStack) { public int getDamageToComponent(ItemStack aStack) {