This commit is contained in:
Technus 2017-05-07 22:21:44 +02:00 committed by Blood-Asp
parent a99e0d4ffb
commit a4f0426159
5 changed files with 49 additions and 41 deletions

View file

@ -2,9 +2,9 @@ package gregtech.api.objects;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import gregtech.GT_Mod;
import gregtech.api.enums.GT_Values;
import gregtech.api.util.GT_Log;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.config.ConfigCategory;
import net.minecraftforge.common.config.Configuration;
@ -53,11 +53,11 @@ public class GT_UO_DimensionList {
public void SetDafultValues() {
SetConfigValues("Overworld", "0", "gas_natural_gas", "gas_natural_gas", 0, 625, 20, 7);
SetConfigValues("Overworld", "0", "liquid_light_oil", "liquid_light_oil", 0, 625, 20, 5);
SetConfigValues("Overworld", "0", "liquid_medium_oil", "liquid_medium_oil", 0, 625, 20, 3);
SetConfigValues("Overworld", "0", "liquid_heavy_oil", "liquid_heavy_oil", 0, 625, 20, 1);
SetConfigValues("Overworld", "0", "oil", "oil", 0, 625, 20, 3);
SetConfigValues("Moon", "Moon", "helium-3", "helium-3", 1, 375, 100, 1);
SetConfigValues("Overworld", "0", "liquid_light_oil", "liquid_light_oil", 0, 625, 20, 6);
SetConfigValues("Overworld", "0", "liquid_medium_oil", "liquid_medium_oil", 0, 625, 20, 5);
SetConfigValues("Overworld", "0", "liquid_heavy_oil", "liquid_heavy_oil", 0, 625, 20, 4);
SetConfigValues("Overworld", "0", "oil", "oil", 0, 625, 20, 5);
SetConfigValues("Moon", "Moon", "helium-3", "helium-3", 24, 128, 100, 1);
}
public void getConfig(Configuration aConfig, String aCategory) {
@ -66,7 +66,7 @@ public class GT_UO_DimensionList {
if (!fConfig.hasCategory(fCategory))
SetDafultValues();
fConfig.setCategoryComment(fCategory, "Config Undeground Fluids (Delete this Category for regenerate)");
fConfig.setCategoryComment(fCategory, "Config Underground Fluids (Delete this Category for regenerate)");
fConfig.setCategoryComment(fCategory+".Default", "Set Default Generating (Use this Category for Default settings)");
fConfig.setCategoryComment(fCategory+".Overworld", "Set Overworld Generating");
fConfig.setCategoryComment(fCategory+".Moon", "Set Moon Generating");

View file

@ -9,6 +9,10 @@ import net.minecraftforge.common.config.ConfigCategory;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import java.util.Random;
import static gregtech.common.GT_UndergroundOil.DIVIDER;
public class GT_UO_Fluid {
public String Registry = "null";
public int MaxAmount = 0;
@ -19,27 +23,27 @@ public class GT_UO_Fluid {
public GT_UO_Fluid(ConfigCategory aConfigCategory) {
if (aConfigCategory.containsKey("Registry"))
{
aConfigCategory.get("Registry").comment = "Fluid registry";
aConfigCategory.get("Registry").comment = "Fluid registry name";
Registry = aConfigCategory.get("Registry").getString();
}
if (aConfigCategory.containsKey("MaxAmount"))
{
aConfigCategory.get("MaxAmount").comment = "Max amount generation (per operation Amount)";
aConfigCategory.get("MaxAmount").comment = "Max amount generation (per operation, sets the VeinData) 80000 MAX";
MaxAmount = aConfigCategory.get("MaxAmount").getInt(0);
}
if (aConfigCategory.containsKey("MinAmount"))
{
aConfigCategory.get("MinAmount").comment = "Max amount generation (per operation Amount)";
aConfigCategory.get("MinAmount").comment = "Min amount generation (per operation, sets the VeinData) 0 MIN";
MinAmount = aConfigCategory.get("MinAmount").getInt(0);
}
if (aConfigCategory.containsKey("Chance"))
{
aConfigCategory.get("Chance").comment = "Chance generating";
aConfigCategory.get("Chance").comment = "Chance generating (weighted chance!, there will be a fluid in chunk always!)";
Chance = aConfigCategory.get("Chance").getInt(0);
}
if (aConfigCategory.containsKey("DecreasePerOperationAmount"))
{
aConfigCategory.get("DecreasePerOperationAmount").comment = "Decrease per operation Amount (X/5000L per operation)";
aConfigCategory.get("DecreasePerOperationAmount").comment = "Decrease per operation (actual fluid gained works like (Litre)VeinData/5000)";
DecreasePerOperationAmount = aConfigCategory.get("DecreasePerOperationAmount").getInt(5);
}
//System.out.println("GT UO "+aConfigCategory.getName()+" Fluid:"+Registry+" Max:"+MaxAmount+" Min:"+MinAmount+" Chance:"+Chance);
@ -53,11 +57,10 @@ public class GT_UO_Fluid {
}
}
public int getRandomAmount(Random aRandom){//generates milliBuckets
int r1 = (int)Math.round(Math.pow((MaxAmount-MinAmount)*500000.d, 0.2));
int r2 = (int)Math.floor(Math.pow(MinAmount*500000.d, 0.2));
double amount = aRandom.nextInt(r1)+r2+aRandom.nextDouble();
return (int) (Math.pow(amount, 5) / 100);
public int getRandomAmount(Random aRandom){//generates some random ass number that correlates to extraction speeds
int div = (int)Math.floor(Math.pow((MaxAmount-MinAmount)*100.d*DIVIDER, 0.2d));
int min = (int)Math.floor(Math.pow(MinAmount*100.d*DIVIDER, 0.2d));
double amount = min+aRandom.nextInt(div)+aRandom.nextDouble();
return (int) (Math.pow(amount, 5) / 100);//reverses the computation above
}
}

View file

@ -22,8 +22,9 @@ import static gregtech.common.GT_Proxy.*;
* Created by Tec on 29.04.2017.
*/
public class GT_UndergroundOil {
public static final short DIVIDER=5000;
public static FluidStack undergroundOil(IGregTechTileEntity te,float drainSpeedCoefficient){
public static FluidStack undergroundOil(IGregTechTileEntity te, float drainSpeedCoefficient){
return undergroundOil(te.getWorld().getChunkFromBlockCoords(te.getXCoord(),te.getZCoord()),drainSpeedCoefficient);
}
@ -43,7 +44,7 @@ public class GT_UndergroundOil {
int[] tInts = chunkData.get(chunk.getChunkCoordIntPair());
if(tInts==null) tInts=getDefaultChunkDataOnCreation();//init if null
else if(tInts[GTOIL]==0){
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);
}
@ -76,17 +77,20 @@ public class GT_UndergroundOil {
}
//do stuff on it if needed
if(drainSpeedCoefficient>=0) {
int actualExtractionSpeed=(int)(uoFluid.DecreasePerOperationAmountInBuckets*1000*drainSpeedCoefficient);
if(fluidInChunk.amount>actualExtractionSpeed) {
fluidInChunk.amount=actualExtractionSpeed;//give appropriate amount
tInts[GTOIL]-=actualExtractionSpeed;//diminish amount
}else if(fluidInChunk.amount>0) {
//fluidInChunk.amount= the same amount... going to return this
tInts[GTOIL]=0;
}else{
if(drainSpeedCoefficient>=0){
if(fluidInChunk.amount<DIVIDER){
fluidInChunk=null;
tInts[GTOIL]=0;//just to be on safe side...
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
}
}else{//just get info
if(fluidInChunk.amount<DIVIDER){
fluidInChunk.amount=0;//return informative stack
tInts[GTOIL]=0;//so in next access it will stop way above
}else{
fluidInChunk.amount=fluidInChunk.amount/DIVIDER;//give moderate extraction speed
}
}

View file

@ -32,6 +32,7 @@ import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.ChunkPosition;
import net.minecraftforge.fluids.FluidStack;
@ -142,25 +143,24 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba
int tLeftZBound = GT_Utility.getScaleCoordinates(this.getBaseMetaTileEntity().getZCoord() - radius, 16);
int tRightZBound = GT_Utility.getScaleCoordinates(this.getBaseMetaTileEntity().getZCoord() + radius, 16);
HashMap<ChunkPosition, FluidStack> tFluids = new HashMap<ChunkPosition, FluidStack>();
HashMap<ChunkCoordIntPair, FluidStack> tFluids = new HashMap<>();
try {
for (int x = tLeftXBound; x <= tRightXBound; ++x)
for (int z = tLeftZBound; z <= tRightZBound; ++z)
{
ChunkPosition tPos = new ChunkPosition(GT_Utility.getScaleCoordinates(x*16,96), 0, GT_Utility.getScaleCoordinates(z*16,96));
FluidStack tFluid = GT_UndergroundOil.undergroundOil(getBaseMetaTileEntity(),-1);
ChunkCoordIntPair cInts = getBaseMetaTileEntity().getWorld().getChunkFromChunkCoords(tPos.chunkPosX,tPos.chunkPosZ).getChunkCoordIntPair();
FluidStack tFluid = GT_UndergroundOil.undergroundOil(getBaseMetaTileEntity().getWorld().getChunkFromChunkCoords(tPos.chunkPosX,tPos.chunkPosZ),-1);
if (tFluid != null)
if (tFluids.containsKey(tPos))
{
if (tFluids.get(tPos).amount<tFluid.amount)
tFluids.get(tPos).amount = tFluid.amount;
} else if (tFluid.amount / 5000 > 0)
tFluids.put(tPos, tFluid);
if (tFluids.containsKey(cInts)) {
if (tFluids.get(cInts).amount<tFluid.amount)
tFluids.get(cInts).amount = tFluid.amount;
} else tFluids.put(cInts, tFluid);
}
for (HashMap.Entry<ChunkPosition, FluidStack> fl : tFluids.entrySet()) {
aOils.put(fl.getKey().chunkPosX + "," + fl.getKey().chunkPosZ + "," + (fl.getValue().amount / 5000) + "," + fl.getValue().getLocalizedName(), fl.getValue().amount / 5000);
for (Map.Entry<ChunkCoordIntPair, FluidStack> fl : tFluids.entrySet()) {
aOils.put(fl.getKey().chunkXPos + "," + fl.getKey().chunkZPos + "," + fl.getValue().amount + "," + fl.getValue().getLocalizedName(), fl.getValue().amount);
}
} catch (Exception e) {
// TODO: handle exception

View file

@ -12,6 +12,7 @@ import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.objects.ItemData;
import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Utility;
import gregtech.common.GT_UndergroundOil;
import gregtech.common.blocks.GT_Block_Ores_Abstract;
import gregtech.common.blocks.GT_TileEntity_Ores;
import ic2.core.Ic2Items;
@ -102,7 +103,7 @@ public class GT_MetaTileEntity_SeismicProspector extends GT_MetaTileEntity_Basic
}
}
if(tStringList.size()<1){tStringList.add("No Ores found.");}
FluidStack tFluid = GT_Utility.getUndergroundOil(getBaseMetaTileEntity().getWorld(), getBaseMetaTileEntity().getXCoord(), getBaseMetaTileEntity().getZCoord());
FluidStack tFluid = GT_UndergroundOil.undergroundOil(getBaseMetaTileEntity(),-1);
String[] tStringArray = new String[tStringList.size()];
{
for (int i = 0; i < tStringArray.length; i++) {