aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorMartin Robertz <dream-master@gmx.net>2018-03-23 06:06:02 +0100
committerGitHub <noreply@github.com>2018-03-23 06:06:02 +0100
commit22760d22fefc8f1359db21f358f11374bc63608d (patch)
tree1638c3a7ea0102f687f168072cd5167f05626c98 /src/main/java
parent54e94138da2bdc73ec69e94badfa2ea65f6c4162 (diff)
parentcef4048c9e8d19ff0791705ed382f7559344aa42 (diff)
downloadGT5-Unofficial-22760d22fefc8f1359db21f358f11374bc63608d.tar.gz
GT5-Unofficial-22760d22fefc8f1359db21f358f11374bc63608d.tar.bz2
GT5-Unofficial-22760d22fefc8f1359db21f358f11374bc63608d.zip
Merge pull request #109 from codewarrior0/adv-seismic-prospector-buffs
[WIP] Adv seismic prospector buffs
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/gregtech/api/util/GT_Utility.java34
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_AdvSeismicProspector.java97
2 files changed, 77 insertions, 54 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..8a1a7feb3d 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);
@@ -2161,7 +2161,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"
@@ -2170,20 +2170,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 3099959501..a040d1cf17 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,14 +22,15 @@ 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 {
+
+public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_BasicMachine {
boolean ready = false;
int radius;
int near;
@@ -39,10 +39,7 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba
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,13 +59,14 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba
step = aStep;
}
- 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);
- radius = aRadius;
- near = aNear;
- middle = aMiddle;
- 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,
@@ -109,7 +107,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 +116,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 +127,45 @@ 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 oilfieldSize = 8;
+ int xChunk = (tChunk.xPosition / oilfieldSize) * oilfieldSize - ((tChunk.xPosition < 0 && tChunk.xPosition % oilfieldSize != 0) ? oilfieldSize : 0);
+ int zChunk = (tChunk.zPosition / oilfieldSize) * oilfieldSize - ((tChunk.zPosition < 0 && tChunk.zPosition % oilfieldSize != 0) ? oilfieldSize : 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 (int i = 0; i < oilfieldSize; i++) {
+ for (int j = 0; j < oilfieldSize; j++) {
+ tChunk = getBaseMetaTileEntity().getWorld().getChunkFromChunkCoords(
+ xChunk + i + x * oilfieldSize,
+ zChunk + j + z * oilfieldSize);
+ 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<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
- }
+ }
+ } catch (Exception e) {/*Do nothing*/}
}
//private void putOil(int x, int z, HashMap<String, Integer> aOils) {//TODO Old method??
@@ -167,7 +174,7 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba
// aOils.put(x + "," + z + "," + (tFluid.amount / 5000) + "," + tFluid.getLocalizedName(), tFluid.amount / 5000);
//}
- private void prospectOres(Map<String, Integer> aNearOres, Map<String, Integer> aMiddleOres, Map<String, Integer> aFarOres) {
+ private void prospectOres(Map<String, Integer> aNearOres, Map<String, Integer> aMiddleOres, Map<String, Integer> aFarOres) {
int tLeftXBound = this.getBaseMetaTileEntity().getXCoord() - radius;
int tRightXBound = tLeftXBound + 2*radius;
@@ -185,13 +192,13 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba
prospectHole(i, k, aMiddleOres);
else
prospectHole(i, k, aFarOres);
- }
+ }
}
private void prospectHole(int i, int k, Map<String, Integer> aOres) {
String tFoundOre;
for (int j = this.getBaseMetaTileEntity().getYCoord(); j > 0; j--) {
- tFoundOre = checkForOre(i, j, k);
+ tFoundOre = checkForOre(i, j, k);
if (tFoundOre != null)
countOre(aOres, tFoundOre);
}