aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorDream-Master <dream-master@gmx.net>2017-09-12 23:06:55 +0200
committerDream-Master <dream-master@gmx.net>2017-09-12 23:06:55 +0200
commita4a0a7c2cc3c299969c62e509cc3c366a90214f3 (patch)
tree2266e68d17df268eb1e73513184169fd613947af /src/main
parentffc256ab87f905fa21bdb7102212cafa54c9f6bd (diff)
downloadGT5-Unofficial-a4a0a7c2cc3c299969c62e509cc3c366a90214f3.tar.gz
GT5-Unofficial-a4a0a7c2cc3c299969c62e509cc3c366a90214f3.tar.bz2
GT5-Unofficial-a4a0a7c2cc3c299969c62e509cc3c366a90214f3.zip
cherry pick
11213d18d7345ee29f2efce6c5d421a855bed056 fb163d1be0aa291508bb6513e34cacba3ca06b36 fb508132d91543d5e837dfa4fac09cf5e4b9e7a8 d682ca0d36e3824b1bf73cc800f58c4126bcf104 0f2db4f76a88c26ca08b2da444b264444ce01316 50229e4506687d184c93ed702cdeeecea65e326a f5195f822d9951015c4ef6599e5b4f6544ec0714 fbdb6ceecf60183ab382f043b78b61941157eccf 55af1972b86a82bf6038342aa1a3bf9013d0f164 c0d9d5a268da4b58385ee95e27408e06829c74b8 416890142c0fa62617fc6e4537826689635e9eb3 d532cb67f7bc68243e3d2dc2a12a466ed9c9e2d9 d1671eaf33b3b4223da174e115f35b9bc1f19c5a 4d90afad87375e3f1013a493f4b3b5d4e92bf521 3c397d61697c13f0467e0cb67fb127fff8401f71 64957ccd0f51ef283cc561d52a5439c3752c4e71 b7e0863207253ee758742a22c607c3ccc37af6d3 ae5a1e117d47876de9d2d2e8ea581e15686c5e1a a0eb30d03f8fc311598f628ad45b5365c7391917 505a9c263e88e5519bade6a3167f829e41e13e64 9cbb9c66a2f63e7e0cb4aceebfc9c93776b82be2 Drillers upgrade #1163 https://github.com/Blood-Asp/GT5-Unofficial/pull/1163
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/gregtech/api/enums/ItemList.java2
-rw-r--r--src/main/java/gregtech/api/gui/GT_GUIContainer_MultiMachine.java25
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DataAccess.java4
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java2
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller1.java51
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller2.java66
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java125
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java357
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill.java270
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill1.java51
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill2.java51
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill3.java51
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java152
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java269
-rw-r--r--src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java13
15 files changed, 959 insertions, 530 deletions
diff --git a/src/main/java/gregtech/api/enums/ItemList.java b/src/main/java/gregtech/api/enums/ItemList.java
index b1c993a8aa..1e0f667498 100644
--- a/src/main/java/gregtech/api/enums/ItemList.java
+++ b/src/main/java/gregtech/api/enums/ItemList.java
@@ -661,7 +661,7 @@ public enum ItemList implements IItemContainer {
Casing_Tank_1, Casing_Tank_2, Casing_Tank_3, Casing_Tank_4, Casing_Tank_5, Casing_Tank_6, Casing_Tank_7, Casing_Tank_8, Casing_Tank_9, Casing_Tank_10, Casing_Tank_11, Casing_Tank_12, Casing_Tank_13, Casing_Tank_14, Casing_Tank_15, Casing_Tank_0,
MobRep_LV, MobRep_MV, MobRep_HV, MobRep_EV, MobRep_IV, MobRep_LuV, MobRep_ZPM, MobRep_UV, Cover_PlayerDetector, Machine_Multi_HeatExchanger,
Block_BronzePlate, Block_IridiumTungstensteel, Block_Plascrete, Block_TungstenSteelReinforced,
- Honeycomb, Charcoal_Pile, Block_BrittleCharcoal, Seismic_Prospector, Seismic_Prospector_Adv, OilDrill, OreDrill1, OreDrill2, OreDrill3, OreDrill4, PyrolyseOven, OilCracker, Crop_Drop_UUMBerry, Crop_Drop_UUABerry, Empty_Board_Basic, Empty_Board_Elite,
+ Honeycomb, Charcoal_Pile, Block_BrittleCharcoal, Seismic_Prospector, Seismic_Prospector_Adv, OilDrill1, OilDrill2, OilDrill3, ConcreteBackfiller1, ConcreteBackfiller2, OreDrill1, OreDrill2, OreDrill3, OreDrill4, PyrolyseOven, OilCracker, Crop_Drop_UUMBerry, Crop_Drop_UUABerry, Empty_Board_Basic, Empty_Board_Elite,
Battery_Charger_4by4_ULV, Battery_Charger_4by4_LV, Battery_Charger_4by4_MV, Battery_Charger_4by4_HV, Battery_Charger_4by4_EV, Battery_Charger_4by4_IV, Battery_Charger_4by4_LuV, Battery_Charger_4by4_ZPM, Battery_Charger_4by4_UV, Battery_Charger_4by4_MAX,
MicroTransmitter_HV, MicroTransmitter_EV, MicroTransmitter_IV, MicroTransmitter_LUV, MicroTransmitter_ZPM,
Crop_Drop_Bauxite, Crop_Drop_Ilmenite, Crop_Drop_Pitchblende, Crop_Drop_Uraninite, Crop_Drop_Thorium, Crop_Drop_Nickel, Crop_Drop_Zinc, Crop_Drop_Manganese, Crop_Drop_Scheelite, Crop_Drop_Platinum, Crop_Drop_Iridium, Crop_Drop_Osmium, Crop_Drop_Naquadah, Uraniumcell_1, Uraniumcell_2, Uraniumcell_4, Moxcell_1, Moxcell_2, Moxcell_4,
diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_MultiMachine.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_MultiMachine.java
index 5a7c4873ec..62e6f8cea1 100644
--- a/src/main/java/gregtech/api/gui/GT_GUIContainer_MultiMachine.java
+++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_MultiMachine.java
@@ -1,14 +1,18 @@
package gregtech.api.gui;
-import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
-import gregtech.api.util.GT_LanguageManager;
-import gregtech.api.util.GT_ModHandler;
-import gregtech.api.util.GT_Utility;
-import gregtech.common.items.GT_MetaGenerated_Tool_01;
-import net.minecraft.entity.player.InventoryPlayer;
-import net.minecraft.item.ItemStack;
+ import static gregtech.api.enums.GT_Values.RES_PATH_GUI;
+
+ import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+ import gregtech.api.util.GT_LanguageManager;
+ import gregtech.api.util.GT_ModHandler;
+ import gregtech.api.util.GT_Utility;
+ import gregtech.common.items.GT_MetaGenerated_Tool_01;
+ import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_DrillerBase;
+ import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_LargeTurbine;
+ import net.minecraft.entity.player.InventoryPlayer;
+ import net.minecraft.item.ItemStack;
+
-import static gregtech.api.enums.GT_Values.RES_PATH_GUI;
/**
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
@@ -54,13 +58,12 @@ public class GT_GUIContainer_MultiMachine extends GT_GUIContainerMetaTile_Machin
} else {
fontRendererObj.drawString(trans("142","Running perfectly."), 10, 16, 16448255);
}
- int id = mContainer.mTileEntity.getMetaTileID();
- if (id == 1157 || id == 1158 || id == 1177 || id == 1178 || id == 1179) {
+ if (mContainer.mTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_DrillerBase) {
ItemStack tItem = mContainer.mTileEntity.getMetaTileEntity().getStackInSlot(1);
if (tItem == null || !GT_Utility.areStacksEqual(tItem, GT_ModHandler.getIC2Item("miningPipe", 1L))) {
fontRendererObj.drawString(trans("143", "Missing Mining Pipe"), 10, ((GT_Container_MultiMachine) mContainer).mActive == 0 ? 40 : 24, 16448255);
}
- } else if (id == 1131 || id == 1151 || id == 1152 || id == 1153) {
+ } else if (mContainer.mTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbine) {
ItemStack tItem = mContainer.mTileEntity.getMetaTileEntity().getStackInSlot(1);
if (tItem == null || !(tItem.getItem() == GT_MetaGenerated_Tool_01.INSTANCE && tItem.getItemDamage() >= 170 && tItem.getItemDamage() <= 177)) {
fontRendererObj.drawString(trans("144", "Missing Turbine Rotor"), 10, ((GT_Container_MultiMachine) mContainer).mActive == 0 ? 40 : 24, 16448255);
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DataAccess.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DataAccess.java
index e28f5e6024..bbdf0ec31d 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DataAccess.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DataAccess.java
@@ -98,4 +98,8 @@ public class GT_MetaTileEntity_Hatch_DataAccess extends GT_MetaTileEntity_Hatch
public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
return false;
}
+ @Override
+ public int getInventoryStackLimit() {
+ return 1;
+ }
}
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java
index 85fa7370f7..2934fc527c 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java
@@ -322,7 +322,7 @@ public class GT_MetaTileEntity_AssemblyLine
* @param state using bitmask, 1 for IntegratedCircuit, 2 for DataStick, 4 for DataOrb
*/
private boolean isCorrectDataItem(ItemStack aStack, int state){
- if ((state & 1) != 0 && ItemList.Circuit_Integrated.isStackEqual(aStack, false, true)) return true;
+ if ((state & 1) != 0 && ItemList.Circuit_Integrated.isStackEqual(aStack, true, true)) return true;
if ((state & 2) != 0 && ItemList.Tool_DataStick.isStackEqual(aStack, false, true)) return true;
if ((state & 4) != 0 && ItemList.Tool_DataOrb.isStackEqual(aStack, false, true)) return true;
return false;
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller1.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller1.java
new file mode 100644
index 0000000000..84bba3b3dd
--- /dev/null
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller1.java
@@ -0,0 +1,51 @@
+package gregtech.common.tileentities.machines.multi;
+
+import gregtech.api.enums.ItemList;
+import gregtech.api.enums.Materials;
+import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+
+public class GT_MetaTileEntity_ConcreteBackfiller1 extends GT_MetaTileEntity_ConcreteBackfillerBase {
+ public GT_MetaTileEntity_ConcreteBackfiller1(int aID, String aName, String aNameRegional) {
+ super(aID, aName, aNameRegional);
+ }
+
+ public GT_MetaTileEntity_ConcreteBackfiller1(String aName) {
+ super(aName);
+ }
+
+ @Override
+ public String[] getDescription() {
+ return getDescriptionInternal("");
+ }
+
+ @Override
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new GT_MetaTileEntity_ConcreteBackfiller1(mName);
+ }
+
+ @Override
+ protected ItemList getCasingBlockItem() {
+ return ItemList.Casing_SolidSteel;
+ }
+
+ @Override
+ protected Materials getFrameMaterial() {
+ return Materials.Steel;
+ }
+
+ @Override
+ protected int getCasingTextureIndex() {
+ return 16;
+ }
+
+ @Override
+ protected int getRadius() {
+ return 16;
+ }
+
+ @Override
+ protected int getMinTier() {
+ return 2;
+ }
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller2.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller2.java
new file mode 100644
index 0000000000..6357783b01
--- /dev/null
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller2.java
@@ -0,0 +1,66 @@
+package gregtech.common.tileentities.machines.multi;
+
+import static gregtech.api.enums.GT_Values.VN;
+
+import gregtech.api.enums.ItemList;
+import gregtech.api.enums.Materials;
+import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+
+public class GT_MetaTileEntity_ConcreteBackfiller2 extends GT_MetaTileEntity_ConcreteBackfillerBase {
+ public GT_MetaTileEntity_ConcreteBackfiller2(int aID, String aName, String aNameRegional) {
+ super(aID, aName, aNameRegional);
+ }
+
+ public GT_MetaTileEntity_ConcreteBackfiller2(String aName) {
+ super(aName);
+ }
+
+ @Override
+ public String[] getDescription() {
+ String casings = getCasingBlockItem().get(0).getDisplayName();
+ return new String[]{
+ "Controller Block for the Advanced Concrete Backfiller",
+ "Size(WxHxD): 3x7x3", "Controller (Front middle at bottom)",
+ "3x1x3 Base of " + casings,
+ "1x3x1 " + casings + " pillar (Center of base)",
+ "1x3x1 " + getFrameMaterial().mName + " Frame Boxes (Each pillar side and on top)",
+ "1x Input Hatch (One of base casings)",
+ "1x Maintenance Hatch (One of base casings)",
+ "1x " + VN[getMinTier()] + "+ Energy Hatch (Any bottom layer casing)",
+ "Put Programmed Circuits into Data Access to config radius",
+ "Radius = (total config value)x2 blocks",
+ "Default 64, Maximum 128",};
+ }
+
+ @Override
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new GT_MetaTileEntity_ConcreteBackfiller2(mName);
+ }
+
+ @Override
+ protected ItemList getCasingBlockItem() {
+ return ItemList.Casing_StableTitanium;
+ }
+
+ @Override
+ protected Materials getFrameMaterial() {
+ return Materials.Titanium;
+ }
+
+ @Override
+ protected int getCasingTextureIndex() {
+ return 50;
+ }
+
+ @Override
+ protected int getRadius() {
+ int tConfig = getTotalConfigValue() * 2;
+ return tConfig >= 128 ? 128 : tConfig <= 0 ? 64 : tConfig;
+ }
+
+ @Override
+ protected int getMinTier() {
+ return 4;
+ }
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java
new file mode 100644
index 0000000000..169bb262cc
--- /dev/null
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java
@@ -0,0 +1,125 @@
+package gregtech.common.tileentities.machines.multi;
+
+import static gregtech.api.enums.GT_Values.V;
+import static gregtech.api.enums.GT_Values.VN;
+
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.Materials;
+import gregtech.api.gui.GT_GUIContainer_MultiMachine;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.util.GT_Utility;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.item.ItemStack;
+
+public abstract class GT_MetaTileEntity_ConcreteBackfillerBase extends GT_MetaTileEntity_DrillerBase {
+
+ private int mLastXOff = 0, mLastZOff = 0;
+
+ public GT_MetaTileEntity_ConcreteBackfillerBase(int aID, String aName, String aNameRegional) {
+ super(aID, aName, aNameRegional);
+ }
+
+ public GT_MetaTileEntity_ConcreteBackfillerBase(String aName) {
+ super(aName);
+ }
+
+ protected String[] getDescriptionInternal(String tierSuffix) {
+ String casings = getCasingBlockItem().get(0).getDisplayName();
+ return new String[]{
+ "Controller Block for the Concrete Backfiller " + (tierSuffix != null ? tierSuffix : ""),
+ "Size(WxHxD): 3x7x3", "Controller (Front middle at bottom)",
+ "3x1x3 Base of " + casings,
+ "1x3x1 " + casings + " pillar (Center of base)",
+ "1x3x1 " + getFrameMaterial().mName + " Frame Boxes (Each pillar side and on top)",
+ "1x Input Hatch (One of base casings)",
+ "1x Maintenance Hatch (One of base casings)",
+ "1x " + VN[getMinTier()] + "+ Energy Hatch (Any bottom layer casing)",
+ "Radius is " + getRadius() + " blocks"};
+ }
+
+ @Override
+ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "DrillingRig.png");
+ }
+
+ protected abstract int getRadius();
+
+ @Override
+ protected boolean checkHatches() {
+ return !mMaintenanceHatches.isEmpty() && !mInputHatches.isEmpty() && !mEnergyHatches.isEmpty();
+ }
+
+ @Override
+ protected void setElectricityStats() {
+ this.mEfficiency = getCurrentEfficiency(null);
+ this.mEfficiencyIncrease = 10000;
+ //T1 = 48; T2 = 192; T3 = 768; T4 = 3072
+ this.mEUt = 12 * (1 << (getMinTier() << 1));
+ this.mMaxProgresstime = (isPickingPipes ? 240: 80) / (1 << getMinTier());
+
+ long voltage = getMaxInputVoltage();
+ long overclockEu = V[Math.max(1, GT_Utility.getTier(voltage)) - 1];
+ while (this.mEUt <= overclockEu) {
+ this.mEUt *= 4;
+ this.mMaxProgresstime /= 2;
+ }
+
+ this.mEUt = -this.mEUt;
+ this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
+ }
+
+ @Override
+ protected boolean workingUpward(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead) {
+ if (isRefillableBlock(xPipe, yHead - 1, zPipe))
+ return tryRefillBlock(xPipe, yHead - 1, zPipe);
+ int radius = getRadius();
+ if (mLastXOff == 0 && mLastZOff == 0) {
+ mLastXOff = - radius;
+ mLastZOff = - radius;
+ }
+ if (yHead != yDrill) {
+ for (int i = mLastXOff; i <= radius; i++) {
+ for (int j = (i == mLastXOff ? mLastZOff : - radius); j <= radius; j++) {
+ if (isRefillableBlock(xPipe + i, yHead, zPipe + j)){
+ mLastXOff = i;
+ mLastZOff = j;
+ return tryRefillBlock(xPipe + i, yHead, zPipe + j);
+ }
+ }
+ }
+ }
+
+ if (tryPickPipe()) {
+ mLastXOff = 0;
+ mLastZOff = 0;
+ return true;
+ } else {
+ isPickingPipes = false;
+ stopMachine();
+ return false;
+ }
+ }
+
+ private boolean isRefillableBlock(int aX, int aY, int aZ){
+ if (getBaseMetaTileEntity().getTileEntity(aX, aY, aZ) != null) return false;
+ if (getBaseMetaTileEntity().getAir(aX, aY, aZ) || !getBaseMetaTileEntity().getBlock(aX, aY, aZ).getMaterial().isSolid())
+ return true;
+ return false;
+ }
+
+ private boolean tryRefillBlock(int aX, int aY, int aZ) {
+ if (!tryConsumeFluid())
+ return false;
+ getBaseMetaTileEntity().getWorld().setBlock(aX, aY, aZ, GregTech_API.sBlockConcretes, 8, 3);
+ return true;
+ }
+
+ private boolean tryConsumeFluid() {
+ if (!depleteInput(Materials.Concrete.getMolten(144L))){
+ mMaxProgresstime = 0;
+ return false;
+ }
+ return true;
+ }
+
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java
new file mode 100644
index 0000000000..2e7616b029
--- /dev/null
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java
@@ -0,0 +1,357 @@
+package gregtech.common.tileentities.machines.multi;
+
+import static gregtech.api.enums.GT_Values.W;
+
+import java.util.ArrayList;
+
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.ItemList;
+import gregtech.api.enums.Materials;
+import gregtech.api.enums.Textures;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_DataAccess;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
+import gregtech.api.objects.GT_RenderedTexture;
+import gregtech.api.util.GT_ModHandler;
+import gregtech.api.util.GT_Utility;
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraftforge.common.util.ForgeDirection;
+
+public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_MultiBlockBase {
+ private static final ItemStack miningPipe = GT_ModHandler.getIC2Item("miningPipe", 0);
+ private static final ItemStack miningPipeTip = GT_ModHandler.getIC2Item("miningPipeTip", 0);
+ private static final Block miningPipeBlock = GT_Utility.getBlockFromStack(miningPipe);
+ private static final Block miningPipeTipBlock = GT_Utility.getBlockFromStack(miningPipeTip);
+
+ private Block casingBlock;
+ private int casingMeta;
+ private int frameMeta;
+ private int casingTextureIndex;
+
+ private ForgeDirection back;
+
+ private int xDrill, yDrill, zDrill, xPipe, zPipe, yHead;
+ protected boolean isPickingPipes;
+
+ public GT_MetaTileEntity_DrillerBase(int aID, String aName, String aNameRegional) {
+ super(aID, aName, aNameRegional);
+ initFields();
+ }
+
+ public GT_MetaTileEntity_DrillerBase(String aName) {
+ super(aName);
+ initFields();
+ }
+
+ private void initFields() {
+ casingBlock = getCasingBlockItem().getBlock();
+ casingMeta = getCasingBlockItem().get(0).getItemDamage();
+ int frameId = 4096 + getFrameMaterial().mMetaItemSubID;
+ frameMeta = GregTech_API.METATILEENTITIES[frameId] != null ? GregTech_API.METATILEENTITIES[frameId].getTileEntityBaseType() : W;
+ casingTextureIndex = getCasingTextureIndex();
+ isPickingPipes = false;
+ }
+
+ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
+ if (aSide == aFacing)
+ return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[casingTextureIndex],new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_ORE_DRILL_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_ORE_DRILL)};
+ return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[casingTextureIndex]};
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ super.saveNBTData(aNBT);
+ aNBT.setBoolean("isPickingPipe", isPickingPipes);
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ super.loadNBTData(aNBT);
+ isPickingPipes = aNBT.getBoolean("isPickingPipes");
+ }
+
+ protected boolean tryPickPipe() {
+ if (yHead == yDrill) return false;
+ if (tryOutputPipe()){
+ if (checkBlockAndMeta(xPipe, yHead + 1, zPipe, miningPipeBlock, W))
+ getBaseMetaTileEntity().getWorld().setBlock(xPipe, yHead + 1, zPipe, miningPipeTipBlock);
+ getBaseMetaTileEntity().getWorld().setBlockToAir(xPipe, yHead, zPipe);
+ return true;
+ }
+ return false;
+ }
+
+ protected boolean tryLowerPipe() {
+ if (!isHasMiningPipes()) return false;
+
+ if (yHead <= 0) return false;
+ if (!canLowerPipe()) return false;
+
+ getBaseMetaTileEntity().getWorld().setBlock(xPipe, yHead - 1, zPipe, miningPipeTipBlock);
+ if (yHead != yDrill) getBaseMetaTileEntity().getWorld().setBlock(xPipe, yHead, zPipe, miningPipeBlock);
+
+ getBaseMetaTileEntity().decrStackSize(1, 1);
+ return true;
+ }
+
+ private void putMiningPipesFromInputsInController() {
+ int maxPipes = miningPipe.getMaxStackSize();
+ if (isHasMiningPipes(maxPipes)) return;
+
+ ItemStack pipes = getStackInSlot(1);
+ for (ItemStack storedItem : getStoredInputs()) {
+ if (!storedItem.isItemEqual(miningPipe)) continue;
+
+ if (pipes == null) {
+ setInventorySlotContents(1, GT_Utility.copy(miningPipe));
+ pipes = getStackInSlot(1);
+ }
+
+ if (pipes.stackSize == maxPipes) break;
+
+ int needPipes = maxPipes - pipes.stackSize;
+ int transferPipes = storedItem.stackSize < needPipes ? storedItem.stackSize : needPipes;
+
+ pipes.stackSize += transferPipes;
+ storedItem.stackSize -= transferPipes;
+ }
+ updateSlots();
+ }
+
+ private boolean tryOutputPipe(){
+ if (!getBaseMetaTileEntity().addStackToSlot(1, GT_Utility.copyAmount(1, miningPipe)))
+ mOutputItems = new ItemStack[] {GT_Utility.copyAmount(1, miningPipe)};
+ return true;
+ }
+
+ protected boolean canLowerPipe(){
+ return yHead > 0 && !checkBlockAndMeta(xPipe, yHead - 1, zPipe, Blocks.bedrock, W);
+ }
+
+ private boolean isHasMiningPipes() {
+ return isHasMiningPipes(1);
+ }
+
+ private boolean isHasMiningPipes(int minCount) {
+ ItemStack pipe = getStackInSlot(1);
+ return pipe != null && pipe.stackSize > minCount - 1 && pipe.isItemEqual(miningPipe);
+ }
+
+ private boolean isEnergyEnough() {
+ long requiredEnergy = 512 + getMaxInputVoltage() * 4;
+ for (GT_MetaTileEntity_Hatch_Energy energyHatch : mEnergyHatches) {
+ requiredEnergy -= energyHatch.getEUVar();
+ if (requiredEnergy <= 0) return true;
+ }
+ return false;
+ }
+
+ protected boolean workingDownward(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead){
+ if(!tryLowerPipe())
+ if(waitForPipes()) return false;
+ isPickingPipes = true;
+ return true;
+ }
+
+ protected boolean workingUpward(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead) {
+ if (tryPickPipe()) {
+ return true;
+ } else {
+ isPickingPipes = false;
+ stopMachine();
+ return false;
+ }
+ }
+
+ @Override
+ public boolean checkRecipe(ItemStack aStack) {
+ //Public pipe actions
+ setElectricityStats();
+ int oldYHead = yHead;
+ if (!checkPipesAndSetYHead() || !isEnergyEnough()) {
+ stopMachine();
+ return false;
+ }
+ putMiningPipesFromInputsInController();
+ if (!isPickingPipes)
+ return workingDownward(aStack, xDrill, yDrill, zDrill, xPipe, zPipe, yHead, oldYHead);
+ else
+ return workingUpward(aStack, xDrill, yDrill, zDrill, xPipe, zPipe, yHead, oldYHead);
+ }
+
+ @Override
+ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
+ updateCoordinates();
+ //check base layer
+ for (int xOff = -1 + back.offsetX; xOff <= 1 + back.offsetX; xOff++) {
+ for (int zOff = -1 + back.offsetZ; zOff <= 1 + back.offsetZ; zOff++) {
+ if (xOff == 0 && zOff == 0) continue;
+
+ IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xOff, 0, zOff);
+ if (!checkCasingBlock(xOff, 0, zOff)
+ && !addMaintenanceToMachineList(tTileEntity, casingTextureIndex)
+ && !addInputToMachineList(tTileEntity, casingTextureIndex)
+ && !addOutputToMachineList(tTileEntity, casingTextureIndex)
+ && !addEnergyInputToMachineList(tTileEntity, casingTextureIndex)
+ && !addDataAccessToMachineList(tTileEntity, casingTextureIndex))
+ return false;
+ }
+ }
+ if(!checkHatches()) return false;
+ if (GT_Utility.getTier(getMaxInputVoltage()) < getMinTier()) return false;
+ //check tower
+ for (int yOff = 1; yOff < 4; yOff++) {
+ if (!checkCasingBlock(back.offsetX, yOff, back.offsetZ)
+ || !checkFrameBlock(back.offsetX + 1, yOff, back.offsetZ)
+ || !checkFrameBlock(back.offsetX - 1, yOff, back.offsetZ)
+ || !checkFrameBlock(back.offsetX, yOff, back.offsetZ + 1)
+ || !checkFrameBlock(back.offsetX, yOff, back.offsetZ - 1)
+ || !checkFrameBlock(back.offsetX, yOff + 3, back.offsetZ))
+ return false;
+ }
+ return true;
+ }
+
+ private void updateCoordinates() {
+ xDrill = getBaseMetaTileEntity().getXCoord();
+ yDrill = getBaseMetaTileEntity().getYCoord();
+ zDrill = getBaseMetaTileEntity().getZCoord();
+ back = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing());
+ xPipe = xDrill + back.offsetX;
+ zPipe = zDrill + back.offsetZ;
+ }
+
+ private boolean checkPipesAndSetYHead() {
+ yHead = yDrill - 1;
+ while (checkBlockAndMeta(xPipe, yHead, zPipe, miningPipeBlock, W)) yHead--; //skip pipes
+ //is pipe tip OR is controller layer
+ if (checkBlockAndMeta(xPipe, yHead, zPipe, miningPipeTipBlock, W) || ++yHead == yDrill) return true;
+ //pipe column is broken - try fix
+ getBaseMetaTileEntity().getWorld().setBlock(xPipe, yHead, zPipe, miningPipeTipBlock);
+ return true;
+ }
+
+ protected boolean checkCasingBlock(int xOff, int yOff, int zOff) {
+ return checkBlockAndMetaOffset(xOff, yOff, zOff, casingBlock, casingMeta);
+ }
+ //meta of frame is getTileEntityBaseType; frame should be checked using its drops (possible a high weight operation)
+ protected boolean checkFrameBlock(int xOff, int yOff, int zOff) {
+ return checkBlockAndMetaOffset(xOff, yOff, zOff, GregTech_API.sBlockMachines, frameMeta);
+ }
+
+ protected boolean checkBlockAndMetaOffset(int xOff, int yOff, int zOff, Block block, int meta) {
+ return checkBlockAndMeta(xDrill + xOff, yDrill + yOff, zDrill + zOff, block, meta);
+ }
+
+ private boolean checkBlockAndMeta(int x, int y, int z, Block block, int meta) {
+ return (meta == W || getBaseMetaTileEntity().getMetaID(x, y, z) == meta)
+ && getBaseMetaTileEntity().getBlock(x, y, z) == block;
+ }
+
+ protected boolean waitForPipes(){
+ if (canLowerPipe()) {
+ mMaxProgresstime = 0;
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean isCorrectMachinePart(ItemStack aStack) {
+ return true;
+ }
+
+ @Override
+ public int getMaxEfficiency(ItemStack aStack) {
+ return 10000;
+ }
+
+ @Override
+ public int getPollutionPerTick(ItemStack aStack) {
+ return 0;
+ }
+
+ @Override
+ public int getDamageToComponent(ItemStack aStack) {
+ return 0;
+ }
+
+ @Override
+ public boolean explodesOnComponentBreak(ItemStack aStack) {
+ return false;
+ }
+
+ public abstract Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity);
+
+ protected abstract ItemList getCasingBlockItem();
+
+ protected abstract Materials getFrameMaterial();
+
+ protected abstract int getCasingTextureIndex();
+
+ protected abstract int getMinTier();
+
+ protected abstract boolean checkHatches();
+
+ protected abstract void setElectricityStats();
+
+ public int getTotalConfigValue(){
+ int config = 0;
+ ArrayList<ItemStack> tCircuitList = getDataItems(1);
+ for (ItemStack tCircuit : tCircuitList)
+ config += tCircuit.getItemDamage();
+ return config;
+ }
+
+ public ArrayList<GT_MetaTileEntity_Hatch_DataAccess> mDataAccessHatches = new ArrayList<GT_MetaTileEntity_Hatch_DataAccess>();
+
+ /**
+ * @param state using bitmask, 1 for IntegratedCircuit, 2 for DataStick, 4 for DataOrb
+ */
+ private boolean isCorrectDataItem(ItemStack aStack, int state){
+ if ((state & 1) != 0 && ItemList.Circuit_Integrated.isStackEqual(aStack, true, true)) return true;
+ if ((state & 2) != 0 && ItemList.Tool_DataStick.isStackEqual(aStack, false, true)) return true;
+ if ((state & 4) != 0 && ItemList.Tool_DataOrb.isStackEqual(aStack, false, true)) return true;
+ return false;
+ }
+
+ /**
+ * @param state using bitmask, 1 for IntegratedCircuit, 2 for DataStick, 4 for DataOrb
+ */
+ public ArrayList<ItemStack> getDataItems(int state) {
+ ArrayList<ItemStack> rList = new ArrayList<ItemStack>();
+ if (GT_Utility.isStackValid(mInventory[1]) && isCorrectDataItem(mInventory[1], state)) {
+ rList.add(mInventory[1]);
+ }
+ for (GT_MetaTileEntity_Hatch_DataAccess tHatch : mDataAccessHatches) {
+ if (isValidMetaTileEntity(tHatch)) {
+ for (int i = 0; i < tHatch.getBaseMetaTileEntity().getSizeInventory(); i++) {
+ if (tHatch.getBaseMetaTileEntity().getStackInSlot(i) != null
+ && isCorrectDataItem(tHatch.getBaseMetaTileEntity().getStackInSlot(i), state))
+ rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i));
+ }
+ }
+ }
+ return rList;
+ }
+
+ public boolean addDataAccessToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
+ if (aTileEntity == null) return false;
+ IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
+ if (aMetaTileEntity == null) return false;
+ if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DataAccess) {
+ ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex;
+ return mDataAccessHatches.add((GT_MetaTileEntity_Hatch_DataAccess) aMetaTileEntity);
+ }
+ return false;
+ }
+
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill.java
deleted file mode 1