diff options
Diffstat (limited to 'src/main/java/kr/syeyoung')
27 files changed, 459 insertions, 119 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java b/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java index 1093e645..99fa3d17 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/Keybinds.java @@ -32,6 +32,7 @@ public class Keybinds public static KeyBinding editingSession; public static KeyBinding sendBombdefuse; public static KeyBinding nextSecret; + public static KeyBinding refreshPathfind; public static KeyBinding togglePathfind; public static KeyBinding freezeLines; @@ -45,6 +46,8 @@ public class Keybinds ClientRegistry.registerKeyBinding(nextSecret); togglePathfind = new KeyBinding("Toggle Pathfind. (Req option enabled at /dg)", Keyboard.KEY_NONE, "Dungeons Guide"); ClientRegistry.registerKeyBinding(togglePathfind); + refreshPathfind = new KeyBinding("Refresh or Pathfind Pathfindline to hovered secret", Keyboard.KEY_NONE, "Dungeons Guide"); + ClientRegistry.registerKeyBinding(refreshPathfind); freezeLines = new KeyBinding("Toggle freeze pathfind lines", Keyboard.KEY_NONE, "Dungeons Guide"); ClientRegistry.registerKeyBinding(freezeLines); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java index 8ef26e1e..918aedca 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java @@ -166,7 +166,7 @@ public class CommandDungeonsGuide extends CommandBase { DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); GeneralRoomProcessor grp = (GeneralRoomProcessor) dungeonRoom.getRoomProcessor(); - grp.pathfind("COMMAND", args[1], args[2]); + grp.pathfind("COMMAND", args[1], args[2], FeatureRegistry.SECRET_LINE_PROPERTIES_GLOBAL.getRouteProperties()); } catch (Throwable t) { t.printStackTrace(); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MCategory.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MCategory.java index b0062df5..77111fe7 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MCategory.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MCategory.java @@ -25,9 +25,11 @@ import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor; import lombok.Getter; import lombok.Setter; import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; @@ -87,8 +89,10 @@ public class MCategory extends MPanel { @Override public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { - if (lastAbsClip.contains(absMouseX, absMouseY)) + if (lastAbsClip.contains(absMouseX, absMouseY)) { + Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F)); rootConfigPanel.setCurrentPageAndPushHistory(nestedCategory.categoryFull()); + } } @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameterEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameterEdit.java index 5cf44bc8..b4b2a8e8 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameterEdit.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameterEdit.java @@ -18,6 +18,7 @@ package kr.syeyoung.dungeonsguide.config.guiconfig; +import com.google.common.base.Predicates; import kr.syeyoung.dungeonsguide.config.types.AColor; import kr.syeyoung.dungeonsguide.features.AbstractFeature; import kr.syeyoung.dungeonsguide.features.FeatureParameter; @@ -29,6 +30,7 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; import java.awt.*; +import java.util.function.Predicate; public class MParameterEdit extends MPanel { private AbstractFeature abstractFeature; @@ -37,10 +39,17 @@ public class MParameterEdit extends MPanel { private MPanel valueEditHolder; private MPanel valueEdit; + private Predicate<FeatureParameter> isDisabled ; + public MParameterEdit(AbstractFeature abstractFeature, FeatureParameter parameter, RootConfigPanel rootConfigPanel) { + this(abstractFeature, parameter, rootConfigPanel, (a) -> false); + } + + public MParameterEdit(AbstractFeature abstractFeature, FeatureParameter parameter, RootConfigPanel rootConfigPanel, Predicate<FeatureParameter> isDisabled ) { this.abstractFeature = abstractFeature; this.featureParameter = parameter; this.rootConfigPanel = rootConfigPanel; + this.isDisabled = isDisabled; if (parameter.getValue_type().equals("string")) { valueEdit = new MTextField() { @@ -133,6 +142,14 @@ public class MParameterEdit extends MPanel { } @Override + public void render0(double scale, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { + super.render0(scale, parentPoint, parentClip, absMousex, absMousey, relMousex0, relMousey0, partialTicks); + if (isDisabled.test(featureParameter)) { + Gui.drawRect(0,0, getBounds().width, getBounds().height, 0x55000000); + } + } + + @Override public Dimension getPreferredSize() { FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; int descriptionHeight = fr.listFormattedStringToWidth(featureParameter.getDescription(), Math.max(50, 2*bounds.width/3-10)).size() * fr.FONT_HEIGHT; @@ -144,4 +161,52 @@ public class MParameterEdit extends MPanel { super.setBounds(bounds); valueEditHolder.setBounds(new Rectangle(2*bounds.width / 3, 0, bounds.width / 3, bounds.height)); } + + @Override + public void keyPressed0(char typedChar, int keyCode) { + if (isDisabled.test(featureParameter)) return; + super.keyPressed0(typedChar, keyCode); + } + + @Override + public void keyHeld0(char typedChar, int keyCode, long heldMS) { + if (isDisabled.test(featureParameter)) return; + super.keyHeld0(typedChar, keyCode, heldMS); + } + + @Override + public void keyReleased0(char typedChar, int keyCode, long heldMS) { + if (isDisabled.test(featureParameter)) return; + super.keyReleased0(typedChar, keyCode, heldMS); + } + + @Override + public boolean mouseClicked0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int mouseButton) { + if (isDisabled.test(featureParameter)) return false; + return super.mouseClicked0(absMouseX, absMouseY, relMouseX0, relMouseY0, mouseButton); + } + + @Override + public void mouseReleased0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int state) { + if (isDisabled.test(featureParameter)) return ; + super.mouseReleased0(absMouseX, absMouseY, relMouseX0, relMouseY0, state); + } + + @Override + public void mouseClickMove0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int clickedMouseButton, long timeSinceLastClick) { + if (isDisabled.test(featureParameter)) return ; + super.mouseClickMove0(absMouseX, absMouseY, relMouseX0, relMouseY0, clickedMouseButton, timeSinceLastClick); + } + + @Override + public void mouseScrolled0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) { + if (isDisabled.test(featureParameter)) return ; + super.mouseScrolled0(absMouseX, absMouseY, relMouseX0, relMouseY0, scrollAmount); + } + + @Override + public void mouseMoved0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) { + if (isDisabled.test(featureParameter)) return ; + super.mouseMoved0(absMouseX, absMouseY, relMouseX0, relMouseY0); + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/AbstractAction.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/AbstractAction.java index a551f544..4fd4056d 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/AbstractAction.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/AbstractAction.java @@ -18,6 +18,7 @@ package kr.syeyoung.dungeonsguide.dungeon.actions; +import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; @@ -25,32 +26,32 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent; public abstract class AbstractAction implements Action { @Override - public void onPlayerInteract(DungeonRoom dungeonRoom, PlayerInteractEvent event) { + public void onPlayerInteract(DungeonRoom dungeonRoom, PlayerInteractEvent event, ActionRoute.ActionRouteProperties actionRouteProperties) { } @Override - public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks) { + public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag) { } @Override - public void onLivingDeath(DungeonRoom dungeonRoom, LivingDeathEvent event) { + public void onLivingDeath(DungeonRoom dungeonRoom, LivingDeathEvent event, ActionRoute.ActionRouteProperties actionRouteProperties) { } @Override - public void onRenderScreen(DungeonRoom dungeonRoom, float partialTicks) { + public void onRenderScreen(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties) { } @Override - public void onLivingInteract(DungeonRoom dungeonRoom, PlayerInteractEntityEvent event) { + public void onLivingInteract(DungeonRoom dungeonRoom, PlayerInteractEntityEvent event, ActionRoute.ActionRouteProperties actionRouteProperties) { } @Override - public void onTick(DungeonRoom dungeonRoom) { + public void onTick(DungeonRoom dungeonRoom, ActionRoute.ActionRouteProperties actionRouteProperties) { } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java index 87cb54c6..1a4ad682 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java @@ -18,6 +18,7 @@ package kr.syeyoung.dungeonsguide.dungeon.actions; +import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; @@ -28,12 +29,12 @@ import java.util.Set; public interface Action { Set<Action> getPreRequisites(DungeonRoom dungeonRoom); - void onPlayerInteract(DungeonRoom dungeonRoom, PlayerInteractEvent event); - void onLivingInteract(DungeonRoom dungeonRoom, PlayerInteractEntityEvent event); - void onLivingDeath(DungeonRoom dungeonRoom, LivingDeathEvent event); - void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks); - void onRenderScreen(DungeonRoom dungeonRoom, float partialTicks); - void onTick(DungeonRoom dungeonRoom); + void onPlayerInteract(DungeonRoom dungeonRoom, PlayerInteractEvent event, ActionRoute.ActionRouteProperties actionRouteProperties); + void onLivingInteract(DungeonRoom dungeonRoom, PlayerInteractEntityEvent event, ActionRoute.ActionRouteProperties actionRouteProperties); + void onLivingDeath(DungeonRoom dungeonRoom, LivingDeathEvent event, ActionRoute.ActionRouteProperties actionRouteProperties); + void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag); + void onRenderScreen(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties); + void onTick(DungeonRoom dungeonRoom, ActionRoute.ActionRouteProperties actionRouteProperties); boolean isComplete(DungeonRoom dungeonRoom); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionBreakWithSuperBoom.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionBreakWithSuperBoom.java index d80496f2..39d3e7ef 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionBreakWithSuperBoom.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionBreakWithSuperBoom.java @@ -18,8 +18,7 @@ package kr.syeyoung.dungeonsguide.dungeon.actions; -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; +import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.utils.RenderUtils; @@ -31,12 +30,9 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.renderer.vertex.VertexBuffer; import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; import net.minecraft.util.BlockPos; -import net.minecraft.util.MathHelper; import java.awt.*; import java.util.HashSet; @@ -62,7 +58,7 @@ public class ActionBreakWithSuperBoom extends AbstractAction { } @Override - public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks) { + public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag) { Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); BlockPos blockpos = target.getBlockPos(dungeonRoom); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java index f5958914..1b463f2e 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java @@ -20,11 +20,11 @@ package kr.syeyoung.dungeonsguide.dungeon.actions; import com.google.common.base.Predicate; import com.google.common.base.Predicates; +import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import lombok.Data; -import lombok.EqualsAndHashCode; import net.minecraft.item.ItemStack; import net.minecraft.util.BlockPos; import net.minecraftforge.event.entity.player.PlayerInteractEvent; @@ -56,7 +56,7 @@ public class ActionClick extends AbstractAction { } @Override - public void onPlayerInteract(DungeonRoom dungeonRoom, PlayerInteractEvent event) { + public void onPlayerInteract(DungeonRoom dungeonRoom, PlayerInteractEvent event, ActionRoute.ActionRouteProperties actionRouteProperties) { if (clicked) return; if (target.getBlockPos(dungeonRoom).equals(event.pos) && (predicate == null || predicate.apply(event.entityLiving.getHeldItem()))) { @@ -64,7 +64,7 @@ public class ActionClick extends AbstractAction { } } @Override - public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks) { + public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag) { BlockPos pos = target.getBlockPos(dungeonRoom); RenderUtils.highlightBlock(pos, new Color(0, 255,255,50),partialTicks, true); RenderUtils.drawTextAtWorld("Click", pos.getX() + 0.5f, pos.getY() + 0.3f, pos.getZ() + 0.5f, 0xFFFFFF00, 0.02f, false, false, partialTicks); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java index 356c592a..975c19e9 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java @@ -20,12 +20,12 @@ package kr.syeyoung.dungeonsguide.dungeon.actions; import com.google.common.base.Predicate; import com.google.common.base.Predicates; +import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import lombok.Data; -import lombok.EqualsAndHashCode; import net.minecraft.item.ItemStack; import net.minecraft.util.BlockPos; import net.minecraftforge.event.entity.player.PlayerInteractEvent; @@ -56,7 +56,7 @@ public class ActionClickSet extends AbstractAction { private boolean clicked = false; @Override - public void onPlayerInteract(DungeonRoom dungeonRoom, PlayerInteractEvent event) { + public void onPlayerInteract(DungeonRoom dungeonRoom, PlayerInteractEvent event, ActionRoute.ActionRouteProperties actionRouteProperties) { if (clicked) return; for (OffsetPoint pt2: target.getOffsetPointList()) { if (pt2.getBlockPos(dungeonRoom).equals(event.pos) && @@ -68,7 +68,7 @@ public class ActionClickSet extends AbstractAction { } @Override - public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks) { + public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag) { float xAcc = 0; float yAcc = 0; float zAcc = 0; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java index a6f7eb59..2e90d3a3 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java @@ -20,13 +20,12 @@ package kr.syeyoung.dungeonsguide.dungeon.actions; import com.google.common.base.Predicate; import com.google.common.base.Predicates; +import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import lombok.Data; -import lombok.EqualsAndHashCode; import net.minecraft.entity.item.EntityItem; -import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; @@ -59,7 +58,7 @@ public class ActionDropItem extends AbstractAction { return (predicate == null || predicate.apply(item.get(0))); } @Override - public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks) { + public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag) { BlockPos pos = target.getBlockPos(dungeonRoom); RenderUtils.highlightBlock(pos, new Color(0, 255,255,50),partialTicks, true); RenderUtils.drawTextAtWorld("Drop Item", pos.getX() + 0.5f, pos.getY() + 0.3f, pos.getZ() + 0.5f, 0xFFFFFF00, 0.02f, false, false, partialTicks); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionInteract.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionInteract.java index acdda662..3033754c 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionInteract.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionInteract.java @@ -21,6 +21,7 @@ package kr.syeyoung.dungeonsguide.dungeon.actions; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import kr.syeyoung.dungeonsguide.dungeon.DungeonActionManager; +import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; @@ -57,7 +58,7 @@ public class ActionInteract extends AbstractAction { private boolean interacted = false; @Override - public void onLivingInteract(DungeonRoom dungeonRoom, PlayerInteractEntityEvent event) { + public void onLivingInteract(DungeonRoom dungeonRoom, PlayerInteractEntityEvent event, ActionRoute.ActionRouteProperties actionRouteProperties) { if (interacted) return; Vec3 spawnLoc = DungeonActionManager.getSpawnLocation().get(event.getEntity().getEntityId()); @@ -67,7 +68,7 @@ public class ActionInteract extends AbstractAction { interacted = true; } @Override - public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks) { + public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag) { BlockPos pos = target.getBlockPos(dungeonRoom); RenderUtils.highlightBlock(pos, new Color(0, 255,255,50),partialTicks, true); RenderUtils.drawTextAtWorld("Interact", pos.getX() + 0.5f, pos.getY() + 0.3f, pos.getZ() + 0.5f, 0xFFFFFF00, 0.02f, false, false, partialTicks); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java index 010c5f89..a08b81f0 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java @@ -21,8 +21,8 @@ package kr.syeyoung.dungeonsguide.dungeon.actions; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import kr.syeyoung.dungeonsguide.dungeon.DungeonActionManager; +import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonSecret; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import lombok.Data; @@ -66,7 +66,7 @@ public class ActionKill extends AbstractAction { private boolean killed = false; @Override - public void onLivingDeath(DungeonRoom dungeonRoom, LivingDeathEvent event) { + public void onLivingDeath(DungeonRoom dungeonRoom, LivingDeathEvent event, ActionRoute.ActionRouteProperties actionRouteProperties) { if (killed) return; Vec3 spawnLoc = DungeonActionManager.getSpawnLocation().get(event.entity.getEntityId()); @@ -76,7 +76,7 @@ public class ActionKill extends AbstractAction { killed = true; } @Override - public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks) { + public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag) { BlockPos pos = target.getBlockPos(dungeonRoom); RenderUtils.highlightBlock(pos, new Color(0, 255,255,50),partialTicks, true); RenderUtils.drawTextAtWorld("Spawn", pos.getX() + 0.5f, pos.getY() + 0.3f, pos.getZ() + 0.5f, 0xFFFFFF00, 0.02f, false, false, partialTicks); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java index f0b694b0..754bdf35 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java @@ -19,21 +19,17 @@ package kr.syeyoung.dungeonsguide.dungeon.actions; import kr.syeyoung.dungeonsguide.Keybinds; +import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import lombok.Data; import net.minecraft.client.Minecraft; -import net.minecraft.pathfinding.PathEntity; -import net.minecraft.pathfinding.PathFinder; -import net.minecraft.pathfinding.PathPoint; import net.minecraft.util.BlockPos; import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; -import java.awt.*; -import java.util.ArrayList; import java.util.HashSet; import java.util.Set; import java.util.List; @@ -60,23 +56,24 @@ public class ActionMove extends AbstractAction { } @Override - public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks) { + public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag) { BlockPos pos = target.getBlockPos(dungeonRoom); float distance = MathHelper.sqrt_double(pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition())); float multiplier = distance / 120f; //mobs only render ~120 blocks away + if (flag) multiplier *= 2.0f; float scale = 0.45f * multiplier; scale *= 25.0 / 6.0; - if (FeatureRegistry.SECRET_BEACONS.isEnabled()) { - RenderUtils.renderBeaconBeam(pos.getX(), pos.getY(), pos.getZ(), FeatureRegistry.SECRET_BROWSE.getColor(), partialTicks); - RenderUtils.highlightBlock(pos, FeatureRegistry.SECRET_BROWSE.getColor(), partialTicks); + if (actionRouteProperties.isBeacon()) { + RenderUtils.renderBeaconBeam(pos.getX(), pos.getY(), pos.getZ(), actionRouteProperties.getBeaconBeamColor(), partialTicks); + RenderUtils.highlightBlock(pos, actionRouteProperties.getBeaconColor(), partialTicks); } - RenderUtils.drawTextAtWorld("Destination", pos.getX() + 0.5f, pos.getY() + 0.5f + scale, pos.getZ() + 0.5f, 0xFF00FF00, 1f, true, false, partialTicks); - RenderUtils.drawTextAtWorld(String.format("%.2f",MathHelper.sqrt_double(pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition())))+"m", pos.getX() + 0.5f, pos.getY() + 0.5f - scale, pos.getZ() + 0.5f, 0xFFFFFF00, 1f, true, false, partialTicks); + RenderUtils.drawTextAtWorld("Destination", pos.getX() + 0.5f, pos.getY() + 0.5f + scale, pos.getZ() + 0.5f, 0xFF00FF00, flag ? 2f : 1f, true, false, partialTicks); + RenderUtils.drawTextAtWorld(String.format("%.2f",MathHelper.sqrt_double(pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition())))+"m", pos.getX() + 0.5f, pos.getY() + 0.5f - scale, pos.getZ() + 0.5f, 0xFFFFFF00, flag ? 2f : 1f, true, false, partialTicks); if (!FeatureRegistry.SECRET_TOGGLE_KEY.isEnabled() || !Keybinds.togglePathfindStatus) { if (poses != null){ - RenderUtils.drawLinesVec3(poses, FeatureRegistry.SECRET_BROWSE.getColor(), FeatureRegistry.SECRET_BROWSE.getThickness(), partialTicks, true); + RenderUtils.drawLinesVec3(poses, actionRouteProperties.getLineColor(), actionRouteProperties.getLineWidth(), partialTicks, true); } } } @@ -86,8 +83,8 @@ public class ActionMove extends AbstractAction { private Future<List<Vec3>> latestFuture; @Override - public void onTick(DungeonRoom dungeonRoom) { - tick = (tick+1) % Math.max(1, FeatureRegistry.SECRET_BROWSE.getRefreshRate()); + public void onTick(DungeonRoom dungeonRoom, ActionRoute.ActionRouteProperties actionRouteProperties) { + tick = (tick+1) % Math.max(1, actionRouteProperties.getLineRefreshRate()); if (latestFuture != null && latestFuture.isDone()) { try { poses = latestFuture.get(); @@ -97,16 +94,21 @@ public class ActionMove extends AbstractAction { } } - if (tick == 0) { + if (tick == 0 && actionRouteProperties.isPathfind()) { try { if (latestFuture != null) latestFuture.cancel(true); } catch (Exception ignored) {} if (!FeatureRegistry.SECRET_FREEZE_LINES.isEnabled() || poses == null) - latestFuture = dungeonRoom.createEntityPathTo(dungeonRoom.getContext().getWorld(), - Minecraft.getMinecraft().thePlayer, target.getBlockPos(dungeonRoom), Integer.MAX_VALUE); + latestFuture = dungeonRoom.createEntityPathTo(dungeonRoom.getContext().getWorld(), Minecraft.getMinecraft().thePlayer, target.getBlockPos(dungeonRoom), Integer.MAX_VALUE, actionRouteProperties.getLineRefreshRate()* 50- 10); } } + public void forceRefresh(DungeonRoom dungeonRoom) { + try { + if (latestFuture != null) latestFuture.cancel(true); + } catch (Exception ignored) {} + latestFuture = dungeonRoom.createEntityPathTo(dungeonRoom.getContext().getWorld(), Minecraft.getMinecraft().thePlayer, target.getBlockPos(dungeonRoom), Integer.MAX_VALUE, 10000); + } @Override public String toString() { return "Move\n- target: "+target.toString(); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java index b2746157..d990a835 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java @@ -19,20 +19,17 @@ package kr.syeyoung.dungeonsguide.dungeon.actions; import kr.syeyoung.dungeonsguide.Keybinds; +import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import lombok.Data; import net.minecraft.client.Minecraft; -import net.minecraft.pathfinding.PathEntity; -import net.minecraft.pathfinding.PathPoint; import net.minecraft.util.BlockPos; import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; -import java.awt.*; -import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -59,22 +56,24 @@ public class ActionMoveNearestAir extends AbstractAction { } @Override - public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks) { + public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks, ActionRoute.ActionRouteProperties actionRouteProperties, boolean flag) { BlockPos pos = target.getBlockPos(dungeonRoom); + float distance = MathHelper.sqrt_double(pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition())); float multiplier = distance / 120f; //mobs only render ~120 blocks away + if (flag) multiplier *= 2.0f; float scale = 0.45f * multiplier; scale *= 25.0 / 6.0; - if (FeatureRegistry.SECRET_BEACONS.isEnabled()) { - RenderUtils.renderBeaconBeam(pos.getX(), pos.getY(), pos.getZ(), FeatureRegistry.SECRET_BROWSE.getColor(), partialTicks); - RenderUtils.highlightBlock(pos, FeatureRegistry.SECRET_BROWSE.getColor(), partialTicks); + if (actionRouteProperties.isBeacon()) { + RenderUtils.renderBeaconBeam(pos.getX(), pos.getY(), pos.getZ(), actionRouteProperties.getBeaconBeamColor(), partialTicks); + RenderUtils.highlightBlock(pos, actionRouteProperties.getBeaconColor(), partialTicks); } - RenderUtils.drawTextAtWorld("Destination", pos.getX() + 0.5f, pos.getY() + 0.5f + scale, pos.getZ() + 0.5f, 0xFF00FF00, 1f, true, false, partialTicks); - RenderUtils.drawTextAtWorld(String.format("%.2f",MathHelper.sqrt_double(pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition())))+"m", pos.getX() + 0.5f, pos.getY() + 0.5f - scale, pos.getZ() + 0.5f, 0xFFFFFF00, 1f, true, false, partialTicks); + RenderUtils.drawTextAtWorld("Destination", pos.getX() + 0.5f, pos.getY() + 0.5f + scale, pos.getZ() + 0.5f, 0xFF00FF00, flag ? 2f : 1f, true, false, partialTicks); + RenderUtils.drawTextAtWorld(String.format("%.2f",MathHelper.sqrt_double(pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition())))+"m", pos.getX() + 0.5f, pos.getY() + 0.5f - scale, pos.getZ() + 0.5f, 0xFFFFFF00, flag ? 2f : 1f, true, false, partialTicks); if (!FeatureRegistry.SECRET_TOGGLE_KEY.isEnabled() || !Keybinds.togglePathfindStatus) { if (poses != null){ - RenderUtils.drawLinesVec3(poses, FeatureRegistry.SECRET_BROWSE.getColor(), FeatureRegistry.SECRET_BROWSE.getThickness(), partialTicks, true); + RenderUtils.drawLinesVec3(poses, actionRouteProperties.getLineColor(), actionRouteProperties.getLineWidth(), partialTicks, true); } } } @@ -83,8 +82,8 @@ public class ActionMoveNearestAir extends AbstractAction { private List<Vec3> poses; private Future<List<Vec3>> latestFuture; @Override - public void onTick(DungeonRoom dungeonRoom) { - tick = (tick+1) % Math.max(1, FeatureRegistry.SECRET_BROWSE.getRefreshRate()); + public void onTick(DungeonRoom dungeonRoom, ActionRoute.ActionRouteProperties actionRouteProperties) { + tick = (tick+1) % Math.max(1, actionRouteProperties.getLineRefreshRate()); if (latestFuture != null && latestFuture.isDone()) { try { poses = latestFuture.get(); @@ -94,17 +93,22 @@ public class ActionMoveNearestAir extends AbstractAction { } } - if (tick == 0) { + if (tick == 0 && actionRouteProperties.isPathfind()) { try { if (latestFuture != null) latestFuture.cancel(true); } catch (Exception ignored) {} - if (!FeatureRegistry.SECRET_FREEZE_LINES.isEnabled()|| poses == null) - latestFuture = dungeonRoom.createEntityPathTo(dungeonRoom.getContext().getWorld(), - Minecraft.getMinecraft().thePlayer, target.getBlockPos(dungeonRoom), Integer.MAX_VALUE); + if (!FeatureRegistry.SECRET_FREEZE_LINES.isEnabled() || poses == null) + latestFuture = dungeonRoom.createEntityPathTo(dungeonRoom.getContext().getWorld(), Minecraft.getMinecraft().thePlayer, target.getBlockPos(dungeonRoom), Integer.MAX_VALUE, actionRouteProperties.getLineRefreshRate()* 50- 10); } } + public void forceRefresh(DungeonRoom dungeonRoom) { + try { + if (latestFuture != null) latestFuture.cancel(true); + } catch (Exception ignored) {} + latestFuture = dungeonRoom.createEntityPathTo(dungeonRoom.getContext().getWorld(), Minecraft.getMinecraft().thePlayer, target.getBlockPos(dungeonRoom), Integer.MAX_VALUE, 10000); + } @Override public String toString() { return "MoveNearestAir\n- target: "+target.toString(); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionRoute.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionRoute.java index 76fe5c85..3580dd03 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionRoute.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionRoute.java @@ -18,10 +18,13 @@ package kr.syeyoung.dungeonsguide.dungeon.actions.tree; +import kr.syeyoung.dungeonsguide.config.types.AColor; import kr.syeyoung.dungeonsguide.dungeon.actions.*; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; +import lombok.Data; import lombok.Getter; +import net.minecraft.client.Minecraft; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; @@ -40,9 +43,13 @@ public class ActionRoute { private final DungeonRoom dungeonRoom; - public ActionRoute(DungeonRoom dungeonRoom, String mechanic, String state) { + @Getter + private final ActionRouteProperties actionRouteProperties; + + public ActionRoute(DungeonRoom dungeonRoom, String mechanic, String state, ActionRouteProperties actionRouteProperties) { this.mechanic = mechanic; this.state = state; + this.actionRouteProperties = actionRouteProperties; ActionChangeState actionChangeState = new ActionChangeState(mechanic, state); ActionTree tree= ActionTree.buildActionTree(actionChangeState, dungeonRoom); @@ -71,25 +78,27 @@ public class ActionRoute { public void onPlayerInteract(PlayerInteractEvent event) { - getCurrentAction().onPlayerInteract(dungeonRoom, event); + getCurrentAction().onPlayerInteract(dungeonRoom, event, actionRouteProperties ); } public void onLivingDeath(LivingDeathEvent event) { - getCurrentAction().onLivingDeath(dungeonRoom, event); + getCurrentAction().onLivingDeath(dungeonRoom, event, actionRouteProperties ); } - public void onRenderWorld(float partialTicks) { - if (current -1 >= 0 && (actions.get(current-1) instanceof ActionMove || actions.get(current-1) instanceof ActionMoveNearestAir)) actions.get(current-1).onRenderWorld(dungeonRoom, partialTicks); - getCurrentAction().onRenderWorld(dungeonRoom, partialTicks); + public void onRenderWorld(float partialTicks, boolean flag) { + if (current -1 >= 0 && ( + (actions.get(current-1) instanceof ActionMove && ((ActionMove) actions.get(current-1)).getTarget().getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()) >= 25) + || (actions.get(current-1) instanceof ActionMoveNearestAir && ((ActionMoveNearestAir) actions.get(current-1)).getTarget().getBlockPos(dungeonRoom).distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()) >= 25))) actions.get(current-1).onRenderWorld(dungeonRoom, partialTicks, actionRouteProperties, flag ); + getCurrentAction().onRenderWorld(dungeonRoom, partialTicks, actionRouteProperties, flag); } public void onRenderScreen(float partialTicks) { - getCurrentAction().onRenderScreen(dungeonRoom, partialTicks); + getCurrentAction().onRenderScreen(dungeonRoom, partialTicks, actionRouteProperties); } public void onTick() { Action current = getCurrentAction(); - current.onTick(dungeonRoom); - if (this.current -1 >= 0 && (actions.get(this.current-1) instanceof ActionMove || actions.get(this.current-1) instanceof ActionMoveNearestAir)) actions.get(this.current-1).onTick(dungeonRoom); + current.onTick(dungeonRoom, actionRouteProperties); + if (this.current -1 >= 0 && (actions.get(this.current-1) instanceof ActionMove || actions.get(this.current-1) instanceof ActionMoveNearestAir)) actions.get(this.current-1).onTick(dungeonRoom, actionRouteProperties ); if (dungeonRoom.getMechanics().get(mechanic).getCurrentState(dungeonRoom).equals(state)) { this.current = actions.size() - 1; @@ -99,5 +108,17 @@ public class ActionRoute { next(); } - public void onLivingInteract(PlayerInteractEntityEvent event) { getCurrentAction().onLivingInteract(dungeonRoom, event); } + public void onLivingInteract(PlayerInteractEntityEvent event) { getCurrentAction().onLivingInteract(dungeonRoom, event, actionRouteProperties ); } + + @Data + public static class ActionRouteProperties { + private boolean pathfind; + private int lineRefreshRate; + private AColor lineColor; + private float lineWidth; + + private boolean beacon; + private AColor beaconColor; + private AColor beaconBeamColor; + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java index 70c714fe..65408f92 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java @@ -156,6 +156,7 @@ public class DungeonSecret implements DungeonMechanic { return base; } if (!"found".equalsIgnoreCase(state)) throw new IllegalArgumentException(state+" is not valid state for secret"); + if (state.equals("found") && getSecretStatus(dungeonRoom) == SecretStatus.FOUND) return new HashSet<>(); Set<Action> base; Set<Action> preRequisites = base = new HashSet<Action>(); if (secretType == SecretType.CHEST || secretType == SecretType.ESSENCE) { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java index c68cb511..00b81f59 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java @@ -94,13 +94,13 @@ public class DungeonRoom { this.currentState = currentState; } - public ScheduledFuture<List<Vec3>> createEntityPathTo(IBlockAccess blockaccess, Entity entityIn, BlockPos targetPos, float dist) { + public ScheduledFuture<List<Vec3>> createEntityPathTo(IBlockAccess blockaccess, Entity entityIn, BlockPos targetPos, float dist, int timeout) { if (FeatureRegistry.SECRET_PATHFIND_STRATEGY.isEnabled()) { ScheduledFuture<List<Vec3>> sf = asyncPathFinder.schedule(() -> { BlockPos min = new BlockPos(getMin().getX(), 0, getMin().getZ()); BlockPos max= new BlockPos(getMax().getX(), 255, getMax().getZ()); JPSPathfinder pathFinder = new JPSPathfinder(context.getWorld(), min, max); - pathFinder.pathfind(entityIn.getPositionVector(), new Vec3(targetPos).addVector(0.5, 0.5, 0.5), 1.5f,1000); + pathFinder.pathfind(entityIn.getPositionVector(), new Vec3(targetPos).addVector(0.5, 0.5, 0.5), 1.5f,timeout); return pathFinder.getRoute(); }, 0, TimeUnit.MILLISECONDS); return sf; @@ -118,7 +118,6 @@ public class DungeonRoom { } return new ArrayList<>(); }, 0, TimeUnit.MILLISECONDS); - asyncPathFinder.schedule(() -> sf.cancel(true), 10, TimeUnit.SECONDS); return sf; } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java index be20aa8e..438e9b80 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java @@ -36,10 +36,8 @@ import kr.syeyoung.dungeonsguide.features.impl.etc.ability.FeatureAbilityCooldow import kr.syeyoung.dungeonsguide.features.impl.party.APIKey; import kr.syeyoung.dungeonsguide.features.impl.party.customgui.FeatureCustomPartyFinder; import kr.syeyoung.dungeonsguide.features.impl.party.playerpreview.FeatureViewPlayerOnJoin; -import kr.syeyoung.dungeonsguide.features.impl.secret.FeatureActions; -import kr.syeyoung.dungeonsguide.features.impl.secret.FeatureFreezePathfind; +import kr.syeyoung.dungeonsguide.features.impl.secret.*; import kr.syeyoung.dungeonsguide.features.impl.secret.mechanicbrowser.FeatureMechanicBrowse; -import kr.syeyoung.dungeonsguide.features.impl.secret.FeatureSoulRoomWarning; import lombok.Getter; import java.util.ArrayList; @@ -157,19 +155,33 @@ public class FeatureRegistry { public static final SimpleFeature DUNGEON_INTERMODCOMM = register(new SimpleFeature("Dungeon.Teammates", "Communicate With Other's Dungeons Guide", "Sends total secret in the room to others\nSo that they can use the data to calculate total secret in dungeon run\n\nThis automates player chatting action, (chatting data) Thus it might be against hypixel's rules.\nBut mods like auto-gg which also automate player action and is kinda allowed mod exist so I'm leaving this feature.\nThis option is use-at-your-risk and you'll be responsible for ban if you somehow get banned because of this feature\n(Although it is not likely to happen)\nDefaults to off", "dungeon.intermodcomm", false)); public static final FeaturePlayerESP DUNGEON_PLAYERESP = register(new FeaturePlayerESP()); public static final FeatureHideNameTags DUNGEON_HIDENAMETAGS = register(new FeatureHideNameTags()); + public static final FeatureSoulRoomWarning DUNGEON_FAIRYSOUL = register(new FeatureSoulRoomWarning()); + + public static final FeatureMechanicBrowse SECRET_BROWSE = register(new FeatureMechanicBrowse()); + public static final PathfindLineProperties SECRET_LINE_PROPERTIES_SECRET_BROWSER = register(new PathfindLineProperties("Dungeon Secrets.Secret Browser", "Line Settings", "Line Settings when pathfinding using Secret Browser", "secret.lineproperties.secretbrowser", true)); public static final FeatureActions SECRET_ACTIONS = register(new FeatureActions()); - public static final FeatureSoulRoomWarning SECRET_FAIRYSOUL = register(new FeatureSoulRoomWarning()); - public static final SimpleFeature SECRET_AUTO_BROWSE_NEXT = register(new SimpleFeature("Dungeon Secret.Secret Pathfind.Legacy AutoPathfind", "Auto Pathfind to next secret", "Auto browse best next secret after current one completes.\nthe first pathfinding of first secret needs to be triggered first in order for this option to work", "secret.autobrowse", false)); - public static final SimpleFeature SECRET_AUTO_START = register(new SimpleFeature("Dungeon Secret.Secret Pathfind.Legacy AutoPathfind", "Auto pathfind to new secret", "Auto browse best secret upon entering the room.", "secret.autouponenter", false)); - public static final SimpleFeature SECRET_NEXT_KEY = register(new SimpleFeature("Dungeon Secret.Secret Pathfind.Legacy AutoPathfind", "Auto Pathfind to new secret upon pressing a key", "Auto browse the best next secret when you press key.\nChange key at your key settings (Settings -> Controls)", "secret.keyfornext", false)); - public static final SimpleFeature SECRET_PATHFIND_ALL = register(new SimpleFeature("Dungeon Secret.Secret Pathfind", "Start pathfind to all secrets upon entering a room", "Auto browse to all secrets in the room", "secret.secretpathfind.allbrowse", false)); - public static final SimpleFeature SECRET_PATHFIND_STRATEGY = register(new SimpleFeature("Dungeon Secret.Secret Pathfind", "Use NEW JPS Optimization instead of standard A Star", "Faster, and accurate routes.", "secret.secretpathfind.algorithm", true)); - - public static final SimpleFeature SECRET_TOGGLE_KEY = register(new SimpleFeature("Dungeon Secret.Pathfind Display", "Toggle Pathfind Lines", "A key for toggling pathfound line visibility.\nChange key at your key settings (Settings -> Controls)", "secret.togglePathfind")); - public static final SimpleFeature SECRET_BEACONS = register(new SimpleFeature("Dungeon Secret.Pathfind Display", "Beacons on pathfind", "When pathfinding, display beacons as well as lines", "secret.beacons")); + + public static final SimpleFeature SECRET_PATHFIND_STRATEGY = register(new SimpleFeature("Dungeon Secrets", "Use NEW JPS Optimization instead of standard A Star", "Faster, and accurate routes.", "secret.secretpathfind.algorithm", true)); + public static final SimpleFeature SECRET_TOGGLE_KEY = register(new SimpleFeature("Dungeon Secrets.Keybinds", "Toggle Pathfind Lines", "A key for toggling pathfound line visibility.\nChange key at your key settings (Settings -> Controls)", "secret.togglePathfind")); public static final SimpleFeature SECRET_FREEZE_LINES = register(new FeatureFreezePathfind()); + static { + categoryDescription.put("ROOT.Dungeon Secrets.Keybinds", "Useful keybinds / Toggle Pathfind lines, Freeze Pathfind lines"); + } + + public static final PathfindLineProperties SECRET_LINE_PROPERTIES_GLOBAL = register(new PathfindLineProperties("Dungeon Secrets", "Global Line Settings", "Global Line Settings", "secret.lineproperties.global", true)); + + public static final SimpleFeature SECRET_AUTO_BROWSE_NEXT = register(new SimpleFeature("Dungeon Secrets.Legacy AutoPathfind", "Auto Pathfind to next secret", "Auto browse best next secret after current one completes.\nthe first pathfinding of first secret needs to be triggered first in order for this option to work", "secret.autobrowse", false)); + public static final SimpleFeature SECRET_AUTO_START = register(new SimpleFeature("Dungeon Secrets.Legacy AutoPathfind", "Auto pathfind to new secret", "Auto browse best secret upon entering the room.", "secret.autouponenter", false)); + public static final SimpleFeature SECRET_NEXT_KEY = register(new SimpleFeature("Dungeon Secrets.Legacy AutoPathfind", "Auto Pathfind to new secret upon pressing a key", "Auto browse the best next secret when you press key.\nChange key at your key settings (Settings -> Controls)", "secret.keyfornext", false)); + public static final PathfindLineProperties SECRET_LINE_PROPERTIES_AUTOPATHFIND = register(new PathfindLineProperties("Dungeon Secrets.Legacy AutoPathfind", "Line Settings", "Line Settings when pathfinding using above features", "secret.lineproperties.autopathfind", true)); + + public static final FeaturePathfindToAll SECRET_PATHFIND_ALL = register(new FeaturePathfindToAll()); + public static final PathfindLineProperties SECRET_LINE_PROPERTIES_PATHFINDALL_BAT = register(new PathfindLineProperties("Dungeon Secrets.Pathfind To All", "Bat Line Settings", "Line Settings when pathfind to Bat, when using above feature", "secret.lineproperties.apf.bat", false)); + public static final PathfindLineProperties SECRET_LINE_PROPERTIES_PATHFINDALL_CHEST = register(new PathfindLineProperties("Dungeon Secrets.Pathfind To All", "Chest Line Settings", "Line Settings when pathfind to Chest, when using above feature", "secret.lineproperties.apf.chest", false)); + public static final PathfindLineProperties SECRET_LINE_PROPERTIES_PATHFINDALL_ESSENCE = register(new PathfindLineProperties("Dungeon Secrets.Pathfind To All", "Essence Line Settings", "Line Settings when pathfind to Essence, when using above feature", "secret.lineproperties.apf.essence", false)); + public static final PathfindLineProperties SECRET_LINE_PROPERTIES_PATHFINDALL_ITEM_DROP = register(new PathfindLineProperties("Dungeon Secrets.Pathfind To All", "Item Drop Line Settings", "Line Settings when pathfind to Item Drop, when using above feature", "secret.lineproperties.apf.itemdrop", false)); public static final FeatureNicknamePrefix COSMETIC_PREFIX = register(new FeatureNicknamePrefix()); public static final FeatureNicknameColor COSMETIC_NICKNAMECOLOR = register(new FeatureNicknameColor()); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureActions.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureActions.java index 0ae1e668..0b9744ea 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureActions.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureActions.java @@ -39,7 +39,7 @@ import java.util.List; public class FeatureActions extends TextHUDFeature { public FeatureActions() { - super("Dungeon Secret.Pathfind Display", "Action Viewer", "View List of actions that needs to be taken", "secret.actionview", false, 200, getFontRenderer().FONT_HEIGHT * 10); + super("Dungeon Secrets", "Action Viewer", "View List of actions that needs to be taken", "secret.actionview", false, 200, getFontRenderer().FONT_HEIGHT * 10); getStyles().add(new TextStyle("pathfinding", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); getStyles().add(new TextStyle("mechanic", new AColor(0x55, 0xFF,0x55,255), new AColor(0, 0,0,0), false)); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureFreezePathfind.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureFreezePathfind.java index 67f0be5f..a8102ad2 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureFreezePathfind.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureFreezePathfind.java @@ -24,7 +24,7 @@ import kr.syeyoung.dungeonsguide.features.SimpleFeature; public class FeatureFreezePathfind extends SimpleFeature { public FeatureFreezePathfind() { - super("Dungeon Secret.Pathfind Display", "Freeze Pathfind", "Freeze Pathfind, meaning the pathfind lines won't change when you move", "secret.freezepathfind", false); + super("Dungeon Secrets.Keybinds", "Global Freeze Pathfind", "Freeze Pathfind, meaning the pathfind lines won't change when you move. Can be toggled with key set in Minecraft Key Settings", "secret.freezepathfind", false); } SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeaturePathfindToAll.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeaturePathfindToAll.java new file mode 100644 index 00000000..886eefef --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeaturePathfindToAll.java @@ -0,0 +1,45 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.features.impl.secret; + +import kr.syeyoung.dungeonsguide.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.features.SimpleFeature; + +public class FeaturePathfindToAll extends SimpleFeature { + public FeaturePathfindToAll(){ + super("Dungeon Secrets.Pathfind To All", "Start pathfind to all secrets upon entering a room", "Auto browse to all secrets in the room", "secret.secretpathfind.allbrowse", false); + this.parameters.put("bat", new FeatureParameter<Boolean>("bat", "Trigger pathfind to Bat", "This feature will trigger pathfind to all bats in this room when entering a room", true, "boolean")); + this.parameters.put("chest", new FeatureParameter<Boolean>("chest", "Trigger pathfind to Chest", "This feature will trigger pathfind to all chests in this room when entering a room", true, "boolean")); + this.parameters.put("essence", new FeatureParameter<Boolean>("essence", "Trigger pathfind to Essence", "This feature will trigger pathfind to all essences in this room when entering a room", true, "boolean")); + this.parameters.put("itemdrop", new FeatureParameter<Boolean>("itemdrop", "Trigger pathfind to Itemdrop", "This feature will trigger pathfind to all itemdrops in this room when entering a room", true, "boolean")); + } + + public boolean isBat() { + return this.<Boolean>getParameter("bat").getValue(); + } + public boolean isChest() { + return this.<Boolean>getParameter("chest").getValue(); + } + public boolean isEssence() { + return this.<Boolean>getParameter("essence").getValue(); + } + public boolean isItemdrop() { + return this.<Boolean>getParameter("itemdrop").getValue(); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/PathfindLineProperties.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/PathfindLineProperties.java new file mode 100644 index 00000000..e389cbd7 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/PathfindLineProperties.java @@ -0,0 +1,108 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.features.impl.secret; + +import com.google.common.base.Supplier; +import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator; +import kr.syeyoung.dungeonsguide.config.guiconfig.MFeatureEdit; +import kr.syeyoung.dungeonsguide.config.guiconfig.MParameterEdit; +import kr.syeyoung.dungeonsguide.config.guiconfig.RootConfigPanel; +import kr.syeyoung.dungeonsguide.config.types.AColor; +import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; +import kr.syeyoung.dungeonsguide.features.AbstractFeature; +import kr.syeyoung.dungeonsguide.features.FeatureParameter; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.gui.MPanel; + +import java.util.LinkedHashMap; + +public class PathfindLineProperties extends SimpleFeature { + public PathfindLineProperties(String category, String name, String description, String key, boolean useGlobal) { + super(category, name, description, key); + this.parameters = new LinkedHashMap<>(); + if (!key.equals("secret.lineproperties.global")) + this.parameters.put("useGlobal", new FeatureParameter<Boolean>("useGlobal", "Use Global Settings instead of this", "Completely ignore these settings, then use the global one", useGlobal, "boolean")); + this.parameters.put("pathfind", new FeatureParameter<Boolean>("pathfind", "Enable Pathfinding", "Enable pathfind for secrets", useGlobal, "boolean")); + this.parameters.put("lineColor", new FeatureParameter<AColor>("lineColor", "Line Color", "Color of the pathfind line", new AColor(0xFFFF0000, true), "acolor")); + this.parameters.put("lineWidth", new FeatureParameter<Float>("lineWidth", "Line Thickness", "Thickness of the pathfind line",1.0f, "float")); + this.parameters.put("refreshrate", new FeatureParameter<Integer>("refreshrate", "Line Refreshrate", "Ticks to wait per line refresh. Specify it to -1 to don't refresh line at all", 10, "integer")); + this.parameters.put("beacon", new FeatureParameter<Boolean>("beacon", "Enable Beacons", "Enable beacons for pathfind line targets", true, "boolean")); + this.parameters.put("beamColor", new FeatureParameter<AColor>("beamColor", "Beam Color", "Color of the beacon beam", new AColor(0x77FF0000, true), "acolor")); + this.parameters.put("targetColor", new FeatureParameter<AColor>("targetColor", "Target Color", "Color of the target", new AColor(0x33FF0000, true), "acolor")); + } + + + public String getEditRoute(RootConfigPanel rootConfigPanel) { + ConfigPanelCreator.map.put("base." + getKey() , new Supplier<MPanel>() { + @Override + public MPanel get() { + MFeatureEdit featureEdit = new MFeatureEdit(PathfindLineProperties.this, rootConfigPanel); + for (FeatureParameter parameter: getParameters()) { + featureEdit.addParameterEdit(parameter.getKey(), new MParameterEdit(PathfindLineProperties.this, parameter, rootConfigPanel, a -> !a.getKey().equals("useGlobal") && isGlobal())); + } + return featureEdit; + } + }); + return "base." + getKey() ; + } + + @Override + public boolean isDisyllable() { + return false; + } + + public boolean isGlobal() { + if (getKey().equals("secret.lineproperties.global")) return false; + return this.<Boolean>getParameter("useGlobal").getValue(); + } + + public boolean isPathfind() { + return isGlobal() ? FeatureRegistry.SECRET_LINE_PROPERTIES_GLOBAL.isPathfind() : this.<Boolean>getParameter("pathfind").getValue(); + } + public AColor getLineColor() { + return isGlobal() ? FeatureRegistry.SECRET_LINE_PROPERTIES_GLOBAL.getLineColor() : this.<AColor>getParameter("lineColor").getValue(); + } + public float getLineWidth() { + return isGlobal() ? FeatureRegistry.SECRET_LINE_PROPERTIES_GLOBAL.getLineWidth() : this.<Float>getParameter("lineWidth").getValue(); + } + public int getRefreshRate() { + return isGlobal() ? FeatureRegistry.SECRET_LINE_PROPERTIES_GLOBAL.getRefreshRate() : this.<Integer>getParameter("refreshrate").getValue(); + } + public boolean isBeacon() { + return isGlobal() ? FeatureRegistry.SECRET_LINE_PROPERTIES_GLOBAL.isBeacon() : this.<Boolean>getParameter("beacon").getValue(); + } + public AColor getBeamColor() { + return isGlobal() ? FeatureRegistry.SECRET_LINE_PROPERTIES_GLOBAL.getBeamColor() : this.<AColor>getParameter("beamColor").getValue(); + } + public AColor getTargetColor() { + return isGlobal() ? FeatureRegistry.SECRET_LINE_PROPERTIES_GLOBAL.getTargetColor() : this.<AColor>getParameter("targetColor").getValue(); + } + public ActionRoute.ActionRouteProperties getRouteProperties() { + ActionRoute.ActionRouteProperties actionRouteProperties = new ActionRoute.ActionRouteProperties(); + actionRouteProperties.setPathfind(isPathfind()); + actionRouteProperties.setLineColor(getLineColor()); + actionRouteProperties.setLineWidth(getLineWidth()); + actionRouteProperties.setLineRefreshRate(getRefreshRate()); + actionRouteProperties.setBeacon(isBeacon()); + actionRouteProperties.setBeaconBeamColor(getBeamColor()); + actionRouteProperties.setBeaconColor(getTargetColor()); + return actionRouteProperties; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java index 21898427..6a00b72b 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/FeatureMechanicBrowse.java @@ -65,25 +65,13 @@ import java.util.List; public class FeatureMechanicBrowse extends GuiFeature implements GuiPreRenderListener, GuiClickListener, WorldRenderListener { public FeatureMechanicBrowse() { - super("Dungeon Secret.Secret Pathfind","Secret Browser", "Browse and Pathfind secrets and mechanics in the current room", "secret.mechanicbrowse", false, 100, 300); - parameters.put("linecolor2", new FeatureParameter<AColor>("linecolor2", "Color", "Color of Pathfind line", new AColor(0xFF00FF00, true), "acolor")); - parameters.put("linethickness", new FeatureParameter<Float>("linethickness", "Thickness", "Thickness of Pathfind line", 1.0f, "float")); - parameters.put("refreshrate", new FeatureParameter<Integer>("refreshrate", "Line Refreshrate", "How many ticks per line refresh?", 10, "integer")); + super("Dungeon Secrets.Secret Browser","Secret Browser", "Browse and Pathfind secrets and mechanics in the current room", "secret.mechanicbrowse", false, 100, 300); parameters.put("scale", new FeatureParameter<Float>("scale", "Scale", "Scale", 1.0f, "float")); mGuiMechanicBrowser = new MGuiMechanicBrowser(this); mGuiMechanicBrowser.setWorldAndResolution(Minecraft.getMinecraft(), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight); lastWidth = Minecraft.getMinecraft().displayWidth; lastHeight = Minecraft.getMinecraft().displayHeight; } - public AColor getColor() { - return this.<AColor>getParameter("linecolor2").getValue(); - } - public float getThickness() { - return this.<Float>getParameter("linethickness").getValue(); - } - public int getRefreshRate() { - return this.<Integer>getParameter("refreshrate").getValue(); - } public double getScale() { return this.<Float>getParameter("scale").getValue(); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/PanelMechanicBrowser.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/PanelMechanicBrowser.java index 5a558a1e..caf7bf8e 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/PanelMechanicBrowser.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/mechanicbrowser/PanelMechanicBrowser.java @@ -23,6 +23,7 @@ import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; import kr.syeyoung.dungeonsguide.dungeon.mechanics.*; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.gui.MPanel; import kr.syeyoung.dungeonsguide.gui.elements.MList; import kr.syeyoung.dungeonsguide.gui.elements.MPanelScaledGUI; @@ -256,7 +257,7 @@ public class PanelMechanicBrowser extends MPanelScaledGUI { for (String state : states) { mechanicBrowserTooltip.getMList().add(new MechanicBrowserElement(() -> state, false, (m2, pt2) -> { if (dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor) - ((GeneralRoomProcessor)dungeonRoom.getRoomProcessor()).pathfind("MECH-BROWSER", id, state); + ((GeneralRoomProcessor)dungeonRoom.getRoomProcessor()).pathfind("MECH-BROWSER", id, state, FeatureRegistry.SECRET_LINE_PROPERTIES_SECRET_BROWSER.getRouteProperties()); mechanicBrowserTooltip.close(); mechanicBrowserTooltip = null; })); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/JPSPathfinder.java b/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/JPSPathfinder.java index b824c731..3d3e5f2a 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/JPSPathfinder.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/pathfinding/JPSPathfinder.java @@ -24,6 +24,7 @@ import lombok.Getter; import lombok.RequiredArgsConstructor; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; import net.minecraft.util.*; import net.minecraft.world.ChunkCache; import net.minecraft.world.World; @@ -127,7 +128,7 @@ public class JPSPathfinder { Node end = null; float minDist = Float.MAX_VALUE; long forceEnd = System.currentTimeMillis() + timeout; while(!open.isEmpty()) { - if (forceEnd < System.currentTimeMillis()) break; + if (forceEnd < System.currentTimeMillis() && timeout != -1) break; Node n = open.poll(); n.closed= true; if (minDist > n.h) { @@ -323,7 +324,7 @@ public class JPSPathfinder { Block b = iblockstate1.getBlock(); if (!b.getMaterial().blocksMovement())continue; if (b.isFullCube() && i2 == k-1) continue; - if (b.isFullCube()) { + if (b.isFullCube() && !iblockstate1.equals( NodeProcessorDungeonRoom.preBuilt)) { theBit |= (3L << bitStart); arr[location] = theBit; return true; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java index 68b460cb..259d956b 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java @@ -23,6 +23,8 @@ import kr.syeyoung.dungeonsguide.Keybinds; import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; import kr.syeyoung.dungeonsguide.dungeon.DungeonActionManager; import kr.syeyoung.dungeonsguide.dungeon.actions.ActionComplete; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionMove; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionMoveNearestAir; import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonMechanic; @@ -33,8 +35,11 @@ import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.roomedit.EditingContext; import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonAddSet; import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonRoomEdit; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.utils.VectorUtils; import lombok.Getter; import lombok.Setter; +import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; @@ -43,6 +48,7 @@ import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityArmorStand; import net.minecraft.entity.passive.EntityBat; +import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.util.*; import net.minecraftforge.client.event.GuiScreenEvent; @@ -73,7 +79,15 @@ public class GeneralRoomProcessor implements RoomProcessor { if (!ticked && FeatureRegistry.SECRET_PATHFIND_ALL.isEnabled()) { for (Map.Entry<String, DungeonMechanic> value : getDungeonRoom().getDungeonRoomInfo().getMechanics().entrySet()) { if (value.getValue() instanceof DungeonSecret && ((DungeonSecret) value.getValue()).getSecretStatus(dungeonRoom) != DungeonSecret.SecretStatus.FOUND) { - pathfind(value.getKey(), "found"); + DungeonSecret dungeonSecret = (DungeonSecret) value.getValue(); + if (FeatureRegistry.SECRET_PATHFIND_ALL.isBat() && dungeonSecret.getSecretType() == DungeonSecret.SecretType.BAT) + pathfind(value.getKey(), "found", FeatureRegistry.SECRET_LINE_PROPERTIES_PATHFINDALL_BAT.getRouteProperties()); + if (FeatureRegistry.SECRET_PATHFIND_ALL.isChest() && dungeonSecret.getSecretType() == DungeonSecret.SecretType.CHEST) + pathfind(value.getKey(), "found", FeatureRegistry.SECRET_LINE_PROPERTIES_PATHFINDALL_CHEST.getRouteProperties()); + if (FeatureRegistry.SECRET_PATHFIND_ALL.isEssence() && dungeonSecret.getSecretType() == DungeonSecret.SecretType.ESSENCE) + pathfind(value.getKey(), "found", FeatureRegistry.SECRET_LINE_PROPERTIES_PATHFINDALL_ESSENCE.getRouteProperties()); + if (FeatureRegistry.SECRET_PATHFIND_ALL.isItemdrop() && dungeonSecret.getSecretType() == DungeonSecret.SecretType.ITEM_DROP) + pathfind(value.getKey(), "found", FeatureRegistry.SECRET_LINE_PROPERTIES_PATHFINDALL_ITEM_DROP.getRouteProperties()); } } } @@ -131,7 +145,7 @@ public class GeneralRoomProcessor implements RoomProcessor { } if (lowestWeightMechanic != null) { visited.add(lowestWeightMechanic.getKey()); - pathfind("AUTO-BROWSE", lowestWeightMechanic.getKey(), "found"); + pathfind("AUTO-BROWSE", lowestWeightMechanic.getKey(), "found", FeatureRegistry.SECRET_LINE_PROPERTIES_AUTOPATHFIND.getRouteProperties()); } else { visited.clear(); } @@ -167,14 +181,50 @@ public class GeneralRoomProcessor implements RoomProcessor { value.getValue().highlight(new Color(0,255,255,50), value.getKey(), dungeonRoom, partialTicks); } } + + + ActionRoute finalSmallest = getBestFit(partialTicks); path.values().forEach(a -> { - a.onRenderWorld(partialTicks); + a.onRenderWorld(partialTicks, finalSmallest == a); }); } + private ActionRoute getBestFit(float partialTicks) { + + ActionRoute smallest = null; + double smallestTan = 0.002; + for (ActionRoute value : path.values()) { + BlockPos target; + if (value.getCurrentAction() instanceof ActionMove) { + target = ((ActionMove) value.getCurrentAction()).getTarget().getBlockPos(dungeonRoom); + } else if (value.getCurrentAction() instanceof ActionMoveNearestAir) { + target = ((ActionMoveNearestAir) value.getCurrentAction()).getTarget().getBlockPos(dungeonRoom); + } else if (value.getCurrent() >= 1 && value.getActions().get(value.getCurrent()-1) instanceof ActionMove) { + target = ((ActionMove)value.getActions().get(value.getCurrent()-1)).getTarget().getBlockPos(dungeonRoom); + } else if (value.getCurrent() >= 1 && value.getActions().get(value.getCurrent()-1) instanceof ActionMoveNearestAir) { + target = ((ActionMoveNearestAir)value.getActions().get(value.getCurrent()-1)).getTarget().getBlockPos(dungeonRoom); + } else continue; + + if (value.getActionRouteProperties().getLineRefreshRate() != -1 && value.getActionRouteProperties().isPathfind() && !FeatureRegistry.SECRET_FREEZE_LINES.isEnabled()) continue; + + Entity e = Minecraft.getMinecraft().getRenderViewEntity(); + + double vectorV = VectorUtils.distSquared(e.getLook(partialTicks), e.getPositionEyes(partialTicks), new Vec3(target).addVector(0.5,0.5,0.5)); + + if (vectorV < smallestTan) { + smallest = value; + smallestTan = vectorV; + } + } + return smallest; + } + @Override public void chatReceived(IChatComponent chat) { - + if (lastChest != null && chat.getFormattedText().equals("§r§cThis chest has already been searched!§r")) { + getDungeonRoom().getRoomContext().put("c-"+lastChest.toString(), true); + lastChest = null; + } } private int stack = 0; @@ -237,13 +287,13 @@ public class GeneralRoomProcessor implements RoomProcessor { return path.get(id); } - public String pathfind(String mechanic, String state) { + public String pathfind(String mechanic, String state, ActionRoute.ActionRouteProperties actionRouteProperties) { String str; - pathfind(str = UUID.randomUUID().toString(), mechanic, state); + pathfind(str = UUID.randomUUID().toString(), mechanic, state, actionRouteProperties); return str; } - public void pathfind(String id, String mechanic, String state) { - path.put(id, new ActionRoute(getDungeonRoom(), mechanic, state)); + public void pathfind(String id, String mechanic, String state, ActionRoute.ActionRouteProperties actionRouteProperties) { + path.put(id, new ActionRoute(getDungeonRoom(), mechanic, state, actionRouteProperties)); } public void cancelAll() { path.clear(); @@ -272,6 +322,19 @@ public class GeneralRoomProcessor implements RoomProcessor { public void onKeyPress(InputEvent.KeyInputEvent keyInputEvent) { if (FeatureRegistry.SECRET_NEXT_KEY.isEnabled() && Keybinds.nextSecret.isKeyDown()) { searchForNextTarget(); + } else if (Keybinds.refreshPathfind.isKeyDown()) { + ActionRoute actionRoute = getBestFit(0); + if (actionRoute.getCurrentAction() instanceof ActionMove) { + ActionMove ac = (ActionMove) actionRoute.getCurrentAction(); + ac.forceRefresh(getDungeonRoom()); + } else if (actionRoute.getCurrentAction() instanceof ActionMoveNearestAir) { + ActionMoveNearestAir ac = (ActionMoveNearestAir) actionRoute.getCurrentAction(); + ac.forceRefresh(getDungeonRoom()); + } else if (actionRoute.getCurrent() >= 1 && actionRoute.getActions().get(actionRoute.getCurrent()-1) instanceof ActionMove) { + ((ActionMove)actionRoute.getActions().get(actionRoute.getCurrent()-1)).forceRefresh(dungeonRoom); + } else if (actionRoute.getCurrent() >= 1 && actionRoute.getActions().get(actionRoute.getCurrent()-1) instanceof ActionMoveNearestAir) { + ((ActionMoveNearestAir)actionRoute.getActions().get(actionRoute.getCurrent()-1)).forceRefresh(dungeonRoom); + } } } @@ -283,12 +346,17 @@ public class GeneralRoomProcessor implements RoomProcessor { } private boolean last = false; + private BlockPos lastChest; @Override public void onInteractBlock(PlayerInteractEvent event) { path.values().forEach(a -> { a.onPlayerInteract(event); }); + IBlockState iBlockState = event.world.getBlockState(event.pos); + if (iBlockState.getBlock() == Blocks.chest || iBlockState.getBlock() == Blocks.trapped_chest) + lastChest = event.pos; + if (event.entityPlayer.getHeldItem() != null && event.entityPlayer.getHeldItem().getItem() == Items.stick && FeatureRegistry.ADVANCED_ROOMEDIT.isEnabled() && diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/VectorUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/VectorUtils.java index 8f13dd8a..59eaa866 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/VectorUtils.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/VectorUtils.java @@ -18,6 +18,12 @@ package kr.syeyoung.dungeonsguide.utils; +import lombok.AllArgsConstructor; +import lombok.Data; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ActiveRenderInfo; +import net.minecraft.util.Vec3; + import javax.vecmath.Vector2d; public class VectorUtils { @@ -30,4 +36,18 @@ public class VectorUtils { public static Vector2d rotateClockwise(Vector2d vector2d) { return new Vector2d(-vector2d.y, vector2d.x); } + + @Data @AllArgsConstructor + public static class ProjectionResult { + private float x; + private float y; + private boolean back; + } + + public static double distSquared(Vec3 lookVec, Vec3 posVec, Vec3 objectVec) { + Vec3 v = objectVec.subtract(posVec); + double t = v.dotProduct(lookVec); + Vec3 p = posVec.addVector(lookVec.xCoord * t, lookVec.yCoord * t, lookVec.zCoord * t); + return p.squareDistanceTo(objectVec) / p.squareDistanceTo(posVec); + } } |