Adding Fake Player for all drills and pumps
This commit is contained in:
parent
9d8ac82535
commit
e725c455b3
7 changed files with 159 additions and 79 deletions
|
@ -54,7 +54,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;
|
||||
|
||||
|
@ -67,6 +72,8 @@ import java.text.NumberFormat;
|
|||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import static gregtech.api.enums.GT_Values.*;
|
||||
import static gregtech.common.GT_Proxy.GTPOLLUTION;
|
||||
import static gregtech.common.GT_UndergroundOil.undergroundOilReadInformation;
|
||||
|
@ -1982,6 +1989,40 @@ public class GT_Utility {
|
|||
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) {
|
||||
|
|
|
@ -17,6 +17,7 @@ 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;
|
||||
|
||||
|
@ -133,7 +134,7 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine {
|
|||
}
|
||||
|
||||
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, 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 +167,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 +198,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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
|
||||
|
@ -26,6 +28,9 @@ import java.util.Iterator;
|
|||
import static gregtech.api.enums.GT_Values.V;
|
||||
|
||||
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;
|
||||
|
@ -171,7 +176,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();
|
||||
|
@ -179,14 +184,13 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch {
|
|||
return false;
|
||||
}
|
||||
if ((!consumeFluid(getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord())) && (!getBaseMetaTileEntity().getAir(getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord()))) {
|
||||
|
||||
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;
|
||||
|
@ -194,19 +198,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;
|
||||
|
@ -281,6 +282,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))) {
|
||||
|
@ -447,4 +449,12 @@ 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
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;
|
||||
|
@ -92,15 +91,15 @@ public abstract class GT_MetaTileEntity_ConcreteBackfillerBase extends GT_MetaTi
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ 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;
|
||||
|
||||
public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_MultiBlockBase {
|
||||
|
@ -91,23 +92,30 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu
|
|||
return false;
|
||||
}
|
||||
|
||||
protected boolean tryLowerPipe() {
|
||||
/**
|
||||
* @return 0 for succeeded, 1 for invalid block, 2 for not having mining pipes, 3 for event canceled.
|
||||
*/
|
||||
protected int tryLowerPipe() {
|
||||
return tryLowerPipe(false);
|
||||
}
|
||||
|
||||
protected boolean tryLowerPipe(boolean isSimulating) {
|
||||
if (!isHasMiningPipes()) return false;
|
||||
|
||||
if (yHead <= 0) return false;
|
||||
if (!canLowerPipe()) return false;
|
||||
/**
|
||||
* @return 0 for succeeded, 1 for invalid block, 2 for not having mining pipes, 3 for event canceled.
|
||||
*/
|
||||
protected int tryLowerPipe(boolean isSimulating) {
|
||||
if (!isHasMiningPipes()) return 2;
|
||||
switch (canLowerPipe()) {
|
||||
case 1: return 1;
|
||||
case 2: return 3;
|
||||
}
|
||||
|
||||
if (!GT_Utility.setBlockByFakePlayer(getFakePlayer(getBaseMetaTileEntity()), xPipe, yHead - 1, zPipe, miningPipeTipBlock, 0, isSimulating)) return 3;
|
||||
if (!isSimulating) {
|
||||
getBaseMetaTileEntity().getWorld().setBlock(xPipe, yHead - 1, zPipe, miningPipeTipBlock);
|
||||
if (yHead != yDrill) getBaseMetaTileEntity().getWorld().setBlock(xPipe, yHead, zPipe, miningPipeBlock);
|
||||
|
||||
getBaseMetaTileEntity().decrStackSize(1, 1);
|
||||
}
|
||||
return true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void putMiningPipesFromInputsInController() {
|
||||
|
@ -140,8 +148,19 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu
|
|||
return true;
|
||||
}
|
||||
|
||||
protected boolean canLowerPipe(){
|
||||
return yHead > 0 && !checkBlockAndMeta(xPipe, yHead - 1, zPipe, Blocks.bedrock, W);
|
||||
/**
|
||||
* @return 0 for available, 1 for invalid block, 2 for event canceled.
|
||||
*/
|
||||
protected int canLowerPipe(){
|
||||
IGregTechTileEntity aBaseTile = getBaseMetaTileEntity();
|
||||
if (yHead > 0 && GT_Utility.getBlockHardnessAt(aBaseTile.getWorld(), xPipe, yHead - 1, zPipe) >= 0) {
|
||||
return GT_Utility.eraseBlockByFakePlayer(getFakePlayer(aBaseTile), xPipe, yHead - 1, zPipe, true) ? 0 : 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
protected boolean reachingVoidOrBedrock() {
|
||||
return yHead <= 0 || checkBlockAndMeta(xPipe, yHead - 1, zPipe, Blocks.bedrock, 0);
|
||||
}
|
||||
|
||||
private boolean isHasMiningPipes() {
|
||||
|
@ -163,19 +182,19 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu
|
|||
}
|
||||
|
||||
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;
|
||||
workState = STATE_AT_BOTTOM;
|
||||
switch (tryLowerPipe()) {
|
||||
case 2: mMaxProgresstime = 0; return false;
|
||||
case 3: workState = STATE_UPWARD; return true;
|
||||
case 1: workState = STATE_AT_BOTTOM; return true;
|
||||
default: return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean workingAtBottom(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead) {
|
||||
if(tryLowerPipe(true))
|
||||
workState = STATE_DOWNWARD;
|
||||
else
|
||||
workState = STATE_UPWARD;
|
||||
return true;
|
||||
switch (tryLowerPipe(true)) {
|
||||
case 0: workState = STATE_DOWNWARD; return true;
|
||||
default: workState = STATE_UPWARD; return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean workingUpward(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead) {
|
||||
|
@ -279,12 +298,12 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu
|
|||
&& getBaseMetaTileEntity().getBlock(x, y, z) == block;
|
||||
}
|
||||
|
||||
protected boolean waitForPipes(){
|
||||
if (canLowerPipe()) {
|
||||
mMaxProgresstime = 0;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -312,8 +331,6 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu
|
|||
return false;
|
||||
}
|
||||
|
||||
public abstract Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity);
|
||||
|
||||
protected abstract ItemList getCasingBlockItem();
|
||||
|
||||
protected abstract Materials getFrameMaterial();
|
||||
|
@ -371,7 +388,7 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu
|
|||
IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
|
||||
if (aMetaTileEntity == null) return false;
|
||||
if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DataAccess) {
|
||||
((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex;
|
||||
((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; // TODO
|
||||
return mDataAccessHatches.add((GT_MetaTileEntity_Hatch_DataAccess) aMetaTileEntity);
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
package gregtech.common.tileentities.machines.multi;
|
||||
|
||||
import static gregtech.api.enums.GT_Values.VN;
|
||||
import static gregtech.common.GT_UndergroundOil.undergroundOil;
|
||||
import static gregtech.common.GT_UndergroundOil.undergroundOilReadInformation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import gregtech.api.gui.GT_GUIContainer_MultiMachine;
|
||||
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
|
||||
import gregtech.api.util.GT_Utility;
|
||||
|
@ -10,13 +16,6 @@ import net.minecraft.world.chunk.Chunk;
|
|||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static gregtech.api.enums.GT_Values.V;
|
||||
import static gregtech.api.enums.GT_Values.VN;
|
||||
import static gregtech.common.GT_UndergroundOil.undergroundOil;
|
||||
import static gregtech.common.GT_UndergroundOil.undergroundOilReadInformation;
|
||||
|
||||
public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_DrillerBase {
|
||||
|
||||
private boolean completedCycle = false;
|
||||
|
@ -86,21 +85,20 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D
|
|||
|
||||
@Override
|
||||
protected boolean workingAtBottom(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead) {
|
||||
if(tryLowerPipe(true)) {
|
||||
workState = STATE_DOWNWARD;
|
||||
setElectricityStats();
|
||||
switch (tryLowerPipe(true)) {
|
||||
case 0: workState = STATE_DOWNWARD; setElectricityStats(); return true;
|
||||
case 3: workState = STATE_UPWARD; return true;
|
||||
}
|
||||
else {
|
||||
if (tryFillChunkList()) {
|
||||
float speed = .5F+(GT_Utility.getTier(getMaxInputVoltage()) - getMinTier()) *.25F;
|
||||
FluidStack tFluid = pumpOil(speed);
|
||||
if (tFluid != null && tFluid.amount > getTotalConfigValue()){
|
||||
this.mOutputFluids = new FluidStack[]{tFluid};
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!reachingVoidOrBedrock() && tryFillChunkList()) {
|
||||
float speed = .5F+(GT_Utility.getTier(getMaxInputVoltage()) - getMinTier()) *.25F;
|
||||
FluidStack tFluid = pumpOil(speed);
|
||||
if (tFluid != null && tFluid.amount > getTotalConfigValue()){
|
||||
this.mOutputFluids = new FluidStack[]{tFluid};
|
||||
return true;
|
||||
}
|
||||
workState = STATE_UPWARD;
|
||||
}
|
||||
workState = STATE_UPWARD;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package gregtech.common.tileentities.machines.multi;
|
||||
|
||||
import static gregtech.api.enums.GT_Values.*;
|
||||
import static gregtech.api.enums.GT_Values.VN;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
@ -46,11 +46,11 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
|
|||
|
||||
fillMineListIfEmpty(xDrill, yDrill, zDrill, xPipe, zPipe, yHead);
|
||||
if (oreBlockPositions.isEmpty()) {
|
||||
if (!tryLowerPipe()) {
|
||||
if (waitForPipes()) return false;
|
||||
workState = STATE_AT_BOTTOM;
|
||||
return true;
|
||||
}
|
||||
switch (tryLowerPipe()) {
|
||||
case 2: mMaxProgresstime = 0; return false;
|
||||
case 3: workState = STATE_UPWARD; return true;
|
||||
case 1: workState = STATE_AT_BOTTOM; return true;
|
||||
}
|
||||
//new layer - fill again
|
||||
fillMineListIfEmpty(xDrill, yDrill, zDrill, xPipe, zPipe, yHead);
|
||||
}
|
||||
|
@ -60,10 +60,14 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
|
|||
|
||||
while ((oreBlock == null || oreBlock == Blocks.air) && !oreBlockPositions.isEmpty()) {
|
||||
oreBlockPos = oreBlockPositions.remove(0);
|
||||
oreBlock = getBaseMetaTileEntity().getBlock(oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ);
|
||||
if (GT_Utility.eraseBlockByFakePlayer(getFakePlayer(getBaseMetaTileEntity()), oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ, true))
|
||||
oreBlock = getBaseMetaTileEntity().getBlock(oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ);
|
||||
}
|
||||
|
||||
if (!tryConsumeDrillingFluid()) return false;
|
||||
if (!tryConsumeDrillingFluid()) {
|
||||
oreBlockPositions.add(0, oreBlockPos);
|
||||
return false;
|
||||
}
|
||||
if (oreBlock != null && oreBlock != Blocks.air) {
|
||||
ArrayList<ItemStack> oreBlockDrops = getBlockDrops(oreBlock, oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ);
|
||||
getBaseMetaTileEntity().getWorld().setBlockToAir(oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ);
|
||||
|
|
Loading…
Reference in a new issue