diff options
Diffstat (limited to 'src/main/java/me/Danker')
39 files changed, 1592 insertions, 902 deletions
diff --git a/src/main/java/me/Danker/TheMod.java b/src/main/java/me/Danker/DankersSkyblockMod.java index 9f0e935..2c75a0e 100644 --- a/src/main/java/me/Danker/TheMod.java +++ b/src/main/java/me/Danker/DankersSkyblockMod.java @@ -1,65 +1,19 @@ package me.Danker; -import java.awt.Image; -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; -import java.util.Map; -import java.util.regex.Pattern; - -import org.apache.commons.lang3.time.StopWatch; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; - import com.google.gson.JsonObject; - -import me.Danker.commands.ArmourCommand; -import me.Danker.commands.BankCommand; -import me.Danker.commands.BlockSlayerCommand; -import me.Danker.commands.DHelpCommand; -import me.Danker.commands.DankerGuiCommand; -import me.Danker.commands.DisplayCommand; -import me.Danker.commands.DungeonsCommand; -import me.Danker.commands.GetkeyCommand; -import me.Danker.commands.GuildOfCommand; -import me.Danker.commands.ImportFishingCommand; -import me.Danker.commands.LobbySkillsCommand; -import me.Danker.commands.LootCommand; -import me.Danker.commands.MoveCommand; -import me.Danker.commands.PetsCommand; -import me.Danker.commands.ReloadConfigCommand; -import me.Danker.commands.ResetLootCommand; -import me.Danker.commands.ScaleCommand; -import me.Danker.commands.SetkeyCommand; -import me.Danker.commands.SkillTrackerCommand; -import me.Danker.commands.SkillsCommand; -import me.Danker.commands.SkyblockPlayersCommand; -import me.Danker.commands.SlayerCommand; -import me.Danker.commands.ToggleCommand; -import me.Danker.gui.DankerGui; -import me.Danker.gui.DisplayGui; -import me.Danker.gui.EditLocationsGui; -import me.Danker.gui.OnlySlayerGui; -import me.Danker.gui.PuzzleSolversGui; -import me.Danker.gui.SkillTrackerGui; -import me.Danker.handlers.APIHandler; -import me.Danker.handlers.ConfigHandler; -import me.Danker.handlers.PacketHandler; -import me.Danker.handlers.ScoreboardHandler; -import me.Danker.handlers.TextRenderer; +import me.Danker.commands.*; +import me.Danker.gui.*; +import me.Danker.handlers.*; +import me.Danker.utils.TicTacToeUtils; 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.Gui; import net.minecraft.client.gui.GuiChat; +import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.client.settings.GameSettings; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItemFrame; @@ -73,22 +27,16 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.ContainerChest; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; +import net.minecraft.item.Item; +import net.minecraft.item.ItemMap; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.IChatComponent; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StringUtils; -import net.minecraft.util.Vec3; +import net.minecraft.util.*; import net.minecraft.world.World; +import net.minecraft.world.storage.MapData; import net.minecraftforge.client.ClientCommandHandler; -import net.minecraftforge.client.event.ClientChatReceivedEvent; -import net.minecraftforge.client.event.GuiScreenEvent; -import net.minecraftforge.client.event.RenderGameOverlayEvent; -import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.client.GuiIngameForge; +import net.minecraftforge.client.event.*; import net.minecraftforge.client.event.sound.PlaySoundEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.EntityJoinWorldEvent; @@ -110,16 +58,26 @@ import net.minecraftforge.fml.common.gameevent.TickEvent; import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent; import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion; +import org.apache.commons.lang3.time.StopWatch; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.text.NumberFormat; +import java.util.List; +import java.util.*; +import java.util.regex.Pattern; -@Mod(modid = TheMod.MODID, version = TheMod.VERSION, clientSideOnly = true) -public class TheMod +@Mod(modid = DankersSkyblockMod.MODID, version = DankersSkyblockMod.VERSION, clientSideOnly = true) +public class DankersSkyblockMod { public static final String MODID = "Danker's Skyblock Mod"; - public static final String VERSION = "1.8.3"; + public static final String VERSION = "1.8.4"; static double checkItemsNow = 0; static double itemsChecked = 0; - public static Map<String, String> t6Enchants = new HashMap<String, String>(); + public static Map<String, String> t6Enchants = new HashMap<>(); public static Pattern pattern = Pattern.compile(""); static boolean updateChecked = false; public static int titleTimer = -1; @@ -133,7 +91,6 @@ public class TheMod static String lastMaddoxCommand = "/cb placeholder"; static double lastMaddoxTime = 0; static KeyBinding[] keyBindings = new KeyBinding[2]; - static int lastMouse = -1; static boolean usingLabymod = false; public static String guiToOpen = null; static boolean foundLivid = false; @@ -145,7 +102,7 @@ public class TheMod static String[] riddleSolutions = {"The reward is not in my chest!", "At least one of them is lying, and the reward is not in", "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[]>(); + static Map<String, String[]> triviaSolutions = new HashMap<>(); static String[] triviaAnswers = null; static Entity highestBlaze = null; static Entity lowestBlaze = null; @@ -153,11 +110,21 @@ public class TheMod static final int[] CREEPER_COLOURS = {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 List<Vec3[]> creeperLines = new ArrayList<>(); static boolean prevInWaterRoom = false; static boolean inWaterRoom = false; - - static double dungeonStartTime = 0; + static String waterAnswers = null; + static AxisAlignedBB correctTicTacToeButton = null; + static Slot[] clickInOrderSlots = new Slot[36]; + static int lastChronomatronRound = 0; + static List<String> chronomatronPattern = new ArrayList<>(); + static int chronomatronMouseClicks = 0; + static int lastUltraSequencerClicked = 0; + static ItemStack[] experimentTableSlots = new ItemStack[54]; + static int pickBlockBind; + static boolean pickBlockBindSwapped = false; + + static double dungeonStartTime = 0; static double bloodOpenTime = 0; static double watcherClearTime = 0; static double bossClearTime = 0; @@ -283,9 +250,9 @@ public class TheMod keyBindings[0] = new KeyBinding("Open Maddox Menu", Keyboard.KEY_M, "Danker's Skyblock Mod"); keyBindings[1] = new KeyBinding("Start/Stop Skill Tracker", Keyboard.KEY_NUMPAD5, "Danker's Skyblock Mod"); - - for (int i = 0; i < keyBindings.length; i++) { - ClientRegistry.registerKeyBinding(keyBindings[i]); + + for (KeyBinding keyBinding : keyBindings) { + ClientRegistry.registerKeyBinding(keyBinding); } } @@ -332,7 +299,7 @@ public class TheMod new Thread(() -> { EntityPlayer player = Minecraft.getMinecraft().thePlayer; - System.err.println("Checking for updates..."); + System.out.println("Checking for updates..."); JsonObject latestRelease = APIHandler.getResponse("https://api.github.com/repos/bowser0000/SkyblockMod/releases/latest"); String latestTag = latestRelease.get("tag_name").getAsString(); @@ -348,7 +315,7 @@ public class TheMod try { Thread.sleep(2000); } catch (InterruptedException ex) { - System.err.println(ex); + ex.printStackTrace(); } player.addChatMessage(new ChatComponentText(ERROR_COLOUR + MODID + " is outdated. Please update to " + latestTag + ".\n").appendSibling(update)); } @@ -375,77 +342,62 @@ public class TheMod for (String section : actionBarSections) { if (section.contains("+") && section.contains("/") && section.contains("(")) { if (!section.contains("Runecrafting") && !section.contains("Carpentry")) { - int limit = section.contains("Farming") ? 60 : 50; + int limit = section.contains("Farming") || section.contains("Enchanting") ? 60 : 50; double currentXP = Double.parseDouble(section.substring(section.indexOf("(") + 1, section.indexOf("/")).replace(",", "")); int xpToLevelUp = Integer.parseInt(section.substring(section.indexOf("/") + 1, section.indexOf(")")).replaceAll(",", "")); xpLeft = xpToLevelUp - currentXP; int previousXP = Utils.getPastXpEarned(xpToLevelUp, limit); double totalXP = currentXP + previousXP; - double xpGained = Double.parseDouble(section.substring(section.indexOf("+") + 1, section.indexOf(" ")).replace(",", "")); String skill = section.substring(section.indexOf(" ") + 1, section.lastIndexOf(" ")); switch (skill) { case "Farming": lastSkill = "Farming"; - if (farmingXP == 0) { - farmingXP = totalXP; - } else { + if (farmingXP != 0) { if (skillStopwatch.isStarted() && !skillStopwatch.isSuspended()) farmingXPGained += totalXP - farmingXP; - farmingXP = totalXP; } + farmingXP = totalXP; break; case "Mining": lastSkill = "Mining"; - if (miningXP == 0) { - miningXP = totalXP; - } else { + if (miningXP != 0) { if (skillStopwatch.isStarted() && !skillStopwatch.isSuspended()) miningXPGained += totalXP - miningXP; - miningXP = totalXP; } + miningXP = totalXP; break; case "Combat": lastSkill = "Combat"; - if (combatXP == 0) { - combatXP = totalXP; - } else { + if (combatXP != 0) { if (skillStopwatch.isStarted() && !skillStopwatch.isSuspended()) combatXPGained += totalXP - combatXP; - combatXP = totalXP; } + combatXP = totalXP; break; case "Foraging": lastSkill = "Foraging"; - if (foragingXP == 0) { - foragingXP = totalXP; - } else { + if (foragingXP != 0) { if (skillStopwatch.isStarted() && !skillStopwatch.isSuspended()) foragingXPGained += totalXP - foragingXP; - foragingXP = totalXP; } + foragingXP = totalXP; break; case "Fishing": lastSkill = "Fishing"; - if (fishingXP == 0) { - fishingXP = totalXP; - } else { + if (fishingXP != 0) { if (skillStopwatch.isStarted() && !skillStopwatch.isSuspended()) fishingXPGained += totalXP - fishingXP; - fishingXP = totalXP; } + fishingXP = totalXP; break; case "Enchanting": lastSkill = "Enchanting"; - if (enchantingXP == 0) { - enchantingXP = totalXP; - } else { + if (enchantingXP != 0) { if (skillStopwatch.isStarted() && !skillStopwatch.isSuspended()) enchantingXPGained += totalXP - enchantingXP; - enchantingXP = totalXP; } + enchantingXP = totalXP; break; case "Alchemy": lastSkill = "Alchemy"; - if (alchemyXP == 0) { - alchemyXP = totalXP; - } else { + if (alchemyXP != 0) { if (skillStopwatch.isStarted() && !skillStopwatch.isSuspended()) alchemyXPGained += totalXP - alchemyXP; - alchemyXP = totalXP; } + alchemyXP = totalXP; break; default: System.err.println("Unknown skill."); @@ -457,7 +409,7 @@ public class TheMod double currentXp = Double.parseDouble(section.substring(section.indexOf("(") + 1, section.indexOf("/")).replace(",", "")); int limit; int totalXp; - if (section.contains("Farming")) { + if (section.contains("Farming") || section.contains("Enchanting")) { limit = 60; totalXp = 111672425; } else { @@ -465,7 +417,7 @@ public class TheMod totalXp = 55172425; } int previousXp = Utils.getPastXpEarned(Integer.parseInt(section.substring(section.indexOf("/") + 1, section.indexOf(")")).replaceAll(",", "")), limit); - double percentage = (double) Math.floor(((currentXp + previousXp) / totalXp) * 10000D) / 100D; + double percentage = Math.floor(((currentXp + previousXp) / totalXp) * 10000D) / 100D; NumberFormat nf = NumberFormat.getNumberInstance(Locale.US); skillTimer = SKILL_TIME; @@ -512,6 +464,13 @@ public class TheMod event.setCanceled(true); return; } + + if (!ToggleCommand.implosionMessages) { + if (message.contains("Your Implosion hit ") || message.contains("There are blocks in the way")) { + event.setCanceled(true); + return; + } + } if (ToggleCommand.oruoToggled && Utils.inDungeons) { // Don't set every answer to wrong with this question @@ -528,11 +487,14 @@ public class TheMod if (triviaAnswers != null && (message.contains("ⓐ") || message.contains("ⓑ") || message.contains("ⓒ"))) { boolean isSolution = false; for (String solution : triviaAnswers) { - if (message.contains(solution)) isSolution = true; + if (message.contains(solution)) { + isSolution = true; + break; + } } if (!isSolution) { char letter = message.charAt(5); - String option = message.substring(6, message.length()); + String option = message.substring(6); event.message = new ChatComponentText(" " + EnumChatFormatting.GOLD + letter + TRIVIA_WRONG_ANSWER_COLOUR + option); return; } @@ -551,7 +513,7 @@ public class TheMod trayIcon.displayMessage("Guild Party", message, TrayIcon.MessageType.INFO); tray.remove(trayIcon); } catch (Exception ex) { - System.err.print(ex); + ex.printStackTrace(); } } } @@ -1206,7 +1168,7 @@ public class TheMod @SubscribeEvent public void renderPlayerInfo(final RenderGameOverlayEvent.Post event) { - if (usingLabymod) return; + if (usingLabymod && !(Minecraft.getMinecraft().ingameGUI instanceof GuiIngameForge)) return; if (event.type != RenderGameOverlayEvent.ElementType.EXPERIENCE && event.type != RenderGameOverlayEvent.ElementType.JUMPBAR) return; renderEverything(); } @@ -1259,7 +1221,7 @@ public class TheMod if (ToggleCommand.cakeTimerToggled && Utils.inSkyblock) { double scale = ScaleCommand.cakeTimerScale; - double scaleReset = (double) Math.pow(scale, -1); + double scaleReset = Math.pow(scale, -1); GL11.glScaled(scale, scale, scale); double timeNow = System.currentTimeMillis() / 1000; @@ -1278,7 +1240,7 @@ public class TheMod } if (showSkillTracker && Utils.inSkyblock) { - int xpPerHour = 0; + int xpPerHour; double xpToShow = 0; switch (lastSkill) { case "Farming": @@ -1319,14 +1281,18 @@ public class TheMod new TextRenderer(mc, skillTrackerText, MoveCommand.skillTrackerXY[0], MoveCommand.skillTrackerXY[1], ScaleCommand.skillTrackerScale); } - + + if (ToggleCommand.waterToggled && Utils.inDungeons && waterAnswers != null) { + new TextRenderer(mc, waterAnswers, MoveCommand.waterAnswerXY[0], MoveCommand.waterAnswerXY[1], ScaleCommand.waterAnswerScale); + } + if (!DisplayCommand.display.equals("off")) { String dropsText = ""; String countText = ""; - String dropsTextTwo = ""; - String countTextTwo = ""; - String timeBetween = "Never"; - String bossesBetween = "Never"; + String dropsTextTwo; + String countTextTwo; + String timeBetween; + String bossesBetween; String drop20; double timeNow = System.currentTimeMillis() / 1000; NumberFormat nf = NumberFormat.getIntegerInstance(Locale.US); @@ -2262,6 +2228,9 @@ public class TheMod if (event.toolTip == null) return; ItemStack item = event.itemStack; + Minecraft mc = Minecraft.getMinecraft(); + EntityPlayerSP player = mc.thePlayer; + if (ToggleCommand.goldenToggled) { for (int i = 0; i < event.toolTip.size(); i++) { event.toolTip.set(i, Utils.returnGoldenEnchants(event.toolTip.get(i))); @@ -2285,16 +2254,42 @@ public class TheMod } } } + + if (mc.currentScreen instanceof GuiChest) { + ContainerChest chest = (ContainerChest) player.openContainer; + IInventory inv = chest.getLowerChestInventory(); + String chestName = inv.getDisplayName().getUnformattedText(); + if (ToggleCommand.superpairsToggled && chestName.contains("Superpairs (")) { + if (Item.getIdFromItem(item.getItem()) != 95) return; + if (item.getDisplayName().contains("Click any button") || item.getDisplayName().contains("Click a second button") || item.getDisplayName().contains("Next button is instantly rewarded") || item.getDisplayName().contains("Stained Glass")) { + Slot slot = ((GuiChest) mc.currentScreen).getSlotUnderMouse(); + ItemStack itemStack = experimentTableSlots[slot.getSlotIndex()]; + if (itemStack == null) return; + String itemName = itemStack.getDisplayName(); + + if (event.toolTip.stream().anyMatch(x->StringUtils.stripControlCodes(x).equals(StringUtils.stripControlCodes(itemName)))) return; + event.toolTip.removeIf(x -> { + x = StringUtils.stripControlCodes(x); + if (x.equals("minecraft:stained_glass")) return true; + return x.startsWith("NBT: "); + }); + event.toolTip.add(itemName); + event.toolTip.add(itemStack.getItem().getRegistryName()); + } + + } + } + } - + @SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) { if (event.phase != Phase.START) return; - + Minecraft mc = Minecraft.getMinecraft(); World world = mc.theWorld; EntityPlayerSP player = mc.thePlayer; - + // Checks every second tickAmount++; if (tickAmount % 20 == 0) { @@ -2302,8 +2297,8 @@ public class TheMod Utils.checkForSkyblock(); Utils.checkForDungeons(); } - - if (DisplayCommand.auto && mc != null && world != null && player != null) { + + if (DisplayCommand.auto && world != null && player != null) { List<String> scoreboard = ScoreboardHandler.getSidebarLines(); boolean found = false; for (String s : scoreboard) { @@ -2347,8 +2342,8 @@ public class TheMod if (!found) DisplayCommand.display = "off"; ConfigHandler.writeStringConfig("misc", "display", DisplayCommand.display); } - - if (ToggleCommand.creeperToggled && Utils.inDungeons && world != null) { + + if (ToggleCommand.creeperToggled && Utils.inDungeons && world != null && player != null) { double x = player.posX; double y = player.posY; double z = player.posZ; @@ -2384,8 +2379,8 @@ public class TheMod drawCreeperLines = false; } } - - if (ToggleCommand.waterToggled && Utils.inDungeons && world != null) { + + if (ToggleCommand.waterToggled && Utils.inDungeons && world != null && player != null) { // multi thread block checking new Thread(() -> { prevInWaterRoom = inWaterRoom; @@ -2402,20 +2397,20 @@ public class TheMod } if (foundPiston) break; } - + if (foundPiston) { for (int x = (int) (player.posX - 25); x <= player.posX + 25; x++) { for (int z = (int) (player.posZ - 25); z <= player.posZ + 25; z++) { BlockPos blockPos = new BlockPos(x, 82, z); if (world.getBlockState(blockPos).getBlock() == Blocks.piston_head) { inWaterRoom = true; - if (!prevInWaterRoom && inWaterRoom) { + if (!prevInWaterRoom) { boolean foundGold = false; boolean foundClay = false; boolean foundEmerald = false; boolean foundQuartz = false; boolean foundDiamond = false; - + // Detect first blocks near water stream BlockPos scan1 = new BlockPos(x + 1, 78, z + 1); BlockPos scan2 = new BlockPos(x - 1, 77, z - 1); @@ -2434,7 +2429,7 @@ public class TheMod foundDiamond = true; } } - + int variant = 0; if (foundGold && foundClay) { variant = 1; @@ -2445,13 +2440,13 @@ public class TheMod } else if (foundGold && foundQuartz) { variant = 4; } - + // Return solution - String purple = ""; - String orange = ""; - String blue = ""; - String green = ""; - String red = ""; + String purple; + String orange; + String blue; + String green; + String red; switch (variant) { case 1: purple = EnumChatFormatting.WHITE + "Quartz, " + EnumChatFormatting.YELLOW + "Gold, " + EnumChatFormatting.AQUA + "Diamond, " + EnumChatFormatting.RED + "Clay"; @@ -2485,28 +2480,28 @@ public class TheMod purple = orange = blue = green = red = ERROR_COLOUR + "Error detecting water puzzle variant."; break; } - player.addChatMessage(new ChatComponentText(DELIMITER_COLOUR + EnumChatFormatting.BOLD + "-------------------\n" + - MAIN_COLOUR + " The following levers must be down:\n " + - EnumChatFormatting.DARK_PURPLE + "Purple: " + purple + "\n " + - EnumChatFormatting.GOLD + "Orange: " + orange + "\n " + - EnumChatFormatting.BLUE + "Blue: " + blue + "\n " + - EnumChatFormatting.GREEN + "Green: " + green + "\n " + - EnumChatFormatting.RED + "Red: " + red + "\n" + - DELIMITER_COLOUR + EnumChatFormatting.BOLD + " -------------------")); + waterAnswers = MAIN_COLOUR + "The following levers must be down:\n" + + EnumChatFormatting.DARK_PURPLE + "Purple: " + purple + "\n" + + EnumChatFormatting.GOLD + "Orange: " + orange + "\n" + + EnumChatFormatting.BLUE + "Blue: " + blue + "\n" + + EnumChatFormatting.GREEN + "Green: " + green + "\n" + + EnumChatFormatting.RED + "Red: " + red; done = true; - break; + break; } } } if (done) break; - } - } + } + } else { + waterAnswers = null; + } }).start(); } - + if (ToggleCommand.lividSolverToggled && Utils.inDungeons && !foundLivid && world != null) { boolean inF5 = false; - + List<String> scoreboard = ScoreboardHandler.getSidebarLines(); for (String s : scoreboard) { String sCleaned = ScoreboardHandler.cleanSB(s); @@ -2515,9 +2510,9 @@ public class TheMod break; } } - + if (inF5) { - List<Entity> loadedLivids = new ArrayList<Entity>(); + List<Entity> loadedLivids = new ArrayList<>(); List<Entity> entities = world.getLoadedEntityList(); for (Entity entity : entities) { String name = entity.getName(); @@ -2531,54 +2526,180 @@ public class TheMod } } } - + + if (ToggleCommand.ticTacToeToggled && Utils.inDungeons && world != null && player != null) { + correctTicTacToeButton = null; + AxisAlignedBB aabb = new AxisAlignedBB(player.posX - 6, player.posY - 6, player.posZ - 6, player.posX + 6, player.posY + 6, player.posZ + 6); + List<EntityItemFrame> itemFrames = world.getEntitiesWithinAABB(EntityItemFrame.class, aabb); + List<EntityItemFrame> itemFramesWithMaps = new ArrayList<>(); + // Find how many item frames have maps already placed + for (EntityItemFrame itemFrame : itemFrames) { + ItemStack item = itemFrame.getDisplayedItem(); + if (item == null || !(item.getItem() instanceof ItemMap)) continue; + MapData mapData = ((ItemMap) item.getItem()).getMapData(item, world); + if (mapData == null) continue; + + itemFramesWithMaps.add(itemFrame); + } + + // Only run when it's your turn + if (itemFramesWithMaps.size() != 9 && itemFramesWithMaps.size() % 2 == 1) { + char[][] board = new char[3][3]; + BlockPos leftmostRow = null; + int sign = 1; + char facing = 'X'; + for (EntityItemFrame itemFrame : itemFramesWithMaps) { + ItemStack map = itemFrame.getDisplayedItem(); + MapData mapData = ((ItemMap) map.getItem()).getMapData(map, world); + + // Find position on board + int row = 0; + int column; + sign = 1; + + if (itemFrame.facingDirection == EnumFacing.SOUTH || itemFrame.facingDirection == EnumFacing.WEST) { + sign = -1; + } + + BlockPos itemFramePos = new BlockPos(itemFrame.posX, Math.floor(itemFrame.posY), itemFrame.posZ); + for (int i = 2; i >= 0; i--) { + int realI = i * sign; + BlockPos blockPos = itemFramePos; + if (itemFrame.posX % 0.5 == 0) { + blockPos = itemFramePos.add(realI, 0, 0); + } else if (itemFrame.posZ % 0.5 == 0) { + blockPos = itemFramePos.add(0, 0, realI); + facing = 'Z'; + } + Block block = world.getBlockState(blockPos).getBlock(); + if (block == Blocks.air || block == Blocks.stone_button) { + leftmostRow = blockPos; + row = i; + break; + } + } + + if (itemFrame.posY == 72.5) { + column = 0; + } else if (itemFrame.posY == 71.5) { + column = 1; + } else if (itemFrame.posY == 70.5) { + column = 2; + } else { + continue; + } + + // Get colour + // Middle pixel = 64*128 + 64 = 8256 + int colourInt = mapData.colors[8256] & 255; + if (colourInt == 114) { |
