FIX for oil rig ...
This commit is contained in:
parent
dd4dfcece3
commit
9fa7776929
4 changed files with 110 additions and 49 deletions
|
@ -18,6 +18,7 @@ import gregtech.api.items.GT_Generic_Item;
|
|||
import gregtech.api.net.GT_Packet_Sound;
|
||||
import gregtech.api.objects.GT_ItemStack;
|
||||
import gregtech.api.objects.ItemData;
|
||||
import gregtech.api.objects.XSTR;
|
||||
import gregtech.api.threads.GT_Runnable_Sound;
|
||||
import gregtech.common.GT_Proxy;
|
||||
import ic2.api.recipe.IRecipeInput;
|
||||
|
@ -1524,44 +1525,104 @@ public class GT_Utility {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static FluidStack getUndergroundOil(World aWorld, int aX, int aZ) {
|
||||
Random tRandom = new Random((aWorld.getSeed() + (aX / 6) + (7 * (aZ / 6))));
|
||||
int oil = tRandom.nextInt(4);
|
||||
double amount = tRandom.nextInt(50) + tRandom.nextDouble();
|
||||
// System.out.println("Oil: "+(aX/6)+" "+(aZ/6)+" "+oil+" "+amount);
|
||||
// amount = 40;
|
||||
Fluid tFluid = null;
|
||||
switch (oil) {
|
||||
case 0:
|
||||
tFluid = Materials.NatruralGas.mGas;
|
||||
break;
|
||||
case 1:
|
||||
tFluid = Materials.OilLight.mFluid;
|
||||
break;
|
||||
case 2:
|
||||
tFluid = Materials.OilMedium.mFluid;
|
||||
break;
|
||||
case 3:
|
||||
tFluid = Materials.OilHeavy.mFluid;
|
||||
break;
|
||||
default:
|
||||
tFluid = Materials.Oil.mFluid;
|
||||
}
|
||||
int tAmount = (int) (Math.pow(amount, 5) / 100);
|
||||
public static FluidStack undergroundOil(World aWorld, int aX, int aZ,boolean save,int sub) {
|
||||
ChunkPosition tPos = new ChunkPosition(aX, 1, aZ);
|
||||
int[] tInts = {0,0};
|
||||
if(GT_Proxy.chunkData.containsKey(tPos)){
|
||||
tInts = GT_Proxy.chunkData.get(tPos);
|
||||
if(GT_Proxy.chunkData.containsKey(tPos)){
|
||||
tInts = GT_Proxy.chunkData.get(tPos);
|
||||
if(tInts.length>0){
|
||||
if(tInts[0]>=0) tAmount = tInts[0];
|
||||
int type=tInts[0]>>24;
|
||||
int amnt=tInts[0]-(type<<24)-sub;
|
||||
if(type==0){//update old thing //IGNORES SAVE - chunk must be updated
|
||||
//here i don't care about type it will be added
|
||||
if(amnt<=0) tInts[0] = 0;
|
||||
else tInts[0] = amnt;
|
||||
return setUndergroundOilFromOld(aWorld,aX,aZ,tPos,tInts);//compatibility thing
|
||||
}
|
||||
if(save){//obvious?
|
||||
if(amnt<=0) tInts[0] = type << 24;
|
||||
else tInts[0] = type << 24 + amnt;
|
||||
GT_Proxy.chunkData.remove(tPos);
|
||||
GT_Proxy.chunkData.put(tPos, tInts);
|
||||
}
|
||||
return getUndergroundOilFromInfo(type,amnt);//return negative amounts? if u extract too much
|
||||
}
|
||||
GT_Proxy.chunkData.remove(tPos);
|
||||
}
|
||||
tAmount = tAmount - 5>=0?tAmount-5:0;
|
||||
tInts[0] = tAmount;
|
||||
GT_Proxy.chunkData.put(tPos, tInts);
|
||||
|
||||
return new FluidStack(tFluid, tAmount);
|
||||
GT_Proxy.chunkData.remove(tPos);//remove broken
|
||||
}
|
||||
return setUndergroundOil(aWorld,aX,aZ,tPos,tInts);//will save if empty
|
||||
}
|
||||
|
||||
private static FluidStack getUndergroundOilFromInfo(int type,int amnt){
|
||||
switch (type) {//0 is old system
|
||||
case 1:
|
||||
return new FluidStack(Materials.OilLight .mFluid,amnt);
|
||||
case 2:
|
||||
return new FluidStack(Materials.OilMedium.mFluid,amnt);
|
||||
case 3:
|
||||
return new FluidStack(Materials.OilHeavy .mFluid,amnt);
|
||||
case 4:
|
||||
return new FluidStack(Materials.Oil .mFluid,amnt);
|
||||
}
|
||||
return new FluidStack(Materials.NatruralGas.mGas,amnt);//5
|
||||
}
|
||||
|
||||
private static FluidStack setUndergroundOil(World aWorld, int aX, int aZ,ChunkPosition tPos,int[] tInts) {
|
||||
XSTR tRandom = new XSTR((aWorld.getSeed() + (aX / 6) + (7 * (aZ / 6))));
|
||||
int type=tRandom.nextInt(5);//type slowly changes
|
||||
int amnt=tRandom.nextInt(50);//Big value slowly changes
|
||||
tRandom = new XSTR();//small value is rapid changing,hence regen the seed from time
|
||||
amnt = (int) (Math.pow(amnt+tRandom.nextDouble(), 5) / 100);
|
||||
//max is 51^5/100 roughly uses 22 bits
|
||||
FluidStack tFluidStack;
|
||||
switch (type) {//0 is old system
|
||||
case 1:
|
||||
tFluidStack=new FluidStack(Materials.OilLight .mFluid,amnt);
|
||||
break;
|
||||
case 2:
|
||||
tFluidStack=new FluidStack(Materials.OilMedium.mFluid,amnt);
|
||||
break;
|
||||
case 3:
|
||||
tFluidStack=new FluidStack(Materials.OilHeavy .mFluid,amnt);
|
||||
break;
|
||||
case 4:
|
||||
tFluidStack=new FluidStack(Materials.Oil .mFluid,amnt);
|
||||
break;
|
||||
default://case 0; -> 5
|
||||
type=5;//important, 0 is invalid !
|
||||
tFluidStack=new FluidStack(Materials.NatruralGas.mGas,amnt);//5
|
||||
}
|
||||
|
||||
tInts[0]=type<<24+amnt;
|
||||
GT_Proxy.chunkData.put(tPos, tInts);
|
||||
return tFluidStack;
|
||||
}
|
||||
|
||||
private static FluidStack setUndergroundOilFromOld(World aWorld, int aX, int aZ,ChunkPosition tPos,int[] tInts) {
|
||||
FluidStack tFluidStack;
|
||||
int type=new Random((aWorld.getSeed() + (aX / 6) + (7 * (aZ / 6)))).nextInt(4);//Get old type of fluid
|
||||
//this gives value from 0 to 3 :D
|
||||
switch (type) {
|
||||
case 0:
|
||||
type=5;//important, 0 is invalid !
|
||||
tFluidStack = new FluidStack(Materials.NatruralGas.mGas,tInts[0]);
|
||||
break;
|
||||
case 1:
|
||||
tFluidStack = new FluidStack(Materials.OilLight.mFluid,tInts[0]);
|
||||
break;
|
||||
case 2:
|
||||
tFluidStack = new FluidStack(Materials.OilMedium.mFluid,tInts[0]);
|
||||
break;
|
||||
case 3:
|
||||
tFluidStack = new FluidStack(Materials.OilHeavy.mFluid,tInts[0]);
|
||||
break;
|
||||
default://unreachable but still here XD
|
||||
type=4;
|
||||
tFluidStack = new FluidStack(Materials.Oil.mFluid,tInts[0]);
|
||||
}
|
||||
tInts[0]+=type<<24;
|
||||
GT_Proxy.chunkData.remove(tPos);
|
||||
GT_Proxy.chunkData.put(tPos, tInts);
|
||||
return tFluidStack;
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -1752,9 +1813,9 @@ public class GT_Utility {
|
|||
if (D1) e.printStackTrace(GT_Log.err);
|
||||
}
|
||||
}
|
||||
if (aPlayer.capabilities.isCreativeMode&>_Values.D1) {
|
||||
FluidStack tFluid = getUndergroundOil(aWorld, aX>>4, aZ>>4);
|
||||
tList.add(EnumChatFormatting.GOLD+"Oil"+EnumChatFormatting.RESET+" in Chunk: " +EnumChatFormatting.YELLOW+ tFluid.amount + " " + tFluid.getLocalizedName()+EnumChatFormatting.RESET);
|
||||
if (aPlayer.capabilities.isCreativeMode) {
|
||||
FluidStack tFluid = undergroundOil(aWorld, aX>>4, aZ>>4,false,0);
|
||||
tList.add(EnumChatFormatting.GOLD+tFluid.getLocalizedName()+EnumChatFormatting.RESET+": " +EnumChatFormatting.YELLOW+ tFluid.amount +EnumChatFormatting.RESET+" L");
|
||||
}
|
||||
// if(aPlayer.capabilities.isCreativeMode){
|
||||
ChunkPosition tPos = new ChunkPosition(aX>>4, 1, aZ>>4);
|
||||
|
@ -1951,7 +2012,7 @@ public class GT_Utility {
|
|||
|
||||
public static void setProspectionData(ItemStack aStack, int aX, int aY, int aZ, int aDim, FluidStack aFluid, String[] aOres) {
|
||||
NBTTagCompound tNBT = getNBT(aStack);
|
||||
String tData = aX + "," + aY + "," + aZ + "," + aDim + "," + (aFluid.amount / 5000) + "," + aFluid.getLocalizedName() + ",";
|
||||
String tData = aX + "," + aY + "," + aZ + "," + aDim + "," + aFluid.amount + "," + aFluid.getLocalizedName() + ",";//fixed dividing 1L=1mB
|
||||
for (String tString : aOres) {
|
||||
tData += tString + ",";
|
||||
}
|
||||
|
@ -1964,13 +2025,13 @@ public class GT_Utility {
|
|||
String tData = tNBT.getString("prospection");
|
||||
String[] tDataArray = tData.split(",");
|
||||
if (tDataArray.length > 6) {
|
||||
tNBT.setString("author", "X: " + tDataArray[0] + " Y: " + tDataArray[1] + " Z: " + tDataArray[2] + " Dim: " + tDataArray[3]);
|
||||
tNBT.setString("author", "X:" + tDataArray[0] + " Y:" + tDataArray[1] + " Z:" + tDataArray[2] + " Dim:" + tDataArray[3]);
|
||||
NBTTagList tNBTList = new NBTTagList();
|
||||
String tOres = " Prospected Ores: ";
|
||||
for (int i = 6; tDataArray.length > i; i++) {
|
||||
tOres += (tDataArray[i] + " ");
|
||||
}
|
||||
tNBTList.appendTag(new NBTTagString("Prospection Data From: X" + tDataArray[0] + " Z:" + tDataArray[2] + " Dim:" + tDataArray[3] + " Produces " + tDataArray[4] + "L " + tDataArray[5] + " " + tOres));
|
||||
tNBTList.appendTag(new NBTTagString("Prospection Data From X:" + tDataArray[0] + " Z:" + tDataArray[2] + " Dim:" + tDataArray[3] + " Produces " + tDataArray[4] + "L of " + tDataArray[5] + " and:" + tOres));
|
||||
tNBT.setTag("pages", tNBTList);
|
||||
}
|
||||
setNBT(aStack, tNBT);
|
||||
|
|
|
@ -85,7 +85,7 @@ public class GT_Pollution {
|
|||
tNeighbor.add(new ChunkPosition(tPos.chunkPosX, 1, tPos.chunkPosZ-1));
|
||||
for(ChunkPosition tNPos : tNeighbor){
|
||||
if(!GT_Proxy.chunkData.containsKey(tNPos)){
|
||||
GT_Utility.getUndergroundOil(aWorld,tNPos.chunkPosX,tNPos.chunkPosZ);
|
||||
GT_Utility.undergroundOil(aWorld,tNPos.chunkPosX,tNPos.chunkPosZ,false,0);
|
||||
}
|
||||
int tNPol = GT_Proxy.chunkData.get(tNPos)[1];
|
||||
if(tNPol*6 < tPollution*5){
|
||||
|
|
|
@ -98,7 +98,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()>>4, getBaseMetaTileEntity().getZCoord()>>4);
|
||||
FluidStack tFluid = GT_Utility.undergroundOil(getBaseMetaTileEntity().getWorld(), getBaseMetaTileEntity().getXCoord()>>4, getBaseMetaTileEntity().getZCoord()>>4,false,0);
|
||||
String[] tStringArray = new String[tStringList.size()];
|
||||
{
|
||||
for (int i = 0; i < tStringArray.length; i++) {
|
||||
|
|
|
@ -6,6 +6,7 @@ import gregtech.api.gui.GT_GUIContainer_MultiMachine;
|
|||
import gregtech.api.interfaces.ITexture;
|
||||
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
|
||||
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
|
||||
import gregtech.api.metatileentity.MetaTileEntity;
|
||||
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
|
||||
import gregtech.api.objects.GT_RenderedTexture;
|
||||
import gregtech.api.util.GT_ModHandler;
|
||||
|
@ -73,10 +74,9 @@ public class GT_MetaTileEntity_OilDrill extends GT_MetaTileEntity_MultiBlockBase
|
|||
}
|
||||
}
|
||||
}
|
||||
FluidStack tFluid = GT_Utility.getUndergroundOil(getBaseMetaTileEntity().getWorld(), getBaseMetaTileEntity().getXCoord()>>4, getBaseMetaTileEntity().getZCoord()>>4);
|
||||
if (tFluid == null) {
|
||||
return false;
|
||||
}
|
||||
//Output fluid
|
||||
FluidStack tFluid = GT_Utility.undergroundOil(getBaseMetaTileEntity().getWorld(), getBaseMetaTileEntity().getXCoord()>>4, getBaseMetaTileEntity().getZCoord()>>4,true,5000);
|
||||
if (tFluid == null) return false;//impossible
|
||||
if (getBaseMetaTileEntity().getBlockOffset(ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetX, getYOfPumpHead() - 1 - getBaseMetaTileEntity().getYCoord(), ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetZ) != Blocks.bedrock) {
|
||||
if (completedCycle) {
|
||||
moveOneDown();
|
||||
|
@ -84,10 +84,10 @@ public class GT_MetaTileEntity_OilDrill extends GT_MetaTileEntity_MultiBlockBase
|
|||
tFluid = null;
|
||||
if (mEnergyHatches.size() > 0 && mEnergyHatches.get(0).getEUVar() > (512 + getMaxInputVoltage() * 4))
|
||||
completedCycle = true;
|
||||
} else if (tFluid.amount < 5000) {
|
||||
return false;
|
||||
} else if (tFluid.amount <=-5000) {//no fluid remaining
|
||||
return false;//stops processing??
|
||||
} else {
|
||||
tFluid.amount = tFluid.amount / 5000;
|
||||
tFluid.amount = 5000+Math.min(tFluid.amount,0);//give the fluid... adds negative values of lacking fluid, zero if there is MOOOORE
|
||||
}
|
||||
this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
|
||||
this.mEfficiencyIncrease = 10000;
|
||||
|
|
Loading…
Reference in a new issue