aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_AdvSeismicProspector.java51
1 files changed, 19 insertions, 32 deletions
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 5c0e2cbf25..46ea555ad0 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
@@ -103,12 +103,12 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba
this.ready = false;
// prospecting ores
- HashMap<String, Integer> tOres = new HashMap<String, Integer>(36);
+ HashMap<String, Integer> tOres = new HashMap<>(36);
prospectOres(tOres);
// prospecting oils
- ArrayList<String> tOils = new ArrayList<String>();
+ ArrayList<String> tOils = new ArrayList<>();
prospectOils(tOils);
GT_Utility.ItemNBT.setAdvancedProspectionData(mTier,
@@ -128,30 +128,31 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba
private void prospectOils(ArrayList<String> aOils) {
- FluidStack tFluid;
-
- Chunk tChunk = getBaseMetaTileEntity().getWorld().getChunkFromBlockCoords(getBaseMetaTileEntity().getXCoord(), getBaseMetaTileEntity().getZCoord());
- int oilfieldSize = 8;
- int xChunk = Math.floorDiv(tChunk.xPosition , oilfieldSize) * oilfieldSize - ((tChunk.xPosition < 0 && tChunk.xPosition % oilfieldSize != 0) ? oilfieldSize : 0);
- int zChunk = Math.floorDiv(tChunk.zPosition , oilfieldSize) * oilfieldSize - ((tChunk.zPosition < 0 && tChunk.zPosition % oilfieldSize != 0) ? oilfieldSize : 0);
+ int xChunk = (getBaseMetaTileEntity().getXCoord() >> 7) << 3; // oil field aligned chunk coords
+ int zChunk = (getBaseMetaTileEntity().getZCoord() >> 7) << 3;
LinkedHashMap<ChunkCoordIntPair, FluidStack> tFluids = new LinkedHashMap<>();
int oilFieldCount = 0;
try {
+ final int oilfieldSize = 8;
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<>();
+ ChunkCoordIntPair cInts = new ChunkCoordIntPair(x, z);
+ int min = Integer.MAX_VALUE;
+ int max = Integer.MIN_VALUE;
for (int i = 0; i < oilfieldSize; i++) {
for (int j = 0; j < oilfieldSize; j++) {
- tChunk = getBaseMetaTileEntity().getWorld().getChunkFromChunkCoords(
+ Chunk tChunk = getBaseMetaTileEntity().getWorld().getChunkFromChunkCoords(
xChunk + i + x * oilfieldSize,
zChunk + j + z * oilfieldSize);
- tFluid = undergroundOilReadInformation(tChunk);
+ FluidStack tFluid = undergroundOilReadInformation(tChunk);
if (tFluid != null) {
- minMaxValue.add(tFluid.amount);
+ if (tFluid.amount > max)
+ max = tFluid.amount;
+ if (tFluid.amount < min)
+ min = tFluid.amount;
if (!tFluids.containsKey(cInts)) {
tFluids.put(cInts, tFluid);
}
@@ -159,20 +160,12 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba
}
}
- int min = Collections.min(minMaxValue);
- int max = Collections.max(minMaxValue);
aOils.add(++oilFieldCount + "," + min + "-" + max + "," + tFluids.get(cInts).getLocalizedName());
}
}
- } catch (Exception e) {/*Do nothing*/}
+ } catch (Exception ignored) {}
}
- //private void putOil(int x, int z, HashMap<String, Integer> aOils) {//TODO Old method??
- // FluidStack tFluid = GT_Utility.undergroundOil(getBaseMetaTileEntity().getWorld(),x,z,false,0);
- // if (tFluid.amount / 5000 > 0)
- // aOils.put(x + "," + z + "," + (tFluid.amount / 5000) + "," + tFluid.getLocalizedName(), tFluid.amount / 5000);
- //}
-
private void prospectOres(Map<String, Integer> aOres) {
int tLeftXBound = this.getBaseMetaTileEntity().getXCoord() - radius;
int tRightXBound = tLeftXBound + 2*radius;
@@ -181,20 +174,14 @@ public class GT_MetaTileEntity_AdvSeismicProspector extends GT_MetaTileEntity_Ba
int tRightZBound = tLeftZBound + 2*radius;
for (int i = tLeftXBound; i <= tRightXBound; i += step) {
- if ( (Math.abs(i)/16-1)%3!=0 ) {
+ if (Math.abs(i >> 4) % 3 != 1)
continue;
- }
for (int k = tLeftZBound; k <= tRightZBound; k += step) {
- if ( (Math.abs(k)/16-1)%3!=0 ) {
+ if (Math.abs(k >> 4) % 3 != 1)
continue;
- }
-
- int di = Math.abs(i - this.getBaseMetaTileEntity().getXCoord());
- int dk = Math.abs(k - this.getBaseMetaTileEntity().getZCoord());
-
- cX = (Math.floorDiv(i,16))*16;
- cZ = (Math.floorDiv(k,16))*16;
+ cX = (i >> 4) << 4;
+ cZ = (k >> 4) << 4;
String separator = (cX +8)+ "," + (cZ + 8) + " --------";
aOres.put(separator, 1);