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