diff options
author | Antifluxfield <lyj_299792458@163.com> | 2017-09-21 20:33:23 +0800 |
---|---|---|
committer | Antifluxfield <lyj_299792458@163.com> | 2017-09-21 20:33:23 +0800 |
commit | 0802fdbd0272c4251c4615026643c8eadcf7fe70 (patch) | |
tree | 080e268e59482a95b6cff79a463bff536ec3baf3 /src/main/java/gregtech | |
parent | 73662e531f353013f67ec5de71db77475f33b3a2 (diff) | |
download | GT5-Unofficial-0802fdbd0272c4251c4615026643c8eadcf7fe70.tar.gz GT5-Unofficial-0802fdbd0272c4251c4615026643c8eadcf7fe70.tar.bz2 GT5-Unofficial-0802fdbd0272c4251c4615026643c8eadcf7fe70.zip |
Fix Oil Drill logic; rebalance EU cost
Diffstat (limited to 'src/main/java/gregtech')
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 29b37f6d00..2f88d4465e 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 7f1cfafb11..aa0bd0f1b1 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 a4311ee172..7d3b4678f0 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);
|