aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/api')
-rw-r--r--src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java4
-rw-r--r--src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java2
-rw-r--r--src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java3
-rw-r--r--src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java5
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java6
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java59
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java24
-rw-r--r--src/main/java/gregtech/api/objects/GT_UO_Dimension.java8
-rw-r--r--src/main/java/gregtech/api/objects/GT_UO_DimensionList.java13
-rw-r--r--src/main/java/gregtech/api/objects/GT_UO_Fluid.java25
-rw-r--r--src/main/java/gregtech/api/util/GT_Utility.java175
11 files changed, 203 insertions, 121 deletions
diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java b/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java
index b62ed4500b..63020684c0 100644
--- a/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java
+++ b/src/main/java/gregtech/api/interfaces/tileentity/IEnergyConnected.java
@@ -1,8 +1,10 @@
package gregtech.api.interfaces.tileentity;
import cofh.api.energy.IEnergyReceiver;
+import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
import gregtech.api.util.GT_Utility;
+import gregtech.common.GT_Pollution;
import ic2.api.energy.tile.IEnergySink;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
@@ -85,6 +87,8 @@ public interface IEnergyConnected extends IColoredTileEntity, IHasWorldObjectAnd
GT_Utility.sendSoundToPlayers(tWorld, GregTech_API.sSoundList.get(209), 1.0F, -1, tX, tY, tZ);
tWorld.setBlock(tX, tY, tZ, Blocks.air);
if (GregTech_API.sMachineExplosions)
+ if(GT_Mod.gregtechproxy.mPollution)
+ GT_Pollution.addPollution(tWorld.getChunkFromBlockCoords(tX,tZ), 100000);
tWorld.createExplosion(null, tX + 0.5, tY + 0.5, tZ + 0.5, tStrength, true);
}
}
diff --git a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java
index dacc42ccbb..baa5d23b4c 100644
--- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java
+++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java
@@ -339,7 +339,7 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements
if (name.equals("gt.metatool.01.170") || name.equals("gt.metatool.01.172") || name.equals("gt.metatool.01.174") || name.equals("gt.metatool.01.176")) {
aList.add(tOffset + 0, EnumChatFormatting.WHITE + "Durability: " + EnumChatFormatting.GREEN + (tMaxDamage - getToolDamage(aStack)) + " / " + tMaxDamage + EnumChatFormatting.GRAY);
aList.add(tOffset + 1, EnumChatFormatting.WHITE + tMaterial.mDefaultLocalName + EnumChatFormatting.YELLOW + " lvl " + getHarvestLevel(aStack, "") + EnumChatFormatting.GRAY);
- aList.add(tOffset + 2, EnumChatFormatting.WHITE + "Turbine Efficency: " + EnumChatFormatting.BLUE + (50.0F + (10.0F * getToolCombatDamage(aStack))) + EnumChatFormatting.GRAY);
+ aList.add(tOffset + 2, EnumChatFormatting.WHITE + "Turbine Efficiency: " + EnumChatFormatting.BLUE + (50.0F + (10.0F * getToolCombatDamage(aStack))) + EnumChatFormatting.GRAY);
aList.add(tOffset + 3, EnumChatFormatting.WHITE + "Optimal Steam flow: " + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 1000) + EnumChatFormatting.GRAY + "L/sec");
aList.add(tOffset + 3, EnumChatFormatting.WHITE + "Optimal Gas flow(EU burnvalue per tick): " + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 50) + EnumChatFormatting.GRAY + "EU/t");
aList.add(tOffset + 3, EnumChatFormatting.WHITE + "Optimal Plasma flow(Plasma energyvalue per tick): " + EnumChatFormatting.LIGHT_PURPLE + Math.max(Float.MIN_NORMAL, tStats.getSpeedMultiplier() * getPrimaryMaterial(aStack).mToolSpeed * 2000) + EnumChatFormatting.GRAY + "EU/t");
diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
index 4aa49a954c..b537ce71ef 100644
--- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
+++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
@@ -1146,7 +1146,8 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
}
}
}
- GT_Pollution.addPollution(getWorld(), new ChunkPosition(getXCoord(), getYCoord(), getZCoord()), 100000);
+
+ GT_Pollution.addPollution(this, 100000);
mMetaTileEntity.doExplosion(aAmount);
}
}
diff --git a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java
index b34483c31b..3adf2b618b 100644
--- a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java
+++ b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java
@@ -2,6 +2,7 @@ package gregtech.api.metatileentity;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
+import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
@@ -9,6 +10,7 @@ import gregtech.api.objects.GT_ItemStack;
import gregtech.api.util.GT_Config;
import gregtech.api.util.GT_LanguageManager;
import gregtech.api.util.GT_Utility;
+import gregtech.common.GT_Pollution;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -644,8 +646,9 @@ public abstract class MetaPipeEntity implements IMetaTileEntity {
int tX = getBaseMetaTileEntity().getXCoord(), tY = getBaseMetaTileEntity().getYCoord(), tZ = getBaseMetaTileEntity().getZCoord();
World tWorld = getBaseMetaTileEntity().getWorld();
tWorld.setBlock(tX, tY, tZ, Blocks.air);
- if (GregTech_API.sMachineExplosions)
+ if (GregTech_API.sMachineExplosions) {
tWorld.createExplosion(null, tX + 0.5, tY + 0.5, tZ + 0.5, tStrength, true);
+ }
}
@Override
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java
index 76b2e9aaf5..73d3c19a6b 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java
@@ -203,8 +203,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity
if (tFuelValue > 0 && tConsumed > 0 && mFluid.amount > tConsumed) {
long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue);
if (tFluidAmountToUse > 0 && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)) {
- GT_Pollution.addPollution(this.getBaseMetaTileEntity().getWorld(), new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()),
- 10 * getPollution());
+ GT_Pollution.addPollution(getBaseMetaTileEntity(),10 * getPollution());
mFluid.amount -= tFluidAmountToUse * tConsumed;
}
}
@@ -216,8 +215,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity
if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tEmptyContainer)) {
aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true);
aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1);
- GT_Pollution.addPollution(this.getBaseMetaTileEntity().getWorld(), new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()),
- 10 * getPollution());
+ GT_Pollution.addPollution(getBaseMetaTileEntity(),10 * getPollution());
}
}
}
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java
index dde8d7cf4f..1209b9c582 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java
@@ -1,14 +1,18 @@
package gregtech.api.metatileentity.implementations;
+import gregtech.GT_Mod;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.objects.GT_RenderedTexture;
+import gregtech.api.objects.XSTR;
import gregtech.common.GT_Pollution;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.ChunkPosition;
+import net.minecraft.world.World;
+import net.minecraftforge.common.util.ForgeDirection;
public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch {
public GT_MetaTileEntity_Hatch_Muffler(int aID, String aName, String aNameRegional, int aTier) {
@@ -69,7 +73,7 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch {
public boolean polluteEnvironment() {
if (getBaseMetaTileEntity().getAirAtSide(getBaseMetaTileEntity().getFrontFacing())) {
- GT_Pollution.addPollution(this.getBaseMetaTileEntity().getWorld(), new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), calculatePollutionReduction(10000));
+ GT_Pollution.addPollution(getBaseMetaTileEntity(), calculatePollutionReduction(10000));
return true;
}
return false;
@@ -88,4 +92,57 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch {
public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
return false;
}
+
+ @Override
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ super.onPostTick(aBaseMetaTileEntity, aTick);
+ if(aBaseMetaTileEntity.isClientSide() && this.getBaseMetaTileEntity().isActive())
+ pollutionParticles(this.getBaseMetaTileEntity().getWorld(),"largesmoke");
+ }
+
+ private static XSTR floatGen=new XSTR();
+
+ public void pollutionParticles(World aWorld,String name){
+ boolean chk1,chk2,chk3;
+ float ran1=floatGen.nextFloat(),ran2=0,ran3=0;
+ chk1=ran1*100<calculatePollutionReduction(100);
+ if(GT_Pollution.getPollution(getBaseMetaTileEntity())>= GT_Mod.gregtechproxy.mPollutionSmogLimit){
+ ran2=floatGen.nextFloat();
+ ran3=floatGen.nextFloat();
+ chk2=ran2*100<calculatePollutionReduction(100);
+ chk3=ran3*100<calculatePollutionReduction(100);
+ if(!(chk1||chk2||chk3))return;
+ }else{
+ if(!chk1)return;
+ chk2=chk3=false;
+ }
+
+ IGregTechTileEntity aMuffler=this.getBaseMetaTileEntity();
+ ForgeDirection aDir=ForgeDirection.getOrientation(aMuffler.getFrontFacing());
+ float xPos=aDir.offsetX*0.76F+aMuffler.getXCoord()+0.25F;
+ float yPos=aDir.offsetY*0.76F+aMuffler.getYCoord()+0.25F;
+ float zPos=aDir.offsetZ*0.76F+aMuffler.getZCoord()+0.25F;
+
+ float ySpd=aDir.offsetY*0.1F+0.2F+0.1F*floatGen.nextFloat();
+ float xSpd;
+ float zSpd;
+
+ if(aDir.offsetY==-1){
+ float temp=floatGen.nextFloat()*2*(float)Math.PI;
+ xSpd=(float)Math.sin(temp)*0.1F;
+ zSpd=(float)Math.cos(temp)*0.1F;
+ }else{
+ xSpd=aDir.offsetX*(0.1F+0.2F*floatGen.nextFloat());
+ zSpd=aDir.offsetZ*(0.1F+0.2F*floatGen.nextFloat());
+ }
+
+ if(chk1)
+ aWorld.spawnParticle(name, xPos + ran1*0.5F, yPos + floatGen.nextFloat()*0.5F, zPos + floatGen.nextFloat()*0.5F, xSpd, ySpd, zSpd);
+
+ if(chk2)
+ aWorld.spawnParticle(name, xPos + ran2*0.5F, yPos + floatGen.nextFloat()*0.5F, zPos + floatGen.nextFloat()*0.5F, xSpd, ySpd, zSpd);
+
+ if(chk3)
+ aWorld.spawnParticle(name, xPos + ran3*0.5F, yPos + floatGen.nextFloat()*0.5F, zPos + floatGen.nextFloat()*0.5F, xSpd, ySpd, zSpd);
+ }
}
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
index bd10ca635c..86d74f3dac 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
@@ -16,6 +16,7 @@ import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
import gregtech.api.util.GT_Utility;
+import gregtech.common.GT_Pollution;
import gregtech.common.items.GT_MetaGenerated_Tool_01;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
@@ -495,6 +496,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
}
public void explodeMultiblock() {
+ GT_Pollution.addPollution(getBaseMetaTileEntity(), 300000);
mInventory[1] = null;
for (MetaTileEntity tTileEntity : mInputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]);
for (MetaTileEntity tTileEntity : mOutputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]);
@@ -646,11 +648,11 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
public ArrayList<ItemStack> getStoredOutputs() {
ArrayList<ItemStack> rList = new ArrayList<ItemStack>();
- for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) {
- if (isValidMetaTileEntity(tHatch)) {
- rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(1));
- }
- }
+// for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) {
+// if (isValidMetaTileEntity(tHatch)) {
+// rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(1));
+// }
+// }
for (GT_MetaTileEntity_Hatch_OutputBus tHatch : mOutputBusses) {
if (isValidMetaTileEntity(tHatch)) {
for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) {
@@ -674,12 +676,12 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
public ArrayList<ItemStack> getStoredInputs() {
ArrayList<ItemStack> rList = new ArrayList<ItemStack>();
- for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) {
- tHatch.mRecipeMap = getRecipeMap();
- if (isValidMetaTileEntity(tHatch) && tHatch.getBaseMetaTileEntity().getStackInSlot(0) != null) {
- rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(0));
- }
- }
+// for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) {
+// tHatch.mRecipeMap = getRecipeMap();
+// if (isValidMetaTileEntity(tHatch) && tHatch.getBaseMetaTileEntity().getStackInSlot(0) != null) {
+// rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(0));
+// }
+// }
for (GT_MetaTileEntity_Hatch_InputBus tHatch : mInputBusses) {
tHatch.mRecipeMap = getRecipeMap();
if (isValidMetaTileEntity(tHatch)) {
diff --git a/src/main/java/gregtech/api/objects/GT_UO_Dimension.java b/src/main/java/gregtech/api/objects/GT_UO_Dimension.java
index ffad72868c..657e9353c6 100644
--- a/src/main/java/gregtech/api/objects/GT_UO_Dimension.java
+++ b/src/main/java/gregtech/api/objects/GT_UO_Dimension.java
@@ -18,7 +18,7 @@ public class GT_UO_Dimension {
private int maxChance;
public String Dimension = "null";
- public GT_UO_Dimension(ConfigCategory aConfigCategory) {
+ public GT_UO_Dimension(ConfigCategory aConfigCategory) {//TODO CONFIGURE
fFluids = HashBiMap.create();
if (aConfigCategory.containsKey("Dimension"))
{
@@ -35,18 +35,14 @@ public class GT_UO_Dimension {
}
public GT_UO_Fluid getRandomFluid (Random aRandom) {
- int random = aRandom.nextInt(3);
- random = aRandom.nextInt(1000);
- int step = 0;
+ int random = aRandom.nextInt(1000);
for (BiMap.Entry<String, GT_UO_Fluid> fl : fFluids.entrySet()) {
int chance = fl.getValue().Chance*1000/maxChance;
if (random<=chance) return fl.getValue();
//System.out.println("GT UO "+fl.getValue().Registry+" Chance:"+chance+" Random:"+random);
random-=chance;
}
-
return null;
-
}
}
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 89340132be..ce3bdc51cb 100644
--- a/src/main/java/gregtech/api/objects/GT_UO_DimensionList.java
+++ b/src/main/java/gregtech/api/objects/GT_UO_DimensionList.java
@@ -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;
@@ -48,15 +48,16 @@ public class GT_UO_DimensionList {
fConfig.get(Category, "MaxAmount", aMaxAmount).getInt(aMaxAmount);
fConfig.get(Category, "Chance", aChance).getInt(aChance);
fConfig.get(Category, "DecreasePerOperationAmount", aDecreasePerOperationAmount).getInt(aDecreasePerOperationAmount);
+ //IT IS IN BUCKETS!!!
}
public void SetDafultValues() {
- 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", "gas_natural_gas", "gas_natural_gas", 0, 625, 20, 7);
+ 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, 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", 0, 375, 100, 5);
+ SetConfigValues("Moon", "Moon", "helium-3", "helium-3", 24, 128, 100, 1);
}
public void getConfig(Configuration aConfig, String aCategory) {
@@ -65,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");
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 c2d9b70bd2..5eea9c323f 100644
--- a/src/main/java/gregtech/api/objects/GT_UO_Fluid.java
+++ b/src/main/java/gregtech/api/objects/GT_UO_Fluid.java
@@ -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){
- 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/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java
index f3013a767e..642fc5d9a4 100644
--- a/src/main/java/gregtech/api/util/GT_Utility.java
+++ b/src/main/java/gregtech/api/util/GT_Utility.java
@@ -53,10 +53,13 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.MathHelper;
+import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.ChunkPosition;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
+import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
@@ -73,6 +76,9 @@ import java.util.*;
import java.util.Map.Entry;
import static gregtech.api.enums.GT_Values.*;
+import static gregtech.common.GT_Proxy.GTPOLLUTION;
+import static gregtech.common.GT_Proxy.dimensionWiseChunkData;
+import static gregtech.common.GT_UndergroundOil.undergroundOil;
/**
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
@@ -95,6 +101,14 @@ public class GT_Utility {
GregTech_API.sItemStackMappings.add(sFilledContainerToData);
GregTech_API.sItemStackMappings.add(sEmptyContainerToFluidToData);
}
+
+ public static int safeInt(long number, int margin){
+ return number>Integer.MAX_VALUE-margin ? Integer.MAX_VALUE-margin :(int)number;
+ }
+
+ public static int safeInt(long number){
+ return number>GT_Values.V[GT_Values.V.length-1] ? safeInt(GT_Values.V[GT_Values.V.length-1],1) : number<Integer.MIN_VALUE ? Integer.MIN_VALUE : (int)number;
+}
public static Field getPublicField(Object aObject, String aField) {
Field rField = null;
@@ -1531,70 +1545,70 @@ public class GT_Utility {
return (int)Math.floor(aValue / aScale);
}
- public static FluidStack getUndergroundOil(World aWorld, int aX, int aZ) {
- return getUndergroundOil(aWorld, aX, aZ, false);
- }
-
- public static FluidStack getUndergroundOil(World aWorld, int aX, int aZ, boolean needConsumeOil) {
-
- if (GT_Mod.gregtechproxy.mUndergroundOil.CheckBlackList(aWorld.provider.dimensionId))
- return null;
-
- Random tRandom = new Random((aWorld.getSeed() + aWorld.provider.dimensionId * 2 + (getScaleCoordinates(aX,96)) + (7 * (getScaleCoordinates(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 {
- GT_UO_Fluid uoFluid = GT_Mod.gregtechproxy.mUndergroundOil.GetDimension(aWorld.provider.dimensionId).getRandomFluid(tRandom);
- if (uoFluid != null)
- {
- 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);
- }
-
- } catch (Exception e) {
- tAmount = 0;
- tFluidId = 0;
- }
-
- try {
- ChunkPosition tPos = new ChunkPosition(getScaleCoordinates(aX,16), aWorld.provider.dimensionId, getScaleCoordinates(aZ,16));
- int[] tInts = new int[3];
- if(GT_Proxy.chunkData.containsKey(tPos)){
- tInts = GT_Proxy.chunkData.get(tPos);
- if(tInts.length>0){
- if(tInts[0]>0){tAmount = tInts[0];}
- }
- if(tInts.length>2){
- if(tInts[2]>0&&tInts[2]!=tFluidId)
- {
- tFluidId = tInts[2];
- tFluid = FluidRegistry.getFluid(tFluidId);
- }
- }
- GT_Proxy.chunkData.remove(tPos);
- }
-
- if (needConsumeOil && tAmount >= 5000)
- tAmount = tAmount - tDecreasePerOperationAmount;
-
- tInts[0] = tAmount;
- tInts[2] = tFluidId;
- GT_Proxy.chunkData.put(tPos, tInts);
- } catch (Exception e) {
- System.out.println("getUndergroundOil() - Error put data");
- }
- if (tFluid!=null)
- return new FluidStack(tFluid, tAmount);
- return null;
- }
-
+// public static FluidStack getUndergroundOil(World aWorld, int aX, int aZ) {
+// return getUndergroundOil(aWorld, aX, aZ, false);
+// }
+//
+// public static FluidStack getUndergroundOil(World aWorld, int aX, int aZ, boolean needConsumeOil) {
+//
+// if (GT_Mod.gregtechproxy.mUndergroundOil.CheckBlackList(aWorld.provider.dimensionId))
+// return null;
+//
+// Random tRandom = new Random((aWorld.getSeed() + aWorld.provider.dimensionId * 2 + (getScaleCoordinates(aX,96)) + (7 * (getScaleCoordinates(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 {
+// GT_UO_Fluid uoFluid = GT_Mod.gregtechproxy.mUndergroundOil.GetDimension(aWorld.provider.dimensionId).getRandomFluid(tRandom);
+// if (uoFluid != null)
+// {
+// 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);
+// }
+//
+// } catch (Exception e) {
+// tAmount = 0;
+// tFluidId = 0;
+// }
+//
+// try {
+// ChunkPosition tPos = new ChunkPosition(getScaleCoordinates(aX,16), aWorld.provider.dimensionId, getScaleCoordinates(aZ,16));
+// int[] tInts = new int[3];
+// if(GT_Proxy.chunkData.containsKey(tPos)){
+// tInts = GT_Proxy.chunkData.get(tPos);
+// if(tInts.length>0){
+// if(tInts[0]>0){tAmount = tInts[0];}
+// }
+// if(tInts.length>2){
+// if(tInts[2]>0&&tInts[2]!=tFluidId)
+// {
+// tFluidId = tInts[2];
+// tFluid = FluidRegistry.getFluid(tFluidId);
+// }
+// }
+// GT_Proxy.chunkData.remove(tPos);
+// }
+//
+// if (needConsumeOil && tAmount >= 5000)
+// tAmount = tAmount - tDecreasePerOperationAmount;
+//
+// tInts[0] = tAmount;
+// tInts[2] = tFluidId;
+// GT_Proxy.chunkData.put(tPos, tInts);
+// } catch (Exception e) {
+// System.out.println("getUndergroundOil() - Error put data");
+// }
+// if (tFluid!=null)
+// return new FluidStack(tFluid, tAmount);
+// return null;
+// }
+
public static int getCoordinateScan(ArrayList<String> aList, EntityPlayer aPlayer, World aWorld, int aScanLevel, int aX, int aY, int aZ, int aSide, float aClickX, float aClickY, float aClickZ) {
if (aList == null) return 0;
@@ -1783,22 +1797,25 @@ public class GT_Utility {
if (D1) e.printStackTrace(GT_Log.err);
}
}
- if (aPlayer.capabilities.isCreativeMode&&GT_Values.D1) {
- FluidStack tFluid = getUndergroundOil(aWorld, aX, aZ);
+
+ if (aPlayer.capabilities.isCreativeMode && GT_Values.D1) {
+ FluidStack tFluid = undergroundOil(aWorld.getChunkFromBlockCoords(aX,aZ),-1);//-# to only read
if (tFluid!=null)
- tList.add("Oil in Chunk: " + tFluid.amount + " " + tFluid.getLocalizedName());
- }
-// if(aPlayer.capabilities.isCreativeMode){
- ChunkPosition tPos = new ChunkPosition(getScaleCoordinates(aX,16), aWorld.provider.dimensionId, getScaleCoordinates(aZ,16));
- if(GT_Proxy.chunkData.containsKey(tPos)){
- int[] tPollution = GT_Proxy.chunkData.get(tPos);
- if(tPollution.length>1){
- tList.add("Pollution in Chunk: "+tPollution[1]);
- }else{
- tList.add("No Pollution in Chunk");
- }
- }
-// }
+ tList.add(EnumChatFormatting.GOLD+tFluid.getLocalizedName()+EnumChatFormatting.RESET+": " +EnumChatFormatting.YELLOW+ tFluid.amount +EnumChatFormatting.RESET+" L");
+ else
+ tList.add(EnumChatFormatting.GOLD+"Nothing"+EnumChatFormatting.RESET+": " +EnumChatFormatting.YELLOW+ '0' +EnumChatFormatting.RESET+" L");
+ }
+// if(aPlayer.capabilities.isCreativeMode){
+ int[] chunkData = GT_Proxy.dimensionWiseChunkData.get(aWorld.provider.dimensionId).get(aWorld.getChunkFromBlockCoords(aX,aZ).getChunkCoordIntPair());
+ if(chunkData !=null){
+ if(chunkData[GTPOLLUTION]>0){
+ tList.add("Pollution in Chunk: "+EnumChatFormatting.RED+chunkData[GTPOLLUTION]+EnumChatFormatting.RESET+" gibbl");
+ }else{
+ tList.add(EnumChatFormatting.GREEN+"No Pollution in Chunk! HAYO!"+EnumChatFormatting.RESET);
+ }
+ }else{
+ tList.add(EnumChatFormatting.GREEN+"No Pollution in Chunk! HAYO!"+EnumChatFormatting.RESET);
+}
try {
if (tBlock instanceof IDebugableBlock) {