Fix eu consumption absence by AssemblyLine and some clean up

This commit is contained in:
Techlone 2017-04-27 19:35:07 +05:00
parent 07aa57e7de
commit cae69aa28f

View file

@ -67,58 +67,61 @@ public class GT_MetaTileEntity_AssemblyLine
} }
public boolean checkRecipe(ItemStack aStack) { public boolean checkRecipe(ItemStack aStack) {
if(!GT_Utility.isStackValid(mInventory[1]) && !ItemList.Tool_DataStick.isStackEqual(mInventory[1], false, true))return false; if (!GT_Utility.isStackValid(mInventory[1]) || !ItemList.Tool_DataStick.isStackEqual(mInventory[1], false, true))
NBTTagCompound tTag = mInventory[1].getTagCompound(); return false;
if(tTag==null)return false;
ItemStack tStack[] = new ItemStack[15]; NBTTagCompound tTag = mInventory[1].getTagCompound();
for(int i = 0;i<15;i++){ if (tTag == null) return false;
if(tTag.hasKey(""+i)){ ItemStack tStack[] = new ItemStack[15];
tStack[i] = GT_Utility.loadItem(tTag, ""+i); for (int i = 0; i < 15; i++) {
if(tStack[i]!=null){ if (!tTag.hasKey("" + i)) continue;
if(mInputBusses.get(i)==null)return false; 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){ tStack[i] = GT_Utility.loadItem(tTag, "" + i);
}else{return false;} if (tStack[i] == null) continue;
}} ItemStack stackInSlot = mInputBusses.get(i).getBaseMetaTileEntity().getStackInSlot(0);
} if (!GT_Utility.areStacksEqual(tStack[i], stackInSlot, true) || tStack[i].stackSize > stackInSlot.stackSize) {
FluidStack[] tFluids = new FluidStack[4]; return false;
for(int i = 0;i<4;i++){ }
if(tTag.hasKey("f"+i)){ }
tFluids[i] = GT_Utility.loadFluid(tTag, "f"+i);
if(tFluids[i]!=null){ FluidStack[] tFluids = new FluidStack[4];
if(mInputHatches.get(i)==null)return false; for (int i = 0; i < 4; i++) {
if(mInputHatches.get(i).mFluid!=null && GT_Utility.areFluidsEqual(mInputHatches.get(i).mFluid, tFluids[i], true) && mInputHatches.get(i).mFluid.amount>=tFluids[i].amount){ if (!tTag.hasKey("f" + i)) continue;
}else{return false;} tFluids[i] = GT_Utility.loadFluid(tTag, "f" + i);
} if (tFluids[i] == null) continue;
} if (mInputHatches.get(i) == null) return false;
} FluidStack fluidInHatch = mInputHatches.get(i).mFluid;
if(tTag.hasKey("output")){ if (fluidInHatch == null || !GT_Utility.areFluidsEqual(fluidInHatch, tFluids[i], true) || fluidInHatch.amount < tFluids[i].amount) {
mOutputItems = new ItemStack[]{GT_Utility.loadItem(tTag, "output")}; return false;
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 (!tTag.hasKey("output")) return false;
if(mMaxProgresstime<=0)return false; mOutputItems = new ItemStack[]{GT_Utility.loadItem(tTag, "output")};
}else{return false;} if (mOutputItems[0] == null || !GT_Utility.isStackValid(mOutputItems[0]))
if(tTag.hasKey("eu")){ return false;
mEUt = tTag.getInteger("eu");
}else{return false;} if (!tTag.hasKey("time")) return false;
for(int i = 0;i<15;i++){ mMaxProgresstime = tTag.getInteger("time");
if(tStack[i]!=null){ if (mMaxProgresstime <= 0) return false;
mInputBusses.get(i).getBaseMetaTileEntity().getStackInSlot(0).stackSize -= tStack[i].stackSize;
if(mInputBusses.get(i).getBaseMetaTileEntity().getStackInSlot(0).stackSize <= 0){ if (!tTag.hasKey("eu")) return false;
} mEUt = tTag.getInteger("eu");
} for (int i = 0; i < 15; i++) {
} if (tStack[i] == null) continue;
ItemStack stackInSlot = mInputBusses.get(i).getBaseMetaTileEntity().getStackInSlot(0);
for(int i = 0;i<4;i++){ stackInSlot.stackSize -= tStack[i].stackSize;
if(tFluids[i]!=null){ }
mInputHatches.get(i).mFluid.amount -= tFluids[i].amount;
if(mInputHatches.get(i).mFluid.amount<=0){ for (int i = 0; i < 4; i++) {
mInputHatches.get(i).mFluid = null; if (tFluids[i] == null) continue;
} mInputHatches.get(i).mFluid.amount -= tFluids[i].amount;
} if (mInputHatches.get(i).mFluid.amount <= 0) {
} mInputHatches.get(i).mFluid = null;
byte tTier = (byte) Math.max(1, GT_Utility.getTier(getMaxInputVoltage())); }
}
byte tTier = (byte) Math.max(1, GT_Utility.getTier(getMaxInputVoltage()));
this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
this.mEfficiencyIncrease = 10000; this.mEfficiencyIncrease = 10000;
if (mEUt <= 16) { if (mEUt <= 16) {
@ -130,6 +133,9 @@ public class GT_MetaTileEntity_AssemblyLine
this.mMaxProgresstime /= 2; this.mMaxProgresstime /= 2;
} }
} }
if (this.mEUt > 0) {
this.mEUt = -this.mEUt;
}
this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
updateSlots(); updateSlots();
return true; return true;
@ -138,7 +144,7 @@ public class GT_MetaTileEntity_AssemblyLine
public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) {
super.startSoundLoop(aIndex, aX, aY, aZ); super.startSoundLoop(aIndex, aX, aY, aZ);
if (aIndex == 20) { if (aIndex == 20) {
GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(212), 10, 1.0F, aX, aY, aZ); GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(212), 10, 1.0F, aX, aY, aZ);
} }
} }
@ -146,71 +152,117 @@ public class GT_MetaTileEntity_AssemblyLine
int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX;
int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ;
if (xDir != 0) { if (xDir != 0) {
for(int r = 0; r <= 16; r++){ for (int r = 0; r <= 16; r++) {
int i = r*xDir; int i = r * xDir;
if(i!=0&& !(aBaseMetaTileEntity.getBlockOffset(0, 0, i)==GregTech_API.sBlockCasings3&&aBaseMetaTileEntity.getMetaIDOffset(0, 0, i)==10)){return false;} if (i != 0 && !(aBaseMetaTileEntity.getBlockOffset(0, 0, i) == GregTech_API.sBlockCasings3 && aBaseMetaTileEntity.getMetaIDOffset(0, 0, i) == 10)) {
if(!aBaseMetaTileEntity.getBlockOffset(0, -1, i).getUnlocalizedName().equals("blockAlloyGlass")){return false;} return false;
}
if (!aBaseMetaTileEntity.getBlockOffset(0, -1, i).getUnlocalizedName().equals("blockAlloyGlass")) {
return false;
}
IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(0, -2, i); IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(0, -2, i);
if ((!addMaintenanceToMachineList(tTileEntity, 16)) && (!addInputToMachineList(tTileEntity, 16))){ if ((!addMaintenanceToMachineList(tTileEntity, 16)) && (!addInputToMachineList(tTileEntity, 16))) {
if (aBaseMetaTileEntity.getBlockOffset(0, -2, i) != GregTech_API.sBlockCasings2) {return false;} if (aBaseMetaTileEntity.getBlockOffset(0, -2, i) != GregTech_API.sBlockCasings2) {
if (aBaseMetaTileEntity.getMetaIDOffset(0, -2, i) != 0) {return false;} return false;
}
if (aBaseMetaTileEntity.getMetaIDOffset(0, -2, i) != 0) {
return false;
}
} }
tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 1, i); tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 1, i);
if (!addEnergyInputToMachineList(tTileEntity, 16)){ if (!addEnergyInputToMachineList(tTileEntity, 16)) {
if (aBaseMetaTileEntity.getBlockOffset(xDir, 1, i) != GregTech_API.sBlockCasings2) {return false;} if (aBaseMetaTileEntity.getBlockOffset(xDir, 1, i) != GregTech_API.sBlockCasings2) {
if (aBaseMetaTileEntity.getMetaIDOffset(xDir, 1, i) != 0) {return false;} return false;
}
if (aBaseMetaTileEntity.getMetaIDOffset(xDir, 1, i) != 0) {
return false;
}
}
if (i != 0 && !(aBaseMetaTileEntity.getBlockOffset(xDir, 0, i) == GregTech_API.sBlockCasings2 && aBaseMetaTileEntity.getMetaIDOffset(xDir, 0, i) == 9)) {
return false;
}
if (i != 0 && !(aBaseMetaTileEntity.getBlockOffset(xDir, -1, i) == GregTech_API.sBlockCasings2 && aBaseMetaTileEntity.getMetaIDOffset(xDir, -1, i) == 5)) {
return false;
} }
if(i!=0&& !(aBaseMetaTileEntity.getBlockOffset(xDir, 0, i)==GregTech_API.sBlockCasings2&&aBaseMetaTileEntity.getMetaIDOffset(xDir, 0, i)==9)){return false;}
if(i!=0&& !(aBaseMetaTileEntity.getBlockOffset(xDir,-1, i)==GregTech_API.sBlockCasings2&&aBaseMetaTileEntity.getMetaIDOffset(xDir,-1, i)==5)){return false;}
if(!(aBaseMetaTileEntity.getBlockOffset(xDir*2, 0, i)==GregTech_API.sBlockCasings3&&aBaseMetaTileEntity.getMetaIDOffset(xDir*2, 0, i)==10)){return false;} if (!(aBaseMetaTileEntity.getBlockOffset(xDir * 2, 0, i) == GregTech_API.sBlockCasings3 && aBaseMetaTileEntity.getMetaIDOffset(xDir * 2, 0, i) == 10)) {
if(!aBaseMetaTileEntity.getBlockOffset(xDir*2, -1, i).getUnlocalizedName().equals("blockAlloyGlass")){return false;} return false;
tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir*2, -2, i); }
if ((!addMaintenanceToMachineList(tTileEntity, 16)) && (!addInputToMachineList(tTileEntity, 16))){ if (!aBaseMetaTileEntity.getBlockOffset(xDir * 2, -1, i).getUnlocalizedName().equals("blockAlloyGlass")) {
if (aBaseMetaTileEntity.getBlockOffset(xDir*2, -2, i) != GregTech_API.sBlockCasings2) {return false;} return false;
if (aBaseMetaTileEntity.getMetaIDOffset(xDir*2, -2, i) != 0) {return false;} }
tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir * 2, -2, i);
if ((!addMaintenanceToMachineList(tTileEntity, 16)) && (!addInputToMachineList(tTileEntity, 16))) {
if (aBaseMetaTileEntity.getBlockOffset(xDir * 2, -2, i) != GregTech_API.sBlockCasings2) {
return false;
}
if (aBaseMetaTileEntity.getMetaIDOffset(xDir * 2, -2, i) != 0) {
return false;
}
} }
tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, -2, i); tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, -2, i);
if (!addInputToMachineList(tTileEntity, 16)){ if (!addInputToMachineList(tTileEntity, 16) && addOutputToMachineList(tTileEntity, 16)) {
if (!addOutputToMachineList(tTileEntity, 16)){ return r > 0 && mEnergyHatches.size() > 0;
}else{if(r>0){return mEnergyHatches.size()>0;}else{return false;}}
} }
} }
}else{ } else {
for(int r = 0; r <= 16; r++){ for (int r = 0; r <= 16; r++) {
int i = r*-zDir; int i = r * -zDir;
if(i!=0 && !(aBaseMetaTileEntity.getBlockOffset(i, 0, 0)==GregTech_API.sBlockCasings3&&aBaseMetaTileEntity.getMetaIDOffset(i, 0, 0)==10)){return false;} if (i != 0 && !(aBaseMetaTileEntity.getBlockOffset(i, 0, 0) == GregTech_API.sBlockCasings3 && aBaseMetaTileEntity.getMetaIDOffset(i, 0, 0) == 10)) {
if(!aBaseMetaTileEntity.getBlockOffset(i, -1, 0).getUnlocalizedName().equals("blockAlloyGlass")){return false;} return false;
}
if (!aBaseMetaTileEntity.getBlockOffset(i, -1, 0).getUnlocalizedName().equals("blockAlloyGlass")) {
return false;
}
IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, -2, 0); IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, -2, 0);
if ((!addMaintenanceToMachineList(tTileEntity, 16)) && (!addInputToMachineList(tTileEntity, 16))){ if ((!addMaintenanceToMachineList(tTileEntity, 16)) && (!addInputToMachineList(tTileEntity, 16))) {
if (aBaseMetaTileEntity.getBlockOffset(i, -2, 0) != GregTech_API.sBlockCasings2) {return false;} if (aBaseMetaTileEntity.getBlockOffset(i, -2, 0) != GregTech_API.sBlockCasings2) {
if (aBaseMetaTileEntity.getMetaIDOffset(i, -2, 0) != 0) {return false;} return false;
}
if (aBaseMetaTileEntity.getMetaIDOffset(i, -2, 0) != 0) {
return false;
}
} }
tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, 1, zDir); tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, 1, zDir);
if (!addEnergyInputToMachineList(tTileEntity, 16)){ if (!addEnergyInputToMachineList(tTileEntity, 16)) {
if (aBaseMetaTileEntity.getBlockOffset(i, 1, zDir) != GregTech_API.sBlockCasings2) {return false;} if (aBaseMetaTileEntity.getBlockOffset(i, 1, zDir) != GregTech_API.sBlockCasings2) {
if (aBaseMetaTileEntity.getMetaIDOffset(i, 1, zDir) != 0) {return false;} return false;
}
if (aBaseMetaTileEntity.getMetaIDOffset(i, 1, zDir) != 0) {
return false;
}
}
if (i != 0 && !(aBaseMetaTileEntity.getBlockOffset(i, 0, zDir) == GregTech_API.sBlockCasings2 && aBaseMetaTileEntity.getMetaIDOffset(i, 0, zDir) == 9)) {
return false;
}
if (i != 0 && !(aBaseMetaTileEntity.getBlockOffset(i, -1, zDir) == GregTech_API.sBlockCasings2 && aBaseMetaTileEntity.getMetaIDOffset(i, -1, zDir) == 5)) {
return false;
} }
if(i!=0&& !(aBaseMetaTileEntity.getBlockOffset(i, 0, zDir)==GregTech_API.sBlockCasings2&&aBaseMetaTileEntity.getMetaIDOffset(i, 0, zDir)==9)){return false;}
if(i!=0&& !(aBaseMetaTileEntity.getBlockOffset(i,-1, zDir)==GregTech_API.sBlockCasings2&&aBaseMetaTileEntity.getMetaIDOffset(i,-1, zDir)==5)){return false;}
if(!(aBaseMetaTileEntity.getBlockOffset(i, 0, zDir*2)==GregTech_API.sBlockCasings3&&aBaseMetaTileEntity.getMetaIDOffset(i, 0, zDir*2)==10)){return false;} if (!(aBaseMetaTileEntity.getBlockOffset(i, 0, zDir * 2) == GregTech_API.sBlockCasings3 && aBaseMetaTileEntity.getMetaIDOffset(i, 0, zDir * 2) == 10)) {
if(!aBaseMetaTileEntity.getBlockOffset(i, -1, zDir*2).getUnlocalizedName().equals("blockAlloyGlass")){return false;} return false;
tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, -2, zDir*2); }
if ((!addMaintenanceToMachineList(tTileEntity, 16)) && (!addInputToMachineList(tTileEntity, 16))){ if (!aBaseMetaTileEntity.getBlockOffset(i, -1, zDir * 2).getUnlocalizedName().equals("blockAlloyGlass")) {
if (aBaseMetaTileEntity.getBlockOffset(i, -2, zDir*2) != GregTech_API.sBlockCasings2) {return false;} return false;
if (aBaseMetaTileEntity.getMetaIDOffset(i, -2, zDir*2) != 0) {return false;} }
tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, -2, zDir * 2);
if ((!addMaintenanceToMachineList(tTileEntity, 16)) && (!addInputToMachineList(tTileEntity, 16))) {
if (aBaseMetaTileEntity.getBlockOffset(i, -2, zDir * 2) != GregTech_API.sBlockCasings2) {
return false;
}
if (aBaseMetaTileEntity.getMetaIDOffset(i, -2, zDir * 2) != 0) {
return false;
}
} }
tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, -2, zDir); tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, -2, zDir);
if (!addInputToMachineList(tTileEntity, 16)){ if (!addInputToMachineList(tTileEntity, 16) && addOutputToMachineList(tTileEntity, 16)) {
if (!addOutputToMachineList(tTileEntity, 16)){ return r > 0 && mEnergyHatches.size() > 0;
}else{if(r>0){return mEnergyHatches.size()>0;}else{return false;}}
} }
} }
} }
@ -228,6 +280,7 @@ public class GT_MetaTileEntity_AssemblyLine
public int getDamageToComponent(ItemStack aStack) { public int getDamageToComponent(ItemStack aStack) {
return 0; return 0;
} }
public boolean explodesOnComponentBreak(ItemStack aStack) { public boolean explodesOnComponentBreak(ItemStack aStack) {
return false; return false;
} }