From 0802fdbd0272c4251c4615026643c8eadcf7fe70 Mon Sep 17 00:00:00 2001 From: Antifluxfield Date: Thu, 21 Sep 2017 20:33:23 +0800 Subject: [PATCH 01/10] Fix Oil Drill logic; rebalance EU cost --- ...MetaTileEntity_ConcreteBackfillerBase.java | 17 ++----- .../multi/GT_MetaTileEntity_DrillerBase.java | 51 ++++++++++++++----- .../multi/GT_MetaTileEntity_OilDrillBase.java | 39 ++++++-------- 3 files changed, 56 insertions(+), 51 deletions(-) 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 29b37f6d..2f88d446 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 @@ -53,18 +53,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,7 +85,7 @@ public abstract class GT_MetaTileEntity_ConcreteBackfillerBase extends GT_MetaTi mLastZOff = 0; return true; } else { - isPickingPipes = false; + workState = STATE_DOWNWARD; stopMachine(); return false; } 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 7f1cfafb..aa0bd0f1 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 @@ -39,7 +39,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 +58,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 +70,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"); + if (aNBT.hasKey("isPickingPipes")) workState = aNBT.getBoolean("isPickingPipes") ? STATE_UPWARD : STATE_DOWNWARD; } protected boolean tryPickPipe() { @@ -90,15 +92,21 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu } protected boolean tryLowerPipe() { + return tryLowerPipe(false); + } + + protected boolean tryLowerPipe(boolean isSimulating) { 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); + if (!isSimulating) { + getBaseMetaTileEntity().getWorld().setBlock(xPipe, yHead - 1, zPipe, miningPipeTipBlock); + if (yHead != yDrill) getBaseMetaTileEntity().getWorld().setBlock(xPipe, yHead, zPipe, miningPipeBlock); - getBaseMetaTileEntity().decrStackSize(1, 1); + getBaseMetaTileEntity().decrStackSize(1, 1); + } return true; } @@ -154,18 +162,27 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu return false; } - protected boolean workingDownward(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead){ - if(!tryLowerPipe()) + 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; + workState = STATE_AT_BOTTOM; + } 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; + } + 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; + workState = STATE_DOWNWARD; stopMachine(); return false; } @@ -181,10 +198,16 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu return false; } putMiningPipesFromInputsInController(); - if (!isPickingPipes) + switch (workState) { + case STATE_DOWNWARD: return workingDownward(aStack, xDrill, yDrill, zDrill, xPipe, zPipe, yHead, oldYHead); - else + case STATE_AT_BOTTOM: + return workingAtBottom(aStack, xDrill, yDrill, zDrill, xPipe, zPipe, yHead, oldYHead); + case STATE_UPWARD: return workingUpward(aStack, xDrill, yDrill, zDrill, xPipe, zPipe, yHead, oldYHead); + default: + return false; + } } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java index a4311ee1..7d3b4678 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java @@ -78,27 +78,20 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D protected void setElectricityStats() { this.mEfficiency = getCurrentEfficiency(null); this.mEfficiencyIncrease = 10000; - //T1 = 24; T2 = 96; T3 = 384 - this.mEUt = 6 * (1 << (getMinTier() << 1)); - //160 per chunk in MV - this.mMaxProgresstime = (isPickingPipes ? 80 : 640 * getRangeInChunks() * getRangeInChunks()) / (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 = -3 * (1 << (tier << 1)); + this.mMaxProgresstime = (workState == STATE_AT_BOTTOM ? 320 * getRangeInChunks() * getRangeInChunks() : 80) / (1 << tier); this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); } @Override - 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; - if (tryFillChunkList()) { + 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(); + } + else { + if (tryFillChunkList()) { float speed = .5F+(GT_Utility.getTier(getMaxInputVoltage()) - getMinTier()) *.25F; FluidStack tFluid = pumpOil(speed); if (tFluid != null && tFluid.amount > getTotalConfigValue()){ @@ -106,10 +99,9 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D return true; } } - isPickingPipes = true; - return true; - } - return true; + workState = STATE_UPWARD; + } + return true; } private boolean tryFillChunkList(){ @@ -124,11 +116,10 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D if (mOilFieldChunks.isEmpty()) { Chunk tChunk = getBaseMetaTileEntity().getWorld().getChunkFromBlockCoords(getBaseMetaTileEntity().getXCoord(), getBaseMetaTileEntity().getZCoord()); int range = getRangeInChunks(); - int xChunk = (tChunk.xPosition / range) * range, zChunk = (tChunk.zPosition / range) * range; - int xDir = tChunk.xPosition < 0 ? -1 : 1, zDir = tChunk.zPosition < 0 ? -1 : 1; + int xChunk = (tChunk.xPosition / range) * range - (tChunk.xPosition < 0 ? range : 0), zChunk = (tChunk.zPosition / range) * range - (tChunk.zPosition < 0 ? range : 0); for (int i = 0; i < range; i++) { for (int j = 0; j < range; j++) { - tChunk = getBaseMetaTileEntity().getWorld().getChunkFromChunkCoords(xChunk + i * xDir, zChunk + j * zDir); + tChunk = getBaseMetaTileEntity().getWorld().getChunkFromChunkCoords(xChunk + i, zChunk + j); tFluid = undergroundOilReadInformation(tChunk); if (tOil.isFluidEqual(tFluid)) mOilFieldChunks.add(tChunk); From 9d8ac82535b0099ef70e8995bca51f62f39f9f94 Mon Sep 17 00:00:00 2001 From: Antifluxfield Date: Thu, 21 Sep 2017 20:34:38 +0800 Subject: [PATCH 02/10] Fix Ore Drill EU calculation; now Ore Drill is using DrillerBase --- ...T_MetaTileEntity_OreDrillingPlantBase.java | 282 ++---------------- 1 file changed, 30 insertions(+), 252 deletions(-) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java index a227ab74..bc523114 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java @@ -1,18 +1,15 @@ package gregtech.common.tileentities.machines.multi; -import gregtech.api.GregTech_API; +import static gregtech.api.enums.GT_Values.*; + +import java.util.ArrayList; + 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_GUIContainer_MultiMachine; -import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -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.objects.ItemData; -import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; @@ -22,106 +19,40 @@ 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.minecraft.tileentity.TileEntity; import net.minecraft.world.ChunkPosition; -import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import java.util.ArrayList; - -import static gregtech.api.enums.GT_Values.*; - -public abstract class GT_MetaTileEntity_OreDrillingPlantBase 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); - +public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTileEntity_DrillerBase { + private final ArrayList oreBlockPositions = new ArrayList<>(); - private Block casingBlock; - private int casingMeta; - private int frameMeta; - private int casingTextureIndex; - - private ForgeDirection back; - private int xDrill, yDrill, zDrill, xCenter, zCenter, yHead; - - private boolean isPickingPipes; - public GT_MetaTileEntity_OreDrillingPlantBase(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); - initFields(); } public GT_MetaTileEntity_OreDrillingPlantBase(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 Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "OreDrillingPlant.png"); } @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setBoolean("isPickingPipes", isPickingPipes); - } + protected boolean workingDownward(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead) { + if (yHead != oldYHead) oreBlockPositions.clear(); - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - isPickingPipes = aNBT.getBoolean("isPickingPipes"); - } - - @Override - public boolean checkRecipe(ItemStack aStack) { - setElectricityStats(); - int oldYHead = yHead; - if (!checkPipesAndSetYHead() || !isEnergyEnough()) { - stopMachine(); - return false; - } - if (yHead != oldYHead) oreBlockPositions.clear(); - if (isPickingPipes) { - if (tryPickPipe()) { - mOutputItems = new ItemStack[] {GT_Utility.copyAmount(1, miningPipe)}; - return true; - } else { - isPickingPipes = false; - stopMachine(); - return false; - } - } - - putMiningPipesFromInputsInController(); - if (!tryConsumeDrillingFluid()) return false; - - fillMineListIfEmpty(); + fillMineListIfEmpty(xDrill, yDrill, zDrill, xPipe, zPipe, yHead); if (oreBlockPositions.isEmpty()) { if (!tryLowerPipe()) { - isPickingPipes = true; + if (waitForPipes()) return false; + workState = STATE_AT_BOTTOM; return true; } //new layer - fill again - fillMineListIfEmpty(); + fillMineListIfEmpty(xDrill, yDrill, zDrill, xPipe, zPipe, yHead); } ChunkPosition oreBlockPos = null; @@ -132,6 +63,7 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile oreBlock = getBaseMetaTileEntity().getBlock(oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ); } + if (!tryConsumeDrillingFluid()) return false; if (oreBlock != null && oreBlock != Blocks.air) { ArrayList oreBlockDrops = getBlockDrops(oreBlock, oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ); getBaseMetaTileEntity().getWorld().setBlockToAir(oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ); @@ -141,29 +73,19 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile return true; } - 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; + @Override + protected boolean checkHatches(){ + return !mMaintenanceHatches.isEmpty() && !mInputHatches.isEmpty() && !mOutputBusses.isEmpty() && !mEnergyHatches.isEmpty(); } - - private boolean tryPickPipe() { - if (yHead == yDrill) return false; - if (checkBlockAndMeta(xCenter, yHead + 1, zCenter, miningPipeBlock, W)) - getBaseMetaTileEntity().getWorld().setBlock(xCenter, yHead + 1, zCenter, miningPipeTipBlock); - getBaseMetaTileEntity().getWorld().setBlockToAir(xCenter, yHead, zCenter); - return true; - } - - private void setElectricityStats() { + + @Override + protected void setElectricityStats() { this.mEfficiency = getCurrentEfficiency(null); this.mEfficiencyIncrease = 10000; - int overclock = 1 << GT_Utility.getTier(getMaxInputVoltage()) - 1; - this.mEUt = -12 * overclock * overclock; - this.mMaxProgresstime = (isPickingPipes ? 80 : getBaseProgressTime()) / overclock; + int tier = Math.max(1, GT_Utility.getTier(getMaxInputVoltage())); + this.mEUt = -3 * (1 << (tier << 1)); + this.mMaxProgresstime = (workState == STATE_DOWNWARD ? getBaseProgressTime() : 80) / (1 < oreBlockDrops) { @@ -216,37 +138,17 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile } private boolean tryConsumeDrillingFluid() { - return depleteInput(new FluidStack(ItemList.sDrillingFluid, 2000)); - } - - 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; + if (!depleteInput(new FluidStack(ItemList.sDrillingFluid, 2000))) { + mMaxProgresstime = 0; + return false; } - updateSlots(); + return true; } - private void fillMineListIfEmpty() { + private void fillMineListIfEmpty(int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead) { if (!oreBlockPositions.isEmpty()) return; - tryAddOreBlockToMineList(xCenter, yHead - 1, zCenter); + tryAddOreBlockToMineList(xPipe, yHead - 1, zPipe); if (yHead == yDrill) return; //skip controller block layer int radius = getRadiusInChunks() << 4; @@ -271,132 +173,8 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile } } - private boolean tryLowerPipe() { - if (!isHasMiningPipes()) return false; - - if (yHead <= 0) return false; - if (checkBlockAndMeta(xCenter, yHead - 1, zCenter, Blocks.bedrock, W)) return false; - - getBaseMetaTileEntity().getWorld().setBlock(xCenter, yHead - 1, zCenter, miningPipeTipBlock); - if (yHead != yDrill) getBaseMetaTileEntity().getWorld().setBlock(xCenter, yHead, zCenter, miningPipeBlock); - - getBaseMetaTileEntity().decrStackSize(1, 1); - return true; - } - - 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); - } - - @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)) - return false; - } - } - if (mMaintenanceHatches.isEmpty() || mInputHatches.isEmpty() || mOutputBusses.isEmpty() || mEnergyHatches.isEmpty()) 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()); - xCenter = xDrill + back.offsetX; - zCenter = zDrill + back.offsetZ; - } - - private boolean checkPipesAndSetYHead() { - yHead = yDrill - 1; - while (checkBlockAndMeta(xCenter, yHead, zCenter, miningPipeBlock, W)) yHead--; //skip pipes - //is pipe tip OR is controller layer - if (checkBlockAndMeta(xCenter, yHead, zCenter, miningPipeTipBlock, W) || ++yHead == yDrill) return true; - //pipe column is broken - try fix - getBaseMetaTileEntity().getWorld().setBlock(xCenter, yHead, zCenter, miningPipeTipBlock); - return true; - } - - private 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) - private boolean checkFrameBlock(int xOff, int yOff, int zOff) { - return checkBlockAndMetaOffset(xOff, yOff, zOff, GregTech_API.sBlockMachines, frameMeta); - } - - private 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; - } - - @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; - } - - protected abstract ItemList getCasingBlockItem(); - - protected abstract Materials getFrameMaterial(); - - protected abstract int getCasingTextureIndex(); - protected abstract int getRadiusInChunks(); - protected abstract int getMinTier(); - - //returns theoretical progress time for LV energy hatch protected abstract int getBaseProgressTime(); protected String[] getDescriptionInternal(String tierSuffix) { From e725c455b3d9025caeebdbf12cc9d25f238f74bb Mon Sep 17 00:00:00 2001 From: Antifluxfield Date: Fri, 22 Sep 2017 01:34:10 +0800 Subject: [PATCH 03/10] Adding Fake Player for all drills and pumps --- .../java/gregtech/api/util/GT_Utility.java | 43 +++++++++- .../basic/GT_MetaTileEntity_Miner.java | 13 ++- .../basic/GT_MetaTileEntity_Pump.java | 34 +++++--- ...MetaTileEntity_ConcreteBackfillerBase.java | 13 ++- .../multi/GT_MetaTileEntity_DrillerBase.java | 79 +++++++++++-------- .../multi/GT_MetaTileEntity_OilDrillBase.java | 36 ++++----- ...T_MetaTileEntity_OreDrillingPlantBase.java | 20 +++-- 7 files changed, 159 insertions(+), 79 deletions(-) diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index fb89cbba..996e5fd8 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -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; @@ -1981,7 +1988,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) { 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 13f16a2b..254daaf8 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,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 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; + } + } 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 c4fa8d73..4b410407 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.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 mPumpList = new ArrayList(); 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; + } } 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 2f88d446..a285f136 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,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; } 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 aa0bd0f1..7998d102 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 @@ -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) { @@ -278,13 +297,13 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu 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; + + 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 @@ -311,8 +330,6 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu public boolean explodesOnComponentBreak(ItemStack aStack) { return false; } - - public abstract Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity); protected abstract ItemList getCasingBlockItem(); @@ -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; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java index 7d3b4678..068b09db 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java @@ -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; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java index bc523114..4e963d53 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java @@ -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 oreBlockDrops = getBlockDrops(oreBlock, oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ); getBaseMetaTileEntity().getWorld().setBlockToAir(oreBlockPos.chunkPosX, oreBlockPos.chunkPosY, oreBlockPos.chunkPosZ); From 3db38a5c53a771aeb37a8cf2568f79c49bb38c21 Mon Sep 17 00:00:00 2001 From: Antifluxfield Date: Fri, 22 Sep 2017 01:36:28 +0800 Subject: [PATCH 04/10] Update --- .../machines/multi/GT_MetaTileEntity_DrillerBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 7998d102..bb0aaaee 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 @@ -388,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; // TODO + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture((byte) aBaseCasingIndex); return mDataAccessHatches.add((GT_MetaTileEntity_Hatch_DataAccess) aMetaTileEntity); } return false; From aef60bbf3b6752963b51c9c4e27b6ba03f75ba8c Mon Sep 17 00:00:00 2001 From: Antifluxfield Date: Fri, 22 Sep 2017 14:06:42 +0800 Subject: [PATCH 05/10] Fix wrong logic. --- .../machines/multi/GT_MetaTileEntity_DrillerBase.java | 2 +- .../machines/multi/GT_MetaTileEntity_OilDrillBase.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 bb0aaaee..9c05c58d 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 @@ -160,7 +160,7 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu } protected boolean reachingVoidOrBedrock() { - return yHead <= 0 || checkBlockAndMeta(xPipe, yHead - 1, zPipe, Blocks.bedrock, 0); + return yHead <= 0 || checkBlockAndMeta(xPipe, yHead - 1, zPipe, Blocks.bedrock, W); } private boolean isHasMiningPipes() { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java index 068b09db..6e7c0f4f 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java @@ -90,7 +90,7 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D case 3: workState = STATE_UPWARD; return true; } - if (!reachingVoidOrBedrock() && tryFillChunkList()) { + if (reachingVoidOrBedrock() && tryFillChunkList()) { float speed = .5F+(GT_Utility.getTier(getMaxInputVoltage()) - getMinTier()) *.25F; FluidStack tFluid = pumpOil(speed); if (tFluid != null && tFluid.amount > getTotalConfigValue()){ From ef41455fe59f2915c94c204b97cee19aa2ddcd3b Mon Sep 17 00:00:00 2001 From: Antifluxfield Date: Sun, 24 Sep 2017 11:45:15 +0800 Subject: [PATCH 06/10] Fix wrong coordinate --- .../tileentities/machines/basic/GT_MetaTileEntity_Miner.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 254daaf8..c59790d1 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 @@ -134,7 +134,9 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine { } public boolean moveOneDown(IGregTechTileEntity aBaseMetaTileEntity) { - 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)) { + 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; } From 4372034ff4edc9e58629d63123b84c29e6e0e516 Mon Sep 17 00:00:00 2001 From: Antifluxfield Date: Mon, 2 Oct 2017 11:31:01 +0800 Subject: [PATCH 07/10] Rebalance EU cost 2 --- .../machines/multi/GT_MetaTileEntity_OilDrillBase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java index 6e7c0f4f..5d760e62 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java @@ -79,7 +79,7 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D this.mEfficiencyIncrease = 10000; int tier = Math.max(1, GT_Utility.getTier(getMaxInputVoltage())); this.mEUt = -3 * (1 << (tier << 1)); - this.mMaxProgresstime = (workState == STATE_AT_BOTTOM ? 320 * getRangeInChunks() * getRangeInChunks() : 80) / (1 << tier); + this.mMaxProgresstime = (workState == STATE_AT_BOTTOM ? (1280 * getRangeInChunks() * getRangeInChunks() / (1 << getMinTier())) : 80) / (1 << tier); this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); } From f5abfcefe8d77e2c3c6284bff72de25c0a0ef774 Mon Sep 17 00:00:00 2001 From: Antifluxfield Date: Sun, 8 Oct 2017 02:48:49 +0800 Subject: [PATCH 08/10] The right method to find out whether the machine should break the block. --- .../tileentities/machines/basic/GT_MetaTileEntity_Pump.java | 2 +- .../multi/GT_MetaTileEntity_ConcreteBackfillerBase.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) 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 4b410407..f91ce480 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 @@ -183,7 +183,7 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch { if (yHead <= 0) { return false; } - if ((!consumeFluid(getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord())) && (!getBaseMetaTileEntity().getAir(getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord()))) { + if ((!consumeFluid(getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord())) && (!getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord()).isAir(getBaseMetaTileEntity().getWorld(), getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord()))) { return false; } if (!GT_Utility.setBlockByFakePlayer(getFakePlayer(getBaseMetaTileEntity()), getBaseMetaTileEntity().getXCoord(), yHead - 1, getBaseMetaTileEntity().getZCoord(), MINING_PIPE_TIP_BLOCK, 0, false)) { 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 a285f136..73795647 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 @@ -92,8 +92,7 @@ public abstract class GT_MetaTileEntity_ConcreteBackfillerBase extends GT_MetaTi private boolean isRefillableBlock(int aX, int aY, int aZ){ 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 (!aBaseTile.getBlock(aX, aY, aZ).isAir(aBaseTile.getWorld(), 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; } From 15c86d4ea2eb54aa88db839d6a3ed6a83026935f Mon Sep 17 00:00:00 2001 From: Antifluxfield Date: Wed, 18 Oct 2017 17:53:59 +0800 Subject: [PATCH 09/10] Fix --- .../tileentities/machines/basic/GT_MetaTileEntity_Miner.java | 1 + .../tileentities/machines/basic/GT_MetaTileEntity_Pump.java | 1 + .../machines/multi/GT_MetaTileEntity_DrillerBase.java | 1 + 3 files changed, 3 insertions(+) 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 c59790d1..b34f6fa0 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 @@ -205,6 +205,7 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine { protected FakePlayer getFakePlayer(IGregTechTileEntity aBaseTile) { if (mFakePlayer == null) mFakePlayer = GT_Utility.getFakePlayer(aBaseTile); + mFakePlayer.setWorld(aBaseTile.getWorld()); mFakePlayer.setPosition(aBaseTile.getXCoord(), aBaseTile.getYCoord(), aBaseTile.getZCoord()); return mFakePlayer; } 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 f91ce480..1c02526a 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 @@ -454,6 +454,7 @@ public class GT_MetaTileEntity_Pump extends GT_MetaTileEntity_Hatch { protected FakePlayer getFakePlayer(IGregTechTileEntity aBaseTile) { if (mFakePlayer == null) mFakePlayer = GT_Utility.getFakePlayer(aBaseTile); + mFakePlayer.setWorld(aBaseTile.getWorld()); mFakePlayer.setPosition(aBaseTile.getXCoord(), aBaseTile.getYCoord(), aBaseTile.getZCoord()); return mFakePlayer; } 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 9c05c58d..b98d9936 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 @@ -302,6 +302,7 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu protected FakePlayer getFakePlayer(IGregTechTileEntity aBaseTile) { if (mFakePlayer == null) mFakePlayer = GT_Utility.getFakePlayer(aBaseTile); + mFakePlayer.setWorld(aBaseTile.getWorld()); mFakePlayer.setPosition(aBaseTile.getXCoord(), aBaseTile.getYCoord(), aBaseTile.getZCoord()); return mFakePlayer; } From 540ddb3e09d47d14c620b2b49dd93c84d9db5c8a Mon Sep 17 00:00:00 2001 From: Dimach Date: Thu, 2 Nov 2017 17:27:30 +0200 Subject: [PATCH 10/10] Fixed bug - miners digs bedrock. --- .../tileentities/machines/basic/GT_MetaTileEntity_Miner.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 c59790d1..5c17d8c7 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 @@ -135,8 +135,8 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine { public boolean moveOneDown(IGregTechTileEntity aBaseMetaTileEntity) { 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)) { + || GT_Utility.getBlockHardnessAt(aBaseMetaTileEntity.getWorld(), aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord() + drillY - 1, aBaseMetaTileEntity.getZCoord()) < 0 + || !GT_Utility.setBlockByFakePlayer(getFakePlayer(aBaseMetaTileEntity), aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord() + drillY - 1, aBaseMetaTileEntity.getZCoord(), MINING_PIPE_TIP_BLOCK, 0, true)) { isPickingPipes = true; return false; }