From a22e0c7e35a95698dbee1e7b17fc03fd7a4957e8 Mon Sep 17 00:00:00 2001 From: syeyoung Date: Sun, 17 Jan 2021 13:53:57 +0900 Subject: bossfight processor --- .../dungeonsguide/dungeon/DungeonContext.java | 14 +++++ .../dungeon/doorfinder/CatacombDataProvider.java | 6 ++ .../doorfinder/DungeonSpecificDataProvider.java | 6 +- .../eventlistener/DungeonListener.java | 14 +++++ .../bossfight/BossfightProcessor.java | 10 +++ .../bossfight/GeneralBossfightProcessor.java | 71 ++++++++++++++++++++++ 6 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessor.java create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/GeneralBossfightProcessor.java (limited to 'src/main/java/kr/syeyoung') diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonContext.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonContext.java index ddbfa299..6d1874c0 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonContext.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonContext.java @@ -1,11 +1,15 @@ package kr.syeyoung.dungeonsguide.dungeon; +import kr.syeyoung.dungeonsguide.SkyblockStatus; +import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonSpecificDataProvider; +import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonSpecificDataProviderRegistry; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.e; import kr.syeyoung.dungeonsguide.events.BossroomEnterEvent; import kr.syeyoung.dungeonsguide.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.features.impl.FeatureDungeonMap; import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessor; +import kr.syeyoung.dungeonsguide.roomprocessor.bossfight.BossfightProcessor; import kr.syeyoung.dungeonsguide.utils.TextUtils; import lombok.Getter; import lombok.Setter; @@ -52,6 +56,10 @@ public class DungeonContext { @Setter private int BossRoomEnterSeconds = -1; + @Getter + @Setter + private BossfightProcessor bossfightProcessor; + @Getter private Set players = new HashSet(); @@ -71,6 +79,12 @@ public class DungeonContext { if (mapProcessor.isInitialized() && BossRoomEnterSeconds == -1 && !roomBoundary.contains(mapProcessor.worldPointToMapPoint(Minecraft.getMinecraft().thePlayer.getPositionVector()))) { BossRoomEnterSeconds = FeatureRegistry.DUNGEON_SBTIME.getTimeElapsed() / 1000; MinecraftForge.EVENT_BUS.post(new BossroomEnterEvent()); + DungeonSpecificDataProvider doorFinder = DungeonSpecificDataProviderRegistry.getDoorFinder(((SkyblockStatus) e.getDungeonsGuide().getSkyblockStatus()).getDungeonName()); + if (doorFinder != null) { + bossfightProcessor = doorFinder.createBossfightProcessor(world, e.getDungeonsGuide().getSkyblockStatus().getDungeonName()); + } else { + e.sendDebugChat(new ChatComponentText("Error:: Null Data Providier")); + } } List list = FeatureDungeonMap.field_175252_a.sortedCopy(Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()); try { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/CatacombDataProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/CatacombDataProvider.java index 7f4e9813..463ee3db 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/CatacombDataProvider.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/CatacombDataProvider.java @@ -2,6 +2,7 @@ package kr.syeyoung.dungeonsguide.dungeon.doorfinder; import com.google.common.base.Predicate; import com.google.common.collect.Sets; +import kr.syeyoung.dungeonsguide.roomprocessor.bossfight.BossfightProcessor; import net.minecraft.entity.item.EntityArmorStand; import net.minecraft.init.Blocks; import net.minecraft.util.BlockPos; @@ -64,4 +65,9 @@ public class CatacombDataProvider implements DungeonSpecificDataProvider { } return null; } + + @Override + public BossfightProcessor createBossfightProcessor(World w, String dungeonName) { + return null; + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonSpecificDataProvider.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonSpecificDataProvider.java index cc97d73a..3103adf0 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonSpecificDataProvider.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonSpecificDataProvider.java @@ -1,5 +1,7 @@ package kr.syeyoung.dungeonsguide.dungeon.doorfinder; +import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessor; +import kr.syeyoung.dungeonsguide.roomprocessor.bossfight.BossfightProcessor; import net.minecraft.util.BlockPos; import net.minecraft.world.World; @@ -8,4 +10,6 @@ import javax.vecmath.Vector2d; public interface DungeonSpecificDataProvider { BlockPos findDoor(World w, String dungeonName); Vector2d findDoorOffset(World w, String dungeonName); -} + + BossfightProcessor createBossfightProcessor(World w, String dungeonName); +} \ No newline at end of file diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java index 7ce151a3..2bc878a1 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java @@ -78,6 +78,7 @@ public class DungeonListener { DungeonContext context = skyblockStatus.getContext(); EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; if (thePlayer == null) return; + if (context.getBossfightProcessor() != null) context.getBossfightProcessor().tick(); Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); @@ -113,6 +114,7 @@ public class DungeonListener { EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); + if (context.getBossfightProcessor() != null) context.getBossfightProcessor().drawScreen(postRender.partialTicks); DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; if (dungeonRoom == null) { @@ -157,6 +159,13 @@ public class DungeonListener { } catch (Throwable t) { t.printStackTrace(); } + + if (context.getBossfightProcessor() != null) { + if (clientChatReceivedEvent.type == 2) + context.getBossfightProcessor().actionbarReceived(clientChatReceivedEvent.message); + else + context.getBossfightProcessor().chatReceived(clientChatReceivedEvent.message); + } RoomProcessor roomProcessor = null; try { DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); @@ -208,6 +217,11 @@ public class DungeonListener { if (skyblockStatus.getContext() != null) { + + if (context.getBossfightProcessor() != null) { + context.getBossfightProcessor().drawWorld(renderWorldLastEvent.partialTicks); + } + EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessor.java new file mode 100644 index 00000000..c893258e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/BossfightProcessor.java @@ -0,0 +1,10 @@ +package kr.syeyoung.dungeonsguide.roomprocessor.bossfight; + +import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessor; + +import java.util.List; + +public interface BossfightProcessor extends RoomProcessor { + List getPhases(); + String getCurrentPhase(); +} \ No newline at end of file diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/GeneralBossfightProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/GeneralBossfightProcessor.java new file mode 100644 index 00000000..4fa60623 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/bossfight/GeneralBossfightProcessor.java @@ -0,0 +1,71 @@ +package kr.syeyoung.dungeonsguide.roomprocessor.bossfight; + +import lombok.Builder; +import lombok.Data; +import net.minecraft.util.IChatComponent; + +import java.util.*; + +public class GeneralBossfightProcessor implements BossfightProcessor { + private Map phases = new HashMap(); + private PhaseData currentPhase = null; + + public void addPhase(PhaseData phaseData) { + if (phaseData == null) return; + if (currentPhase == null) currentPhase = phaseData; + phases.put(phaseData.getPhase(), phaseData); + } + + @Override + public List getPhases() { + List phases = new ArrayList(); + for (PhaseData pd:this.phases.values()) + phases.add(pd.getPhase()); + return phases; + } + + @Override + public String getCurrentPhase() { + return currentPhase == null ? "unknown" : currentPhase.getPhase(); + } + + @Override + public void chatReceived(IChatComponent chat) { + if (currentPhase == null) return; + + for (String nextPhase : currentPhase.getNextPhases()) { + PhaseData phaseData = phases.get(nextPhase); + if (phaseData == null) continue; + if (phaseData.signatureMsg.contains(chat.getFormattedText())) { + currentPhase = phaseData; + onPhaseChange(); + return; + } + } + } + + @Override + public void actionbarReceived(IChatComponent chat) {} + + @Override + public void tick() {} + + @Override + public void drawScreen(float partialTicks) {} + + @Override + public void drawWorld(float partialTicks) {} + + @Override + public boolean readGlobalChat() {return true;} + + public void onPhaseChange() {} + + @Data + @Builder + public static class PhaseData { + private String phase; + private Set signatureMsg; + private Set nextPhases; + } +} -- cgit