Add Automatic Maintainance Hatch
This commit is contained in:
parent
4b29e30e75
commit
13c8f127cd
4 changed files with 91 additions and 5 deletions
|
@ -639,7 +639,7 @@ public enum ItemList implements IItemContainer {
|
|||
ModularBasicHelmet, ModularBasicChestplate, ModularBasicLeggings, ModularBasicBoots,
|
||||
ModularElectric1Helmet, ModularElectric1Chestplate, ModularElectric1Leggings, ModularElectric1Boots,
|
||||
ModularElectric2Helmet, ModularElectric2Chestplate, ModularElectric2Leggings, ModularElectric2Boots, Block_Powderbarrel, GelledToluene,
|
||||
FluidRegulator_LV, FluidRegulator_MV, FluidRegulator_HV, FluidRegulator_EV, FluidRegulator_IV, FluidRegulator_LuV, FluidRegulator_ZPM, FluidRegulator_UV, FluidFilter, CuringOven, Machine_Multi_Assemblyline, Machine_Multi_DieselEngine, QuantumEye, QuantumStar, Gravistar, Block_SSFUEL, Block_MSSFUEL, SFMixture, MSFMixture, Depleted_Naquadah_1, Depleted_Naquadah_2, Depleted_Naquadah_4, NaquadahCell_1, NaquadahCell_2, NaquadahCell_4;
|
||||
FluidRegulator_LV, FluidRegulator_MV, FluidRegulator_HV, FluidRegulator_EV, FluidRegulator_IV, FluidRegulator_LuV, FluidRegulator_ZPM, FluidRegulator_UV, FluidFilter, CuringOven, Machine_Multi_Assemblyline, Machine_Multi_DieselEngine, QuantumEye, QuantumStar, Gravistar, Block_SSFUEL, Block_MSSFUEL, SFMixture, MSFMixture, Depleted_Naquadah_1, Depleted_Naquadah_2, Depleted_Naquadah_4, NaquadahCell_1, NaquadahCell_2, NaquadahCell_4, Hatch_AutoMaintenance;
|
||||
|
||||
public static final ItemList[]
|
||||
DYE_ONLY_ITEMS = {Color_00, Color_01, Color_02, Color_03, Color_04, Color_05, Color_06, Color_07, Color_08, Color_09, Color_10, Color_11, Color_12, Color_13, Color_14, Color_15}, SPRAY_CAN_DYES = {Spray_Color_00, Spray_Color_01, Spray_Color_02, Spray_Color_03, Spray_Color_04, Spray_Color_05, Spray_Color_06, Spray_Color_07, Spray_Color_08, Spray_Color_09, Spray_Color_10, Spray_Color_11, Spray_Color_12, Spray_Color_13, Spray_Color_14, Spray_Color_15}, SPRAY_CAN_DYES_USED = {Spray_Color_Used_00, Spray_Color_Used_01, Spray_Color_Used_02, Spray_Color_Used_03, Spray_Color_Used_04, Spray_Color_Used_05, Spray_Color_Used_06, Spray_Color_Used_07, Spray_Color_Used_08, Spray_Color_Used_09, Spray_Color_Used_10, Spray_Color_Used_11, Spray_Color_Used_12, Spray_Color_Used_13, Spray_Color_Used_14, Spray_Color_Used_15}, TRANSFORMERS = {Transformer_LV_ULV, Transformer_MV_LV, Transformer_HV_MV, Transformer_EV_HV, Transformer_IV_EV, Transformer_LuV_IV, Transformer_ZPM_LuV, Transformer_UV_ZPM, Transformer_MAX_UV}, MACHINE_HULLS = {Hull_ULV, Hull_LV, Hull_MV, Hull_HV, Hull_EV, Hull_IV, Hull_LuV, Hull_ZPM, Hull_UV, Hull_MAX}, HATCHES_DYNAMO = {Hatch_Dynamo_ULV, Hatch_Dynamo_LV, Hatch_Dynamo_MV, Hatch_Dynamo_HV, Hatch_Dynamo_EV, Hatch_Dynamo_IV, Hatch_Dynamo_LuV, Hatch_Dynamo_ZPM, Hatch_Dynamo_UV, Hatch_Dynamo_MAX}, HATCHES_ENERGY = {Hatch_Energy_ULV, Hatch_Energy_LV, Hatch_Energy_MV, Hatch_Energy_HV, Hatch_Energy_EV, Hatch_Energy_IV, Hatch_Energy_LuV, Hatch_Energy_ZPM, Hatch_Energy_UV, Hatch_Energy_MAX}, HATCHES_INPUT = {Hatch_Input_ULV, Hatch_Input_LV, Hatch_Input_MV, Hatch_Input_HV, Hatch_Input_EV, Hatch_Input_IV, Hatch_Input_LuV, Hatch_Input_ZPM, Hatch_Input_UV, Hatch_Input_MAX}, HATCHES_INPUT_BUS = {Hatch_Input_Bus_ULV, Hatch_Input_Bus_LV, Hatch_Input_Bus_MV, Hatch_Input_Bus_HV, Hatch_Input_Bus_EV, Hatch_Input_Bus_IV, Hatch_Input_Bus_LuV, Hatch_Input_Bus_ZPM, Hatch_Input_Bus_UV, Hatch_Input_Bus_MAX}, HATCHES_OUTPUT = {Hatch_Output_ULV, Hatch_Output_LV, Hatch_Output_MV, Hatch_Output_HV, Hatch_Output_EV, Hatch_Output_IV, Hatch_Output_LuV, Hatch_Output_ZPM, Hatch_Output_UV, Hatch_Output_MAX}, HATCHES_OUTPUT_BUS = {Hatch_Output_Bus_ULV, Hatch_Output_Bus_LV, Hatch_Output_Bus_MV, Hatch_Output_Bus_HV, Hatch_Output_Bus_EV, Hatch_Output_Bus_IV, Hatch_Output_Bus_LuV, Hatch_Output_Bus_ZPM, Hatch_Output_Bus_UV, Hatch_Output_Bus_MAX}, HATCHES_MUFFLER = {Hatch_Muffler_LV, Hatch_Muffler_LV, Hatch_Muffler_MV, Hatch_Muffler_HV, Hatch_Muffler_EV, Hatch_Muffler_IV, Hatch_Muffler_LuV, Hatch_Muffler_ZPM, Hatch_Muffler_UV, Hatch_Muffler_MAX};
|
||||
|
|
|
@ -1,9 +1,17 @@
|
|||
package gregtech.api.metatileentity.implementations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import gregtech.GT_Mod;
|
||||
import gregtech.api.GregTech_API;
|
||||
import gregtech.api.enums.ItemList;
|
||||
import gregtech.api.enums.Materials;
|
||||
import gregtech.api.enums.OrePrefixes;
|
||||
import gregtech.api.enums.Textures;
|
||||
import gregtech.api.gui.GT_Container_2by2;
|
||||
import gregtech.api.gui.GT_Container_MaintenanceHatch;
|
||||
import gregtech.api.gui.GT_GUIContainer_2by2;
|
||||
import gregtech.api.gui.GT_GUIContainer_MaintenanceHatch;
|
||||
import gregtech.api.interfaces.ITexture;
|
||||
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
|
||||
|
@ -18,20 +26,30 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
|||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import scala.actors.threadpool.Arrays;
|
||||
|
||||
public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch {
|
||||
public boolean mWrench = false, mScrewdriver = false, mSoftHammer = false, mHardHammer = false, mSolderingTool = false, mCrowbar = false;
|
||||
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");
|
||||
mAuto = false;
|
||||
}
|
||||
|
||||
public GT_MetaTileEntity_Hatch_Maintenance(String aName, int aTier, String aDescription, ITexture[][][] aTextures) {
|
||||
super(aName, aTier, 1, aDescription, aTextures);
|
||||
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");
|
||||
mAuto = aAuto;
|
||||
}
|
||||
|
||||
public GT_MetaTileEntity_Hatch_Maintenance(String aName, int aTier, String aDescription, ITexture[][][] aTextures, boolean aAuto) {
|
||||
super(aName, aTier, aAuto ? 4 : 1, aDescription, aTextures);
|
||||
mAuto = aAuto;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getDescription() {
|
||||
if(mAuto)return new String[]{mDescription, "Cannot be shared between Multiblocks!","4 Ducttape, 2 Lubricant Cells","4 Steel Screws, 2 Adv Circuits","For each autorepair"};
|
||||
return new String[]{mDescription, "Cannot be shared between Multiblocks!"};
|
||||
}
|
||||
|
||||
|
@ -72,7 +90,8 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch
|
|||
|
||||
@Override
|
||||
public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
|
||||
return new GT_MetaTileEntity_Hatch_Maintenance(mName, mTier, mDescription, mTextures);
|
||||
if(aTileEntity.getMetaTileID()==111) return new GT_MetaTileEntity_Hatch_Maintenance(mName, mTier, mDescription, mTextures, true);
|
||||
return new GT_MetaTileEntity_Hatch_Maintenance(mName, mTier, mDescription, mTextures, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -84,14 +103,71 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch
|
|||
|
||||
@Override
|
||||
public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
|
||||
if(mAuto) return new GT_Container_2by2(aPlayerInventory, aBaseMetaTileEntity);
|
||||
return new GT_Container_MaintenanceHatch(aPlayerInventory, aBaseMetaTileEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
|
||||
if(mAuto) return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, getLocalName());
|
||||
return new GT_GUIContainer_MaintenanceHatch(aPlayerInventory, aBaseMetaTileEntity);
|
||||
}
|
||||
|
||||
@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 (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);
|
||||
}
|
||||
|
||||
public void onToolClick(ItemStack aStack, EntityLivingBase aPlayer) {
|
||||
if (aStack == null || aPlayer == null) return;
|
||||
if (GT_Utility.isStackInList(aStack, GregTech_API.sWrenchList) && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer))
|
||||
|
@ -125,4 +201,8 @@ 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -206,6 +206,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
|
|||
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;
|
||||
|
@ -714,6 +715,7 @@ 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;
|
||||
|
|
|
@ -345,6 +345,10 @@ public class GT_Loader_MetaTileEntities implements Runnable {
|
|||
|
||||
GT_ModHandler.addCraftingRecipe(ItemList.Hatch_Maintenance.get(1L, new Object[0]), bitsd, new Object[]{"dwx", "hMc", "fsr", 'M', ItemList.Hull_LV});
|
||||
|
||||
ItemList.Hatch_AutoMaintenance.set(new GT_MetaTileEntity_Hatch_Maintenance(111, "hatch.maintenance.auto", "Auto Maintenance Hatch", 5, true).getStackForm(1L));
|
||||
|
||||
GT_ModHandler.addCraftingRecipe(ItemList.Hatch_AutoMaintenance.get(1L, new Object[0]), bitsd, new Object[]{"CHC", "AMA", "CHC", 'M', ItemList.Hull_IV,'H',ItemList.Hatch_Maintenance,'A',ItemList.Robot_Arm_IV,'C',OrePrefixes.circuit.get(Materials.Ultimate)});
|
||||
|
||||
ItemList.Hatch_Muffler_LV.set(new GT_MetaTileEntity_Hatch_Muffler(91, "hatch.muffler.tier.01", "Muffler Hatch (LV)", 1).getStackForm(1L));
|
||||
ItemList.Hatch_Muffler_MV.set(new GT_MetaTileEntity_Hatch_Muffler(92, "hatch.muffler.tier.02", "Muffler Hatch (MV)", 2).getStackForm(1L));
|
||||
ItemList.Hatch_Muffler_HV.set(new GT_MetaTileEntity_Hatch_Muffler(93, "hatch.muffler.tier.03", "Muffler Hatch (HV)", 3).getStackForm(1L));
|
||||
|
|
Loading…
Reference in a new issue