aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2021-08-19 14:27:10 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2021-08-19 14:27:10 +0200
commit80ef1d055cd685bf6dc643a2f51354d91f227862 (patch)
tree669cc5fcd701981611d59dc989f1f830de3ed17c /src/main
parentc8a767d0125dec4a1cc3d9fecddcb4aa3a45c301 (diff)
downloadNotEnoughUpdates-80ef1d055cd685bf6dc643a2f51354d91f227862.tar.gz
NotEnoughUpdates-80ef1d055cd685bf6dc643a2f51354d91f227862.tar.bz2
NotEnoughUpdates-80ef1d055cd685bf6dc643a2f51354d91f227862.zip
using less accurate calculations to have a higher probability of finding it even with some calculation errors
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java
index 62f47787..a21673da 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java
@@ -24,7 +24,7 @@ public class CrystalMetalDetectorSolver {
if (possibleBlocks.size() == 0) {
locations.add(mc.thePlayer.getPosition());
for (int zOffset = (int) Math.floor(-dist); zOffset <= Math.ceil(dist); zOffset++) {
- for (int yOffset = 65; yOffset <= 69; yOffset++) {
+ for (int yOffset = 65; yOffset <= 70; yOffset++) {
float calculatedDist = 0;
int xOffset = 0;
while (calculatedDist < dist) {
@@ -33,10 +33,11 @@ public class CrystalMetalDetectorSolver {
BlockPos above = new BlockPos(Math.floor(mc.thePlayer.posX) + xOffset,
yOffset + 1, Math.floor(mc.thePlayer.posZ) + zOffset);
xOffset++;
- calculatedDist = round(calculateDistance(new Vec3(pos).addVector(0, 1d, 0), new Vec3(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ)), 1);
- if (calculatedDist == dist && treasureAllowed(pos) && !possibleBlocks.contains(pos) &&
+ calculatedDist = calculateDistance(new Vec3(pos).addVector(0, 1d, 0), new Vec3(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ));
+ if (inRange(calculatedDist, dist) && treasureAllowed(pos) && !possibleBlocks.contains(pos) &&
mc.theWorld.getBlockState(above).getBlock().getRegistryName().equals("minecraft:air")) {
possibleBlocks.add(pos);
+ System.out.println(calculatedDist);
}
xOffset++;
}
@@ -47,16 +48,16 @@ public class CrystalMetalDetectorSolver {
yOffset, Math.floor(mc.thePlayer.posZ) + zOffset);
BlockPos above = new BlockPos(Math.floor(mc.thePlayer.posX) - xOffset,
yOffset + 1, Math.floor(mc.thePlayer.posZ) + zOffset);
- calculatedDist = round(calculateDistance(new Vec3(pos).addVector(0, 1d, 0), new Vec3(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ)), 1);
- if (calculatedDist == dist && treasureAllowed(pos) && !possibleBlocks.contains(pos) &&
+ calculatedDist = calculateDistance(new Vec3(pos).addVector(0, 1d, 0), new Vec3(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ));
+ if (inRange(calculatedDist, dist) && treasureAllowed(pos) && !possibleBlocks.contains(pos) &&
mc.theWorld.getBlockState(above).getBlock().getRegistryName().equals("minecraft:air")) {
possibleBlocks.add(pos);
+ System.out.println(calculatedDist);
}
xOffset++;
}
}
}
- if (possibleBlocks.size() == 1) possibleBlocks.clear(); //protection from completely wrong things
sendMessage();
} else if (possibleBlocks.size() != 1) {
locations.add(mc.thePlayer.getPosition());
@@ -66,6 +67,14 @@ public class CrystalMetalDetectorSolver {
temp.add(pos);
}
}
+ if(temp.size() == 0){
+ for (BlockPos pos : possibleBlocks) {
+ if (inRange(calculateDistance(new Vec3(pos).addVector(0, 1d, 0), new Vec3(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ)), dist)) {
+ temp.add(pos);
+ mc.thePlayer.addChatMessage(new ChatComponentText("Less accurate calculation"));
+ }
+ }
+ }
possibleBlocks = temp;
sendMessage();
}
@@ -122,4 +131,8 @@ public class CrystalMetalDetectorSolver {
private static float calculateDistance(Vec3 pos1, Vec3 pos2) {
return (float) Math.sqrt(Math.pow(pos2.xCoord - pos1.xCoord, 2) + Math.pow(pos2.yCoord - pos1.yCoord, 2) + Math.pow(pos2.zCoord - pos1.zCoord, 2));
}
+
+ private static boolean inRange(float number, float dist) {
+ return dist + 0.1D >= number && dist - 0.1D <= number;
+ }
}