diff options
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/features/impl')
9 files changed, 454 insertions, 0 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/CorrectThePaneSolutionProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/CorrectThePaneSolutionProvider.java new file mode 100644 index 00000000..33bfa631 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/CorrectThePaneSolutionProvider.java @@ -0,0 +1,35 @@ +package kr.syeyoung.dungeonsguide.features.impl.boss.terminal; + +import net.minecraft.init.Blocks; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.Slot; +import net.minecraft.item.EnumDyeColor; +import net.minecraft.item.Item; + +import java.util.ArrayList; +import java.util.List; + +public class CorrectThePaneSolutionProvider implements TerminalSolutionProvider { + @Override + public TerminalSolution provideSolution(ContainerChest chest, List<Slot> clicked) { + TerminalSolution ts = new TerminalSolution(); + ts.setCurrSlots(new ArrayList<Slot>()); + for (Slot inventorySlot : chest.inventorySlots) { + if (inventorySlot.inventory != chest.getLowerChestInventory()) continue; + if (inventorySlot.getHasStack() && inventorySlot.getStack() != null) { + if (inventorySlot.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && + inventorySlot.getStack().getItemDamage() == EnumDyeColor.RED.getMetadata()) { + ts.getCurrSlots().add(inventorySlot); + } + } + } + + + return ts; + } + + @Override + public boolean isApplicable(ContainerChest chest) { + return chest.getLowerChestInventory().getName().equals("Correct all the panes!"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/FeatureTerminalSolvers.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/FeatureTerminalSolvers.java new file mode 100644 index 00000000..07ab1106 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/FeatureTerminalSolvers.java @@ -0,0 +1,138 @@ +package kr.syeyoung.dungeonsguide.features.impl.boss.terminal; + +import kr.syeyoung.dungeonsguide.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.features.listener.*; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.Slot; +import net.minecraftforge.client.event.GuiOpenEvent; +import net.minecraftforge.client.event.GuiScreenEvent; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; +import org.lwjgl.input.Mouse; + +import java.util.ArrayList; +import java.util.List; + +public class FeatureTerminalSolvers extends SimpleFeature implements GuiOpenListener, TickListener, GuiPostRenderListener, GuiClickListener, TooltipListener { + public FeatureTerminalSolvers() { + super("Bossfight","F7 GUI Terminal Solver", "Solve f7 gui terminals. (color, startswith, order, navigate, correct panes)", "bossfight.terminals"); + } + + public static final List<TerminalSolutionProvider> solutionProviders = new ArrayList<TerminalSolutionProvider>(); + + static { + solutionProviders.add(new WhatStartsWithSolutionProvider()); + solutionProviders.add(new SelectAllColorSolutionProivider()); + solutionProviders.add(new SelectInOrderSolutionProvider()); + solutionProviders.add(new NavigateMazeSolutionProvider()); + solutionProviders.add(new CorrectThePaneSolutionProvider()); + } + + private TerminalSolutionProvider solutionProvider; + private TerminalSolution solution; + private List<Slot> clicked = new ArrayList<Slot>(); + + @Override + public void onGuiOpen(GuiOpenEvent event) { + if (!isEnabled()) return; + solution = null; + solutionProvider = null; + clicked.clear(); + if (event.gui instanceof GuiChest) { + ContainerChest cc = (ContainerChest) ((GuiChest) event.gui).inventorySlots; + for (TerminalSolutionProvider solutionProvider : solutionProviders) { + if (solutionProvider.isApplicable(cc)) { + solution = solutionProvider.provideSolution(cc, clicked); + this.solutionProvider = solutionProvider; + } + } + } + } + + @Override + public void onTick() { + if (!isEnabled()) return; + if (solutionProvider == null) return; + if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) { + solution = null; + solutionProvider = null; + clicked.clear(); + return; + } + ContainerChest cc = (ContainerChest) ((GuiChest) Minecraft.getMinecraft().currentScreen).inventorySlots; + + solution = solutionProvider.provideSolution(cc, clicked); + } + + @Override + public void onGuiPostRender(GuiScreenEvent.DrawScreenEvent.Post rendered) { + if (!isEnabled()) return; + if (solutionProvider == null) return; + if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) { + solution = null; + solutionProvider = null; + clicked.clear(); + return; + } + + if (solution != null) { + int i = 222; + int j = i - 108; + int ySize = j + (((ContainerChest)(((GuiChest) Minecraft.getMinecraft().currentScreen).inventorySlots)).getLowerChestInventory().getSizeInventory() / 9) * 18; + int left = (rendered.gui.width - 176) / 2; + int top = (rendered.gui.height - ySize ) / 2; + GlStateManager.pushMatrix(); + GlStateManager.disableDepth(); + GlStateManager.disableLighting(); + GlStateManager.colorMask(true, true, true, false); + GlStateManager.translate(left, top, 0); + if (solution.getCurrSlots() != null) { + for (Slot currSlot : solution.getCurrSlots()) { + int x = currSlot.xDisplayPosition; + int y = currSlot.yDisplayPosition; + Gui.drawRect(x, y, x + 16, y + 16, 0x7700FFFF); + } + } + if (solution.getNextSlots() != null) { + for (Slot nextSlot : solution.getNextSlots()) { + int x = nextSlot.xDisplayPosition; + int y = nextSlot.yDisplayPosition; + Gui.drawRect(x, y, x + 16, y + 16, 0x77FFFF00); + } + } + GlStateManager.colorMask(true, true, true, true); + GlStateManager.popMatrix(); + } + } + + @Override + public void onMouseInput(GuiScreenEvent.MouseInputEvent.Pre mouseInputEvent) { + if (!isEnabled()) return; + if (Mouse.getEventButton() == -1) return; + if (solutionProvider == null) return; + if (solution == null) return; + if (solution.getCurrSlots() == null) { + mouseInputEvent.setCanceled(true); + return; + } + mouseInputEvent.setCanceled(true); + Slot s = ((GuiChest) Minecraft.getMinecraft().currentScreen).getSlotUnderMouse(); + if (solution.getCurrSlots().contains(s)) { + clicked.add(s); + Minecraft.getMinecraft().playerController.windowClick(((GuiChest)Minecraft.getMinecraft().currentScreen).inventorySlots.windowId, s.getSlotIndex(), + 2, 0, Minecraft.getMinecraft().thePlayer); + return; + } + } + + @Override + public void onTooltip(ItemTooltipEvent event) { + if (!isEnabled()) return; + if (solutionProvider == null) return; + event.toolTip.clear(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/NavigateMazeSolutionProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/NavigateMazeSolutionProvider.java new file mode 100644 index 00000000..6a19d848 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/NavigateMazeSolutionProvider.java @@ -0,0 +1,126 @@ +package kr.syeyoung.dungeonsguide.features.impl.boss.terminal; + +import net.minecraft.init.Blocks; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.Slot; +import net.minecraft.item.EnumDyeColor; +import net.minecraft.item.Item; + +import java.util.ArrayList; +import java.util.List; + +public class NavigateMazeSolutionProvider implements TerminalSolutionProvider { + @Override + public TerminalSolution provideSolution(ContainerChest chest, List<Slot> clicked) { + TerminalSolution ts = new TerminalSolution(); + ts.setCurrSlots(new ArrayList<Slot>()); + Slot solution = null; + for (Slot inventorySlot : chest.inventorySlots) { + if (inventorySlot.inventory != chest.getLowerChestInventory()) continue; + if (inventorySlot.getHasStack() && inventorySlot.getStack() != null) { + if (inventorySlot.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && + inventorySlot.getStack().getItemDamage() == EnumDyeColor.WHITE.getMetadata()) { + int x = inventorySlot.slotNumber % 9; + int y = inventorySlot.slotNumber / 9; + + if (x > 0) { + Slot toChk = chest.inventorySlots.get(y * 9 + x - 1); + + if (toChk.getHasStack() && toChk.getStack() != null && + toChk.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && + toChk.getStack().getItemDamage() == EnumDyeColor.LIME.getMetadata()) { + solution = inventorySlot; + break; + } + } + if (x < 8) { + Slot toChk = chest.inventorySlots.get(y * 9 + x + 1); + + if (toChk.getHasStack() && toChk.getStack() != null && + toChk.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && + toChk.getStack().getItemDamage() == EnumDyeColor.LIME.getMetadata()) { + solution = inventorySlot; + break; + } + } + if (y > 0) { + Slot toChk = chest.inventorySlots.get((y-1) * 9 + x); + + if (toChk.getHasStack() && toChk.getStack() != null && + toChk.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && + toChk.getStack().getItemDamage() == EnumDyeColor.LIME.getMetadata()) { + solution = inventorySlot; + break; + } + } + if (y < chest.getLowerChestInventory().getSizeInventory() / 9 - 1) { + Slot toChk = chest.inventorySlots.get((y+1) * 9 + x); + + if (toChk.getHasStack() && toChk.getStack() != null && + toChk.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && + toChk.getStack().getItemDamage() == EnumDyeColor.LIME.getMetadata()) { + solution = inventorySlot; + break; + } + } + } + } + } + + if (solution == null) return null; + ts.getCurrSlots().add(solution); + ts.setNextSlots(new ArrayList<Slot>()); + { + int x = solution.slotNumber % 9; + int y = solution.slotNumber / 9; + + if (x > 0) { + Slot toChk = chest.inventorySlots.get(y * 9 + x - 1); + + if (toChk.getHasStack() && toChk.getStack() != null && + toChk.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && + toChk.getStack().getItemDamage() == EnumDyeColor.WHITE.getMetadata()) { + ts.getNextSlots().add(toChk); + return ts; + } + } + if (x < 8) { + Slot toChk = chest.inventorySlots.get(y * 9 + x + 1); + + if (toChk.getHasStack() && toChk.getStack() != null && + toChk.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && + toChk.getStack().getItemDamage() == EnumDyeColor.WHITE.getMetadata()) { + ts.getNextSlots().add(toChk); + return ts; + } + } + if (y > 0) { + Slot toChk = chest.inventorySlots.get((y-1) * 9 + x); + + if (toChk.getHasStack() && toChk.getStack() != null && + toChk.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && + toChk.getStack().getItemDamage() == EnumDyeColor.WHITE.getMetadata()) { + ts.getNextSlots().add(toChk); + return ts; + } + } + if (y < chest.getLowerChestInventory().getSizeInventory() / 9 - 1) { + Slot toChk = chest.inventorySlots.get((y+1) * 9 + x); + + if (toChk.getHasStack() && toChk.getStack() != null && + toChk.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && + toChk.getStack().getItemDamage() == EnumDyeColor.WHITE.getMetadata()) { + ts.getNextSlots().add(toChk); + return ts; + } + } + } + + return ts; + } + + @Override + public boolean isApplicable(ContainerChest chest) { + return chest.getLowerChestInventory().getName().equals("Navigate the maze!"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/SelectAllColorSolutionProivider.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/SelectAllColorSolutionProivider.java new file mode 100644 index 00000000..663cce11 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/SelectAllColorSolutionProivider.java @@ -0,0 +1,42 @@ +package kr.syeyoung.dungeonsguide.features.impl.boss.terminal; + +import net.minecraft.init.Items; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.Slot; +import net.minecraft.item.EnumDyeColor; + +import java.util.ArrayList; +import java.util.List; + +public class SelectAllColorSolutionProivider implements TerminalSolutionProvider { + @Override + public TerminalSolution provideSolution(ContainerChest chest, List<Slot> clicked) { + TerminalSolution ts = new TerminalSolution(); + ts.setCurrSlots(new ArrayList<Slot>()); + String name = chest.getLowerChestInventory().getName(); + EnumDyeColor edc = null; + for (EnumDyeColor edc2 : EnumDyeColor.values()) { + if (name.contains(edc2.getName().toUpperCase().replace("_"," "))) { + edc = edc2; + break; + } + } + if (edc == null) return null; + + for (Slot inventorySlot : chest.inventorySlots) { + if (inventorySlot.inventory != chest.getLowerChestInventory()) continue; + if (inventorySlot.getHasStack() && inventorySlot.getStack() != null && !inventorySlot.getStack().isItemEnchanted()) { + if (inventorySlot.getStack().getItem() != Items.dye && inventorySlot.getStack().getItemDamage() == edc.getMetadata()) + ts.getCurrSlots().add(inventorySlot); + else if (inventorySlot.getStack().getItem() == Items.dye && inventorySlot.getStack().getItemDamage() == edc.getDyeDamage()) + ts.getCurrSlots().add(inventorySlot); + } + } + return ts; + } + + @Override + public boolean isApplicable(ContainerChest chest) { + return chest.getLowerChestInventory().getName().startsWith("Select all the "); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/SelectInOrderSolutionProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/SelectInOrderSolutionProvider.java new file mode 100644 index 00000000..d03f71fa --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/SelectInOrderSolutionProvider.java @@ -0,0 +1,54 @@ +package kr.syeyoung.dungeonsguide.features.impl.boss.terminal; + +import net.minecraft.init.Blocks; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.Slot; +import net.minecraft.item.EnumDyeColor; +import net.minecraft.item.Item; + +import java.util.ArrayList; +import java.util.List; + +public class SelectInOrderSolutionProvider implements TerminalSolutionProvider { + @Override + public TerminalSolution provideSolution(ContainerChest chest, List<Slot> clicked) { + TerminalSolution ts = new TerminalSolution(); + ts.setCurrSlots(new ArrayList<Slot>()); + int lowest = 1000; + Slot slotLowest = null; + for (Slot inventorySlot : chest.inventorySlots) { + if (inventorySlot.inventory != chest.getLowerChestInventory()) continue; + if (inventorySlot.getHasStack() && inventorySlot.getStack() != null && inventorySlot.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) + && inventorySlot.getStack().getItemDamage() == EnumDyeColor.LIME.getMetadata()) { + if (inventorySlot.getStack().stackSize < lowest) { + lowest = inventorySlot.getStack().stackSize; + slotLowest = inventorySlot; + } + } + } + if (slotLowest != null) + ts.getCurrSlots().add(slotLowest); + + Slot next = null; + for (Slot inventorySlot : chest.inventorySlots) { + if (inventorySlot.inventory != chest.getLowerChestInventory()) continue; + if (inventorySlot.getHasStack() && inventorySlot.getStack() != null && inventorySlot.getStack().getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) + && inventorySlot.getStack().getItemDamage() == EnumDyeColor.LIME.getMetadata()) { + if (inventorySlot.getStack().stackSize == lowest + 1) { + next = inventorySlot; + } + } + } + if (next != null) { + ts.setNextSlots(new ArrayList<Slot>()); + ts.getNextSlots().add(next); + } + + return ts; + } + + @Override + public boolean isApplicable(ContainerChest chest) { + return chest.getLowerChestInventory().getName().equals("Click in order!"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/TerminalSolution.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/TerminalSolution.java new file mode 100644 index 00000000..bf82d5f2 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/TerminalSolution.java @@ -0,0 +1,12 @@ +package kr.syeyoung.dungeonsguide.features.impl.boss.terminal; + +import lombok.Data; +import net.minecraft.inventory.Slot; + +import java.util.List; + +@Data +public class TerminalSolution { + private List<Slot> currSlots; + private List<Slot> nextSlots; +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/TerminalSolutionProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/TerminalSolutionProvider.java new file mode 100644 index 00000000..3a3dbe03 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/TerminalSolutionProvider.java @@ -0,0 +1,11 @@ +package kr.syeyoung.dungeonsguide.features.impl.boss.terminal; + +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.Slot; + +import java.util.List; + +public interface TerminalSolutionProvider { + TerminalSolution provideSolution(ContainerChest chest, List<Slot> clicked); + boolean isApplicable(ContainerChest chest); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/WhatStartsWithSolutionProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/WhatStartsWithSolutionProvider.java new file mode 100644 index 00000000..eb33a5b5 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/WhatStartsWithSolutionProvider.java @@ -0,0 +1,33 @@ +package kr.syeyoung.dungeonsguide.features.impl.boss.terminal; + +import kr.syeyoung.dungeonsguide.utils.TextUtils; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.Slot; +import org.apache.logging.log4j.core.appender.db.jpa.converter.ThrowableAttributeConverter; + +import java.util.ArrayList; +import java.util.List; + +public class WhatStartsWithSolutionProvider implements TerminalSolutionProvider{ + @Override + public TerminalSolution provideSolution(ContainerChest chest, List<Slot> clicked) { + String that = chest.getLowerChestInventory().getName().replace("What starts with: '", "").replace("'?", "").trim().toLowerCase(); + + TerminalSolution ts = new TerminalSolution(); + ts.setCurrSlots(new ArrayList<Slot>()); + for (Slot inventorySlot : chest.inventorySlots) { + if (inventorySlot.inventory != chest.getLowerChestInventory()) continue; + if (inventorySlot.getHasStack() && inventorySlot.getStack() != null && !inventorySlot.getStack().isItemEnchanted() ) { + String name = TextUtils.stripColor(inventorySlot.getStack().getDisplayName()).toLowerCase(); + if (name.startsWith(that)) + ts.getCurrSlots().add(inventorySlot); + } + } + return ts; + } + + @Override + public boolean isApplicable(ContainerChest chest) { + return chest.getLowerChestInventory().getName().startsWith("What starts with: '"); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureMechanicBrowse.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureMechanicBrowse.java index 2e1451dc..e7aa9421 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureMechanicBrowse.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureMechanicBrowse.java @@ -97,6 +97,7 @@ public class FeatureMechanicBrowse extends GuiFeature implements GuiPreRenderLis @Override public void onGuiPreRender(GuiScreenEvent.DrawScreenEvent.Pre rendered) { + if (!isEnabled()) return; if (Minecraft.getMinecraft().currentScreen instanceof GuiGuiLocationConfig || Minecraft.getMinecraft().currentScreen instanceof GuiConfig || Minecraft.getMinecraft().currentScreen instanceof GuiDungeonRoomEdit @@ -294,6 +295,7 @@ public class FeatureMechanicBrowse extends GuiFeature implements GuiPreRenderLis @Override public void onMouseInput(GuiScreenEvent.MouseInputEvent.Pre mouseInputEvent) { + if (!isEnabled()) return; if (Minecraft.getMinecraft().currentScreen instanceof GuiGuiLocationConfig || Minecraft.getMinecraft().currentScreen instanceof GuiConfig || Minecraft.getMinecraft().currentScreen instanceof GuiDungeonRoomEdit @@ -383,6 +385,7 @@ public class FeatureMechanicBrowse extends GuiFeature implements GuiPreRenderLis @Override public void drawWorld(float partialTicks) { + if (!isEnabled()) return; if (!skyblockStatus.isOnDungeon()) return; if (skyblockStatus.getContext() == null || !skyblockStatus.getContext().getMapProcessor().isInitialized()) return; DungeonContext context = skyblockStatus.getContext(); |