From 16de12d5ca1871c3de01fa2442ba9a8b9141401c Mon Sep 17 00:00:00 2001 From: bowser0000 Date: Sat, 28 Nov 2020 18:41:44 -0500 Subject: Add F7 stage 3 arrow and 2 terminal puzzle solvers Starts with letter terminal and select all colour terminal --- src/main/java/me/Danker/TheMod.java | 125 ++++++++++++++------- .../java/me/Danker/commands/ToggleCommand.java | 30 ++++- src/main/java/me/Danker/gui/DankerGui.java | 77 +++++++------ src/main/java/me/Danker/gui/PuzzleSolversGui.java | 58 +++++++++- .../java/me/Danker/handlers/ConfigHandler.java | 6 + .../java/me/Danker/handlers/PacketHandler.java | 32 ++++++ src/main/java/me/Danker/utils/Utils.java | 17 +++ 7 files changed, 262 insertions(+), 83 deletions(-) (limited to 'src/main/java/me') diff --git a/src/main/java/me/Danker/TheMod.java b/src/main/java/me/Danker/TheMod.java index 1ff1df9..7688334 100644 --- a/src/main/java/me/Danker/TheMod.java +++ b/src/main/java/me/Danker/TheMod.java @@ -62,11 +62,13 @@ import net.minecraft.client.gui.GuiChat; import net.minecraft.client.gui.inventory.GuiChest; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItemFrame; 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.init.Items; import net.minecraft.inventory.Container; import net.minecraft.inventory.ContainerChest; import net.minecraft.inventory.IInventory; @@ -90,6 +92,7 @@ import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.client.event.sound.PlaySoundEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.event.entity.player.EntityInteractEvent; import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.world.WorldEvent; @@ -2616,7 +2619,7 @@ public class TheMod mc.displayGuiScreen(new EditLocationsGui()); break; case "puzzlesolvers": - mc.displayGuiScreen(new PuzzleSolversGui()); + mc.displayGuiScreen(new PuzzleSolversGui(1)); break; case "skilltracker": mc.displayGuiScreen(new SkillTrackerGui()); @@ -2666,6 +2669,22 @@ public class TheMod } } + @SubscribeEvent + public void onEntityInteract(EntityInteractEvent event) { + Minecraft mc = Minecraft.getMinecraft(); + if (mc.thePlayer != event.entityPlayer) return; + + if (ToggleCommand.itemFrameOnSeaLanternsToggled && Utils.inDungeons && event.target instanceof EntityItemFrame) { + EntityItemFrame itemFrame = (EntityItemFrame) event.target; + ItemStack item = itemFrame.getDisplayedItem(); + if (item == null || item.getItem() != Items.arrow) return; + BlockPos blockPos = Utils.getBlockUnderItemFrame(mc.theWorld, itemFrame); + if (mc.theWorld.getBlockState(blockPos).getBlock() == Blocks.sea_lantern) { + event.setCanceled(true); + } + } + } + @SubscribeEvent public void onKey(KeyInputEvent event) { if (!Utils.inSkyblock) return; @@ -2794,44 +2813,74 @@ public class TheMod @SubscribeEvent public void onGuiRender(GuiScreenEvent.BackgroundDrawnEvent event) { - if (!Utils.inSkyblock) return; - if (ToggleCommand.petColoursToggled && event.gui instanceof GuiChest) { + //if (!Utils.inSkyblock) return; + if (event.gui instanceof GuiChest) { GuiChest inventory = (GuiChest) event.gui; - List invSlots = inventory.inventorySlots.inventorySlots; - Pattern petPattern = Pattern.compile("\\[Lvl [\\d]{1,3}]"); - for (Slot slot : invSlots) { - ItemStack item = slot.getStack(); - if (item == null) continue; - String name = item.getDisplayName(); - if (petPattern.matcher(StringUtils.stripControlCodes(name)).find()) { - if (name.endsWith("aHealer") || name.endsWith("aMage") || name.endsWith("aBerserk") || name.endsWith("aArcher") || name.endsWith("aTank")) continue; - int colour; - int petLevel = Integer.parseInt(item.getDisplayName().substring(item.getDisplayName().indexOf(" ") + 1, item.getDisplayName().indexOf("]"))); - if (petLevel == 100) { - colour = 0xBFF2D249; // Gold - } else if (petLevel >= 90) { - colour = 0xBF9E794E; // Brown - } else if (petLevel >= 80) { - colour = 0xBF5C1F35; // idk weird magenta - } else if (petLevel >= 70) { - colour = 0xBFD64FC8; // Pink - } else if (petLevel >= 60) { - colour = 0xBF7E4FC6; // Purple - } else if (petLevel >= 50) { - colour = 0xBF008AD8; // Light Blue - } else if (petLevel >= 40) { - colour = 0xBF0EAC35; // Green - } else if (petLevel >= 30) { - colour = 0xBFFFC400; // Yellow - } else if (petLevel >= 20) { - colour = 0xBFEF5230; // Orange - } else if (petLevel >= 10) { - colour = 0xBFD62440; // Red - } else { - colour = 0xBF999999; // Gray - } - Utils.drawOnSlot(inventory.inventorySlots.inventorySlots.size(), slot.xDisplayPosition, slot.yDisplayPosition, colour); - } + Container containerChest = inventory.inventorySlots; + if (containerChest instanceof ContainerChest) { + List invSlots = inventory.inventorySlots.inventorySlots; + String displayName = ((ContainerChest) containerChest).getLowerChestInventory().getDisplayName().getUnformattedText(); + int chestSize = inventory.inventorySlots.inventorySlots.size(); + + if (ToggleCommand.petColoursToggled) { + Pattern petPattern = Pattern.compile("\\[Lvl [\\d]{1,3}]"); + for (Slot slot : invSlots) { + ItemStack item = slot.getStack(); + if (item == null) continue; + String name = item.getDisplayName(); + if (petPattern.matcher(StringUtils.stripControlCodes(name)).find()) { + if (name.endsWith("aHealer") || name.endsWith("aMage") || name.endsWith("aBerserk") || name.endsWith("aArcher") || name.endsWith("aTank")) continue; + int colour; + int petLevel = Integer.parseInt(item.getDisplayName().substring(item.getDisplayName().indexOf(" ") + 1, item.getDisplayName().indexOf("]"))); + if (petLevel == 100) { + colour = 0xBFF2D249; // Gold + } else if (petLevel >= 90) { + colour = 0xBF9E794E; // Brown + } else if (petLevel >= 80) { + colour = 0xBF5C1F35; // idk weird magenta + } else if (petLevel >= 70) { + colour = 0xBFD64FC8; // Pink + } else if (petLevel >= 60) { + colour = 0xBF7E4FC6; // Purple + } else if (petLevel >= 50) { + colour = 0xBF008AD8; // Light Blue + } else if (petLevel >= 40) { + colour = 0xBF0EAC35; // Green + } else if (petLevel >= 30) { + colour = 0xBFFFC400; // Yellow + } else if (petLevel >= 20) { + colour = 0xBFEF5230; // Orange + } else if (petLevel >= 10) { + colour = 0xBFD62440; // Red + } else { + colour = 0xBF999999; // Gray + } + Utils.drawOnSlot(chestSize, slot.xDisplayPosition, slot.yDisplayPosition, colour); + } + } + } + + if (ToggleCommand.startsWithToggled && Utils.inDungeons && displayName.trim().startsWith("What starts with:")) { + char letter = displayName.charAt(displayName.indexOf("'") + 1); + for (Slot slot : invSlots) { + ItemStack item = slot.getStack(); + if (item == null) continue; + if (StringUtils.stripControlCodes(item.getDisplayName()).charAt(0) == letter) { + Utils.drawOnSlot(chestSize, slot.xDisplayPosition, slot.yDisplayPosition, 0xBF40FF40); + } + } + } + + if (ToggleCommand.selectAllToggled && Utils.inDungeons && displayName.trim().startsWith("Select all the")) { + String colour = displayName.split(" ")[3]; + for (Slot slot : invSlots) { + ItemStack item = slot.getStack(); + if (item == null) continue; + if (item.getDisplayName().toUpperCase().contains(colour)) { + Utils.drawOnSlot(chestSize, slot.xDisplayPosition, slot.yDisplayPosition, 0xBF40FF40); + } + } + } } } } diff --git a/src/main/java/me/Danker/commands/ToggleCommand.java b/src/main/java/me/Danker/commands/ToggleCommand.java index 43c9fac..81c41ac 100644 --- a/src/main/java/me/Danker/commands/ToggleCommand.java +++ b/src/main/java/me/Danker/commands/ToggleCommand.java @@ -42,6 +42,10 @@ public class ToggleCommand extends CommandBase implements ICommand { public static boolean onlyShowCorrectBlazeToggled; public static boolean creeperToggled; public static boolean waterToggled; + // Terminal Helpers + public static boolean startsWithToggled; + public static boolean selectAllToggled; + public static boolean itemFrameOnSeaLanternsToggled; @Override public String getCommandName() { @@ -53,7 +57,8 @@ public class ToggleCommand extends CommandBase implements ICommand { return "/" + getCommandName() + " "; + "blazepuzzle/onlyshowcorrectblaze/creeperpuzzle/waterpuzzle/startswithterminal/selectallterminal/" + + "itemframeonsealanterns/list>"; } @Override @@ -70,7 +75,8 @@ public class ToggleCommand extends CommandBase implements ICommand { "expertiselore", "skill50display", "outlinetext", "midasstaffmessages", "healmessages", "caketimer", "lowhealthnotify", "lividsolver", "threemanpuzzle", "oruopuzzle", "blazepuzzle", "onlyshowcorrectblaze", "creeperpuzzle", - "waterpuzzle", "list"); + "waterpuzzle", "startswithterminal", "selectallterminal", + "itemframeonsealanterns", "list"); } return null; } @@ -226,6 +232,21 @@ public class ToggleCommand extends CommandBase implements ICommand { ConfigHandler.writeBooleanConfig("toggles", "WaterPuzzle", waterToggled); player.addChatMessage(new ChatComponentText(TheMod.MAIN_COLOUR + "Water puzzle solver has been set to " + TheMod.SECONDARY_COLOUR + waterToggled + TheMod.MAIN_COLOUR + ".")); break; + case "startswithterminal": + startsWithToggled = !startsWithToggled; + ConfigHandler.writeBooleanConfig("toggles", "StartsWithTerminal", startsWithToggled); + player.addChatMessage(new ChatComponentText(TheMod.MAIN_COLOUR + "Starts with letter terminal solver has been set to " + TheMod.SECONDARY_COLOUR + startsWithToggled + TheMod.MAIN_COLOUR + ".")); + break; + case "selectallterminal": + selectAllToggled = !selectAllToggled; + ConfigHandler.writeBooleanConfig("toggles", "SelectAllTerminal", selectAllToggled); + player.addChatMessage(new ChatComponentText(TheMod.MAIN_COLOUR + "Select all color items terminal solver has been set to " + TheMod.SECONDARY_COLOUR + selectAllToggled + TheMod.MAIN_COLOUR + ".")); + break; + case "itemframeonsealanterns": + itemFrameOnSeaLanternsToggled = !itemFrameOnSeaLanternsToggled; + ConfigHandler.writeBooleanConfig("toggles", "IgnoreItemFrameOnSeaLanterns", itemFrameOnSeaLanternsToggled); + player.addChatMessage(new ChatComponentText(TheMod.MAIN_COLOUR + "Ignore item frames on sea lanterns has been set to " + TheMod.SECONDARY_COLOUR + itemFrameOnSeaLanternsToggled + TheMod.MAIN_COLOUR + ".")); + break; case "list": player.addChatMessage(new ChatComponentText(TheMod.TYPE_COLOUR + "Guild party notifications: " + TheMod.VALUE_COLOUR + gpartyToggled + "\n" + TheMod.TYPE_COLOUR + " Coord/Angle display: " + TheMod.VALUE_COLOUR + coordsToggled + "\n" + @@ -254,7 +275,10 @@ public class ToggleCommand extends CommandBase implements ICommand { TheMod.TYPE_COLOUR + " Blaze puzzle solver: " + TheMod.VALUE_COLOUR + blazeToggled + "\n" + TheMod.TYPE_COLOUR + " Only show correct blaze: " + TheMod.VALUE_COLOUR + onlyShowCorrectBlazeToggled + "\n" + TheMod.TYPE_COLOUR + " Creeper puzzle solver: " + TheMod.VALUE_COLOUR + creeperToggled + "\n" + - TheMod.TYPE_COLOUR + " Water puzzle solver: " + TheMod.VALUE_COLOUR + waterToggled)); + TheMod.TYPE_COLOUR + " Water puzzle solver: " + TheMod.VALUE_COLOUR + waterToggled + "\n" + + TheMod.TYPE_COLOUR + " Starts with letter terminal solver: " + TheMod.VALUE_COLOUR + startsWithToggled + "\n" + + TheMod.TYPE_COLOUR + " Select all color items terminal solver: " + TheMod.VALUE_COLOUR + selectAllToggled + "\n" + + TheMod.TYPE_COLOUR + " Ignore item frames on sea lanterns: " + TheMod.VALUE_COLOUR + itemFrameOnSeaLanternsToggled)); default: player.addChatMessage(new ChatComponentText(TheMod.ERROR_COLOUR + "Usage: " + getCommandUsage(arg0))); } diff --git a/src/main/java/me/Danker/gui/DankerGui.java b/src/main/java/me/Danker/gui/DankerGui.java index f086e25..168f7c7 100644 --- a/src/main/java/me/Danker/gui/DankerGui.java +++ b/src/main/java/me/Danker/gui/DankerGui.java @@ -107,42 +107,47 @@ public class DankerGui extends GuiScreen { rngesusAlert = new GuiButton(0, width / 2 - 100, (int) (height * 0.4), "RNGesus Alerts: " + Utils.getColouredBoolean(ToggleCommand.rngesusAlerts)); lowHealthNotify = new GuiButton(0, width / 2 - 100, (int) (height * 0.5), "Low Health Notifications: " + Utils.getColouredBoolean(ToggleCommand.lowHealthNotifyToggled)); - if (page == 1) { - this.buttonList.add(changeDisplay); - this.buttonList.add(onlySlayer); - this.buttonList.add(puzzleSolvers); - this.buttonList.add(skillTracker); - this.buttonList.add(outlineText); - this.buttonList.add(splitFishing); - this.buttonList.add(coords); - this.buttonList.add(nextPage); - } else if (page == 2) { - this.buttonList.add(dungeonTimer); - this.buttonList.add(cakeTimer); - this.buttonList.add(skill50Display); - this.buttonList.add(slayerCount); - this.buttonList.add(chatMaddox); - this.buttonList.add(aotd); - this.buttonList.add(lividDagger); - this.buttonList.add(nextPage); - this.buttonList.add(backPage); - } else if (page == 3) { - this.buttonList.add(gparty); - this.buttonList.add(spiritBearAlert); - this.buttonList.add(sceptreMessages); - this.buttonList.add(midasStaffMessages); - this.buttonList.add(healMessages); - this.buttonList.add(goldenEnch); - this.buttonList.add(petColours); - this.buttonList.add(nextPage); - this.buttonList.add(backPage); - } else if (page == 4) { - this.buttonList.add(expertiseLore); - this.buttonList.add(lividSolver); - this.buttonList.add(golemAlerts); - this.buttonList.add(rngesusAlert); - this.buttonList.add(lowHealthNotify); - this.buttonList.add(backPage); + switch (page) { + case 1: + this.buttonList.add(changeDisplay); + this.buttonList.add(onlySlayer); + this.buttonList.add(puzzleSolvers); + this.buttonList.add(skillTracker); + this.buttonList.add(outlineText); + this.buttonList.add(splitFishing); + this.buttonList.add(coords); + this.buttonList.add(nextPage); + break; + case 2: + this.buttonList.add(dungeonTimer); + this.buttonList.add(cakeTimer); + this.buttonList.add(skill50Display); + this.buttonList.add(slayerCount); + this.buttonList.add(chatMaddox); + this.buttonList.add(aotd); + this.buttonList.add(lividDagger); + this.buttonList.add(nextPage); + this.buttonList.add(backPage); + break; + case 3: + this.buttonList.add(gparty); + this.buttonList.add(spiritBearAlert); + this.buttonList.add(sceptreMessages); + this.buttonList.add(midasStaffMessages); + this.buttonList.add(healMessages); + this.buttonList.add(goldenEnch); + this.buttonList.add(petColours); + this.buttonList.add(nextPage); + this.buttonList.add(backPage); + break; + case 4: + this.buttonList.add(expertiseLore); + this.buttonList.add(lividSolver); + this.buttonList.add(golemAlerts); + this.buttonList.add(rngesusAlert); + this.buttonList.add(lowHealthNotify); + this.buttonList.add(backPage); + break; } this.buttonList.add(githubLink); diff --git a/src/main/java/me/Danker/gui/PuzzleSolversGui.java b/src/main/java/me/Danker/gui/PuzzleSolversGui.java index ff4a911..8e08389 100644 --- a/src/main/java/me/Danker/gui/PuzzleSolversGui.java +++ b/src/main/java/me/Danker/gui/PuzzleSolversGui.java @@ -11,13 +11,24 @@ import net.minecraft.client.gui.ScaledResolution; public class PuzzleSolversGui extends GuiScreen { + private int page; + private GuiButton goBack; + private GuiButton backPage; + private GuiButton nextPage; private GuiButton riddle; private GuiButton trivia; private GuiButton blaze; private GuiButton onlyShowCorrectBlaze; private GuiButton creeper; private GuiButton water; + private GuiButton startsWith; + private GuiButton selectAll; + private GuiButton itemFrameOnSeaLanterns; + + public PuzzleSolversGui(int page) { + this.page = page; + } @Override public boolean doesGuiPauseGame() { @@ -33,20 +44,39 @@ public class PuzzleSolversGui extends GuiScreen { int width = sr.getScaledWidth(); goBack = new GuiButton(0, 2, height - 30, 100, 20, "Go Back"); + backPage = new GuiButton(0, width / 2 - 100, (int) (height * 0.8), 80, 20, "< Back"); + nextPage = new GuiButton(0, width / 2 + 20, (int) (height * 0.8), 80, 20, "Next >"); + + // Page 1 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)); onlyShowCorrectBlaze = new GuiButton(0, width / 2 - 100, (int) (height * 0.4), "Only Show Correct Blaze Hitbox: " + Utils.getColouredBoolean(ToggleCommand.onlyShowCorrectBlazeToggled)); creeper = new GuiButton(0, width / 2 - 100, (int) (height * 0.5), "Creeper Solver: " + Utils.getColouredBoolean(ToggleCommand.creeperToggled)); water = new GuiButton(0, width / 2 - 100, (int) (height * 0.6), "Water Solver: " + Utils.getColouredBoolean(ToggleCommand.waterToggled)); + startsWith = new GuiButton(0, width / 2 - 100, (int) (height * 0.7), "Starts With Letter Terminal Solver: " + Utils.getColouredBoolean(ToggleCommand.startsWithToggled)); + // Page 2 + selectAll = new GuiButton(0, width / 2 - 100, (int) (height * 0.1), "Select All Color Terminal Solver: " + Utils.getColouredBoolean(ToggleCommand.selectAllToggled)); + itemFrameOnSeaLanterns = new GuiButton(0, width / 2 - 100, (int) (height * 0.2), "Ignore Item Frames On Lanterns: " + Utils.getColouredBoolean(ToggleCommand.itemFrameOnSeaLanternsToggled)); + switch (page) { + case 1: + this.buttonList.add(riddle); + this.buttonList.add(trivia); + this.buttonList.add(blaze); + this.buttonList.add(onlyShowCorrectBlaze); + this.buttonList.add(creeper); + this.buttonList.add(water); + this.buttonList.add(startsWith); + this.buttonList.add(nextPage); + break; + case 2: + this.buttonList.add(selectAll); + this.buttonList.add(itemFrameOnSeaLanterns); + this.buttonList.add(backPage); + break; + } this.buttonList.add(goBack); - this.buttonList.add(riddle); - this.buttonList.add(trivia); - this.buttonList.add(blaze); - this.buttonList.add(onlyShowCorrectBlaze); - this.buttonList.add(creeper); - this.buttonList.add(water); } @Override @@ -59,6 +89,10 @@ public class PuzzleSolversGui extends GuiScreen { public void actionPerformed(GuiButton button) { if (button == goBack) { TheMod.guiToOpen = "dankergui1"; + } else if (button == backPage) { + Minecraft.getMinecraft().displayGuiScreen(new PuzzleSolversGui(page - 1)); + } else if (button == nextPage) { + Minecraft.getMinecraft().displayGuiScreen(new PuzzleSolversGui(page + 1)); } else if (button == riddle) { ToggleCommand.threeManToggled = !ToggleCommand.threeManToggled; ConfigHandler.writeBooleanConfig("toggles", "ThreeManPuzzle", ToggleCommand.threeManToggled); @@ -83,6 +117,18 @@ public class PuzzleSolversGui extends GuiScreen { ToggleCommand.waterToggled = !ToggleCommand.waterToggled; ConfigHandler.writeBooleanConfig("toggles", "WaterPuzzle", ToggleCommand.waterToggled); water.displayString = "Water Solver: " + Utils.getColouredBoolean(ToggleCommand.waterToggled); + } else if (button == startsWith) { + ToggleCommand.startsWithToggled = !ToggleCommand.startsWithToggled; + ConfigHandler.writeBooleanConfig("toggle", "StartsWithTerminal", ToggleCommand.startsWithToggled); + startsWith.displayString = "Starts With Letter Terminal Solver: " + Utils.getColouredBoolean(ToggleCommand.startsWithToggled); + } else if (button == selectAll) { + ToggleCommand.selectAllToggled = !ToggleCommand.selectAllToggled; + ConfigHandler.writeBooleanConfig("toggle", "SelectAllTerminal", ToggleCommand.selectAllToggled); + selectAll.displayString = "Select All Color Terminal Solver: " + Utils.getColouredBoolean(ToggleCommand.selectAllToggled); + } else if (button == itemFrameOnSeaLanterns) { + ToggleCommand.itemFrameOnSeaLanternsToggled = !ToggleCommand.itemFrameOnSeaLanternsToggled; + ConfigHandler.writeBooleanConfig("toggles", "IgnoreItemFrameOnSeaLanterns", ToggleCommand.itemFrameOnSeaLanternsToggled); + itemFrameOnSeaLanterns.displayString = "Ignore Item Frames On Lanterns: " + Utils.getColouredBoolean(ToggleCommand.itemFrameOnSeaLanternsToggled); } } diff --git a/src/main/java/me/Danker/handlers/ConfigHandler.java b/src/main/java/me/Danker/handlers/ConfigHandler.java index 2758f3b..f87dd4c 100644 --- a/src/main/java/me/Danker/handlers/ConfigHandler.java +++ b/src/main/java/me/Danker/handlers/ConfigHandler.java @@ -202,6 +202,9 @@ public class ConfigHandler { if (!hasKey("toggles", "OnlyShowCorrectBlaze")) writeBooleanConfig("toggles", "OnlyShowCorrectBlaze", false); if (!hasKey("toggles", "CreeperPuzzle")) writeBooleanConfig("toggles", "CreeperPuzzle", false); if (!hasKey("toggles", "WaterPuzzle")) writeBooleanConfig("toggles", "WaterPuzzle", false); + if (!hasKey("toggles", "StartsWithTerminal")) writeBooleanConfig("toggles", "StartsWithTerminal", false); + if (!hasKey("toggles", "SelectAllTerminal")) writeBooleanConfig("toggles", "SelectAllTerminal", false); + if (!hasKey("toggles", "IgnoreItemFrameOnSeaLanterns")) writeBooleanConfig("toggles", "IgnoreItemFrameOnSeaLanterns", false); if (!hasKey("api", "APIKey")) writeStringConfig("api", "APIKey", ""); @@ -439,6 +442,9 @@ public class ConfigHandler { ToggleCommand.onlyShowCorrectBlazeToggled = getBoolean("toggles", "OnlyShowCorrectBlaze"); ToggleCommand.creeperToggled = getBoolean("toggles", "CreeperPuzzle"); ToggleCommand.waterToggled = getBoolean("toggles", "WaterPuzzle"); + ToggleCommand.startsWithToggled = getBoolean("toggles", "StartsWithTerminal"); + ToggleCommand.selectAllToggled = getBoolean("toggles", "SelectAllTerminal"); + ToggleCommand.itemFrameOnSeaLanternsToggled = getBoolean("toggles", "IgnoreItemFrameOnSeaLanterns"); String onlySlayer = getString("toggles", "BlockSlayer"); if (!onlySlayer.equals("")) { diff --git a/src/main/java/me/Danker/handlers/PacketHandler.java b/src/main/java/me/Danker/handlers/PacketHandler.java index ed1c8b0..716b27c 100644 --- a/src/main/java/me/Danker/handlers/PacketHandler.java +++ b/src/main/java/me/Danker/handlers/PacketHandler.java @@ -4,13 +4,23 @@ import java.lang.reflect.Field; import io.netty.channel.ChannelDuplexHandler; import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelPromise; +import me.Danker.commands.ToggleCommand; import me.Danker.utils.Utils; import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItemFrame; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; import net.minecraft.network.Packet; +import net.minecraft.network.play.client.C02PacketUseEntity; import net.minecraft.network.play.server.S04PacketEntityEquipment; +import net.minecraft.util.BlockPos; public class PacketHandler extends ChannelDuplexHandler { + // Spirit boots fix @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (Utils.inSkyblock && msg instanceof Packet && msg.getClass().getName().endsWith("S04PacketEntityEquipment")) { // Inventory packet name @@ -26,4 +36,26 @@ public class PacketHandler extends ChannelDuplexHandler { super.channelRead(ctx, msg); } + // Ignore item frames with arrows on sea lanterns + @Override + public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { + if (ToggleCommand.itemFrameOnSeaLanternsToggled && Utils.inDungeons && msg instanceof Packet && msg.getClass().getName().endsWith("C02PacketUseEntity")) { + Minecraft mc = Minecraft.getMinecraft(); + C02PacketUseEntity packet = (C02PacketUseEntity) msg; + Entity entityHit = packet.getEntityFromWorld(mc.theWorld); + if (entityHit instanceof EntityItemFrame) { + EntityItemFrame itemFrame = (EntityItemFrame) entityHit; + ItemStack item = itemFrame.getDisplayedItem(); + if (item != null && item.getItem() == Items.arrow) { + BlockPos blockPos = Utils.getBlockUnderItemFrame(mc.theWorld, itemFrame); + if (mc.theWorld.getBlockState(blockPos).getBlock() == Blocks.sea_lantern) { + return; + } + } + } + } + + super.write(ctx, msg, promise); + } + } diff --git a/src/main/java/me/Danker/utils/Utils.java b/src/main/java/me/Danker/utils/Utils.java index 29e61ed..245d071 100644 --- a/src/main/java/me/Danker/utils/Utils.java +++ b/src/main/java/me/Danker/utils/Utils.java @@ -23,6 +23,7 @@ import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.item.EntityItemFrame; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.scoreboard.ScoreObjective; @@ -31,6 +32,7 @@ import net.minecraft.util.BlockPos; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StringUtils; import net.minecraft.util.Vec3; +import net.minecraft.world.World; public class Utils { @@ -403,4 +405,19 @@ public class Utils { return closestBlock; } + public static BlockPos getBlockUnderItemFrame(World world, EntityItemFrame itemFrame) { + switch (itemFrame.facingDirection) { + case NORTH: + return new BlockPos(itemFrame.posX, itemFrame.posY, itemFrame.posZ + 1); + case EAST: + return new BlockPos(itemFrame.posX - 1, itemFrame.posY, itemFrame.posZ - 0.5); + case SOUTH: + return new BlockPos(itemFrame.posX, itemFrame.posY, itemFrame.posZ - 1); + case WEST: + return new BlockPos(itemFrame.posX + 1, itemFrame.posY, itemFrame.posZ - 0.5); + default: + return null; + } + } + } -- cgit