diff options
Diffstat (limited to 'src/main/java/gregtech/common/GT_UndergroundOil.java')
-rw-r--r-- | src/main/java/gregtech/common/GT_UndergroundOil.java | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/main/java/gregtech/common/GT_UndergroundOil.java b/src/main/java/gregtech/common/GT_UndergroundOil.java index 93fafcfa11..1f45b5fca9 100644 --- a/src/main/java/gregtech/common/GT_UndergroundOil.java +++ b/src/main/java/gregtech/common/GT_UndergroundOil.java @@ -2,6 +2,7 @@ package gregtech.common; import gregtech.GT_Mod; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.GT_UO_Dimension; import gregtech.api.objects.GT_UO_Fluid; import gregtech.api.objects.XSTR; import net.minecraft.world.ChunkCoordIntPair; @@ -12,6 +13,7 @@ import net.minecraftforge.fluids.FluidStack; import java.util.HashMap; +import static gregtech.api.objects.XSTR.XSTR_INSTANCE; import static gregtech.common.GT_Proxy.*; /** @@ -19,7 +21,6 @@ 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); @@ -33,17 +34,19 @@ public class GT_UndergroundOil { return undergroundOil(te.getWorld().getChunkFromBlockCoords(te.getXCoord(),te.getZCoord()),readOrDrainCoefficient); } - //Returns whole content for information purposes -> when drainSpeedCoeff < 0 + //Returns whole content for information purposes -> when drainSpeedCoefficient < 0 //Else returns extracted fluidStack if amount > 0, or null otherwise public static FluidStack undergroundOil(Chunk chunk, float readOrDrainCoefficient) { - if (GT_Mod.gregtechproxy.mUndergroundOil.CheckBlackList(chunk.worldObj.provider.dimensionId)) return null; World aWorld = chunk.worldObj; + int dimensionId=aWorld.provider.dimensionId; + GT_UO_Dimension dimension=GT_Mod.gregtechproxy.mUndergroundOil.GetDimension(dimensionId); + if(dimension==null) return null; //Read hash map - HashMap<ChunkCoordIntPair, int[]> chunkData = dimensionWiseChunkData.get(aWorld.provider.dimensionId); + HashMap<ChunkCoordIntPair, int[]> chunkData = dimensionWiseChunkData.get(dimensionId); if(chunkData==null){ chunkData=new HashMap<>(1024); - dimensionWiseChunkData.put(aWorld.provider.dimensionId,chunkData); + dimensionWiseChunkData.put(dimensionId,chunkData); } int[] tInts = chunkData.get(chunk.getChunkCoordIntPair()); @@ -55,17 +58,18 @@ public class GT_UndergroundOil { } //GEN IT TO GET OBJECT... - final 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))))); - GT_UO_Fluid uoFluid = GT_Mod.gregtechproxy.mUndergroundOil.GetDimension(aWorld.provider.dimensionId).getRandomFluid(tRandom); + final XSTR tRandom = new XSTR(aWorld.getSeed() + dimensionId * 2 + + (chunk.getChunkCoordIntPair().chunkXPos>>3) + + 8267 * (chunk.getChunkCoordIntPair().chunkZPos>>3)); + + GT_UO_Fluid uoFluid = dimension.getRandomFluid(tRandom); //Fluid stack holder FluidStack fluidInChunk; - //Set fluidstack from uoFluid + //Set fluid stack from uoFluid if (uoFluid == null || uoFluid.getFluid()==null){ - tInts[GTOILFLUID]=Integer.MAX_VALUE;//null fluid pointer... kindof + tInts[GTOILFLUID]=Integer.MAX_VALUE;//null fluid pointer... kind of tInts[GTOIL]=0; chunkData.put(chunk.getChunkCoordIntPair(),tInts);//update hash map return null; @@ -74,7 +78,7 @@ public class GT_UndergroundOil { fluidInChunk = new FluidStack(uoFluid.getFluid(),tInts[GTOIL]); }else{ fluidInChunk = new FluidStack(uoFluid.getFluid(), uoFluid.getRandomAmount(tRandom)); - fluidInChunk.amount=(int)((float)fluidInChunk.amount*(0.75f+(random.nextFloat()/2f)));//Randomly change amounts by +/- 25% + fluidInChunk.amount=(int)((float)fluidInChunk.amount*(0.75f+(XSTR_INSTANCE.nextFloat()/2f)));//Randomly change amounts by +/- 25% } tInts[GTOIL]=fluidInChunk.amount; tInts[GTOILFLUID]=fluidInChunk.getFluidID(); @@ -90,12 +94,12 @@ public class GT_UndergroundOil { tInts[GTOIL]=0;//so in next access it will stop way above }else{ fluidInChunk.amount = fluidExtracted;//give appropriate amount - if(random.nextFloat()<(decrease-averageDecrease)) decrease--;//use random to "subtract double from int" + if(XSTR_INSTANCE.nextFloat()<(decrease-averageDecrease)) decrease--;//use XSTR_INSTANCE to "subtract double from int" //ex. // averageDecrease=3.9 // decrease= ceil from 3.9 = 4 // decrease-averageDecrease=0.1 -> chance to subtract 1 - // if random is < chance then subtract 1 + // if XSTR_INSTANCE is < chance then subtract 1 tInts[GTOIL]-=decrease;//diminish amount, "randomly" adjusted to double value (averageDecrease) } }else{//just get info |