aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech')
-rw-r--r--src/main/java/gregtech/api/objects/MaterialStack.java393
-rw-r--r--src/main/java/gregtech/api/util/GT_Utility.java49
-rw-r--r--src/main/java/gregtech/common/GT_Proxy.java6
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java21
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java34
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java34
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java114
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java59
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java287
-rw-r--r--src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java4
10 files changed, 251 insertions, 750 deletions
diff --git a/src/main/java/gregtech/api/objects/MaterialStack.java b/src/main/java/gregtech/api/objects/MaterialStack.java
index 472298bf77..4392d60a07 100644
--- a/src/main/java/gregtech/api/objects/MaterialStack.java
+++ b/src/main/java/gregtech/api/objects/MaterialStack.java
@@ -1,6 +1,7 @@
package gregtech.api.objects;
import gregtech.api.enums.Materials;
+import gregtech.api.util.GT_Utility;
public class MaterialStack implements Cloneable {
public long mAmount;
@@ -31,402 +32,16 @@ public class MaterialStack implements Cloneable {
}
@Override
- //Done sub numbering up to 50. couldn't find a better way to do this
public String toString() {
String temp1 = "", temp2 = mMaterial.getToolTip(true), temp3 = "", temp4 = "";
- if (mAmount == 2) {
- temp4 = "\u2082";
+ if (mAmount > 1) {
+ temp4 = GT_Utility.toSubscript(mAmount);
if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
temp1 = "(";
temp3 = ")";
}
}
- if (mAmount == 3) {
- temp4 = "\u2083";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 4) {
- temp4 = "\u2084";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 5) {
- temp4 = "\u2085";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 6) {
- temp4 = "\u2086";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 7) {
- temp4 = "\u2087";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 8) {
- temp4 = "\u2088";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 9) {
- temp4 = "\u2089";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 10) {
- temp4 = "\u2081"+"\u2080";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 11) {
- temp4 = "\u2081"+"\u2081";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 12) {
- temp4 = "\u2081"+"\u2082";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 13) {
- temp4 = "\u2081"+"\u2083";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 14) {
- temp4 = "\u2081"+"\u2084";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 15) {
- temp4 = "\u2081"+"\u2085";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 16) {
- temp4 = "\u2081"+"\u2086";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 17) {
- temp4 = "\u2081"+"\u2087";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 18) {
- temp4 = "\u2081"+"\u2088";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 19) {
- temp4 = "\u2081"+"\u2089";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 20) {
- temp4 = "\u2082"+"\u2080";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 21) {
- temp4 = "\u2082"+"\u2081";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 22) {
- temp4 = "\u2082"+"\u2082";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 23) {
- temp4 = "\u2082"+"\u2083";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 24) {
- temp4 = "\u2082"+"\u2084";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 25) {
- temp4 = "\u2082"+"\u2085";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 26) {
- temp4 = "\u2082"+"\u2086";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 27) {
- temp4 = "\u2082"+"\u2087";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 28) {
- temp4 = "\u2082"+"\u2088";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 29) {
- temp4 = "\u2082"+"\u2089";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 30) {
- temp4 = "\u2083"+"\u2080";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 31) {
- temp4 = "\u2083"+"\u2081";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 32) {
- temp4 = "\u2083"+"\u2082";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 33) {
- temp4 = "\u2083"+"\u2083";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 34) {
- temp4 = "\u2083"+"\u2084";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 35) {
- temp4 = "\u2083"+"\u2085";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 36) {
- temp4 = "\u2083"+"\u2086";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 37) {
- temp4 = "\u2083"+"\u2087";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 38) {
- temp4 = "\u2083"+"\u2088";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 39) {
- temp4 = "\u2083"+"\u2089";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 40) {
- temp4 = "\u2084"+"\u2080";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 41) {
- temp4 = "\u2084"+"\u2081";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 42) {
- temp4 = "\u2084"+"\u2082";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 43) {
- temp4 = "\u2084"+"\u2083";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 44) {
- temp4 = "\u2084"+"\u2084";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 45) {
- temp4 = "\u2084"+"\u2085";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 46) {
- temp4 = "\u2084"+"\u2086";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 47) {
- temp4 = "\u2084"+"\u2087";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 48) {
- temp4 = "\u2084"+"\u2088";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 49) {
- temp4 = "\u2084"+"\u2089";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
- if (mAmount == 50) {
- temp4 = "\u2085"+"\u2080";
-
- if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) {
- temp1 = "(";
- temp3 = ")";
- }
- }
-
return String.valueOf(new StringBuilder().append(temp1).append(temp2).append(temp3).append(temp4));
}
@@ -444,4 +59,4 @@ public class MaterialStack implements Cloneable {
public int hashCode() {
return mMaterial.hashCode();
}
-}
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java
index 8b8e169ce5..17e2f3d0c4 100644
--- a/src/main/java/gregtech/api/util/GT_Utility.java
+++ b/src/main/java/gregtech/api/util/GT_Utility.java
@@ -1,6 +1,7 @@
package gregtech.api.util;
import cofh.api.transport.IItemDuct;
+import com.mojang.authlib.GameProfile;
import cpw.mods.fml.common.FMLCommonHandler;
import gregtech.api.GregTech_API;
import gregtech.api.damagesources.GT_DamageSources;
@@ -56,7 +57,12 @@ import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.common.util.BlockSnapshot;
+import net.minecraftforge.common.util.FakePlayer;
+import net.minecraftforge.common.util.FakePlayerFactory;
import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraftforge.event.ForgeEventFactory;
+import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.fluids.*;
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
@@ -1949,7 +1955,41 @@ public class GT_Utility {
public static ItemStack getIntegratedCircuit(int config){
return ItemList.Circuit_Integrated.getWithDamage(0, config, new Object[0]);
}
-
+
+ public static float getBlockHardnessAt(World aWorld, int aX, int aY, int aZ) {
+ return aWorld.getBlock(aX, aY, aZ).getBlockHardness(aWorld, aX, aY, aZ);
+ }
+
+ public static FakePlayer getFakePlayer(IGregTechTileEntity aBaseMetaTileEntity) {
+ if (aBaseMetaTileEntity.getWorld() instanceof WorldServer) {
+ return FakePlayerFactory.get((WorldServer) aBaseMetaTileEntity.getWorld(), new GameProfile(null, aBaseMetaTileEntity.getOwnerName()));
+ }
+ return null;
+ }
+
+ public static boolean eraseBlockByFakePlayer(FakePlayer aPlayer, int aX, int aY, int aZ, boolean isSimulate) {
+ if (aPlayer == null) return false;
+ World aWorld = aPlayer.worldObj;
+ BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(aX, aY, aZ, aWorld, aWorld.getBlock(aX, aY, aZ), aWorld.getBlockMetadata(aX, aY, aZ), aPlayer);
+ MinecraftForge.EVENT_BUS.post(event);
+ if (!event.isCanceled()) {
+ if (!isSimulate) return aWorld.setBlockToAir(aX, aY, aZ);
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean setBlockByFakePlayer(FakePlayer aPlayer, int aX, int aY, int aZ, Block aBlock, int aMeta, boolean isSimulate) {
+ if (aPlayer == null) return false;
+ World aWorld = aPlayer.worldObj;
+ BlockEvent.PlaceEvent event = ForgeEventFactory.onPlayerBlockPlace(aPlayer, new BlockSnapshot(aWorld, aX, aY, aZ, aBlock, aMeta), ForgeDirection.UNKNOWN);
+ if (!event.isCanceled()) {
+ if (!isSimulate) return aWorld.setBlock(aX, aY, aZ, aBlock, aMeta, 3);
+ return true;
+ }
+ return false;
+ }
+
public static class ItemNBT {
public static void setNBT(ItemStack aStack, NBTTagCompound aNBT) {
if (aNBT == null) {
@@ -2263,4 +2303,11 @@ public class GT_Utility {
}
}
+ public static String toSubscript(long no){
+ char[] chars=Long.toString(no).toCharArray();
+ for(int i=0;i<chars.length;i++){
+ chars[i]+=8272;
+ }
+ return new String(chars);
+ }
}
diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java
index a067e8e419..670a184b3c 100644
--- a/src/main/java/gregtech/common/GT_Proxy.java
+++ b/src/main/java/gregtech/common/GT_Proxy.java
@@ -1891,4 +1891,10 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler {
this.mModID = ((aModID == null) || (aModID.equals("UNKNOWN")) ? null : aModID);
}
}
+
+ @SubscribeEvent
+ public void onBlockEvent(BlockEvent event) {
+ if (event.block.getUnlocalizedName().equals("blockAlloyGlass"))
+ GregTech_API.causeMachineUpdate(event.world, event.x, event.y, event.z);
+ }
}
diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java
index f8148d5974..c0af4c010e 100644
--- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java
+++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java
@@ -17,9 +17,12 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.common.util.FakePlayer;
import java.util.ArrayList;
+import static gregtech.api.enums.GT_Values.V;
+
public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine {
private static final ItemStack MINING_PIPE = GT_ModHandler.getIC2Item("miningPipe", 0);
private static final Block MINING_PIPE_BLOCK = GT_Utility.getBlockFromStack(MINING_PIPE);
@@ -132,8 +135,14 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine {
}
}
+ @Override
+ public long maxEUStore() {
+ return mTier == 1 ? 4096 : V[mTier] * 64;
+ }
public boolean moveOneDown(IGregTechTileEntity aBaseMetaTileEntity) {
- if (aBaseMetaTileEntity.getYCoord() + drillY - 1 < 0 || aBaseMetaTileEntity.getBlockOffset(0, drillY - 1, 0) == Blocks.bedrock) {
+ if (aBaseMetaTileEntity.getYCoord() + drillY - 1 < 0
+ || GT_Utility.getBlockHardnessAt(aBaseMetaTileEntity.getWorld(), 0, aBaseMetaTileEntity.getYCoord() + drillY - 1, 0) < 0
+ || !GT_Utility.setBlockByFakePlayer(getFakePlayer(aBaseMetaTileEntity), 0, drillY - 1, 0, MINING_PIPE_TIP_BLOCK, 0, true)) {
isPickingPipes = true;
return false;
}
@@ -166,6 +175,7 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine {
}
public void mineBlock(IGregTechTileEntity aBaseMetaTileEntity, int x, int y, int z) {
+ if (!GT_Utility.eraseBlockByFakePlayer(getFakePlayer(aBaseMetaTileEntity), aBaseMetaTileEntity.getXCoord() + x, aBaseMetaTileEntity.getYCoord() + y, aBaseMetaTileEntity.getZCoord() + z, true));
ArrayList<ItemStack> drops = getBlockDrops(aBaseMetaTileEntity.getBlockOffset(x, y, z), aBaseMetaTileEntity.getXCoord() + x, aBaseMetaTileEntity.getYCoord() + y, aBaseMetaTileEntity.getZCoord() + z);
if (drops.size() > 0)
mOutputItems[0] = drops.get(0);
@@ -196,4 +206,13 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine {
drillY = aNBT.getInteger("drillY");
drillZ = aNBT.getInteger("drillZ");
}
+
+ private FakePlayer mFakePlayer = null;
+
+ protected FakePlayer getFakePlayer(IGregTechTileEntity aBaseTile) {
+ if (mFakePlayer == null) mFakePlayer = GT_Utility.getFakePlayer(aBaseTile);
+ mFakePlayer.setPosition(aBaseTile.getXCoord(), aBaseTile.getYCoord(), aBaseTile.getZCoord());
+ return mFakePlayer;
+ }
+
} \ No newline at end of file
diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java
index d5ca16c144..cec1c5a68f 100644
--- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java
+++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Pump.java
@@ -15,8 +15,10 @@ import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
+import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.ChunkPosition;
+import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidBlock;
@@ -26,8 +28,13 @@ import java.util.ArrayList;
import java.util.Iterator;
import static gregtech.api.enums.GT_Values.V;
+import static gregtech.api.util.GT_Utility.getFakePlayer;
public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch {
+ private static final ItemStack MINING_PIPE = GT_ModHandler.getIC2Item("miningPipe", 0);
+ private static final Block MINING_PIPE_BLOCK = GT_Utility.getBlockFromStack(MINING_PIPE);
+ private static final Block MINING_PIPE_TIP_BLOCK = GT_Utility.getBlockFromStack(GT_ModHandler.getIC2Item("miningPipeTip", 0));
+
public ArrayList<ChunkPosition> mPumpList = new ArrayList<ChunkPosition>();
public int mPumpTimer = 0;
@@ -187,7 +194,7 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch {
private boolean moveOneDown() {
if ((this.mInventory[0] == null) || (this.mInventory[0].stackSize < 1)
- || (!GT_Utility.areStacksEqual(this.mInventory[0], GT_ModHandler.getIC2Item("miningPipe", 1L)))) {
+ || (!GT_Utility.areStacksEqual(this.mInventory[0], MINING_PIPE))) {
return false;
}
int yHead = getYOfPumpHead();
@@ -198,11 +205,11 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch {
return false;
}
- if (!(getBaseMetaTileEntity().getWorld().setBlock(getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord(), GT_Utility.getBlockFromStack(GT_ModHandler.getIC2Item("miningPipeTip", 1L))))) {
+ if (!GT_Utility.setBlockByFakePlayer(getFakePlayer(getBaseMetaTileEntity()), getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord(), MINING_PIPE_TIP_BLOCK, 0, false)) {
return false;
}
if (yHead != getBaseMetaTileEntity().getYCoord()) {
- getBaseMetaTileEntity().getWorld().setBlock(getBaseMetaTileEntity().getXCoord(), yHead, getBaseMetaTileEntity().getZCoord(), GT_Utility.getBlockFromStack(GT_ModHandler.getIC2Item("miningPipe", 1L)));
+ getBaseMetaTileEntity().getWorld().setBlock(getBaseMetaTileEntity().getXCoord(), yHead, getBaseMetaTileEntity().getZCoord(), MINING_PIPE_BLOCK);
}
getBaseMetaTileEntity().decrStackSize(0, 1);
return true;
@@ -210,19 +217,16 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch {
private int getYOfPumpHead() {
int y = getBaseMetaTileEntity().getYCoord() - 1;
- while (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord()) == GT_Utility
- .getBlockFromStack(GT_ModHandler.getIC2Item("miningPipe", 1L))) {
+ while (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord()) == MINING_PIPE_BLOCK) {
y--;
}
if (y == getBaseMetaTileEntity().getYCoord() - 1) {
- if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord()) != GT_Utility
- .getBlockFromStack(GT_ModHandler.getIC2Item("miningPipeTip", 1L))) {
+ if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord()) != MINING_PIPE_TIP_BLOCK) {
return y + 1;
}
- } else if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord()) != GT_Utility
- .getBlockFromStack(GT_ModHandler.getIC2Item("miningPipeTip", 1L)) && this.mInventory[0] != null && this.mInventory[0].stackSize > 0 && GT_Utility.areStacksEqual(this.mInventory[0], GT_ModHandler.getIC2Item("miningPipe", 1L))) {
- getBaseMetaTileEntity().getWorld().setBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord(),
- GT_Utility.getBlockFromStack(GT_ModHandler.getIC2Item("miningPipeTip", 1L)));
+ } else if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord()) != MINING_PIPE_TIP_BLOCK
+ && this.mInventory[0] != null && this.mInventory[0].stackSize > 0 && GT_Utility.areStacksEqual(this.mInventory[0], MINING_PIPE)) {
+ getBaseMetaTileEntity().getWorld().setBlock(getBaseMetaTileEntity().getXCoord(), y, getBaseMetaTileEntity().getZCoord(), MINING_PIPE_BLOCK);
getBaseMetaTileEntity().decrStackSize(0, 1);
}
return y;
@@ -297,6 +301,7 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch {
}
private boolean consumeFluid(int aX, int aY, int aZ) {
+ if (!GT_Utility.eraseBlockByFakePlayer(getFakePlayer(getBaseMetaTileEntity()), aX, aY, aZ, true)) return false;
Block aBlock = getBaseMetaTileEntity().getBlock(aX, aY, aZ);
int aMeta = getBaseMetaTileEntity().getMetaID(aX, aY, aZ);
if ((GT_Utility.isBlockValid(aBlock)) && ((this.mPumpedBlock1 == aBlock) || (this.mPumpedBlock2 == aBlock))) {
@@ -463,4 +468,11 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch {
new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ADV_PUMP), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ADV_PUMP),
new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ADV_PUMP), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_ADV_PUMP),};
}
+ private FakePlayer mFakePlayer = null;
+
+ protected FakePlayer getFakePlayer(IGregTechTileEntity aBaseTile) {
+ if (mFakePlayer == null) mFakePlayer = GT_Utility.getFakePlayer(aBaseTile);
+ mFakePlayer.setPosition(aBaseTile.getXCoord(), aBaseTile.getYCoord(), aBaseTile.getZCoord());
+ return mFakePlayer;
+ }
}
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
index 21ab6f566c..3fa1a989cc 100644
--- 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
@@ -1,5 +1,7 @@
package gregtech.common.tileentities.machines.multi;
+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;
@@ -8,9 +10,6 @@ import gregtech.api.util.GT_Utility;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
-import static gregtech.api.enums.GT_Values.V;
-import static gregtech.api.enums.GT_Values.VN;
-
public abstract class GT_MetaTileEntity_ConcreteBackfillerBase extends GT_MetaTileEntity_DrillerBase {
private int mLastXOff = 0, mLastZOff = 0;
@@ -53,18 +52,9 @@ public abstract class GT_MetaTileEntity_ConcreteBackfillerBase extends GT_MetaTi
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;
+ int tier = Math.max(1, GT_Utility.getTier(getMaxInputVoltage()));
+ this.mEUt = -6 * (1 << (tier << 1));
+ this.mMaxProgresstime = (workState == STATE_UPWARD ? 240 : 80) / (1 << tier);
this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
}
@@ -94,22 +84,22 @@ public abstract class GT_MetaTileEntity_ConcreteBackfillerBase extends GT_MetaTi
mLastZOff = 0;
return true;
} else {
- isPickingPipes = false;
+ workState = STATE_DOWNWARD;
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;
+ IGregTechTileEntity aBaseTile = getBaseMetaTileEntity();
+ if (aBaseTile.getTileEntity(aX, aY, aZ) != null) return false;
+ if (!aBaseTile.getAir(aX, aY, aZ) && aBaseTile.getBlock(aX, aY, aZ).getMaterial().isSolid()) return false;
+ if (!GT_Utility.setBlockByFakePlayer(getFakePlayer(aBaseTile), aX, aY, aZ, GregTech_API.sBlockConcretes, 8, true)) return false;
+ return true;
}
private boolean tryRefillBlock(int aX, int aY, int aZ) {
- if (!tryConsumeFluid())
- return false;
+ if (!tryConsumeFluid()) return false;
getBaseMetaTileEntity().getWorld().setBlock(aX, aY, aZ, GregTech_API.sBlockConcretes, 8, 3);
return true;
}
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
index cd2d40f131..0c0e150d53 100644
--- 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
@@ -1,5 +1,9 @@
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;
@@ -19,12 +23,9 @@ 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.FakePlayer;
import net.minecraftforge.common.util.ForgeDirection;
-import java.util.ArrayList;
-
-import static gregtech.api.enums.GT_Values.W;
-
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);
@@ -39,7 +40,8 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu
private ForgeDirection back;
private int xDrill, yDrill, zDrill, xPipe, zPipe, yHead;
- protected boolean isPickingPipes;
+ protected int workState;
+ protected static final int STATE_DOWNWARD = 0, STATE_AT_BOTTOM = 1, STATE_UPWARD = 2;
public GT_MetaTileEntity_DrillerBase(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
@@ -57,7 +59,7 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu
int frameId = 4096 + getFrameMaterial().mMetaItemSubID;
frameMeta = GregTech_API.METATILEENTITIES[frameId] != null ? GregTech_API.METATILEENTITIES[frameId].getTileEntityBaseType() : W;
casingTextureIndex = getCasingTextureIndex();
- isPickingPipes = false;
+ workState = STATE_DOWNWARD;
}
public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
@@ -69,13 +71,14 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu
@Override
public void saveNBTData(NBTTagCompound aNBT) {
super.saveNBTData(aNBT);
- aNBT.setBoolean("isPickingPipe", isPickingPipes);
+ aNBT.setInteger("workState", workState);
}
@Override
public void loadNBTData(NBTTagCompound aNBT) {
super.loadNBTData(aNBT);
- isPickingPipes = aNBT.getBoolean("isPickingPipes");
+ workState = aNBT.getInteger("workState");
+