diff options
author | syeyoung <cyong06@naver.com> | 2021-02-10 15:55:13 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-02-10 15:55:13 +0900 |
commit | 26de881921c351c9b39dfef5e3770e7d042ddd53 (patch) | |
tree | 063fd5271545049467193e6dbdf646dae896019b /src/main/java/kr | |
parent | db031f747b432498f8ba877e6f4405e43ad433fb (diff) | |
download | Skyblock-Dungeons-Guide-26de881921c351c9b39dfef5e3770e7d042ddd53.tar.gz Skyblock-Dungeons-Guide-26de881921c351c9b39dfef5e3770e7d042ddd53.tar.bz2 Skyblock-Dungeons-Guide-26de881921c351c9b39dfef5e3770e7d042ddd53.zip |
bruh
Diffstat (limited to 'src/main/java/kr')
6 files changed, 128 insertions, 18 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTree.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTree.java index 009924cf..8afb9580 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTree.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTree.java @@ -12,9 +12,9 @@ import java.util.Map; import java.util.Set; @Data -public class ActionTree { +public class ActionTree implements Cloneable { @EqualsAndHashCode.Exclude - private ActionTree parent; + private Set<ActionTree> parent; private Action current; private Set<ActionTree> children; @@ -26,7 +26,7 @@ public class ActionTree { ActionRoot root = new ActionRoot(); root.setPreRequisite(actions); ActionTree tree = new ActionTree(); - tree.setParent(null); + tree.setParent(new HashSet<ActionTree>()); tree.setCurrent(root); HashSet<ActionTree> set = new HashSet(); for (Action action : actions) { @@ -43,11 +43,17 @@ public class ActionTree { private static ActionTree buildActionTree(ActionTree parent, Action action, DungeonRoom dungeonRoom, Map<Action, ActionTree> alreadyBuilt) { if (action == null) return null; - if (alreadyBuilt.containsKey(action)) return alreadyBuilt.get(action); + if (alreadyBuilt.containsKey(action)) { + ActionTree tree = alreadyBuilt.get(action); + tree.getParent().add(parent); + return tree; + } ActionTree tree = new ActionTree(); alreadyBuilt.put(action, tree); - tree.setParent(parent); + tree.setParent(new HashSet<ActionTree>()); + if (parent != null) + tree.getParent().add(parent); tree.setCurrent(action); HashSet<ActionTree> set = new HashSet(); for (Action action2 : action.getPreRequisites(dungeonRoom)) { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTreeUtil.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTreeUtil.java new file mode 100644 index 00000000..c55bc149 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTreeUtil.java @@ -0,0 +1,65 @@ +package kr.syeyoung.dungeonsguide.dungeon.actions.tree; + +import kr.syeyoung.dungeonsguide.dungeon.actions.Action; + +import java.util.*; + +public class ActionTreeUtil { + public static List<Action> linearifyActionTree(ActionTree input) { + ActionTree tree = copyActionTree(input); + + List<Action> actions = new ArrayList<Action>(); + + int plsHalt = 0; + while (tree.getChildren().size() != 0) { + plsHalt ++; + if (plsHalt > 1000000) throw new IllegalStateException("Linearifying process ran for 1 million cycle"); + Set<ActionTree> visited = new HashSet<ActionTree>(); + ActionTree curr = tree; + + int plsHalt2 = 0; + while (curr.getChildren().size() != 0) { + plsHalt2 ++; + if (plsHalt2 > 1000000) throw new IllegalStateException("Finding the leaf of tree ran for 1 million cycles"); + if (visited.contains(curr)) throw new IllegalStateException("Circular Reference Detected"); + visited.add(curr); + curr = curr.getChildren().iterator().next(); + } + + plsHalt2 =0; + while(curr.getChildren().size() == 0) { + plsHalt2 ++; + if (plsHalt2 > 1000000) throw new IllegalStateException("Building of array ran for 1 million cycles"); + + actions.add(curr.getCurrent()); + if (curr.getParent().size() == 0) break; + for (ActionTree parentTree:curr.getParent()) + parentTree.getChildren().remove(curr); + curr = curr.getParent().iterator().next(); + } + } + return actions; + } + + public static ActionTree copyActionTree(ActionTree tree) { + Map<ActionTree, ActionTree> built = new HashMap<ActionTree, ActionTree>(); + if (tree.getParent().size() != 0) throw new IllegalArgumentException("that is not head of tree"); + return copyActionTree(tree, built); + } + private static ActionTree copyActionTree(ActionTree tree, Map<ActionTree, ActionTree> preBuilts) { + if (preBuilts.containsKey(tree)) return preBuilts.get(tree); + + ActionTree clone = new ActionTree(); + preBuilts.put(tree, clone); + + clone.setCurrent(tree.getCurrent()); + clone.setParent(new HashSet<ActionTree>()); + clone.setChildren(new HashSet<ActionTree>()); + for (ActionTree tree3 : tree.getChildren()) { + ActionTree clone3 = copyActionTree(tree3, preBuilts); + clone3.getParent().add(clone); + clone.getChildren().add(clone3); + } + return clone; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureWarnLowHealth.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureWarnLowHealth.java index d635f065..2501fa03 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureWarnLowHealth.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureWarnLowHealth.java @@ -74,9 +74,9 @@ public class FeatureWarnLowHealth extends TextHUDFeature { ScorePlayerTeam scorePlayerTeam = scoreboard.getPlayersTeam(sc.getPlayerName()); String line = ScorePlayerTeam.formatPlayerName(scorePlayerTeam, sc.getPlayerName()).trim(); String stripped = TextUtils.keepScoreboardCharacters(TextUtils.stripColor(line)); - if (line.endsWith("❤")) { - String name = stripped.split(" ")[1]; - int health = Integer.parseInt(stripped.split(" ")[2]); + if (line.contains("[") && line.endsWith("❤")) { + String name = stripped.split(" ")[stripped.split(" ").length - 2]; + int health = Integer.parseInt(stripped.split(" ")[stripped.split(" ").length - 1]); if (health < lowestHealth) { lowestHealth = health; lowestHealthName = name; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureCooldownCounter.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureCooldownCounter.java index ddad792e..77ae91e8 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureCooldownCounter.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/etc/FeatureCooldownCounter.java @@ -53,7 +53,7 @@ public class FeatureCooldownCounter extends GuiFeature implements DungeonQuitLis public void onGuiOpen(GuiOpenEvent rendered) { if (!(rendered.gui instanceof GuiChest)) return; ContainerChest chest = (ContainerChest) ((GuiChest) rendered.gui).inventorySlots; - if (chest.getLowerChestInventory().getName().contains("On Cooldown!")) { + if (chest.getLowerChestInventory().getName().contains("On cooldown!")) { leftDungeonTime = System.currentTimeMillis(); } else if (chest.getLowerChestInventory().getName().contains("Error")) { leftDungeonTime = System.currentTimeMillis(); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionTreeDisplayPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionTreeDisplayPane.java index b85f9060..3a111436 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionTreeDisplayPane.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionTreeDisplayPane.java @@ -2,6 +2,7 @@ package kr.syeyoung.dungeonsguide.roomedit.panes; import kr.syeyoung.dungeonsguide.dungeon.actions.Action; import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionTree; +import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionTreeUtil; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.gui.MPanel; import net.minecraft.client.Minecraft; @@ -13,6 +14,7 @@ import org.lwjgl.opengl.GL11; import java.awt.*; import java.util.*; +import java.util.List; public class ActionTreeDisplayPane extends MPanel { @@ -23,9 +25,17 @@ public class ActionTreeDisplayPane extends MPanel { private DungeonRoom dungeonRoom; private ActionTree tree; + private List<Action> linearified; public ActionTreeDisplayPane(DungeonRoom dungeonRoom, ActionTree tree) { this.dungeonRoom = dungeonRoom; this.tree = tree; + try { + this.linearified = ActionTreeUtil.linearifyActionTree(tree); + } catch (Exception e) { + linearified = new ArrayList<Action>(); + e.printStackTrace(); + } + scale = 1.0f; } @Override @@ -37,7 +47,8 @@ public class ActionTreeDisplayPane extends MPanel { GlStateManager.pushMatrix(); GlStateManager.translate(offsetX, offsetY, 0); GlStateManager.scale(scale,scale,1); - renderTree(tree, 5, 5, Minecraft.getMinecraft().fontRendererObj, null, new HashMap<ActionTree, Point>()); + int x = renderTree(tree, 5, 5, Minecraft.getMinecraft().fontRendererObj, null, new HashMap<ActionTree, Point>()); + renderLinearified(linearified, x, 5, fr); GlStateManager.popMatrix(); } @@ -101,6 +112,40 @@ public class ActionTreeDisplayPane extends MPanel { return Math.max(xOff, dim.width); } + public void renderLinearified(List<Action> actions, int x, int y, FontRenderer fr) { + Point lastPt = null; + int y2 = y; + + for (Action action : actions) { + Dimension dim = renderAction(action, x, y2, fr); + if (lastPt != null) { + GlStateManager.pushMatrix(); + GlStateManager.pushAttrib(); + + GlStateManager.enableBlend(); + GlStateManager.disableDepth(); + GlStateManager.disableTexture2D(); + GlStateManager.blendFunc(770, 771); + GlStateManager.enableBlend(); + GL11.glLineWidth(1); + GlStateManager.color(1, 1, 1, 1); + GL11.glBegin(2); + GL11.glVertex2d(lastPt.x, lastPt.y); + GL11.glVertex2d(x + dim.width / 2, y2); + GL11.glEnd(); + GlStateManager.disableBlend(); + GlStateManager.enableTexture2D(); + GlStateManager.enableDepth(); + GlStateManager.disableBlend(); + GlStateManager.popMatrix(); + GlStateManager.popAttrib(); + } + lastPt = new Point(x + dim.width / 2, y2 + dim.height); + + y2 += dim.height + 10; + } + } + public Dimension renderAction(Action action, int x, int y, FontRenderer fr) { String[] lines = action.toString().split("\n"); int maxWidth = 0; @@ -147,5 +192,7 @@ public class ActionTreeDisplayPane extends MPanel { public void mouseScrolled0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { if (scrollAmount > 0) scale += 0.1; if (scrollAmount < 0) scale -= 0.1; + + if (scale < 0) scale = 0.1f; } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java index 301d60f5..68a43b36 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java @@ -44,13 +44,6 @@ public class GeneralRoomProcessor implements RoomProcessor { @Override public void drawScreen(float partialTicks) { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - Entity e = Minecraft.getMinecraft().objectMouseOver.entityHit; - if (e != null && e instanceof EntityArmorStand) { -// fr.drawString( -// e.getInventory()[4].getTagCompound() +"", 0, 0, 0xFFFFFFFF); -// System.out.println(e.getInventory()[4].getTagCompound()); - } } @Override @@ -123,7 +116,6 @@ public class GeneralRoomProcessor implements RoomProcessor { @Override public void onPostGuiRender(GuiScreenEvent.DrawScreenEvent.Post event) { - } @Override |