aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech')
-rw-r--r--src/main/java/gregtech/api/util/GT_Utility.java45
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_AdvSeismicProspector.java100
2 files changed, 98 insertions, 47 deletions
diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java
index fa7d96d0d6..c6a8a6ee65 100644
--- a/src/main/java/gregtech/api/util/GT_Utility.java
+++ b/src/main/java/gregtech/api/util/GT_Utility.java
@@ -1940,8 +1940,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>>()
@@ -2118,8 +2117,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);
@@ -2141,7 +2141,7 @@ public class GT_Utility {
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("§nProspection Data §rFrom: X" + tDataArray[0] + " Z:" + tDataArray[2] + " Dim:" + tDataArray[3] + " Produces " + tDataArray[4] + "L " + tDataArray[5] + " " + tOres));
tNBT.setTag("pages", tNBTList);
}
setNBT(aStack, tNBT);
@@ -2161,7 +2161,7 @@ public class GT_Utility {
NBTTagList tNBTList = new NBTTagList();
- String tPageText = "Advanced prospection\n"
+ String tPageText = "§nAdvanced prospection§r\n\n"
+ tPos + "\n"
+ "Results:\n"
+ "- Close Range Ores: " + (tNearOres != null ? tNearOres.length : 0) + "\n"
@@ -2170,20 +2170,35 @@ 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);
+ fillBookWithList(tNBTList, "§nClose Range Ores§r%s\n\n", ", ", 20, tNearOres);
if (tMiddleOres != null)
- fillBookWithList(tNBTList, "Mid Range Ores%s\n\n", ", ", 20, tMiddleOres);
+ fillBookWithList(tNBTList, "§nMid Range Ores§r%s\n\n", ", ", 20, tMiddleOres);
if (tFarOres != null)
- fillBookWithList(tNBTList, "Far Range Ores%s\n\n", ", ", 20, tFarOres);
+ fillBookWithList(tNBTList, "§nFar Range Ores§r%s\n\n", ", ", 20, tFarOres);
+
+ tPageText = "§nOre notes§r\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]§2[C]§0[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];
+ fillBookWithList(tNBTList, "§nOils§r%s\n\n", "\n", 9, tOils);
+
+ tPageText = "§nOil notes§r\n\n"
+ + "[1][2][3]" + "\n"
+ + "[4]§2[5]§0[6]" + "\n"
+ + "[7][8][9]" + "\n"
+ + "\n"
+ + "§2[5]§0 — 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 3099959501..f91be2e4d3 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
@@ -1,5 +1,6 @@
package gregtech.common.tileentities.machines.basic;
+import static gregtech.common.GT_UndergroundOil.undergroundOilReadInformation;
import gregtech.api.GregTech_API;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Materials;
@@ -10,6 +11,7 @@ import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.objects.ItemData;
+import gregtech.api.util.GT_Log;
import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Utility;
import gregtech.common.GT_UndergroundOil;
@@ -24,25 +26,30 @@ 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.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
+import net.minecraft.world.*;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_BasicMachine {
+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<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
@@ -62,6 +69,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);
@@ -109,7 +126,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,
@@ -118,7 +135,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),
@@ -129,36 +146,55 @@ 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 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<>();
+ HashMap<Integer, FluidStack> tFluids = new HashMap<>();
+ ArrayList<String> minmax = new ArrayList<>();
+ int cInts = 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 (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 x = -1; x < 2; ++x) {
+ for (int z = -1; z < 2; ++z) {
+ int min = 1000;
+ int max = 0;
+
+ for (int i = 0; i < range; i++) {
+ for (int j = 0; j < range; j++) {
+ tChunk = getBaseMetaTileEntity().getWorld().getChunkFromChunkCoords(xChunk + i + z * 6, zChunk + j + x * 6);
+ tFluid = undergroundOilReadInformation(tChunk);
+ if (tFluid != null) {
+ if (max < tFluid.amount)
+ max = tFluid.amount;
+ if (min > tFluid.amount)
+ min = tFluid.amount;
+
+ if (tFluids.containsKey(cInts)) {
+ if (tFluids.get(cInts).amount < tFluid.amount)
+ tFluids.get(cInts).amount = tFluid.amount;
+ } else tFluids.put(cInts, tFluid);
+ }
+ }
+ }
+ cInts++;
+ minmax.add(min + "-" + max);
+ }
+ }
+
+ int i = 0;
+ for (Map.Entry<Integer, FluidStack> fl : tFluids.entrySet()) {
+ aOils.add(i + 1 + "," + minmax.get(i) + "," + fl.getValue().getLocalizedName());
+ i++;
+ }
+ } catch (Exception e) {
+
+ }
}
//private void putOil(int x, int z, HashMap<String, Integer> aOils) {//TODO Old method??