diff options
author | Technus <daniel112092@gmail.com> | 2017-09-13 20:49:37 +0200 |
---|---|---|
committer | Technus <daniel112092@gmail.com> | 2017-09-13 21:33:41 +0200 |
commit | 339494f8c342afb20e99714d17f847cebd2f37da (patch) | |
tree | 81ac6cd341d3e9a42aaa5f507a4d1afc0f77d6e3 /src/main | |
parent | 264236f98f199e50f5d1df00e27523f75c455050 (diff) | |
download | GT5-Unofficial-339494f8c342afb20e99714d17f847cebd2f37da.tar.gz GT5-Unofficial-339494f8c342afb20e99714d17f847cebd2f37da.tar.bz2 GT5-Unofficial-339494f8c342afb20e99714d17f847cebd2f37da.zip |
cherrypick
Diffstat (limited to 'src/main')
5 files changed, 112 insertions, 98 deletions
diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index d31a2529c2..fb89cbba8b 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -69,7 +69,7 @@ import java.util.Map.Entry; import static gregtech.api.enums.GT_Values.*; import static gregtech.common.GT_Proxy.GTPOLLUTION; -import static gregtech.common.GT_UndergroundOil.undergroundOil; +import static gregtech.common.GT_UndergroundOil.undergroundOilReadInformation; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! @@ -1802,7 +1802,7 @@ public class GT_Utility { } if (aPlayer.capabilities.isCreativeMode && GT_Values.D1) { - FluidStack tFluid = undergroundOil(aWorld.getChunkFromBlockCoords(aX,aZ),-1);//-# to only read + FluidStack tFluid = undergroundOilReadInformation(aWorld.getChunkFromBlockCoords(aX,aZ)); if (tFluid!=null) tList.add(EnumChatFormatting.GOLD+tFluid.getLocalizedName()+EnumChatFormatting.RESET+": " +EnumChatFormatting.YELLOW+ tFluid.amount +EnumChatFormatting.RESET+trans("200"," L")); else diff --git a/src/main/java/gregtech/common/GT_UndergroundOil.java b/src/main/java/gregtech/common/GT_UndergroundOil.java index 3e9ca2a3b3..05bb338d85 100644 --- a/src/main/java/gregtech/common/GT_UndergroundOil.java +++ b/src/main/java/gregtech/common/GT_UndergroundOil.java @@ -19,6 +19,15 @@ import static gregtech.common.GT_Proxy.*; */ public class GT_UndergroundOil { public static final short DIVIDER=5000; + private static final XSTR random=new XSTR(); + + public static FluidStack undergroundOilReadInformation(IGregTechTileEntity te){ + return undergroundOil(te.getWorld().getChunkFromBlockCoords(te.getXCoord(),te.getZCoord()),-1); + } + + public static FluidStack undergroundOilReadInformation(Chunk chunk) { + return undergroundOil(chunk,-1); + } public static FluidStack undergroundOil(IGregTechTileEntity te, float drainSpeedCoefficient){ return undergroundOil(te.getWorld().getChunkFromBlockCoords(te.getXCoord(),te.getZCoord()),drainSpeedCoefficient); @@ -46,7 +55,9 @@ public class GT_UndergroundOil { } //GEN IT TO GET OBJECT... - XSTR tRandom = new XSTR( (aWorld.getSeed() + aWorld.provider.dimensionId * 2 + ((int)Math.floor((double)chunk.getChunkCoordIntPair().chunkXPos/(double)6)) + (7 * ((int)Math.floor((double)chunk.getChunkCoordIntPair().chunkZPos/6))))); + final XSTR tRandom = new XSTR(aWorld.getSeed() + aWorld.provider.dimensionId * 2 + + (chunk.getChunkCoordIntPair().chunkXPos>>3) + + 8267 * (chunk.getChunkCoordIntPair().chunkZPos>>3)); GT_UO_Fluid uoFluid = GT_Mod.gregtechproxy.mUndergroundOil.GetDimension(aWorld.provider.dimensionId).getRandomFluid(tRandom); //Fluid stack holder @@ -63,8 +74,7 @@ public class GT_UndergroundOil { fluidInChunk = new FluidStack(uoFluid.getFluid(),tInts[GTOIL]); }else{ fluidInChunk = new FluidStack(uoFluid.getFluid(), uoFluid.getRandomAmount(tRandom)); - tRandom=new XSTR(); - fluidInChunk.amount=(int)((float)fluidInChunk.amount*(0.75f+(tRandom.nextFloat()/2f)));//Randomly change amounts by +/- 25% + fluidInChunk.amount=(int)((float)fluidInChunk.amount*(0.75f+(random.nextFloat()/2f)));//Randomly change amounts by +/- 25% } tInts[GTOIL]=fluidInChunk.amount; tInts[GTOILFLUID]=fluidInChunk.getFluidID(); @@ -72,15 +82,18 @@ public class GT_UndergroundOil { //do stuff on it if needed if(drainSpeedCoefficient>=0){ - if(fluidInChunk.amount<DIVIDER || fluidInChunk.amount<uoFluid.DecreasePerOperationAmount){ + if(fluidInChunk.amount<DIVIDER || fluidInChunk.amount<=(uoFluid.DecreasePerOperationAmount*(double)drainSpeedCoefficient)+1){ fluidInChunk=null; tInts[GTOIL]=0;//so in next access it will stop way above }else{ fluidInChunk.amount = (int)(fluidInChunk.amount*(double)drainSpeedCoefficient/DIVIDER);//give appropriate amount - tInts[GTOIL]-=uoFluid.DecreasePerOperationAmount;//diminish amount + double avrDecrease=uoFluid.DecreasePerOperationAmount * (double)drainSpeedCoefficient; + int decrease=(int)Math.floor(avrDecrease); + decrease+=random.nextFloat()<(avrDecrease-decrease)?1:0; + tInts[GTOIL]-=decrease;//diminish amount } }else{//just get info - if(fluidInChunk.amount<DIVIDER){ + if(fluidInChunk.amount<DIVIDER || fluidInChunk.amount<=(uoFluid.DecreasePerOperationAmount*(double)drainSpeedCoefficient)+1){ fluidInChunk.amount=0;//return informative stack tInts[GTOIL]=0;//so in next access it will stop way above }else{ diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_AdvSeismicProspector.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_AdvSeismicProspector.java index d0ba25a327..ab5f7bd625 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_AdvSeismicProspector.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_AdvSeismicProspector.java @@ -144,7 +144,7 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba { ChunkPosition tPos = new ChunkPosition(GT_Utility.getScaleCoordinates(x*16,96), 0, GT_Utility.getScaleCoordinates(z*16,96)); ChunkCoordIntPair cInts = getBaseMetaTileEntity().getWorld().getChunkFromChunkCoords(tPos.chunkPosX,tPos.chunkPosZ).getChunkCoordIntPair(); - FluidStack tFluid = GT_UndergroundOil.undergroundOil(getBaseMetaTileEntity().getWorld().getChunkFromChunkCoords(tPos.chunkPosX,tPos.chunkPosZ),-1); + FluidStack tFluid = GT_UndergroundOil.undergroundOilReadInformation(getBaseMetaTileEntity().getWorld().getChunkFromChunkCoords(tPos.chunkPosX,tPos.chunkPosZ)); if (tFluid != null) if (tFluids.containsKey(cInts)) { if (tFluids.get(cInts).amount<tFluid.amount) diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_SeismicProspector.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_SeismicProspector.java index 85defad0cb..946a03a49e 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_SeismicProspector.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_SeismicProspector.java @@ -103,7 +103,7 @@ public class GT_MetaTileEntity_SeismicProspector extends GT_MetaTileEntity_Basic } } if(tStringList.size()<1){tStringList.add("No Ores found.");} - FluidStack tFluid = GT_UndergroundOil.undergroundOil(getBaseMetaTileEntity(),-1); + FluidStack tFluid = GT_UndergroundOil.undergroundOilReadInformation(getBaseMetaTileEntity()); String[] tStringArray = new String[tStringList.size()]; { for (int i = 0; i < tStringArray.length; i++) { 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 1847851b4e..a4311ee172 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,11 +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 static gregtech.common.GT_UndergroundOil.undergroundOil;
-
-import java.util.ArrayList;
-
import gregtech.api.gui.GT_GUIContainer_MultiMachine;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.util.GT_Utility;
@@ -16,10 +10,17 @@ 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;
-
+
private ArrayList<Chunk> mOilFieldChunks = new ArrayList<Chunk>();
private int mOilId = 0;
@@ -33,18 +34,18 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D @Override
public void saveNBTData(NBTTagCompound aNBT) {
- super.saveNBTData(aNBT);
- aNBT.setInteger("mOilId", mOilId);
+ super.saveNBTData(aNBT);
+ aNBT.setInteger("mOilId", mOilId);
}
-
+
@Override
public void loadNBTData(NBTTagCompound aNBT) {
- super.loadNBTData(aNBT);
- mOilId = aNBT.getInteger("mOilId");
+ super.loadNBTData(aNBT);
+ mOilId = aNBT.getInteger("mOilId");
}
-
+
protected String[] getDescriptionInternal(String tierSuffix) {
- String casings = getCasingBlockItem().get(0).getDisplayName();
+ String casings = getCasingBlockItem().get(0).getDisplayName();
return new String[]{
"Controller Block for the Oil Drilling Rig " + (tierSuffix != null ? tierSuffix : ""),
"Size(WxHxD): 3x7x3", "Controller (Front middle at bottom)",
@@ -59,23 +60,23 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D }
- @Override
- public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
- return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "DrillingRig.png");
- }
+ @Override
+ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "DrillingRig.png");
+ }
- protected int getRangeInChunks(){
- return 0;
- }
-
- @Override
- protected boolean checkHatches() {
- return !mMaintenanceHatches.isEmpty() && !mOutputHatches.isEmpty() && !mEnergyHatches.isEmpty();
- }
+ protected int getRangeInChunks(){
+ return 0;
+ }
- @Override
- protected void setElectricityStats() {
- this.mEfficiency = getCurrentEfficiency(null);
+ @Override
+ protected boolean checkHatches() {
+ return !mMaintenanceHatches.isEmpty() && !mOutputHatches.isEmpty() && !mEnergyHatches.isEmpty();
+ }
+
+ @Override
+ protected void setElectricityStats() {
+ this.mEfficiency = getCurrentEfficiency(null);
this.mEfficiencyIncrease = 10000;
//T1 = 24; T2 = 96; T3 = 384
this.mEUt = 6 * (1 << (getMinTier() << 1));
@@ -91,62 +92,62 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D this.mEUt = -this.mEUt;
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()) {
- 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;
- }
- }
- isPickingPipes = true;
- return true;
- }
- return true;
- }
-
- private boolean tryFillChunkList(){
- FluidStack tFluid, tOil;
- if (mOilId <= 0) {
- tFluid = undergroundOil(getBaseMetaTileEntity(), -1);
- if (tFluid == null) return false;
- mOilId = tFluid.getFluidID();
- }
- tOil = new FluidStack(FluidRegistry.getFluid(mOilId), 0);
-
- 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;
- for (int i = 0; i < range; i++) {
- for (int j = 0; j < range; j++) {
- tChunk = getBaseMetaTileEntity().getWorld().getChunkFromChunkCoords(xChunk + i * xDir, zChunk + j * zDir);
- tFluid = undergroundOil(tChunk, -1);
- if (tOil.isFluidEqual(tFluid))
- mOilFieldChunks.add(tChunk);
- }
- }
- }
- if (mOilFieldChunks.isEmpty()) return false;
- return true;
- }
-
- private FluidStack pumpOil(float speed){
- if (mOilId <= 0) return null;
- FluidStack tFluid, tOil;
- tOil = new FluidStack(FluidRegistry.getFluid(mOilId), 0);
- for (Chunk tChunk : mOilFieldChunks) {
- tFluid = undergroundOil(getBaseMetaTileEntity(),speed);
- if (tFluid == null) mOilFieldChunks.remove(tChunk);
- if (tOil.isFluidEqual(tFluid)) tOil.amount += tFluid.amount;
- }
- return tOil.amount == 0 ? null : tOil;
- }
-}
+ }
+
+ @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()) {
+ 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;
+ }
+ }
+ isPickingPipes = true;
+ return true;
+ }
+ return true;
+ }
+
+ private boolean tryFillChunkList(){
+ FluidStack tFluid, tOil;
+ if (mOilId <= 0) {
+ tFluid = undergroundOilReadInformation(getBaseMetaTileEntity());
+ if (tFluid == null) return false;
+ mOilId = tFluid.getFluidID();
+ }
+ tOil = new FluidStack(FluidRegistry.getFluid(mOilId), 0);
+
+ 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;
+ for (int i = 0; i < range; i++) {
+ for (int j = 0; j < range; j++) {
+ tChunk = getBaseMetaTileEntity().getWorld().getChunkFromChunkCoords(xChunk + i * xDir, zChunk + j * zDir);
+ tFluid = undergroundOilReadInformation(tChunk);
+ if (tOil.isFluidEqual(tFluid))
+ mOilFieldChunks.add(tChunk);
+ }
+ }
+ }
+ if (mOilFieldChunks.isEmpty()) return false;
+ return true;
+ }
+
+ private FluidStack pumpOil(float speed){
+ if (mOilId <= 0) return null;
+ FluidStack tFluid, tOil;
+ tOil = new FluidStack(FluidRegistry.getFluid(mOilId), 0);
+ for (Chunk tChunk : mOilFieldChunks) {
+ tFluid = undergroundOil(getBaseMetaTileEntity(),speed);
+ if (tFluid == null) mOilFieldChunks.remove(tChunk);
+ if (tOil.isFluidEqual(tFluid)) tOil.amount += tFluid.amount;
+ }
+ return tOil.amount == 0 ? null : tOil;
+ }
+}
\ No newline at end of file |