Fix name config category to UndergroundFluid

Fix comments configuration
Fix Start config - add nether and end to BlackList. Default spawn fluids on overworld and Moon.
Add Decrease Per Operation Amount (if 0 an endless source)
This commit is contained in:
Maxime Legkiy 2017-02-17 01:55:54 +03:00
parent 901a7d66c1
commit 8e2280bc2c
8 changed files with 93 additions and 90 deletions

View file

@ -46,13 +46,13 @@ import net.minecraft.util.WeightedRandomChestContent;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.ChestGenHooks;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
import org.apache.commons.lang3.StringUtils;
import java.io.*;
import java.util.*;
import java.util.regex.Matcher;
@ -253,7 +253,7 @@ public class GT_Mod implements IGT_Mod {
gregtechproxy.mPollutionSourRainLimit = tMainConfig.get("Pollution", "SourRainLimit", 2000000).getInt(2000000);
gregtechproxy.mExplosionItemDrop = tMainConfig.get("general", "ExplosionItemDrops", false).getBoolean(false);
gregtechproxy.mAddGTRecipesToIC2Machines = tMainConfig.get("general", "AddGTRecipesToIC2Machines", true).getBoolean(true);
gregtechproxy.mUndergroundOil.getConfig(tMainConfig, "undergroundoil");
gregtechproxy.mUndergroundOil.getConfig(tMainConfig, "undergroundfluid");
GregTech_API.mOutputRF = GregTech_API.sOPStuff.get(ConfigCategories.general, "OutputRF", true);
GregTech_API.mInputRF = GregTech_API.sOPStuff.get(ConfigCategories.general, "InputRF", false);
@ -803,7 +803,6 @@ public class GT_Mod implements IGT_Mod {
}
}
achievements = new GT_Achievements();
GT_Log.out.println("GT_Mod: Loading finished, deallocating temporary Init Variables.");
GregTech_API.sBeforeGTPreload = null;
GregTech_API.sAfterGTPreload = null;
@ -956,7 +955,6 @@ public class GT_Mod implements IGT_Mod {
GT_OreDictUnificator.setStack(tOutput);
}
}
GregTech_API.mServerStarted = true;
GT_Log.out.println("GT_Mod: ServerStarting-Phase finished!");
GT_Log.ore.println("GT_Mod: ServerStarting-Phase finished!");

View file

@ -16,11 +16,15 @@ public class GT_UO_Dimension {
private BiMap<String, GT_UO_Fluid> fFluids;
private int maxChance;
public String Dimension;
public String Dimension = "null";
public GT_UO_Dimension(ConfigCategory aConfigCategory) {
fFluids = HashBiMap.create();
Dimension = aConfigCategory.get("Dimension").getString();
if (aConfigCategory.containsKey("Dimension"))
{
aConfigCategory.get("Dimension").comment = "Dimension ID or Class Name";
Dimension = aConfigCategory.get("Dimension").getString();
}
maxChance = 0;
//System.out.println("GT UO "+aConfigCategory.getName()+" Dimension:"+Dimension);
for (int i = 0 ; i < aConfigCategory.getChildren().size(); i++) {

View file

@ -39,37 +39,24 @@ public class GT_UO_DimensionList {
}
}
public void SetConfigValues(String aDimensionName, String aDimension, String aName, String aRegistry, int aMinAmount, int aMaxAmount, int aChance) {
public void SetConfigValues(String aDimensionName, String aDimension, String aName, String aRegistry, int aMinAmount, int aMaxAmount, int aChance, int aDecreasePerOperationAmount) {
String Category = fCategory+"."+aDimensionName;
fConfig.get(Category, "Dimension", aDimension, "Dimension ID or Class Name").getString();
fConfig.get(Category, "Dimension", aDimension).getString();
Category+="."+aName;
fConfig.get(Category, "Registry", aRegistry, "Fluid registry").getString();
fConfig.get(Category, "MinAmount", aMinAmount, "Min amount (Amount in step)").getInt(aMinAmount);
fConfig.get(Category, "MaxAmount", aMaxAmount, "Max amount (Amount in step)").getInt(aMaxAmount);
fConfig.get(Category, "Chance", aChance, "Chance generating").getInt(aChance);
fConfig.get(Category, "Registry", aRegistry).getString();
fConfig.get(Category, "MinAmount", aMinAmount).getInt(aMinAmount);
fConfig.get(Category, "MaxAmount", aMaxAmount).getInt(aMaxAmount);
fConfig.get(Category, "Chance", aChance).getInt(aChance);
fConfig.get(Category, "DecreasePerOperationAmount", aDecreasePerOperationAmount).getInt(aDecreasePerOperationAmount);
}
public void SetDafultValues() {
fConfig.setCategoryComment(fCategory+".Default", "Set Default Generating");
SetConfigValues("Default", "Default", "gas_natural_gas", "gas_natural_gas", 0, 625, 20);
SetConfigValues("Default", "Default", "liquid_light_oil", "liquid_light_oil", 0, 625, 20);
SetConfigValues("Default", "Default", "liquid_medium_oil", "liquid_medium_oil", 0, 625, 20);
SetConfigValues("Default", "Default", "liquid_heavy_oil", "liquid_heavy_oil", 0, 625, 20);
SetConfigValues("Default", "Default", "oil", "oil", 0, 625, 20);
fConfig.setCategoryComment(fCategory+".Overworld", "Set Overworld Generating");
SetConfigValues("Overworld", "0", "gas_natural_gas", "gas_natural_gas", 0, 625, 20);
SetConfigValues("Overworld", "0", "liquid_light_oil", "liquid_light_oil", 0, 625, 20);
SetConfigValues("Overworld", "0", "liquid_medium_oil", "liquid_medium_oil", 0, 625, 20);
SetConfigValues("Overworld", "0", "liquid_heavy_oil", "liquid_heavy_oil", 0, 625, 20);
SetConfigValues("Overworld", "0", "oil", "oil", 0, 625, 20);
fConfig.setCategoryComment(fCategory+".Nether", "Set Nether Generating");
SetConfigValues("Nether", "-1", "ic2pahoehoelava", "ic2pahoehoelava", 0, 250, 100);
fConfig.setCategoryComment(fCategory+".Moon", "Set Moon Generating");
SetConfigValues("Moon", "Moon", "molten-cheese", "molten.cheese", 0, 125, 5);
SetConfigValues("Moon", "Moon", "helium-3", "helium-3", 0, 375, 95);
SetConfigValues("Overworld", "0", "gas_natural_gas", "gas_natural_gas", 0, 625, 20, 5);
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, 5);
SetConfigValues("Overworld", "0", "liquid_heavy_oil", "liquid_heavy_oil", 0, 625, 20, 5);
SetConfigValues("Overworld", "0", "oil", "oil", 0, 625, 20, 5);
SetConfigValues("Moon", "Moon", "helium-3", "helium-3", 0, 375, 100, 5);
}
public void getConfig(Configuration aConfig, String aCategory) {
@ -79,7 +66,11 @@ public class GT_UO_DimensionList {
SetDafultValues();
fConfig.setCategoryComment(fCategory, "Config Undeground Fluids (Delete this Category for regenerate)");
int[] BlackList = {1};
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");
int[] BlackList = {-1,1};
BlackList = aConfig.get(fCategory, "DimBlackList", BlackList, "Dimension IDs Black List").getIntList();
java.util.Arrays.sort(BlackList);

View file

@ -10,16 +10,38 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
public class GT_UO_Fluid {
public String Registry;
public int MaxAmount;
public int MinAmount;
public int Chance;
public String Registry = "null";
public int MaxAmount = 0;
public int MinAmount = 0;
public int Chance = 0;
public int DecreasePerOperationAmount = 5;
public GT_UO_Fluid(ConfigCategory aConfigCategory) {
Registry = aConfigCategory.get("Registry").getString();;
MaxAmount = aConfigCategory.get("MaxAmount").getInt();
MinAmount = aConfigCategory.get("MinAmount").getInt();
Chance = aConfigCategory.get("Chance").getInt();
public GT_UO_Fluid(ConfigCategory aConfigCategory) {
if (aConfigCategory.containsKey("Registry"))
{
aConfigCategory.get("Registry").comment = "Fluid registry";
Registry = aConfigCategory.get("Registry").getString();
}
if (aConfigCategory.containsKey("MaxAmount"))
{
aConfigCategory.get("MaxAmount").comment = "Max amount generation (per operation Amount)";
MaxAmount = aConfigCategory.get("MaxAmount").getInt(0);
}
if (aConfigCategory.containsKey("MinAmount"))
{
aConfigCategory.get("MinAmount").comment = "Max amount generation (per operation Amount)";
MinAmount = aConfigCategory.get("MinAmount").getInt(0);
}
if (aConfigCategory.containsKey("Chance"))
{
aConfigCategory.get("Chance").comment = "Chance generating";
Chance = aConfigCategory.get("Chance").getInt(0);
}
if (aConfigCategory.containsKey("DecreasePerOperationAmount"))
{
aConfigCategory.get("DecreasePerOperationAmount").comment = "Decrease per operation Amount (X/5000L per operation)";
DecreasePerOperationAmount = aConfigCategory.get("DecreasePerOperationAmount").getInt(5);
}
//System.out.println("GT UO "+aConfigCategory.getName()+" Fluid:"+Registry+" Max:"+MaxAmount+" Min:"+MinAmount+" Chance:"+Chance);
}

View file

@ -1524,19 +1524,6 @@ public class GT_Utility {
return (int)Math.floor(aValue / aScale);
}
public static int getUndergroundOilType(int aType, int aOil) {
switch (aType) {
case 1:
aOil = 10;
break;
case 2:
aOil = 11;
break;
}
return aOil;
}
public static FluidStack getUndergroundOil(World aWorld, int aX, int aZ) {
return getUndergroundOil(aWorld, aX, aZ, false);
}
@ -1549,6 +1536,7 @@ public class GT_Utility {
Random tRandom = new Random((aWorld.getSeed() + aWorld.provider.dimensionId * 2 + (getScaleСoordinates(aX,96)) + (7 * (getScaleСoordinates(aZ,96)))));
int tAmount = 0;
int tFluidId = 0;
int tDecreasePerOperationAmount = 5;
Fluid tFluid = null;
// System.out.println("Dimension: "+GT_Mod.gregtechproxy.mUndergroundOil.GetDimension(aWorld.provider.dimensionId).Dimension);
try {
@ -1557,6 +1545,7 @@ public class GT_Utility {
{
tFluid = uoFluid.getFluid();
tAmount = uoFluid.getRandomAmount(tRandom);
tDecreasePerOperationAmount = uoFluid.DecreasePerOperationAmount;
if (tFluid != null)
tFluidId = tFluid.getID();
//System.out.println("Fluid: ("+tFluidId+")"+tFluid.getName()+" Amount:"+tAmount);
@ -1567,7 +1556,7 @@ public class GT_Utility {
tFluidId = 0;
}
ChunkPosition tPos = new ChunkPosition(getScaleСoordinates(aX,16), aWorld.provider.dimensionId+1, getScaleСoordinates(aZ,16));
ChunkPosition tPos = new ChunkPosition(getScaleСoordinates(aX,16), aWorld.provider.dimensionId, getScaleСoordinates(aZ,16));
int[] tInts = new int[0];
if(GT_Proxy.chunkData.containsKey(tPos)){
tInts = GT_Proxy.chunkData.get(tPos);
@ -1585,7 +1574,7 @@ public class GT_Utility {
}
if (needConsumeOil && tAmount >= 5000)
tAmount = tAmount - 5;
tAmount = tAmount - tDecreasePerOperationAmount;
tInts[0] = tAmount;
tInts[2] = tFluidId;
@ -1789,7 +1778,7 @@ public class GT_Utility {
tList.add("Oil in Chunk: " + tFluid.amount + " " + tFluid.getLocalizedName());
}
// if(aPlayer.capabilities.isCreativeMode){
ChunkPosition tPos = new ChunkPosition(getScaleСoordinates(aX,16), aWorld.provider.dimensionId+1, getScaleСoordinates(aZ,16));
ChunkPosition tPos = new ChunkPosition(getScaleСoordinates(aX,16), aWorld.provider.dimensionId, getScaleСoordinates(aZ,16));
if(GT_Proxy.chunkData.containsKey(tPos)){
int[] tPollution = GT_Proxy.chunkData.get(tPos);
if(tPollution.length>1){
@ -2056,6 +2045,7 @@ public class GT_Utility {
setBookTitle(aStack, "Raw Prospection Data");
NBTTagCompound tNBT = GT_Utility.ItemNBT.getNBT(aStack);
tNBT.setByte("prospection_tier", aTier);
tNBT.setString("prospection_pos", "X: " + aX + " Y: " + aY + " Z: " + aZ + " Dim: " + aDim);

View file

@ -9,7 +9,6 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.ChunkPosition;
import net.minecraft.world.World;
@ -189,16 +188,11 @@ public class GT_Pollution {
}
}
//Backward compatibility (NOT USE)
public static void addPollution(ChunkPosition aPos, int aPollution){
addPollution(MinecraftServer.getServer().worldServerForDimension(0), aPos, aPollution);
}
//Add aWorld to Save Pollution
public static void addPollution(World aWorld, ChunkPosition aPos, int aPollution){
if(!GT_Mod.gregtechproxy.mPollution)return;
try{
ChunkPosition tPos = new ChunkPosition(GT_Utility.getScaleСoordinates(aPos.chunkPosX,16), aWorld.provider.dimensionId + 1, GT_Utility.getScaleСoordinates(aPos.chunkPosZ,16)); // OLD in coordinate -1 -1 chunk 0 0
ChunkPosition tPos = new ChunkPosition(GT_Utility.getScaleСoordinates(aPos.chunkPosX,16), aWorld.provider.dimensionId, GT_Utility.getScaleСoordinates(aPos.chunkPosZ,16)); // OLD in coordinate -1 -1 chunk 0 0
// System.out.println("add pollution dim: "+aWorld.provider.dimensionId+" x: "+ tPos.chunkPosX +" z: " + tPos.chunkPosZ +" poll: "+aPollution);
int[] tData = new int[2];
if(GT_Proxy.chunkData.containsKey(tPos)){

View file

@ -1701,7 +1701,7 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler {
@SubscribeEvent
public void handleChunkSaveEvent(ChunkDataEvent.Save event)
{
ChunkPosition tPos = new ChunkPosition(event.getChunk().xPosition,event.getChunk().worldObj.provider.dimensionId+1,event.getChunk().zPosition);
ChunkPosition tPos = new ChunkPosition(event.getChunk().xPosition,event.getChunk().worldObj.provider.dimensionId,event.getChunk().zPosition);
if(chunkData.containsKey(tPos)){
int[] tInts = chunkData.get(tPos);
if(tInts.length>0){event.getData().setInteger("GTOIL", tInts[0]);}
@ -1717,7 +1717,7 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler {
int tOilFluid = 0;
int tPollution = 0;
ChunkPosition tPos = new ChunkPosition(event.getChunk().xPosition,event.getChunk().worldObj.provider.dimensionId+1,event.getChunk().zPosition);
ChunkPosition tPos = new ChunkPosition(event.getChunk().xPosition,event.getChunk().worldObj.provider.dimensionId,event.getChunk().zPosition);
int[] tData = new int[0];
if(chunkData.containsKey(tPos)){
tData = chunkData.get(tPos);

View file

@ -31,6 +31,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.ChunkPosition;
import net.minecraftforge.fluids.FluidStack;
import sun.text.resources.es.CollationData_es;
@ -104,7 +105,7 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba
prospectOres(tNearOres, tMiddleOres, tFarOres);
// prospecting oils
HashMap<String, Integer> tOils = new HashMap<String, Integer>(9);
HashMap<String, Integer> tOils = new HashMap<String, Integer>();
prospectOils(tOils);
GT_Utility.ItemNBT.setAdvancedProspectionData(mTier,
@ -126,32 +127,35 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba
private void prospectOils(HashMap<String, Integer> aOils) {
int tLeftXBound = this.getBaseMetaTileEntity().getXCoord() - radius;
int tRightXBound = tLeftXBound + 2*radius;
int tLeftXBound = GT_Utility.getScaleСoordinates(this.getBaseMetaTileEntity().getXCoord() - radius, 16);
int tRightXBound = GT_Utility.getScaleСoordinates(this.getBaseMetaTileEntity().getXCoord() + radius, 16);
int tLeftZBound = this.getBaseMetaTileEntity().getZCoord() - radius;
int tRightZBound = tLeftZBound + 2*radius;
int tLeftZBound = GT_Utility.getScaleСoordinates(this.getBaseMetaTileEntity().getZCoord() - radius, 16);
int tRightZBound = GT_Utility.getScaleСoordinates(this.getBaseMetaTileEntity().getZCoord() + radius, 16);
ArrayList<String> filterList = new ArrayList<String>(9);
String filter;
HashMap<ChunkPosition, FluidStack> tFluids = new HashMap<ChunkPosition, FluidStack>();
for (int x = tLeftXBound; x <= tRightXBound; ++x)
for (int z = tLeftZBound; z <= tRightZBound; ++z) {
filter = x/96 + "," + z/96;
if (!filterList.contains(filter)) {
filterList.add(filter);
putOil((x/96)*96, (z/96)*96, aOils);
try {
for (int x = tLeftXBound; x <= tRightXBound; ++x)
for (int z = tLeftZBound; z <= tRightZBound; ++z)
{
ChunkPosition tPos = new ChunkPosition(GT_Utility.getScaleСoordinates(x*16,96), 0, GT_Utility.getScaleСoordinates(z*16,96));
FluidStack tFluid = GT_Utility.getUndergroundOil(getBaseMetaTileEntity().getWorld(), x*16, z*16);
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);
}
}
}
private void putOil(int x, int z, HashMap<String, Integer> aOils) {
FluidStack tFluid = GT_Utility.getUndergroundOil(getBaseMetaTileEntity().getWorld(), x, z);
if (tFluid != null)
if (tFluid.amount / 5000 > 0)
aOils.put(x + "," + z + "," + (tFluid.amount / 5000) + "," + tFluid.getLocalizedName(), tFluid.amount / 5000);
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);
}
} catch (Exception e) {
// TODO: handle exception
}
}
private void prospectOres(Map<String, Integer> aNearOres, Map<String, Integer> aMiddleOres, Map<String, Integer> aFarOres) {