aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorDoKM <54663875+DoKM@users.noreply.github.com>2021-08-20 20:49:41 +0200
committerGitHub <noreply@github.com>2021-08-20 20:49:41 +0200
commit9bdf107725ec331d0acb24a53ad3708547bfdb06 (patch)
tree3999215700cec982da78456803e815dfb8e7c590 /src/main
parent45005ca693c7b43ff7eedd509b0b4a784cedd9f1 (diff)
parent9ae27a4748cce4713d7cdd3ac56776387be04b52 (diff)
downloadNotEnoughUpdates-9bdf107725ec331d0acb24a53ad3708547bfdb06.tar.gz
NotEnoughUpdates-9bdf107725ec331d0acb24a53ad3708547bfdb06.tar.bz2
NotEnoughUpdates-9bdf107725ec331d0acb24a53ad3708547bfdb06.zip
Merge pull request #21 from DeDiamondPro/master
bug fixes
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java10
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java24
2 files changed, 10 insertions, 24 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
index 2975115c..80fc0667 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
@@ -799,11 +799,11 @@ public class NEUManager {
}
public void showRecipe(JsonObject item) {
- if (item.has("recipe") && Minecraft.getMinecraft().thePlayer.openContainer instanceof ContainerChest) {
- ContainerChest container = (ContainerChest) Minecraft.getMinecraft().thePlayer.openContainer;
- if (container.getLowerChestInventory().getDisplayName().getUnformattedText().equals("Craft Item")) {
- CraftingOverlay.updateItem(item);
- }
+ ContainerChest container = null;
+ if(Minecraft.getMinecraft().thePlayer.openContainer instanceof ContainerChest)
+ container = (ContainerChest) Minecraft.getMinecraft().thePlayer.openContainer;
+ if (item.has("recipe") && container != null && container.getLowerChestInventory().getDisplayName().getUnformattedText().equals("Craft Item")) {
+ CraftingOverlay.updateItem(item);
} else if(item.has("useneucraft") && item.get("useneucraft").getAsBoolean()) {
displayGuiItemRecipe(item.get("internalname").getAsString(), "");
} else if(item.has("clickcommand")) {
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 c6ad2ef1..357d8326 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java
@@ -34,9 +34,8 @@ public class CrystalMetalDetectorSolver {
y, Math.floor(mc.thePlayer.posZ) + zOffset);
BlockPos above = new BlockPos(Math.floor(mc.thePlayer.posX) + xOffset,
y + 1, Math.floor(mc.thePlayer.posZ) + zOffset);
- xOffset++;
- calculatedDist = getPlayerPos().distanceTo(new Vec3(pos).addVector(0D,1D,0D));
- if (inRange(calculatedDist, dist) && treasureAllowed(pos) && !possibleBlocks.contains(pos) &&
+ calculatedDist = getPlayerPos().distanceTo(new Vec3(pos).addVector(0D, 1D, 0D));
+ if (round(calculatedDist, 1) == dist && treasureAllowed(pos) && !possibleBlocks.contains(pos) &&
mc.theWorld.getBlockState(above).getBlock().getRegistryName().equals("minecraft:air")) {
possibleBlocks.add(pos);
}
@@ -49,8 +48,8 @@ public class CrystalMetalDetectorSolver {
y, Math.floor(mc.thePlayer.posZ) + zOffset);
BlockPos above = new BlockPos(Math.floor(mc.thePlayer.posX) - xOffset,
y + 1, Math.floor(mc.thePlayer.posZ) + zOffset);
- calculatedDist = getPlayerPos().distanceTo(new Vec3(pos).addVector(0D,1D,0D));
- if (inRange(calculatedDist, dist) && treasureAllowed(pos) && !possibleBlocks.contains(pos) &&
+ calculatedDist = getPlayerPos().distanceTo(new Vec3(pos).addVector(0D, 1D, 0D));
+ if (round(calculatedDist, 1) == dist && treasureAllowed(pos) && !possibleBlocks.contains(pos) &&
mc.theWorld.getBlockState(above).getBlock().getRegistryName().equals("minecraft:air")) {
possibleBlocks.add(pos);
}
@@ -63,18 +62,10 @@ public class CrystalMetalDetectorSolver {
locations.add(mc.thePlayer.getPosition());
List<BlockPos> temp = new ArrayList<>();
for (BlockPos pos : possibleBlocks) {
- if (round(getPlayerPos().distanceTo(new Vec3(pos).addVector(0D,1D,0D)), 1)
- == dist) {
+ if (round(getPlayerPos().distanceTo(new Vec3(pos).addVector(0D, 1D, 0D)), 1) == dist) {
temp.add(pos);
}
}
- if (temp.size() == 0) {
- for (BlockPos pos : possibleBlocks) {
- if (inRange(getPlayerPos().distanceTo(new Vec3(pos).addVector(0D,1D,0D)), dist)) {
- temp.add(pos);
- }
- }
- }
possibleBlocks = temp;
sendMessage();
}
@@ -128,11 +119,6 @@ public class CrystalMetalDetectorSolver {
}
}
-
- private static boolean inRange(double number, double dist) {
- return dist + 0.1D >= number && dist - 0.1D <= number;
- }
-
private static Vec3 getPlayerPos() {
return new Vec3(mc.thePlayer.posX, mc.thePlayer.posY + (mc.thePlayer.getEyeHeight() - mc.thePlayer.getDefaultEyeHeight()), mc.thePlayer.posZ);
}