Adv seismic prospector reworked (#1419)
* Adv Seismic Prospector reworked Prospects from NW to SE 9 of oilfields (6x6 chunks each) and output min-max oil amount * deleted formatting codes * Cleanup * Added description * Added description * Cleanup imports * Adv Seismic Prospector
This commit is contained in:
parent
860cc0daf0
commit
fcdb80b886
2 changed files with 80 additions and 47 deletions
|
@ -1973,8 +1973,7 @@ public class GT_Utility {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static ArrayList<String> sortByValueToList( Map<String, Integer> map )
|
||||
{
|
||||
public static ArrayList<String> sortByValueToList( Map<String, Integer> map ) {
|
||||
List<Map.Entry<String, Integer>> list =
|
||||
new LinkedList<Map.Entry<String, Integer>>( map.entrySet() );
|
||||
Collections.sort( list, new Comparator<Map.Entry<String, Integer>>()
|
||||
|
@ -2151,8 +2150,9 @@ public class GT_Utility {
|
|||
ArrayList<String> tOilsTransformed = new ArrayList<String>(aOils.size());
|
||||
for (String aStr : aOils) {
|
||||
String[] aStats = aStr.split(",");
|
||||
tOilsTransformed.add(aStats[3] + " " + aStats[2] + "L");
|
||||
tOilsTransformed.add(aStats[0] + ": " + aStats[1] + "L " + aStats[2]);
|
||||
}
|
||||
|
||||
tNBT.setString("prospection_oils", joinListToString(tOilsTransformed));
|
||||
|
||||
tNBT.setString("prospection_bounds", aNear + "|" + aMiddle + "|" + aRadius);
|
||||
|
@ -2194,7 +2194,7 @@ public class GT_Utility {
|
|||
|
||||
NBTTagList tNBTList = new NBTTagList();
|
||||
|
||||
String tPageText = "Advanced prospection\n"
|
||||
String tPageText = "Advanced prospection\n\n"
|
||||
+ tPos + "\n"
|
||||
+ "Results:\n"
|
||||
+ "- Close Range Ores: " + (tNearOres != null ? tNearOres.length : 0) + "\n"
|
||||
|
@ -2210,13 +2210,29 @@ public class GT_Utility {
|
|||
fillBookWithList(tNBTList, "Mid Range Ores%s\n\n", ", ", 20, tMiddleOres);
|
||||
if (tFarOres != null)
|
||||
fillBookWithList(tNBTList, "Far Range Ores%s\n\n", ", ", 20, tFarOres);
|
||||
|
||||
tPageText = "Ore notes\n\n"
|
||||
+ "Close range:\nR <= " + tBounds[0] + "\n"
|
||||
+ "Mid range:\n" + tBounds[0] + " < R <= " + tBounds[1] + "\n"
|
||||
+ "Far range:\n" + tBounds[1] + " < R <= " + tBounds[2] + "\n"
|
||||
+ "\n"
|
||||
+ "[F][F][F][F][F]" + "\n"
|
||||
+ "[F][M][M][M][F]" + "\n"
|
||||
+ "[F][M][C][M][F]" + "\n"
|
||||
+ "[F][M][M][M][F]" + "\n"
|
||||
+ "[F][F][F][F][F]";
|
||||
tNBTList.appendTag(new NBTTagString(tPageText));
|
||||
|
||||
if (tOils != null)
|
||||
fillBookWithList(tNBTList, "Oils%s\n\n", "\n", 9, tOils);
|
||||
|
||||
tPageText = "Notes\n\n"
|
||||
+ "Close range:\nR <= " + tBounds[0] + "\n"
|
||||
+ "Mid range:\n" + tBounds[0] + " < R <= " + tBounds[1] + "\n"
|
||||
+ "Far range:\n" + tBounds[1] + " < R <= " + tBounds[2];
|
||||
tPageText = "Oil notes\n\n"
|
||||
+ "Prospects from NW to SE 324 chunks (9 oilfields) around and gives min-max amount" + "\n\n"
|
||||
+ "[1][2][3]" + "\n"
|
||||
+ "[4][5][6]" + "\n"
|
||||
+ "[7][8][9]" + "\n"
|
||||
+ "\n"
|
||||
+ "[5] - Prospector";
|
||||
tNBTList.appendTag(new NBTTagString(tPageText));
|
||||
|
||||
tNBT.setString("author", tPos);
|
||||
|
|
|
@ -12,7 +12,6 @@ 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;
|
||||
|
@ -23,11 +22,12 @@ 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.minecraft.world.chunk.Chunk;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import static gregtech.common.GT_UndergroundOil.undergroundOilReadInformation;
|
||||
|
||||
public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_BasicMachine {
|
||||
boolean ready = false;
|
||||
|
@ -36,12 +36,12 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba
|
|||
int middle;
|
||||
int step;
|
||||
|
||||
private int mOilId = 0;
|
||||
private ArrayList<Chunk> mOilFieldChunks = new ArrayList<Chunk>();
|
||||
|
||||
public GT_MetaTileEntity_AdvSeismicProspector(int aID, String aName, String aNameRegional, int aTier, int aRadius, int aStep) {
|
||||
super(aID, aName, aNameRegional, aTier, 1, // amperage
|
||||
"Place, activate with explosives ("
|
||||
+ "8 Glyceryl, "
|
||||
+ "32 TNT or "
|
||||
+ "16 ITNT), use Data Stick",
|
||||
"",
|
||||
1, // input slot count
|
||||
1, // output slot count
|
||||
"Default.png", // GUI name
|
||||
|
@ -61,6 +61,16 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba
|
|||
step = aStep;
|
||||
}
|
||||
|
||||
public String[] getDescription() {
|
||||
return new String[]{
|
||||
"Place, activate with explosives ("
|
||||
+ "8 Glyceryl, "
|
||||
+ "32 TNT or "
|
||||
+ "16 ITNT), use Data Stick",
|
||||
"Ore prospection area 191x191 blocks",
|
||||
"Oil prospection area 3x3 oilfields"};
|
||||
}
|
||||
|
||||
protected GT_MetaTileEntity_AdvSeismicProspector(String aName, int aTier, String aDescription, ITexture[][][] aTextures,
|
||||
String aGUIName, String aNEIName, int aNear, int aMiddle, int aRadius, int aStep) {
|
||||
super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName);
|
||||
|
@ -108,7 +118,7 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba
|
|||
prospectOres(tNearOres, tMiddleOres, tFarOres);
|
||||
|
||||
// prospecting oils
|
||||
HashMap<String, Integer> tOils = new HashMap<String, Integer>();
|
||||
ArrayList<String> tOils = new ArrayList<String>();
|
||||
prospectOils(tOils);
|
||||
|
||||
GT_Utility.ItemNBT.setAdvancedProspectionData(mTier,
|
||||
|
@ -117,7 +127,7 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba
|
|||
this.getBaseMetaTileEntity().getYCoord(),
|
||||
this.getBaseMetaTileEntity().getZCoord(),
|
||||
this.getBaseMetaTileEntity().getWorld().provider.dimensionId,
|
||||
GT_Utility.sortByValueToList(tOils),
|
||||
tOils,
|
||||
GT_Utility.sortByValueToList(tNearOres),
|
||||
GT_Utility.sortByValueToList(tMiddleOres),
|
||||
GT_Utility.sortByValueToList(tFarOres),
|
||||
|
@ -128,36 +138,43 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba
|
|||
return true;
|
||||
}
|
||||
|
||||
private void prospectOils(HashMap<String, Integer> aOils) {
|
||||
private void prospectOils(ArrayList<String> aOils) {
|
||||
|
||||
int tLeftXBound = GT_Utility.getScaleCoordinates(this.getBaseMetaTileEntity().getXCoord() - radius, 16);
|
||||
int tRightXBound = GT_Utility.getScaleCoordinates(this.getBaseMetaTileEntity().getXCoord() + radius, 16);
|
||||
FluidStack tFluid;
|
||||
|
||||
int tLeftZBound = GT_Utility.getScaleCoordinates(this.getBaseMetaTileEntity().getZCoord() - radius, 16);
|
||||
int tRightZBound = GT_Utility.getScaleCoordinates(this.getBaseMetaTileEntity().getZCoord() + radius, 16);
|
||||
Chunk tChunk = getBaseMetaTileEntity().getWorld().getChunkFromBlockCoords(getBaseMetaTileEntity().getXCoord(), getBaseMetaTileEntity().getZCoord());
|
||||
int range = 6; //(int)Math.ceil((double)radius / 16);
|
||||
int xChunk = (tChunk.xPosition / range) * range - ((tChunk.xPosition < 0 && tChunk.xPosition % range != 0) ? range : 0);
|
||||
int zChunk = (tChunk.zPosition / range) * range - ((tChunk.zPosition < 0 && tChunk.zPosition % range != 0) ? range : 0);
|
||||
|
||||
HashMap<ChunkCoordIntPair, FluidStack> tFluids = new HashMap<>();
|
||||
LinkedHashMap<ChunkCoordIntPair, FluidStack> tFluids = new LinkedHashMap<>();
|
||||
int oilFieldCount = 0;
|
||||
|
||||
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));
|
||||
ChunkCoordIntPair cInts = getBaseMetaTileEntity().getWorld().getChunkFromChunkCoords(tPos.chunkPosX,tPos.chunkPosZ).getChunkCoordIntPair();
|
||||
FluidStack tFluid = GT_UndergroundOil.undergroundOilReadInformation(getBaseMetaTileEntity().getWorld().getChunkFromChunkCoords(tPos.chunkPosX,tPos.chunkPosZ));
|
||||
if (tFluid != null)
|
||||
if (tFluids.containsKey(cInts)) {
|
||||
if (tFluids.get(cInts).amount<tFluid.amount)
|
||||
tFluids.get(cInts).amount = tFluid.amount;
|
||||
} else tFluids.put(cInts, tFluid);
|
||||
}
|
||||
for (int z = -1; z <= 1; ++z) {
|
||||
for (int x = -1; x <= 1; ++x) {
|
||||
ChunkCoordIntPair cInts = getBaseMetaTileEntity().getWorld().getChunkFromChunkCoords(x, z).getChunkCoordIntPair();
|
||||
ArrayList<Integer> minMaxValue = new ArrayList<>();
|
||||
|
||||
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
|
||||
}
|
||||
for (int i = 0; i < range; i++) {
|
||||
for (int j = 0; j < range; j++) {
|
||||
tChunk = getBaseMetaTileEntity().getWorld().getChunkFromChunkCoords(xChunk + i + x * 6, zChunk + j + z * 6);
|
||||
tFluid = undergroundOilReadInformation(tChunk);
|
||||
if (tFluid != null) {
|
||||
minMaxValue.add(tFluid.amount);
|
||||
if (!tFluids.containsKey(cInts)) {
|
||||
tFluids.put(cInts, tFluid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int min = Collections.min(minMaxValue);
|
||||
int max = Collections.max(minMaxValue);
|
||||
aOils.add(++oilFieldCount + "," + min + "-" + max + "," + tFluids.get(cInts).getLocalizedName());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {/*Do nothing*/}
|
||||
}
|
||||
|
||||
private void prospectOres(Map<String, Integer> aNearOres, Map<String, Integer> aMiddleOres, Map<String, Integer> aFarOres) {
|
||||
|
|
Loading…
Reference in a new issue