Merge pull request #1214 from GTNewHorizons/updateUO

Update UO
This commit is contained in:
Blood-Asp 2017-09-13 22:12:18 +02:00 committed by GitHub
commit 86e1ee61c8
5 changed files with 123 additions and 103 deletions

View file

@ -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

View file

@ -19,14 +19,23 @@ 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 undergroundOil(IGregTechTileEntity te, float drainSpeedCoefficient){
return undergroundOil(te.getWorld().getChunkFromBlockCoords(te.getXCoord(),te.getZCoord()),drainSpeedCoefficient);
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 readOrDrainCoefficient){
return undergroundOil(te.getWorld().getChunkFromBlockCoords(te.getXCoord(),te.getZCoord()),readOrDrainCoefficient);
}
//Returns whole content for information purposes -> when drainSpeedCoeff < 0
//Else returns extracted fluidStack if amount > 0, or null otherwise
public static FluidStack undergroundOil(Chunk chunk, float drainSpeedCoefficient) {
public static FluidStack undergroundOil(Chunk chunk, float readOrDrainCoefficient) {
if (GT_Mod.gregtechproxy.mUndergroundOil.CheckBlackList(chunk.worldObj.provider.dimensionId)) return null;
World aWorld = chunk.worldObj;
@ -42,11 +51,13 @@ public class GT_UndergroundOil {
if(tInts==null) tInts=getDefaultChunkDataOnCreation();//init if null
else if(tInts[GTOIL]==0){//FAST stop
//can return 0 amount stack for info :D
return drainSpeedCoefficient>=0 ? null : new FluidStack(FluidRegistry.getFluid(tInts[GTOILFLUID]),0);
return readOrDrainCoefficient>=0 ? null : new FluidStack(FluidRegistry.getFluid(tInts[GTOILFLUID]),0);
}
//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,24 +74,32 @@ 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();
}
//do stuff on it if needed
if(drainSpeedCoefficient>=0){
if(fluidInChunk.amount<DIVIDER){
if(readOrDrainCoefficient>=0){
int fluidExtracted=(int)Math.floor(fluidInChunk.amount * (double) readOrDrainCoefficient / DIVIDER);
double averageDecrease=uoFluid.DecreasePerOperationAmount * (double)readOrDrainCoefficient;
int decrease=(int)Math.ceil(averageDecrease);
if(fluidExtracted<=0 || fluidInChunk.amount<=decrease){//decrease - here it is max value of extraction for easy check
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
fluidInChunk.amount = fluidExtracted;//give appropriate amount
if(random.nextFloat()<(decrease-averageDecrease)) decrease--;//use random 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
tInts[GTOIL]-=decrease;//diminish amount, "randomly" adjusted to double value (averageDecrease)
}
}else{//just get info
if(fluidInChunk.amount<DIVIDER){
if(fluidInChunk.amount<=DIVIDER){
fluidInChunk.amount=0;//return informative stack
tInts[GTOIL]=0;//so in next access it will stop way above
}else{

View file

@ -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)

View file

@ -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++) {

View file

@ -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,6 +10,13 @@ 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;
@ -114,7 +115,7 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D
private boolean tryFillChunkList(){
FluidStack tFluid, tOil;
if (mOilId <= 0) {
tFluid = undergroundOil(getBaseMetaTileEntity(), -1);
tFluid = undergroundOilReadInformation(getBaseMetaTileEntity());
if (tFluid == null) return false;
mOilId = tFluid.getFluidID();
}
@ -128,7 +129,7 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D
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);
tFluid = undergroundOilReadInformation(tChunk);
if (tOil.isFluidEqual(tFluid))
mOilFieldChunks.add(tChunk);
}