Things on auto maintenance
This commit is contained in:
parent
d85a01caad
commit
4cab8a31e5
3 changed files with 101 additions and 78 deletions
File diff suppressed because one or more lines are too long
|
@ -29,7 +29,6 @@ import java.util.List;
|
||||||
|
|
||||||
public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch {
|
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 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) {
|
public GT_MetaTileEntity_Hatch_Maintenance(int aID, String aName, String aNameRegional, int aTier) {
|
||||||
super(aID, aName, aNameRegional, aTier, 1, "For maintaining Multiblocks");
|
super(aID, aName, aNameRegional, aTier, 1, "For maintaining Multiblocks");
|
||||||
|
@ -37,7 +36,7 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch
|
||||||
}
|
}
|
||||||
|
|
||||||
public GT_MetaTileEntity_Hatch_Maintenance(int aID, String aName, String aNameRegional, int aTier, boolean aAuto) {
|
public GT_MetaTileEntity_Hatch_Maintenance(int aID, String aName, String aNameRegional, int aTier, boolean aAuto) {
|
||||||
super(aID, aName, aNameRegional, aTier, 4, "For automaticly maintaining Multiblocks");
|
super(aID, aName, aNameRegional, aTier, 4, "For automatically maintaining Multiblocks");
|
||||||
mAuto = aAuto;
|
mAuto = aAuto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,13 +47,13 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getDescription() {
|
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!"};
|
return new String[]{mDescription, "Cannot be shared between Multiblocks!"};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ITexture[] getTexturesActive(ITexture aBaseTexture) {
|
public ITexture[] getTexturesActive(ITexture aBaseTexture) {
|
||||||
if(mAuto)return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_AUTOMAINTENANCE)};
|
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)};
|
return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_MAINTENANCE)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,60 +112,89 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch
|
||||||
if(mAuto) return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, getLocalName());
|
if(mAuto) return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, getLocalName());
|
||||||
return new GT_GUIContainer_MaintenanceHatch(aPlayerInventory, aBaseMetaTileEntity);
|
return new GT_GUIContainer_MaintenanceHatch(aPlayerInventory, aBaseMetaTileEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
|
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
|
||||||
if (aBaseMetaTileEntity.isServerSide() && aTimer % 100 == 0 && mController != null) {
|
if(aBaseMetaTileEntity.isServerSide() && mAuto && aTick % 100 ==0){
|
||||||
if(!mController.mCrowbar || !mController.mHardHammer || !mController.mScrewdriver || !mController.mSoftHammer || !mController.mSolderingTool || !mController.mWrench){
|
aBaseMetaTileEntity.setActive(!autoMaintainanceCheck());
|
||||||
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(tSuccess){
|
|
||||||
for (ItemStack tStack : mInputs) {
|
|
||||||
if (tStack != null) {
|
|
||||||
amt = tStack.stackSize;
|
|
||||||
for (ItemStack aStack : aInputs) {
|
|
||||||
if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) {
|
|
||||||
if (aStack.stackSize < amt){
|
|
||||||
amt -= aStack.stackSize;
|
|
||||||
aStack.stackSize = 0;
|
|
||||||
}else{
|
|
||||||
aStack.stackSize -= amt;
|
|
||||||
amt = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.mCrowbar = true;
|
|
||||||
this.mHardHammer = true;
|
|
||||||
this.mScrewdriver = true;
|
|
||||||
this.mSoftHammer = true;
|
|
||||||
this.mSolderingTool = true;
|
|
||||||
this.mWrench = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
super.onPostTick(aBaseMetaTileEntity, aTimer);
|
super.onPostTick(aBaseMetaTileEntity, aTick);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean autoMaintainanceCheck(){
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean autoMaintainance() {
|
||||||
|
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(tSuccess){
|
||||||
|
for (ItemStack tStack : mInputs) {
|
||||||
|
if (tStack != null) {
|
||||||
|
amt = tStack.stackSize;
|
||||||
|
for (ItemStack aStack : aInputs) {
|
||||||
|
if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) {
|
||||||
|
if (aStack.stackSize < amt){
|
||||||
|
amt -= aStack.stackSize;
|
||||||
|
aStack.stackSize = 0;
|
||||||
|
}else{
|
||||||
|
aStack.stackSize -= amt;
|
||||||
|
amt = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.mCrowbar = true;
|
||||||
|
this.mHardHammer = true;
|
||||||
|
this.mScrewdriver = true;
|
||||||
|
this.mSoftHammer = true;
|
||||||
|
this.mSolderingTool = true;
|
||||||
|
this.mWrench = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onToolClick(ItemStack aStack, EntityLivingBase aPlayer) {
|
public void onToolClick(ItemStack aStack, EntityLivingBase aPlayer) {
|
||||||
|
@ -202,8 +230,4 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch
|
||||||
public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
|
public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setController(GT_MetaTileEntity_MultiBlockBase aController){
|
|
||||||
mController = aController;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,29 +208,29 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
|
||||||
if (mMachine) {
|
if (mMachine) {
|
||||||
for (GT_MetaTileEntity_Hatch_Maintenance tHatch : mMaintenanceHatches) {
|
for (GT_MetaTileEntity_Hatch_Maintenance tHatch : mMaintenanceHatches) {
|
||||||
if (isValidMetaTileEntity(tHatch)) {
|
if (isValidMetaTileEntity(tHatch)) {
|
||||||
if (!this.disableMaintenance) {
|
if (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 {
|
|
||||||
mWrench = true;
|
mWrench = true;
|
||||||
mScrewdriver = true;
|
mScrewdriver = true;
|
||||||
mSoftHammer = true;
|
mSoftHammer = true;
|
||||||
mHardHammer = true;
|
mHardHammer = true;
|
||||||
mSolderingTool = true;
|
mSolderingTool = true;
|
||||||
mCrowbar = true;
|
mCrowbar = true;
|
||||||
}
|
} else {
|
||||||
|
if (tHatch.mAuto && (!mWrench||!mScrewdriver||!mSoftHammer||!mHardHammer||!mSolderingTool||!mCrowbar))tHatch.autoMaintainance();
|
||||||
|
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;
|
||||||
|
|
||||||
tHatch.mWrench = false;
|
tHatch.mWrench = false;
|
||||||
tHatch.mScrewdriver = false;
|
tHatch.mScrewdriver = false;
|
||||||
tHatch.mSoftHammer = false;
|
tHatch.mSoftHammer = false;
|
||||||
tHatch.mHardHammer = false;
|
tHatch.mHardHammer = false;
|
||||||
tHatch.mSolderingTool = false;
|
tHatch.mSolderingTool = false;
|
||||||
tHatch.mCrowbar = false;
|
tHatch.mCrowbar = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getRepairStatus() > 0) {
|
if (getRepairStatus() > 0) {
|
||||||
|
@ -768,7 +768,6 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
|
||||||
if (aMetaTileEntity == null) return false;
|
if (aMetaTileEntity == null) return false;
|
||||||
if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) {
|
if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) {
|
||||||
((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex;
|
((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex;
|
||||||
((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity).setController(this);
|
|
||||||
return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity);
|
return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue