diff options
author | syeyoung <cyong06@naver.com> | 2021-02-24 19:14:27 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-02-24 19:14:46 +0900 |
commit | 94c42073098c3f738d565d7febd9d201cbad125d (patch) | |
tree | 0290675d1b7ddb28163e44e66eb2a2cfeb58815a /src/main/java | |
parent | 78a43183b9e4efbd57f8bfc8b80faa5b4bec63b2 (diff) | |
download | Skyblock-Dungeons-Guide-94c42073098c3f738d565d7febd9d201cbad125d.tar.gz Skyblock-Dungeons-Guide-94c42073098c3f738d565d7febd9d201cbad125d.tar.bz2 Skyblock-Dungeons-Guide-94c42073098c3f738d565d7febd9d201cbad125d.zip |
simon says solver
Diffstat (limited to 'src/main/java')
4 files changed, 114 insertions, 0 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java index 639643e9..cb45b416 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/FeatureListener.java @@ -10,6 +10,7 @@ import kr.syeyoung.dungeonsguide.features.listener.*; import net.minecraft.client.Minecraft; import net.minecraftforge.client.event.*; import net.minecraftforge.event.entity.player.ItemTooltipEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; @@ -50,6 +51,21 @@ public class FeatureListener { t.printStackTrace(); } } + @SubscribeEvent + public void onInteract(PlayerInteractEvent postRender) { + try { + SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus(); + if (!skyblockStatus.isOnSkyblock()) return; + + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature instanceof InteractListener) { + ((InteractListener) abstractFeature).onInteract(postRender); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } @SubscribeEvent diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java index ef5e4271..9d87c25d 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java @@ -4,6 +4,7 @@ import kr.syeyoung.dungeonsguide.features.impl.advanced.FeatureDebuggableMap; import kr.syeyoung.dungeonsguide.features.impl.advanced.FeatureRoomCoordDisplay; import kr.syeyoung.dungeonsguide.features.impl.advanced.FeatureRoomDebugInfo; import kr.syeyoung.dungeonsguide.features.impl.boss.*; +import kr.syeyoung.dungeonsguide.features.impl.boss.terminal.FeatureSimonSaysSolver; import kr.syeyoung.dungeonsguide.features.impl.boss.terminal.FeatureTerminalSolvers; import kr.syeyoung.dungeonsguide.features.impl.dungeon.*; import kr.syeyoung.dungeonsguide.features.impl.etc.*; @@ -75,6 +76,7 @@ public class FeatureRegistry { public static final FeatureThornBearPercentage BOSSFIGHT_BEAR_PERCENT = register(new FeatureThornBearPercentage()); public static final FeatureCurrentPhase BOSSFIGHT_CURRENT_PHASE = register(new FeatureCurrentPhase()); public static final FeatureTerminalSolvers BOSSFIGHT_TERMINAL_SOLVERS = register(new FeatureTerminalSolvers()); + public static final FeatureSimonSaysSolver BOSSFIGHT_SIMONSAYS_SOLVER = register(new FeatureSimonSaysSolver()); public static final FeatureInstaCloseChest DUNGEON_INSTACLOSE = register(new FeatureInstaCloseChest()); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/FeatureSimonSaysSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/FeatureSimonSaysSolver.java new file mode 100644 index 00000000..edc56990 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/boss/terminal/FeatureSimonSaysSolver.java @@ -0,0 +1,88 @@ +package kr.syeyoung.dungeonsguide.features.impl.boss.terminal; + +import kr.syeyoung.dungeonsguide.SkyblockStatus; +import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.e; +import kr.syeyoung.dungeonsguide.features.SimpleFeature; +import kr.syeyoung.dungeonsguide.features.listener.InteractListener; +import kr.syeyoung.dungeonsguide.features.listener.TickListener; +import kr.syeyoung.dungeonsguide.features.listener.WorldRenderListener; +import kr.syeyoung.dungeonsguide.roomprocessor.bossfight.BossfightProcessorNecron; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import net.minecraft.init.Blocks; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; + +import java.awt.*; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +public class FeatureSimonSaysSolver extends SimpleFeature implements WorldRenderListener, TickListener, InteractListener { + public FeatureSimonSaysSolver() { + super("Bossfight","Simon Says Solver","Solver for Simon says puzzle", "bossfight.simonsays"); + setEnabled(false); + } + + private SkyblockStatus ss = e.getDungeonsGuide().getSkyblockStatus(); + private List<BlockPos> orderbuild = new ArrayList<BlockPos>(); + private LinkedList<BlockPos> orderclick = new LinkedList<BlockPos>(); + + @Override + public void drawWorld(float partialTicks) { + if (!isEnabled()) return; + + if (orderclick.size() >= 1) + RenderUtils.highlightBlock(orderclick.get(0), new Color(0, 255 ,255, 100), partialTicks, false); + if (orderclick.size() >= 2) + RenderUtils.highlightBlock(orderclick.get(1), new Color(255, 170, 0, 100), partialTicks, false); + } + private boolean wasButton = false; + @Override + public void onTick() { + DungeonContext dc = ss.getContext(); + if (dc == null) { + wasButton = false; + return; + } + if (!(dc.getBossfightProcessor() instanceof BossfightProcessorNecron)) return; + World w = dc.getWorld(); + + if (wasButton && w.getBlockState(new BlockPos(309, 123, 291)).getBlock() == Blocks.air) { + orderclick.clear(); + orderbuild.clear(); + wasButton = false; + } else if (!wasButton && w.getBlockState(new BlockPos(309, 123, 291)).getBlock() == Blocks.stone_button){ + orderclick.addAll(orderbuild); + wasButton = true; + } + + + if (!wasButton) { + for (BlockPos allInBox : BlockPos.getAllInBox(new BlockPos(310, 123, 291), new BlockPos(310, 120, 294))) { + if (w.getBlockState(allInBox).getBlock() == Blocks.sea_lantern && !orderbuild.contains(allInBox)) { + orderbuild.add(allInBox); + } + } + } + } + + @Override + public void onInteract(PlayerInteractEvent event) { + DungeonContext dc = ss.getContext(); + if (dc == null) return; + if (!(dc.getBossfightProcessor() instanceof BossfightProcessorNecron)) return; + World w = dc.getWorld(); + + BlockPos pos = event.pos.add(1,0,0); + if (120 <= pos.getY() && pos.getY() <= 123 && pos.getX() == 310 && 291 <= pos.getZ() && pos.getZ() <= 294) { + if (w.getBlockState(event.pos).getBlock() != Blocks.stone_button) return; + if (!pos.equals(orderclick.peek())) { + if (isEnabled()) event.setCanceled(true); + } else { + orderclick.poll(); + } + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/listener/InteractListener.java b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/InteractListener.java new file mode 100644 index 00000000..1494540b --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/listener/InteractListener.java @@ -0,0 +1,8 @@ +package kr.syeyoung.dungeonsguide.features.listener; + +import net.minecraftforge.event.entity.player.ItemTooltipEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; + +public interface InteractListener { + void onInteract(PlayerInteractEvent event); +} |