diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java | 10 | ||||
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java | 24 |
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); } |