From 275857085d3da2a1d1a73d18949e6785fccc21cd Mon Sep 17 00:00:00 2001 From: Technus Date: Wed, 13 Sep 2017 20:49:37 +0200 Subject: Add more uo methods for reading easily, make consumption scaleable Makes the code more A ok --- src/main/java/gregtech/api/util/GT_Utility.java | 4 ++-- .../java/gregtech/common/GT_UndergroundOil.java | 23 ++++++++++++++++------ .../GT_MetaTileEntity_AdvSeismicProspector.java | 2 +- .../basic/GT_MetaTileEntity_SeismicProspector.java | 2 +- .../multi/GT_MetaTileEntity_OilDrillBase.java | 17 ++++++++-------- 5 files changed, 30 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index e6bfacdf67..9f890ec412 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -71,7 +71,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!!! @@ -1770,7 +1770,7 @@ public class GT_Utility { } if (aPlayer.capabilities.isCreativeMode) { - FluidStack tFluid = undergroundOil(aWorld.getChunkFromBlockCoords(aX,aZ),-1);//-# to only read + FluidStack tFluid = undergroundOilReadInformation(aWorld.getChunkFromBlockCoords(aX,aZ));//-# to only read if (tFluid!=null) tList.add(EnumChatFormatting.GOLD+tFluid.getLocalizedName()+EnumChatFormatting.RESET+": " +EnumChatFormatting.YELLOW+ tFluid.amount +EnumChatFormatting.RESET+" L"); else diff --git a/src/main/java/gregtech/common/GT_UndergroundOil.java b/src/main/java/gregtech/common/GT_UndergroundOil.java index a4354a17b5..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,7 @@ public class GT_UndergroundOil { } //GEN IT TO GET OBJECT... - XSTR tRandom = new XSTR(aWorld.getSeed() + aWorld.provider.dimensionId * 2 + + 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); @@ -65,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(); @@ -74,15 +82,18 @@ public class GT_UndergroundOil { //do stuff on it if needed if(drainSpeedCoefficient>=0){ - if(fluidInChunk.amount