diff options
author | syeyoung <cyong06@naver.com> | 2021-01-17 13:53:57 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-01-17 13:53:57 +0900 |
commit | a22e0c7e35a95698dbee1e7b17fc03fd7a4957e8 (patch) | |
tree | 530ced631575eb91a270a421f3e305a21322be9d | |
parent | abd7802a7b07224c0367e64b40f92fe80d284520 (diff) | |
download | Skyblock-Dungeons-Guide-a22e0c7e35a95698dbee1e7b17fc03fd7a4957e8.tar.gz Skyblock-Dungeons-Guide-a22e0c7e35a95698dbee1e7b17fc03fd7a4957e8.tar.bz2 Skyblock-Dungeons-Guide-a22e0c7e35a95698dbee1e7b17fc03fd7a4957e8.zip |
bossfight processor
6 files changed, 120 insertions, 1 deletions
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; @@ -53,6 +57,10 @@ public class DungeonContext { private int BossRoomEnterSeconds = -1; @Getter + @Setter + private BossfightProcessor bossfightProcessor; + + @Getter private Set<String> players = new HashSet<String>(); public DungeonContext(World world) { @@ -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<NetworkPlayerInfo> 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<String> 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<String, PhaseData> phases = new HashMap<String, PhaseData>(); + 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<String> getPhases() { + List<String> phases = new ArrayList<String>(); + 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<String> signatureMsg; + private Set<String> nextPhases; + } +} |