From 8e0e51673f1148fdbbac13e03b4becaa1ac88ad5 Mon Sep 17 00:00:00 2001 From: Technus Date: Sun, 7 May 2017 22:21:44 +0200 Subject: [PATCH] another oil rewrite, even more BloodAsp like --- .../api/objects/GT_UO_DimensionList.java | 13 +++++---- .../gregtech/api/objects/GT_UO_Fluid.java | 27 +++++++++--------- .../gregtech/common/GT_UndergroundOil.java | 28 +++++++++++-------- ...T_MetaTileEntity_AdvSeismicProspector.java | 20 ++++++------- .../GT_MetaTileEntity_SeismicProspector.java | 3 +- 5 files changed, 49 insertions(+), 42 deletions(-) diff --git a/src/main/java/gregtech/api/objects/GT_UO_DimensionList.java b/src/main/java/gregtech/api/objects/GT_UO_DimensionList.java index 68ad9cfc..a6113687 100644 --- a/src/main/java/gregtech/api/objects/GT_UO_DimensionList.java +++ b/src/main/java/gregtech/api/objects/GT_UO_DimensionList.java @@ -2,6 +2,7 @@ package gregtech.api.objects; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; +import gregtech.api.util.GT_Log; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.config.ConfigCategory; import net.minecraftforge.common.config.Configuration; @@ -50,11 +51,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) { @@ -63,7 +64,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"); diff --git a/src/main/java/gregtech/api/objects/GT_UO_Fluid.java b/src/main/java/gregtech/api/objects/GT_UO_Fluid.java index 81d1387e..5675f73b 100644 --- a/src/main/java/gregtech/api/objects/GT_UO_Fluid.java +++ b/src/main/java/gregtech/api/objects/GT_UO_Fluid.java @@ -6,38 +6,40 @@ 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; public int MinAmount = 0; public int Chance = 0; - public int DecreasePerOperationAmountInBuckets = 5; + public int DecreasePerOperationAmount = 5; public GT_UO_Fluid(ConfigCategory aConfigCategory) {//TODO CONFIGURE 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)"; - DecreasePerOperationAmountInBuckets = aConfigCategory.get("DecreasePerOperationAmount").getInt(5); + 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); } @@ -50,11 +52,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 } - } \ No newline at end of file diff --git a/src/main/java/gregtech/common/GT_UndergroundOil.java b/src/main/java/gregtech/common/GT_UndergroundOil.java index c07729aa..83262716 100644 --- a/src/main/java/gregtech/common/GT_UndergroundOil.java +++ b/src/main/java/gregtech/common/GT_UndergroundOil.java @@ -18,8 +18,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); } @@ -39,7 +40,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); } @@ -72,17 +73,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 tFluids = new HashMap(); + HashMap 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 0) - tFluids.put(tPos, tFluid); + if (tFluids.containsKey(cInts)) { + if (tFluids.get(cInts).amount 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 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 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 55cfc389..de9b6569 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 @@ -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 = null;//<---GT_Utility.undergroundOil(getBaseMetaTileEntity().getWorld(), getBaseMetaTileEntity().getXCoord()>>4, getBaseMetaTileEntity().getZCoord()>>4,false,0);//TODO FIX + FluidStack tFluid = GT_UndergroundOil.undergroundOil(getBaseMetaTileEntity(),-1); String[] tStringArray = new String[tStringList.size()]; { for (int i = 0; i < tStringArray.length; i++) {