aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/tileentities/machines/multi
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/common/tileentities/machines/multi')
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java5
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java25
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java18
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java18
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java5
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java101
6 files changed, 104 insertions, 68 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 68770644de..fdb61e1945 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
@@ -4,6 +4,7 @@ import gregtech.api.GregTech_API;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Materials;
import gregtech.api.enums.Textures;
+import gregtech.api.interfaces.IChunkLoader;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
@@ -29,7 +30,7 @@ import java.util.ArrayList;
import static gregtech.api.enums.GT_Values.W;
-public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_MultiBlockBase {
+public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_MultiBlockBase implements IChunkLoader {
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);
@@ -466,4 +467,6 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu
}
return false;
}
+ @Override
+ public ChunkCoordIntPair getActiveChunk(){return mCurrentChunk;}
}
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java
index e80f3dfb39..2d8ae1f144 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java
@@ -18,16 +18,20 @@ import gregtech.api.util.GT_Utility;
import net.minecraft.block.Block;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.input.Keyboard;
import java.util.ArrayList;
+import static gregtech.api.enums.GT_Values.STEAM_PER_WATER;
+
public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_MultiBlockBase {
private boolean firstRun = true;
private int mSuperEfficencyIncrease = 0;
private int integratedCircuitConfig = 0; //Steam output is reduced by 1000L per config
+ private int excessWater = 0; //Eliminate rounding errors for water
private int excessFuel = 0; //Eliminate rounding errors for fuels that burn half items
private int excessProjectedEU = 0; //Eliminate rounding errors from throttling the boiler
@@ -185,7 +189,10 @@ public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_Mu
mEfficiency = Math.max(0, Math.min(mEfficiency + mSuperEfficencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000)));
int tGeneratedEU = (int) (this.mEUt * 2L * this.mEfficiency / 10000L);
if (tGeneratedEU > 0) {
- long amount = (tGeneratedEU + 160) / 160;
+ long amount = (tGeneratedEU + STEAM_PER_WATER) / STEAM_PER_WATER;
+ excessWater += amount * STEAM_PER_WATER - tGeneratedEU;
+ amount -= excessWater / STEAM_PER_WATER;
+ excessWater %= STEAM_PER_WATER;
if (depleteInput(Materials.Water.getFluid(amount)) || depleteInput(GT_ModHandler.getDistilledWater(amount))) {
addOutput(GT_ModHandler.getSteam(tGeneratedEU));
} else {
@@ -199,6 +206,22 @@ public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_Mu
}
@Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ super.saveNBTData(aNBT);
+ aNBT.setInteger("excessFuel", excessFuel);
+ aNBT.setInteger("excessWater", excessWater);
+ aNBT.setInteger("excessProjectedEU", excessProjectedEU);
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ super.loadNBTData(aNBT);
+ excessFuel = aNBT.getInteger("excessFuel");
+ excessWater = aNBT.getInteger("excessWater");
+ excessProjectedEU = aNBT.getInteger("excessProjectedEU");
+ }
+
+ @Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
if (mProgresstime > 0 && firstRun) {
firstRun = false;
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java
index 306dfe734d..baa63a3e84 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java
@@ -19,11 +19,12 @@ import org.lwjgl.input.Keyboard;
import java.util.ArrayList;
+import static gregtech.api.enums.GT_Values.STEAM_PER_WATER;
import static gregtech.api.objects.XSTR.XSTR_INSTANCE;
public class GT_MetaTileEntity_LargeTurbine_Steam extends GT_MetaTileEntity_LargeTurbine {
- private float water;
+ private int excessWater;
private boolean achievement = false;
private boolean looseFit=false;
@@ -90,11 +91,11 @@ public class GT_MetaTileEntity_LargeTurbine_Steam extends GT_MetaTileEntity_Larg
return 0;
}
- private int useWater(float input) {
- water = water + input;
- int usage = (int) water;
- water = water - usage;
- return usage;
+ private int condenseSteam(int steam) {
+ excessWater += steam;
+ int water = excessWater / STEAM_PER_WATER;
+ excessWater %= STEAM_PER_WATER;
+ return water;
}
@Override
@@ -127,7 +128,7 @@ public class GT_MetaTileEntity_LargeTurbine_Steam extends GT_MetaTileEntity_Larg
remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches
totalFlow += flow; // track total input used
if (!achievement) {
- GT_Mod.instance.achievements.issueAchievement(this.getBaseMetaTileEntity().getWorld().getPlayerEntityByName(this.getBaseMetaTileEntity().getOwnerName()), "muchsteam");
+ GT_Mod.achievements.issueAchievement(this.getBaseMetaTileEntity().getWorld().getPlayerEntityByName(this.getBaseMetaTileEntity().getOwnerName()), "muchsteam");
achievement = true;
}
}else if(GT_ModHandler.isSuperHeatedSteam(aFluidStack)) {
@@ -136,11 +137,10 @@ public class GT_MetaTileEntity_LargeTurbine_Steam extends GT_MetaTileEntity_Larg
}
if(totalFlow<=0)return 0;
tEU = totalFlow;
- int waterToOutput = useWater(totalFlow / 160.0f);
+ int waterToOutput = condenseSteam(totalFlow);
addOutput(GT_ModHandler.getDistilledWater(waterToOutput));
if (totalFlow != aOptFlow) {
float efficiency = 1.0f - Math.abs((totalFlow - aOptFlow) / (float)aOptFlow);
- //if(totalFlow>aOptFlow){efficiency = 1.0f;}
tEU *= efficiency;
tEU = Math.max(1, GT_Utility.safeInt((long)tEU * (long)aBaseEff / 20000L));
} else {
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 a7a7023d34..3c19be674a 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
@@ -2,6 +2,7 @@ package gregtech.common.tileentities.machines.multi;
import gregtech.api.gui.GT_GUIContainer_MultiMachine;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.objects.GT_ChunkManager;
import gregtech.api.util.GT_Log;
import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
import gregtech.api.util.GT_Utility;
@@ -9,8 +10,10 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
+import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
@@ -25,10 +28,7 @@ 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;
-
- private ArrayList<Chunk> mOilFieldChunks = new ArrayList<Chunk>();
+ private final ArrayList<Chunk> mOilFieldChunks = new ArrayList<>();
private int mOilId = 0;
private int chunkRangeConfig = getRangeInChunks();
@@ -95,6 +95,7 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D
@Override
public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ);
+ int oldChunkRange = chunkRangeConfig;
if (aPlayer.isSneaking()) {
if (chunkRangeConfig > 0) {
chunkRangeConfig--;
@@ -108,6 +109,7 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D
if (chunkRangeConfig > getRangeInChunks())
chunkRangeConfig = 1;
}
+ if (oldChunkRange != chunkRangeConfig) mOilFieldChunks.clear();
GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("GT5U.machines.workareaset") + " " + chunkRangeConfig + "x" + chunkRangeConfig + StatCollector.translateToLocal("GT5U.machines.chunks"));//TODO Add translation support
}
@@ -137,6 +139,11 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D
}
if (reachingVoidOrBedrock() && tryFillChunkList()) {
+ if (mWorkChunkNeedsReload) {
+ mCurrentChunk = new ChunkCoordIntPair(xDrill >> 4, zDrill >> 4);
+ GT_ChunkManager.requestChunkLoad((TileEntity) getBaseMetaTileEntity(), null);
+ mWorkChunkNeedsReload = false;
+ }
float speed = .5F+(GT_Utility.getTier(getMaxInputVoltage()) - getMinTier()) *.25F;
FluidStack tFluid = pumpOil(speed);
if (tFluid != null && tFluid.amount > getTotalConfigValue()){
@@ -144,6 +151,7 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D
return true;
}
}
+ GT_ChunkManager.releaseTicket((TileEntity)getBaseMetaTileEntity());
workState = STATE_UPWARD;
return true;
}
@@ -220,7 +228,7 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D
);
}
- ArrayList<Chunk> emptyChunks = new ArrayList<Chunk>();
+ ArrayList<Chunk> emptyChunks = new ArrayList<>();
for (Chunk tChunk : mOilFieldChunks) {
tFluid = undergroundOil(tChunk,speed);
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 e34ed7466f..ea894fc725 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
@@ -37,7 +37,7 @@ import org.lwjgl.input.Keyboard;
import static gregtech.api.enums.GT_Values.VN;
-public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTileEntity_DrillerBase implements IChunkLoader {
+public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTileEntity_DrillerBase {
private final ArrayList<ChunkPosition> oreBlockPositions = new ArrayList<>();
protected int mTier = 1;
private int chunkRadiusConfig = getRadiusInChunks();
@@ -64,9 +64,6 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
}
@Override
- public ChunkCoordIntPair getActiveChunk(){return mCurrentChunk;}
-
- @Override
public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "OreDrillingPlant.png");
}
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java
index 1fdc698fe4..d86e8cf7f8 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ProcessingArray.java
@@ -139,6 +139,7 @@ public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_MultiBl
}
private String mMachine = "";
+
public boolean checkRecipe(ItemStack aStack) {
if (!isCorrectMachinePart(mInventory[1])) {
return false;
@@ -146,62 +147,66 @@ public class GT_MetaTileEntity_ProcessingArray extends GT_MetaTileEntity_MultiBl
GT_Recipe.GT_Recipe_Map map = getRecipeMap();
if (map == null) return false;
- if (mInventory[1].getUnlocalizedName().endsWith("10")) {
- tTier = 9;
- mMult = 2;//u need 4x less machines and they will use 4x less power
- } else if (mInventory[1].getUnlocalizedName().endsWith("11")) {
- tTier = 9;
- mMult = 4;//u need 16x less machines and they will use 16x less power
- } else if (mInventory[1].getUnlocalizedName().endsWith("12") ||
- mInventory[1].getUnlocalizedName().endsWith("13") ||
- mInventory[1].getUnlocalizedName().endsWith("14") ||
- mInventory[1].getUnlocalizedName().endsWith("15")) {
- tTier = 9;
- mMult = 6;//u need 64x less machines and they will use 64x less power
- } else if (mInventory[1].getUnlocalizedName().endsWith("1")) {
- tTier = 1;
- mMult = 0;//*1
- } else if (mInventory[1].getUnlocalizedName().endsWith("2")) {
- tTier = 2;
- mMult = 0;//*1
- } else if (mInventory[1].getUnlocalizedName().endsWith("3")) {
- tTier = 3;
- mMult = 0;//*1
- } else if (mInventory[1].getUnlocalizedName().endsWith("4")) {
- tTier = 4;
- mMult = 0;//*1
- } else if (mInventory[1].getUnlocalizedName().endsWith("5")) {
- tTier = 5;
- mMult = 0;//*1
- } else if (mInventory[1].getUnlocalizedName().endsWith("6")) {
- tTier = 6;
- mMult = 0;//*1
- } else if (mInventory[1].getUnlocalizedName().endsWith("7")) {
- tTier = 7;
- mMult = 0;//*1
- } else if (mInventory[1].getUnlocalizedName().endsWith("8")) {
- tTier = 8;
- mMult = 0;//*1
- } else if (mInventory[1].getUnlocalizedName().endsWith("9")) {
- tTier = 9;
- mMult = 0;//*1
- } else {
- tTier = 0;
- mMult = 0;//*1
+ if (!mMachine.equals(mInventory[1].getUnlocalizedName())) {
+ mLastRecipe = null;
+ mMachine = mInventory[1].getUnlocalizedName();
}
- if (!mMachine.equals(mInventory[1].getUnlocalizedName())) mLastRecipe = null;
- mMachine = mInventory[1].getUnlocalizedName();
+ int machineTier = 0;
+
+ if (mLastRecipe == null) {
+ try {
+ int length = mMachine.length();
+
+ machineTier = Integer.parseInt(mMachine.substring(length - 2));
+
+ } catch (NumberFormatException e) {
+ }
+
+ switch (machineTier) {
+ default:
+ tTier = 0;
+ mMult = 0;//*1
+ break;
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ tTier = machineTier;
+ mMult = 0;//*1
+ break;
+ case 10:
+ tTier = 9;
+ mMult = 2;//u need 4x less machines and they will use 4x less power
+ break;
+ case 11:
+ tTier = 9;
+ mMult = 4;//u need 16x less machines and they will use 16x less power
+ break;
+ case 12:
+ case 13:
+ case 14:
+ case 15:
+ tTier = 9;
+ mMult = 6;//u need 64x less machines and they will use 64x less power
+ break;
+ }
+ }
ArrayList<FluidStack> tFluidList = getStoredFluids();
FluidStack[] tFluids = (FluidStack[]) tFluidList.toArray(new FluidStack[tFluidList.size()]);
if (mSeparate) {
ArrayList<ItemStack> tInputList = new ArrayList<ItemStack>();
for (GT_MetaTileEntity_Hatch_InputBus tHatch : mInputBusses) {
- IGregTechTileEntity tInpuBus = tHatch.getBaseMetaTileEntity();
- for (int i = tInpuBus.getSizeInventory() - 1; i >= 0; i--) {
- if (tInpuBus.getStackInSlot(i) != null)
- tInputList.add(tInpuBus.getStackInSlot(i));
+ IGregTechTileEntity tInputBus = tHatch.getBaseMetaTileEntity();
+ for (int i = tInputBus.getSizeInventory() - 1; i >= 0; i--) {
+ if (tInputBus.getStackInSlot(i) != null)
+ tInputList.add(tInputBus.getStackInSlot(i));
}
ItemStack[] tInputs = (ItemStack[]) tInputList.toArray(new ItemStack[tInputList.size()]);
if (processRecipe(tInputs, tFluids, map))