aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbowser0000 <bowser0000@gmail.com>2020-10-27 18:04:26 -0400
committerbowser0000 <bowser0000@gmail.com>2020-10-27 18:04:26 -0400
commite37d0ebbabaa5b9387cf056228a9aa58479f78e1 (patch)
tree0087311704fe937eb4846a228c3245bf604f6df7
parentd4f348736c7144dcf109b4182134d84276e58d58 (diff)
downloadSkyblockMod-e37d0ebbabaa5b9387cf056228a9aa58479f78e1.tar.gz
SkyblockMod-e37d0ebbabaa5b9387cf056228a9aa58479f78e1.tar.bz2
SkyblockMod-e37d0ebbabaa5b9387cf056228a9aa58479f78e1.zip
Add experimental creeper puzzle solver
-rw-r--r--README.md2
-rw-r--r--src/main/java/me/Danker/TheMod.java57
-rw-r--r--src/main/java/me/Danker/commands/DHelpCommand.java2
-rw-r--r--src/main/java/me/Danker/commands/ToggleCommand.java16
-rw-r--r--src/main/java/me/Danker/gui/PuzzleSolversGui.java7
-rw-r--r--src/main/java/me/Danker/handlers/ConfigHandler.java2
-rw-r--r--src/main/java/me/Danker/utils/Utils.java75
7 files changed, 152 insertions, 9 deletions
diff --git a/README.md b/README.md
index 3169eb0..d508797 100644
--- a/README.md
+++ b/README.md
@@ -22,7 +22,7 @@ Discord Server: https://discord.gg/QsEkNQS
- Fishing tracker (with graphic display) (scalable)
- Expertise kills in fishing rod lore
- Dungeons tracker (with graphic display) (scalable)
-- Dungeons puzzle solver (Riddle, trivia, blaze) (toggleable)
+- Dungeons puzzle solver (Riddle, trivia, blaze, creeper) (toggleable)
- Pet background colors based on level
- Golem spawning alerts (toggleable)
- Show total skill xp instead of progress to next level
diff --git a/src/main/java/me/Danker/TheMod.java b/src/main/java/me/Danker/TheMod.java
index 9f19c97..5ff57e6 100644
--- a/src/main/java/me/Danker/TheMod.java
+++ b/src/main/java/me/Danker/TheMod.java
@@ -5,6 +5,7 @@ import java.awt.SystemTray;
import java.awt.Toolkit;
import java.awt.TrayIcon;
import java.text.NumberFormat;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
@@ -50,14 +51,17 @@ import me.Danker.handlers.PacketHandler;
import me.Danker.handlers.ScoreboardHandler;
import me.Danker.handlers.TextRenderer;
import me.Danker.utils.Utils;
+import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.Entity;
+import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.event.ClickEvent;
import net.minecraft.event.ClickEvent.Action;
+import net.minecraft.init.Blocks;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ContainerChest;
import net.minecraft.inventory.IInventory;
@@ -70,6 +74,7 @@ import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IChatComponent;
import net.minecraft.util.StringUtils;
+import net.minecraft.util.Vec3;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.client.event.GuiScreenEvent;
@@ -122,8 +127,13 @@ public class TheMod
"My chest doesn't have the reward. We are all telling the truth", "My chest has the reward and I'm telling the truth",
"The reward isn't in any of our chests", "Both of them are telling the truth."};
static Map<String, String> triviaSolutions = new HashMap<String, String>();
- Entity highestBlaze = null;
- Entity lowestBlaze = null;
+ static Entity highestBlaze = null;
+ static Entity lowestBlaze = null;
+ // Among Us colours
+ static int[] creeperLineColours = {0x50EF39, 0xC51111, 0x132ED1, 0x117F2D, 0xED54BA, 0xEF7D0D, 0xF5F557, 0xD6E0F0, 0x6B2FBB, 0x39FEDC};
+ static boolean drawCreeperLines = false;
+ static Vec3 creeperLocation = new Vec3(0, 0, 0);
+ static List<Vec3[]> creeperLines = new ArrayList<Vec3[]>();
static double dungeonStartTime = 0;
static double bloodOpenTime = 0;
@@ -195,6 +205,7 @@ public class TheMod
triviaSolutions.put("How many Fairy Souls are there in Blazing Fortress?", "19 Fairy Souls");
triviaSolutions.put("How many Fairy Souls are there in The Park?", "11 Fairy Souls");
triviaSolutions.put("How many Fairy Souls are there in Jerry's Workshop?", "5 Fairy Souls");
+ triviaSolutions.put("How many Fairy Souls are there in Hub?", "79 Fairy Souls");
triviaSolutions.put("How many Fairy Souls are there in The Hub?", "79 Fairy Souls");
triviaSolutions.put("How many Fairy Souls are there in Deep Caverns?", "21 Fairy Souls");
triviaSolutions.put("How many Fairy Souls are there in Gold Mine?", "12 Fairy Souls");
@@ -1927,6 +1938,43 @@ public class TheMod
ConfigHandler.writeStringConfig("misc", "display", DisplayCommand.display);
}
+ if (ToggleCommand.creeperToggled && Utils.inDungeons && mc.theWorld != null) {
+ double x = player.posX;
+ double y = player.posY;
+ double z = player.posZ;
+ // Find creepers nearby
+ AxisAlignedBB creeperScan = new AxisAlignedBB(x - 14, y - 8, z - 13, x + 14, y + 8, z + 13); // 28x16x26 cube
+ List<EntityCreeper> creepers = mc.theWorld.getEntitiesWithinAABB(EntityCreeper.class, creeperScan);
+ // Check if creeper is nearby
+ if (creepers.size() > 0) {
+ EntityCreeper creeper = creepers.get(0);
+ // Start creeper line drawings
+ creeperLines.clear();
+ if (!drawCreeperLines) creeperLocation = new Vec3(creeper.posX, creeper.posY + 1, creeper.posZ);
+ drawCreeperLines = true;
+ // Search for nearby sea lanterns and prismarine blocks
+ BlockPos point1 = new BlockPos(creeper.posX - 14, creeper.posY - 7, creeper.posZ - 13);
+ BlockPos point2 = new BlockPos(creeper.posX + 14, creeper.posY + 10, creeper.posZ + 13);
+ Iterable<BlockPos> blocks = BlockPos.getAllInBox(point1, point2);
+ for (BlockPos blockPos : blocks) {
+ Block block = mc.theWorld.getBlockState(blockPos).getBlock();
+ if (block == Blocks.sea_lantern || block == Blocks.prismarine) {
+ // Connect block to nearest block on opposite side
+ Vec3 startBlock = new Vec3(blockPos.getX() + 0.5, blockPos.getY() + 0.5, blockPos.getZ() + 0.5);
+ BlockPos oppositeBlock = Utils.getFirstBlockPosAfterVectors(mc, startBlock, creeperLocation, 10, 20);
+ BlockPos endBlock = Utils.getNearbyBlock(mc, oppositeBlock, Blocks.sea_lantern, Blocks.prismarine);
+ if (endBlock != null) {
+ // Add to list for drawing
+ Vec3[] insertArray = {startBlock, new Vec3(endBlock.getX() + 0.5, endBlock.getY() + 0.5, endBlock.getZ() + 0.5)};
+ creeperLines.add(insertArray);
+ }
+ }
+ }
+ } else {
+ drawCreeperLines = false;
+ }
+ }
+
tickAmount = 0;
}
@@ -2011,6 +2059,11 @@ public class TheMod
Utils.draw3DBox(aabb, 0x00, 0xFF, 0x00, 0xFF, event.partialTicks);
}
}
+ if (ToggleCommand.creeperToggled && drawCreeperLines && !creeperLines.isEmpty()) {
+ for (int i = 0; i < creeperLines.size(); i++) {
+ Utils.draw3DLine(creeperLines.get(i)[0], creeperLines.get(i)[1], creeperLineColours[i % 10], event.partialTicks);
+ }
+ }
}
@SubscribeEvent
diff --git a/src/main/java/me/Danker/commands/DHelpCommand.java b/src/main/java/me/Danker/commands/DHelpCommand.java
index 1ed931f..bf6ed7f 100644
--- a/src/main/java/me/Danker/commands/DHelpCommand.java
+++ b/src/main/java/me/Danker/commands/DHelpCommand.java
@@ -34,7 +34,7 @@ public class DHelpCommand extends CommandBase {
EnumChatFormatting.GOLD + " Commands, " + EnumChatFormatting.GREEN + " Keybinds.\n" +
EnumChatFormatting.GOLD + " /dhelp" + EnumChatFormatting.AQUA + " - Returns this message.\n" +
EnumChatFormatting.GOLD + " /dsm" + EnumChatFormatting.AQUA + " - Opens the GUI for Danker's Skyblock Mod.\n" +
- EnumChatFormatting.GOLD + " /toggle <gparty/coords/golden/slayercount/rngesusalerts/splitfishing/chatmaddox/spiritbearalerts/aotd/lividdagger/sceptremessages/petcolors/dungeontimer/golemalerts/expertiselore/skill50display/outlinetext/threemanpuzzle/oruopuzzle/blazepuzzle/list>" + EnumChatFormatting.AQUA + " - Toggles features. /toggle list returns values of every toggle.\n" +
+ EnumChatFormatting.GOLD + " /toggle <gparty/coords/golden/slayercount/rngesusalerts/splitfishing/chatmaddox/spiritbearalerts/aotd/lividdagger/sceptremessages/petcolors/dungeontimer/golemalerts/expertiselore/skill50display/outlinetext/threemanpuzzle/oruopuzzle/blazepuzzle/creeperpuzzle/list>" + EnumChatFormatting.AQUA + " - Toggles features. /toggle list returns values of every toggle.\n" +
EnumChatFormatting.GOLD + " /setkey <key>" + EnumChatFormatting.AQUA + " - Sets API key.\n" +
EnumChatFormatting.GOLD + " /getkey" + EnumChatFormatting.AQUA + " - Returns key set with /setkey and copies it to your clipboard.\n" +
EnumChatFormatting.GOLD + " /loot <zombie/spider/wolf/fishing/catacombs> [winter/f(1-6)/session]" + EnumChatFormatting.AQUA + " - Returns loot received from slayer quests or fishing stats. /loot fishing winter returns winter sea creatures instead.\n" +
diff --git a/src/main/java/me/Danker/commands/ToggleCommand.java b/src/main/java/me/Danker/commands/ToggleCommand.java
index 71dc6ac..39f1093 100644
--- a/src/main/java/me/Danker/commands/ToggleCommand.java
+++ b/src/main/java/me/Danker/commands/ToggleCommand.java
@@ -34,6 +34,7 @@ public class ToggleCommand extends CommandBase implements ICommand {
public static boolean threeManToggled;
public static boolean oruoToggled;
public static boolean blazeToggled;
+ public static boolean creeperToggled;
@Override
public String getCommandName() {
@@ -44,7 +45,7 @@ public class ToggleCommand extends CommandBase implements ICommand {
public String getCommandUsage(ICommandSender arg0) {
return "/" + getCommandName() + " <gparty/coords/golden/slayercount/rngesusalerts/splitfishing/chatmaddox/spiritbearalert/" +
"aotd/lividdagger/sceptremessages/petcolors/dungeontimer/golemalerts/expertiselore/skill50display/" +
- "outlinetext/threemanpuzzle/oruopuzzle/blazepuzzle/list>";
+ "outlinetext/threemanpuzzle/oruopuzzle/blazepuzzle/creeperpuzzle/list>";
}
@Override
@@ -59,7 +60,7 @@ public class ToggleCommand extends CommandBase implements ICommand {
"splitfishing", "chatmaddox", "spiritbearalerts", "aotd", "lividdagger",
"sceptremessages", "petcolors", "dungeontimer", "golemalerts",
"expertiselore", "skill50display", "outlinetext", "threemanpuzzle",
- "oruopuzzle", "blazepuzzle", "list");
+ "oruopuzzle", "blazepuzzle", "creeperpuzzle", "list");
}
return null;
}
@@ -149,11 +150,15 @@ public class ToggleCommand extends CommandBase implements ICommand {
} else if (arg1[0].equalsIgnoreCase("oruopuzzle")) {
oruoToggled = !oruoToggled;
cf.writeBooleanConfig("toggles", "OruoPuzzle", oruoToggled);
- player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Oruo trivia solver has been set to " + EnumChatFormatting.DARK_GREEN + threeManToggled + EnumChatFormatting.GREEN + "."));
+ player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Oruo trivia solver has been set to " + EnumChatFormatting.DARK_GREEN + oruoToggled + EnumChatFormatting.GREEN + "."));
} else if (arg1[0].equalsIgnoreCase("blazepuzzle")) {
blazeToggled = !blazeToggled;
cf.writeBooleanConfig("toggles", "BlazePuzzle", blazeToggled);
- player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Blaze puzzle solver has been set to " + EnumChatFormatting.DARK_GREEN + threeManToggled + EnumChatFormatting.GREEN + "."));
+ player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Blaze puzzle solver has been set to " + EnumChatFormatting.DARK_GREEN + blazeToggled + EnumChatFormatting.GREEN + "."));
+ } else if (arg1[0].equalsIgnoreCase("creeperpuzzle")) {
+ creeperToggled = !creeperToggled;
+ cf.writeBooleanConfig("creeperpuzzle", "CreeperPuzzle", creeperToggled);
+ player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Creeper puzzle solver has been set to " + EnumChatFormatting.DARK_GREEN + creeperToggled + EnumChatFormatting.GREEN + "."));
} else if (arg1[0].equalsIgnoreCase("list")) {
player.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Guild party notifications: " + EnumChatFormatting.DARK_GREEN + gpartyToggled + "\n" +
EnumChatFormatting.GREEN + " Coord/Angle display: " + EnumChatFormatting.DARK_GREEN + coordsToggled + "\n" +
@@ -174,7 +179,8 @@ public class ToggleCommand extends CommandBase implements ICommand {
EnumChatFormatting.GREEN + " Outline displayed text: " + EnumChatFormatting.DARK_GREEN + outlineTextToggled + "\n" +
EnumChatFormatting.GREEN + " Three man puzzle solver: " + EnumChatFormatting.DARK_GREEN + threeManToggled + "\n" +
EnumChatFormatting.GREEN + " Oruo trivia solver: " + EnumChatFormatting.DARK_GREEN + oruoToggled + "\n" +
- EnumChatFormatting.GREEN + " Blaze puzzle solver: " + EnumChatFormatting.DARK_GREEN + blazeToggled));
+ EnumChatFormatting.GREEN + " Blaze puzzle solver: " + EnumChatFormatting.DARK_GREEN + blazeToggled + "\n" +
+ EnumChatFormatting.GREEN + " Creeper puzzle solver: " + EnumChatFormatting.DARK_GREEN + creeperToggled));
} else {
player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Usage: " + getCommandUsage(arg0)));
}
diff --git a/src/main/java/me/Danker/gui/PuzzleSolversGui.java b/src/main/java/me/Danker/gui/PuzzleSolversGui.java
index 8fbc32e..e2fa4ef 100644
--- a/src/main/java/me/Danker/gui/PuzzleSolversGui.java
+++ b/src/main/java/me/Danker/gui/PuzzleSolversGui.java
@@ -15,6 +15,7 @@ public class PuzzleSolversGui extends GuiScreen {
private GuiButton riddle;
private GuiButton trivia;
private GuiButton blaze;
+ private GuiButton creeper;
@Override
public boolean doesGuiPauseGame() {
@@ -33,11 +34,13 @@ public class PuzzleSolversGui extends GuiScreen {
riddle = new GuiButton(0, width / 2 - 100, (int) (height * 0.1), "Riddle Solver: " + Utils.getColouredBoolean(ToggleCommand.threeManToggled));
trivia = new GuiButton(0, width / 2 - 100, (int) (height * 0.2), "Trivia Solver: " + Utils.getColouredBoolean(ToggleCommand.oruoToggled));
blaze = new GuiButton(0, width / 2 - 100, (int) (height * 0.3), "Blaze Solver: " + Utils.getColouredBoolean(ToggleCommand.blazeToggled));
+ creeper = new GuiButton(0, width / 2 - 100, (int) (height * 0.4), "Creeper Solver : " + Utils.getColouredBoolean(ToggleCommand.creeperToggled));
this.buttonList.add(goBack);
this.buttonList.add(riddle);
this.buttonList.add(trivia);
this.buttonList.add(blaze);
+ this.buttonList.add(creeper);
}
@Override
@@ -62,6 +65,10 @@ public class PuzzleSolversGui extends GuiScreen {
ToggleCommand.blazeToggled = !ToggleCommand.blazeToggled;
ConfigHandler.writeBooleanConfig("toggles", "BlazePuzzle", ToggleCommand.blazeToggled);
blaze.displayString = "Blaze Solver: " + Utils.getColouredBoolean(ToggleCommand.blazeToggled);
+ } else if (button == creeper) {
+ ToggleCommand.creeperToggled = !ToggleCommand.creeperToggled;
+ ConfigHandler.writeBooleanConfig("toggles", "CreeperPuzzle", ToggleCommand.creeperToggled);
+ creeper.displayString = "Creeper Solver: " + Utils.getColouredBoolean(ToggleCommand.creeperToggled);
}
}
diff --git a/src/main/java/me/Danker/handlers/ConfigHandler.java b/src/main/java/me/Danker/handlers/ConfigHandler.java
index 4663049..51b7f6e 100644
--- a/src/main/java/me/Danker/handlers/ConfigHandler.java
+++ b/src/main/java/me/Danker/handlers/ConfigHandler.java
@@ -192,6 +192,7 @@ public class ConfigHandler {
if (!hasKey("toggles", "ThreeManPuzzle")) writeBooleanConfig("toggles", "ThreeManPuzzle", false);
if (!hasKey("toggles", "OruoPuzzle")) writeBooleanConfig("toggles", "OruoPuzzle", false);
if (!hasKey("toggles", "BlazePuzzle")) writeBooleanConfig("toggles", "BlazePuzzle", false);
+ if (!hasKey("toggles", "CreeperPuzzle")) writeBooleanConfig("toggles", "CreeperPuzzle", false);
if (!hasKey("api", "APIKey")) writeStringConfig("api", "APIKey", "");
@@ -361,6 +362,7 @@ public class ConfigHandler {
tf.threeManToggled = getBoolean("toggles", "ThreeManPuzzle");
tf.oruoToggled = getBoolean("toggles", "OruoPuzzle");
tf.blazeToggled = getBoolean("toggles", "BlazePuzzle");
+ tf.creeperToggled = getBoolean("toggles", "CreeperPuzzle");
final BlockSlayerCommand bs = new BlockSlayerCommand();
String onlySlayer = getString("toggles", "BlockSlayer");
diff --git a/src/main/java/me/Danker/utils/Utils.java b/src/main/java/me/Danker/utils/Utils.java
index 532d1b9..928e02f 100644
--- a/src/main/java/me/Danker/utils/Utils.java
+++ b/src/main/java/me/Danker/utils/Utils.java
@@ -1,5 +1,6 @@
package me.Danker.utils;
+import java.awt.Color;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -10,6 +11,7 @@ import org.lwjgl.opengl.GL11;
import me.Danker.TheMod;
import me.Danker.handlers.ScoreboardHandler;
import me.Danker.handlers.TextRenderer;
+import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
@@ -22,11 +24,13 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
import net.minecraft.scoreboard.ScoreObjective;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StringUtils;
+import net.minecraft.util.Vec3;
public class Utils {
@@ -251,6 +255,37 @@ public class Utils {
return bool ? EnumChatFormatting.GREEN + "On" : EnumChatFormatting.RED + "Off";
}
+ public static void draw3DLine(Vec3 pos1, Vec3 pos2, int colourInt, float partialTicks) {
+ Entity render = Minecraft.getMinecraft().getRenderViewEntity();
+ WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer();
+ Color colour = new Color(colourInt);
+
+ double realX = render.lastTickPosX + (render.posX - render.lastTickPosX) * partialTicks;
+ double realY = render.lastTickPosY + (render.posY - render.lastTickPosY) * partialTicks;
+ double realZ = render.lastTickPosZ + (render.posZ - render.lastTickPosZ) * partialTicks;
+
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(-realX, -realY, -realZ);
+ GlStateManager.disableTexture2D();
+ GlStateManager.enableBlend();
+ GlStateManager.disableAlpha();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GL11.glLineWidth(2);
+ GlStateManager.color(colour.getRed() / 255f, colour.getGreen() / 255f, colour.getBlue()/ 255f, colour.getAlpha() / 255f);
+ worldRenderer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION);
+
+ worldRenderer.pos(pos1.xCoord, pos1.yCoord, pos1.zCoord).endVertex();
+ worldRenderer.pos(pos2.xCoord, pos2.yCoord, pos2.zCoord).endVertex();
+ Tessellator.getInstance().draw();
+
+ GlStateManager.translate(realX, realY, realZ);
+ GlStateManager.disableBlend();
+ GlStateManager.enableAlpha();
+ GlStateManager.enableTexture2D();
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ GlStateManager.popMatrix();
+ }
+
public static void draw3DString(BlockPos pos, String text, int colour, float partialTicks) {
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.thePlayer;
@@ -326,4 +361,44 @@ public class Utils {
GlStateManager.popMatrix();
}
+ public static BlockPos getFirstBlockPosAfterVectors(Minecraft mc, Vec3 pos1, Vec3 pos2, int strength, int distance) {
+ double x = pos2.xCoord - pos1.xCoord;
+ double y = pos2.yCoord - pos1.yCoord;
+ double z = pos2.zCoord - pos1.zCoord;
+
+ for (int i = strength; i < distance * strength; i++) { // Start at least 1 strength away
+ double newX = pos1.xCoord + ((x / strength) * i);
+ double newY = pos1.yCoord + ((y / strength) * i);
+ double newZ = pos1.zCoord + ((z / strength) * i);
+
+ BlockPos newBlock = new BlockPos(newX, newY, newZ);
+ if (mc.theWorld.getBlockState(newBlock).getBlock() != Blocks.air) {
+ return newBlock;
+ }
+ }
+
+ return null;
+ }
+
+ public static BlockPos getNearbyBlock(Minecraft mc, BlockPos pos, Block... blockTypes) {
+ if (pos == null) return null;
+ BlockPos pos1 = new BlockPos(pos.getX() - 2, pos.getY() - 3, pos.getZ() - 2);
+ BlockPos pos2 = new BlockPos(pos.getX() + 2, pos.getY() + 3, pos.getZ() + 2);
+
+ BlockPos closestBlock = null;
+ double closestBlockDistance = 99;
+ Iterable<BlockPos> blocks = BlockPos.getAllInBox(pos1, pos2);
+
+ for (BlockPos block : blocks) {
+ for (Block blockType : blockTypes) {
+ if (mc.theWorld.getBlockState(block).getBlock() == blockType && block.distanceSq(pos) < closestBlockDistance) {
+ closestBlock = block;
+ closestBlockDistance = block.distanceSq(pos);
+ }
+ }
+ }
+
+ return closestBlock;
+ }
+
}