diff options
author | syeyoung <cyong06@naver.com> | 2021-04-17 21:19:44 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-04-17 21:19:44 +0900 |
commit | fbcfc4a5f43a93db3afd0bc0a6b308c653e21a32 (patch) | |
tree | 648a78a90c484338aebcef98bd749d976c36625a /src/main/java/kr | |
parent | 6113dd0a33fbf230044588020ef1b09ba397c96a (diff) | |
download | Skyblock-Dungeons-Guide-fbcfc4a5f43a93db3afd0bc0a6b308c653e21a32.tar.gz Skyblock-Dungeons-Guide-fbcfc4a5f43a93db3afd0bc0a6b308c653e21a32.tar.bz2 Skyblock-Dungeons-Guide-fbcfc4a5f43a93db3afd0bc0a6b308c653e21a32.zip |
saving events, better secret detection (itemdrop)
Diffstat (limited to 'src/main/java/kr')
5 files changed, 84 insertions, 0 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java index 1bd76e57..f73a778e 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandDungeonsGuide.java @@ -5,6 +5,7 @@ import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfig; import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.events.DungeonEventHolder; import kr.syeyoung.dungeonsguide.dungeon.mechanics.*; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry; @@ -39,6 +40,7 @@ import java.security.cert.CertificateException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Map; +import java.util.UUID; import java.util.zip.GZIPOutputStream; public class CommandDungeonsGuide extends CommandBase { @@ -300,6 +302,34 @@ public class CommandDungeonsGuide extends CommandBase { sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §fInternal Party id: "+PartyManager.INSTANCE.getPartyID())); } else if (args[0].equalsIgnoreCase("loc")) { sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §fYou're in "+e.getDungeonsGuide().getSkyblockStatus().getDungeonName())); + } else if (args[0].equalsIgnoreCase("saverun")) { + try { + File f = e.getDungeonsGuide().getConfigDir(); + File runDir = new File(f, "dungeonruns"); + runDir.mkdirs(); + + File runFile = new File(runDir, UUID.randomUUID().toString()+".dgrun"); + + DungeonContext dungeonContext = e.getDungeonsGuide().getSkyblockStatus().getContext(); + if (dungeonContext == null) { + sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §cCouldn't find dungeon to save!")); + return; + } + DungeonEventHolder dungeonEventHolder = new DungeonEventHolder(); + dungeonEventHolder.setDate(dungeonContext.getInit()); + dungeonEventHolder.setPlayers(dungeonContext.getPlayers()); + dungeonEventHolder.setEventDataList(dungeonContext.getEvents()); + + + ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(runFile)); + oos.writeObject(dungeonEventHolder); + oos.flush(); + oos.close(); + sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §fSuccessfully saved dungeon run to "+runFile.getAbsolutePath())); + } catch (Exception e) { + sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §cAn error occured while writing rundata "+e.getMessage())); + e.printStackTrace(); + } } else { sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §e/dg §7-§fOpens configuration gui")); sender.addChatMessage(new ChatComponentText("§eDungeons Guide §7:: §e/dg gui §7-§fOpens configuration gui")); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonContext.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonContext.java index 32bda60a..99517134 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonContext.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonContext.java @@ -83,6 +83,7 @@ public class DungeonContext { @Getter private Set<String> players = new HashSet<String>(); + @Getter private List<DungeonEvent> events = new ArrayList<DungeonEvent>(); public DungeonContext(World world) { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonEventHolder.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonEventHolder.java new file mode 100644 index 00000000..de1752a7 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/events/DungeonEventHolder.java @@ -0,0 +1,13 @@ +package kr.syeyoung.dungeonsguide.dungeon.events; + +import lombok.Data; + +import java.util.List; +import java.util.Set; + +@Data +public class DungeonEventHolder { + private long date; + private Set<String> players; + private List<DungeonEvent> eventDataList; +} 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 a88d0333..b7a3eee9 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java @@ -30,10 +30,46 @@ public class DungeonSecret implements DungeonMechanic { private SecretType secretType = SecretType.CHEST; private List<String> preRequisite = new ArrayList<String>(); + public void tick(DungeonRoom dungeonRoom) { + if (secretType == SecretType.CHEST) { + BlockPos pos = secretPoint.getBlockPos(dungeonRoom); + IBlockState blockState = dungeonRoom.getContext().getWorld().getBlockState(pos); + if (blockState.getBlock() == Blocks.chest || blockState.getBlock() == Blocks.trapped_chest) { + TileEntityChest chest = (TileEntityChest) dungeonRoom.getContext().getWorld().getTileEntity(pos); + if (chest.numPlayersUsing > 0) { + dungeonRoom.getRoomContext().put("c-"+pos.toString(), true); + } + } + } else if (secretType == SecretType.ESSENCE) { + BlockPos pos = secretPoint.getBlockPos(dungeonRoom); + IBlockState blockState = dungeonRoom.getContext().getWorld().getBlockState(pos); + if (blockState.getBlock() == Blocks.skull) { + dungeonRoom.getRoomContext().put("e-"+pos.toString(), true); + } + } else if (secretType == SecretType.ITEM_DROP) { + Vec3 pos = new Vec3(secretPoint.getBlockPos(dungeonRoom)); + Vec3 player = Minecraft.getMinecraft().thePlayer.getPositionVector(); + if (player.squareDistanceTo(pos) < 16) { + Vec3 vec3 = pos.subtract(player).normalize(); + for (int i = 0; i < player.distanceTo(pos); i++) { + Vec3 vec = player.addVector(vec3.xCoord * i, vec3.yCoord * i, vec3.zCoord * i); + BlockPos bpos = new BlockPos(vec); + IBlockState blockState = dungeonRoom.getContext().getWorld().getBlockState(bpos); + if (!NodeProcessorDungeonRoom.isValidBlock(blockState)) + return; + } + dungeonRoom.getRoomContext().put("i-" + pos.toString(), true); + } + } + } + public SecretStatus getSecretStatus(DungeonRoom dungeonRoom) { if (secretType == SecretType.CHEST) { BlockPos pos = secretPoint.getBlockPos(dungeonRoom); IBlockState blockState = dungeonRoom.getContext().getWorld().getBlockState(pos); + if (dungeonRoom.getRoomContext().containsKey("c-"+pos.toString())) + return SecretStatus.FOUND; + if (blockState.getBlock() == Blocks.air) { return SecretStatus.DEFINITELY_NOT; } else if (blockState.getBlock() != Blocks.chest && blockState.getBlock() != Blocks.trapped_chest) { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java index 6a0a3dfa..7a4c4413 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java @@ -69,6 +69,10 @@ public class GeneralRoomProcessor implements RoomProcessor { searchForNextTarget(); } } + + for (DungeonMechanic value : dungeonRoom.getMechanics().values()) { + if (value instanceof DungeonSecret) ((DungeonSecret) value).tick(dungeonRoom); + } } private Set<String> visited = new HashSet<String>(); |