aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/metatileentity
diff options
context:
space:
mode:
authorTechnus <daniel112092@gmail.com>2016-10-27 19:19:48 +0200
committerTechnus <daniel112092@gmail.com>2016-10-27 19:19:48 +0200
commitdf0264a9ab2e58c58dc3ab44ae6e996921c7a06f (patch)
tree577a7a4d9249949baa59683bafc42198c7292730 /src/main/java/gregtech/api/metatileentity
parent54951ee203cffd0ed269d52c3f7b92880a83fd7f (diff)
downloadGT5-Unofficial-df0264a9ab2e58c58dc3ab44ae6e996921c7a06f.tar.gz
GT5-Unofficial-df0264a9ab2e58c58dc3ab44ae6e996921c7a06f.tar.bz2
GT5-Unofficial-df0264a9ab2e58c58dc3ab44ae6e996921c7a06f.zip
Hopefully fixes Auto maintenance on servers (still works on ssp)
Diffstat (limited to 'src/main/java/gregtech/api/metatileentity')
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java68
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java51
2 files changed, 65 insertions, 54 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java
index e2aaf30e99..e22d805f66 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java
@@ -29,7 +29,6 @@ import java.util.List;
public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch {
public boolean mWrench = false, mScrewdriver = false, mSoftHammer = false, mHardHammer = false, mSolderingTool = false, mCrowbar = false, mAuto;
- public GT_MetaTileEntity_MultiBlockBase mController = null;
public GT_MetaTileEntity_Hatch_Maintenance(int aID, String aName, String aNameRegional, int aTier) {
super(aID, aName, aNameRegional, aTier, 1, "For maintaining Multiblocks");
@@ -48,18 +47,18 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch
@Override
public String[] getDescription() {
- if(mAuto)return new String[]{mDescription, "Cannot be shared between Multiblocks!","4 Duct tape, 2 Lubricant Cells","4 Steel Screws, 2 Adv. Circuits","For each auto-repair"};
+ if(mAuto)return new String[]{mDescription, "4 Duct tape, 2 Lubricant Cells","4 Steel Screws, 2 Adv. Circuits","For each auto-repair"};
return new String[]{mDescription, "Cannot be shared between Multiblocks!"};
}
@Override
- public ITexture[] getTexturesActive(ITexture aBaseTexture) {
- if(mAuto)return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_AUTOMAINTENANCE)};
+ public ITexture[] getTexturesActive(ITexture aBaseTexture) {//which is actually inactive
+ if(mAuto)return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_AUTOMAINTENANCE_IDLE)};
return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_MAINTENANCE)};
}
@Override
- public ITexture[] getTexturesInactive(ITexture aBaseTexture) {
+ public ITexture[] getTexturesInactive(ITexture aBaseTexture) {//which is actually active
if(mAuto)return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_AUTOMAINTENANCE)};
return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_MAINTENANCE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_DUCTTAPE)};
}
@@ -116,30 +115,29 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch
@Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
- if (aBaseMetaTileEntity.isServerSide() && aTimer % 100 == 0 && mController != null) {
- if(!mController.mCrowbar || !mController.mHardHammer || !mController.mScrewdriver || !mController.mSoftHammer || !mController.mSolderingTool || !mController.mWrench){
- boolean tSuccess = true;
- ItemStack[] mInputs = new ItemStack[]{ItemList.Duct_Tape.get(4, new Object[]{}),GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Lubricant, 2),GT_OreDictUnificator.get(OrePrefixes.screw, Materials.Steel, 4),GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 2)};
- List<ItemStack> aInputs = Arrays.asList(mInventory);
- if (mInputs.length > 0 && aInputs == null) tSuccess = false;
- int amt = 0;
- for (ItemStack tStack : mInputs) {
- if (tStack != null) {
- amt = tStack.stackSize;
- boolean temp = true;
- for (ItemStack aStack : aInputs) {
- if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) {
- amt -= aStack.stackSize;
- if (amt < 1) {
- temp = false;
- break;
- }
+ if (mAuto && aBaseMetaTileEntity.isServerSide() && aTimer % 100 == 0) {
+ boolean tSuccess = true;
+ ItemStack[] mInputs = new ItemStack[]{ItemList.Duct_Tape.get(4, new Object[]{}),GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Lubricant, 2),GT_OreDictUnificator.get(OrePrefixes.screw, Materials.Steel, 4),GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 2)};
+ List<ItemStack> aInputs = Arrays.asList(mInventory);
+ if (mInputs.length > 0 && aInputs == null) tSuccess = false;
+ int amt = 0;
+ for (ItemStack tStack : mInputs) {
+ if (tStack != null) {
+ amt = tStack.stackSize;
+ boolean temp = true;
+ for (ItemStack aStack : aInputs) {
+ if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) {
+ amt -= aStack.stackSize;
+ if (amt < 1) {
+ temp = false;
+ break;
}
}
- if (temp) tSuccess = false;
}
+ if (temp) tSuccess = false;
}
- if(tSuccess){
+ }
+ if(tSuccess){
for (ItemStack tStack : mInputs) {
if (tStack != null) {
amt = tStack.stackSize;
@@ -157,14 +155,14 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch
}
}
}
- this.mCrowbar = true;
- this.mHardHammer = true;
- this.mScrewdriver = true;
- this.mSoftHammer = true;
- this.mSolderingTool = true;
- this.mWrench = true;
- }
- }
+ //this.mCrowbar = true;
+ //this.mHardHammer = true;
+ //this.mScrewdriver = true;
+ //this.mSoftHammer = true;
+ //this.mSolderingTool = true;
+ //this.mWrench = true;
+ getBaseMetaTileEntity().setActive(false);
+ }
}
super.onPostTick(aBaseMetaTileEntity, aTimer);
}
@@ -202,8 +200,4 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch
public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
return false;
}
-
- public void setController(GT_MetaTileEntity_MultiBlockBase aController){
- mController = aController;
- }
}
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
index 8be2c95aec..45f672fc6f 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
@@ -208,29 +208,47 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
if (mMachine) {
for (GT_MetaTileEntity_Hatch_Maintenance tHatch : mMaintenanceHatches) {
if (isValidMetaTileEntity(tHatch)) {
- if (!this.disableMaintenance) {
- tHatch.setController(this);
- if (tHatch.mWrench) mWrench = true;
- if (tHatch.mScrewdriver) mScrewdriver = true;
- if (tHatch.mSoftHammer) mSoftHammer = true;
- if (tHatch.mHardHammer) mHardHammer = true;
- if (tHatch.mSolderingTool) mSolderingTool = true;
- if (tHatch.mCrowbar) mCrowbar = true;
- } else {
+ if (disableMaintenance){
mWrench = true;
mScrewdriver = true;
mSoftHammer = true;
mHardHammer = true;
mSolderingTool = true;
mCrowbar = true;
+ } else {
+ if(tHatch.mAuto){
+ //if not (fullyRepaired or autoMaintenanceIdle) == if notFullyRepaired and autoMaintenanceReady
+ if(!(mWrench&&mScrewdriver&&mSoftHammer&&mHardHammer&&mSolderingTool&&mCrowbar || tHatch.getBaseMetaTileEntity().isActive())) {
+ mWrench = mScrewdriver = mSoftHammer = mHardHammer = mSolderingTool = mCrowbar = true;
+ tHatch.getBaseMetaTileEntity().setActive(true);
+ }
+ }else{
+ if(tHatch.mWrench){
+ mWrench=true;
+ tHatch.mWrench=false;
+ }
+ if(tHatch.mScrewdriver){
+ mScrewdriver=true;
+ tHatch.mScrewdriver=false;
+ }
+ if(tHatch.mSoftHammer){
+ mSoftHammer=true;
+ tHatch.mSoftHammer=false;
+ }
+ if(tHatch.mHardHammer){
+ mHardHammer=true;
+ tHatch.mHardHammer=false;
+ }
+ if(tHatch.mSolderingTool){
+ mSolderingTool=true;
+ tHatch.mSolderingTool=false;
+ }
+ if(tHatch.mCrowbar){
+ mCrowbar=true;
+ tHatch.mCrowbar=false;
+ }
+ }
}
-
- tHatch.mWrench = false;
- tHatch.mScrewdriver = false;
- tHatch.mSoftHammer = false;
- tHatch.mHardHammer = false;
- tHatch.mSolderingTool = false;
- tHatch.mCrowbar = false;
}
}
if (getRepairStatus() > 0) {
@@ -768,7 +786,6 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
if (aMetaTileEntity == null) return false;
if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) {
((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex;
- ((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity).setController(this);
return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity);
}
return false;