diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 69f5b978..6cecc9f6 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -1973,8 +1973,7 @@ public class GT_Utility { return false; } - public static ArrayList sortByValueToList( Map map ) - { + public static ArrayList sortByValueToList( Map map ) { List> list = new LinkedList>( map.entrySet() ); Collections.sort( list, new Comparator>() @@ -2151,8 +2150,9 @@ public class GT_Utility { ArrayList tOilsTransformed = new ArrayList(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" @@ -2203,20 +2203,36 @@ public class GT_Utility { + "- Oils: " + (tOils != null ? tOils.length : 0) + "\n\n" + "Lists was sorted by volume"; tNBTList.appendTag(new NBTTagString(tPageText)); - + if (tNearOres != null) fillBookWithList(tNBTList, "Close Range Ores%s\n\n", ", ", 20, tNearOres); if (tMiddleOres != null) 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); diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_AdvSeismicProspector.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_AdvSeismicProspector.java index ab5f7bd6..c0d254c3 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_AdvSeismicProspector.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_AdvSeismicProspector.java @@ -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,25 +22,26 @@ 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.*; -public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_BasicMachine { +import static gregtech.common.GT_UndergroundOil.undergroundOilReadInformation; + +public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_BasicMachine { boolean ready = false; int radius; int near; int middle; int step; + private int mOilId = 0; + private ArrayList mOilFieldChunks = new ArrayList(); + 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 tOils = new HashMap(); + ArrayList tOils = new ArrayList(); 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,39 +138,46 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba return true; } - private void prospectOils(HashMap aOils) { + private void prospectOils(ArrayList 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 tFluids = new HashMap<>(); + LinkedHashMap 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 minMaxValue = new ArrayList<>(); + + 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()); } - - 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 - } + } + } catch (Exception e) {/*Do nothing*/} } - private void prospectOres(Map aNearOres, Map aMiddleOres, Map aFarOres) { + private void prospectOres(Map aNearOres, Map aMiddleOres, Map aFarOres) { int tLeftXBound = this.getBaseMetaTileEntity().getXCoord() - radius; int tRightXBound = tLeftXBound + 2*radius; @@ -178,7 +195,7 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba prospectHole(i, k, aMiddleOres); else prospectHole(i, k, aFarOres); - } + } } private void prospectHole( @@ -186,7 +203,7 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba String tFoundOre = null; for (int j = this.getBaseMetaTileEntity().getYCoord(); j > 0; j--) { - tFoundOre = checkForOre(i, j, k); + tFoundOre = checkForOre(i, j, k); if (tFoundOre == null) continue;