diff options
author | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-12-07 11:48:40 +0900 |
---|---|---|
committer | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-12-07 11:48:40 +0900 |
commit | 4e82fbff685a77f1725abe93f87f7648af21ea35 (patch) | |
tree | 93b23e50c8c77cbb54c949165f1d166d95dea484 /src | |
parent | e8a50a6fa1187220539029aa44b809439f1585fb (diff) | |
download | Skyblock-Dungeons-Guide-4e82fbff685a77f1725abe93f87f7648af21ea35.tar.gz Skyblock-Dungeons-Guide-4e82fbff685a77f1725abe93f87f7648af21ea35.tar.bz2 Skyblock-Dungeons-Guide-4e82fbff685a77f1725abe93f87f7648af21ea35.zip |
Global Processor and stuff
Diffstat (limited to 'src')
9 files changed, 73 insertions, 20 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java b/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java index 2fe737c2..d1daa7d6 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java @@ -9,6 +9,7 @@ import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonAddSet; import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonOffsetPointEdit; import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonParameterEdit; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; +import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessor; import kr.syeyoung.dungeonsguide.utils.MapUtils; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import net.minecraft.client.Minecraft; @@ -125,13 +126,23 @@ public class EventListener { EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); - DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); - if (dungeonRoom != null) { - if (dungeonRoom.getRoomProcessor() != null) { - dungeonRoom.getRoomProcessor().chatReceived(clientChatReceivedEvent.message); + try { + DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); + if (dungeonRoom != null) { + if (dungeonRoom.getRoomProcessor() != null) { + dungeonRoom.getRoomProcessor().chatReceived(clientChatReceivedEvent.message); + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + for (RoomProcessor globalRoomProcessor : context.getGlobalRoomProcessors()) { + try { + globalRoomProcessor.chatReceived(clientChatReceivedEvent.message); + } catch (Throwable t) { + t.printStackTrace(); } } - } } catch (Throwable e) { e.printStackTrace(); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonContext.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonContext.java index 30250107..59ce37c6 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonContext.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/DungeonContext.java @@ -1,6 +1,7 @@ package kr.syeyoung.dungeonsguide.dungeon; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessor; import lombok.Getter; import lombok.Setter; import net.minecraft.util.BlockPos; @@ -11,6 +12,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; public class DungeonContext { @Getter @@ -27,6 +29,9 @@ public class DungeonContext { @Getter private List<DungeonRoom> dungeonRoomList = new ArrayList<DungeonRoom>(); + @Getter + private List<RoomProcessor> globalRoomProcessors = new ArrayList<RoomProcessor>(); + public DungeonContext(World world) { this.world = world; mapProcessor = new MapProcessor(this); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java index 32124452..3a7a6256 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java @@ -182,6 +182,8 @@ public class MapProcessor { roomsFound.add(p); context.getRoomMapper().put(p, rooms); } + if (rooms.getRoomProcessor() != null && rooms.getRoomProcessor().readGlobalChat()) + context.getGlobalRoomProcessors().add(rooms.getRoomProcessor()); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java index ce4f6b16..3d326349 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java @@ -35,6 +35,11 @@ public class GeneralRoomProcessor implements RoomProcessor { } + @Override + public boolean readGlobalChat() { + return false; + } + public static class Generator implements RoomProcessorGenerator<GeneralRoomProcessor> { @Override public GeneralRoomProcessor createNew(DungeonRoom dungeonRoom) { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java index 78b5c8c8..f768ac40 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java @@ -8,4 +8,6 @@ public interface RoomProcessor { void drawScreen(float partialTicks); void drawWorld(float partialTicks); void chatReceived(IChatComponent chat); + + boolean readGlobalChat(); }
\ No newline at end of file diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorCreeperSolver.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorCreeperSolver.java index 91b40112..2890555c 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorCreeperSolver.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorCreeperSolver.java @@ -28,22 +28,32 @@ public class RoomProcessorCreeperSolver extends GeneralRoomProcessor { private List<BlockPos[]> poses = new ArrayList<BlockPos[]>(); + private boolean bugged = false; + public RoomProcessorCreeperSolver(DungeonRoom dungeonRoom) { super(dungeonRoom); - World w = dungeonRoom.getContext().getWorld(); + + findCreeperAndDoPoses(); + } + + private void findCreeperAndDoPoses() { + World w = getDungeonRoom().getContext().getWorld(); Set<BlockPos> prismarines = new HashSet<BlockPos>(); - final BlockPos low = dungeonRoom.getMin().add(0,-3,0); - final BlockPos high = dungeonRoom.getMax().add(0,15,0); + final BlockPos low = getDungeonRoom().getMin().add(0,-3,0); + final BlockPos high = getDungeonRoom().getMax().add(0,15,0); List<EntityCreeper> creeepr = w.getEntities(EntityCreeper.class, new Predicate<EntityCreeper>() { @Override public boolean apply(@Nullable EntityCreeper input) { if (input.isInvisible()) return false; - BlockPos pos = input.getPosition(); - return low.getX() < pos.getX() && pos.getX() < high.getX() - && low.getZ() < pos.getZ() && pos.getZ() < high.getZ(); + BlockPos pos = input.getPosition(); + return low.getX() < pos.getX() && pos.getX() < high.getX() + && low.getZ() < pos.getZ() && pos.getZ() < high.getZ(); } }); - if (creeepr.isEmpty()) return; + if (creeepr.isEmpty()) { + bugged = true; + return; + } EntityCreeper creeper = creeepr.get(0); Vec3 position = creeper.getPositionVector().addVector(0,1,0); @@ -91,9 +101,16 @@ public class RoomProcessorCreeperSolver extends GeneralRoomProcessor { System.out.println("Found Set :: "+allInBox + " / "+otherPrismarine + " / "+opposite+" / "+pos +" / "+position); } } - + bugged = false; } + @Override + public void tick() { + super.tick(); + if (bugged) { + findCreeperAndDoPoses(); + } + } private static final Color[] colors = new Color[] {Color.red, Color.orange, Color.green, Color.cyan, Color.blue, Color.pink, Color.yellow, Color.darkGray, Color.lightGray}; @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorIcePath.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorIcePath.java index efb0f98c..b347e409 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorIcePath.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorIcePath.java @@ -32,9 +32,13 @@ public class RoomProcessorIcePath extends GeneralRoomProcessor { public RoomProcessorIcePath(DungeonRoom dungeonRoom) { super(dungeonRoom); - final BlockPos low = dungeonRoom.getMin(); - final BlockPos high = dungeonRoom.getMax(); - List<EntitySilverfish> silverfishs = dungeonRoom.getContext().getWorld().getEntities(EntitySilverfish.class, new Predicate<EntitySilverfish>() { + findSilverFishanddoStuff(); + } + + public void findSilverFishanddoStuff() { + final BlockPos low = getDungeonRoom().getMin(); + final BlockPos high = getDungeonRoom().getMax(); + List<EntitySilverfish> silverfishs = getDungeonRoom().getContext().getWorld().getEntities(EntitySilverfish.class, new Predicate<EntitySilverfish>() { @Override public boolean apply(@Nullable EntitySilverfish input) { if (input.isInvisible()) return false; @@ -51,9 +55,11 @@ public class RoomProcessorIcePath extends GeneralRoomProcessor { } try { buildMap(); + err = false; } catch (Exception e) { e.printStackTrace();; err = true; + return; } } @@ -76,7 +82,10 @@ public class RoomProcessorIcePath extends GeneralRoomProcessor { public void tick() { super.tick(); - if (err) return; + if (err) { + findSilverFishanddoStuff(); + if (err) return; + } if (silverfish.getPosition().equals(lastSilverfishLoc)) { if (sameTick < 10) { sameTick ++; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTrivia.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTrivia.java index d5b60845..f81efb97 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTrivia.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorTrivia.java @@ -164,4 +164,9 @@ public class RoomProcessorTrivia extends GeneralRoomProcessor { return defaultRoomProcessor; } } + + @Override + public boolean readGlobalChat() { + return true; + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/icefill/RoomProcessorIcePath2.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/icefill/RoomProcessorIcePath2.java index b0e28cf1..7671cc80 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/icefill/RoomProcessorIcePath2.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/icefill/RoomProcessorIcePath2.java @@ -19,8 +19,6 @@ import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.CopyOnWriteArrayList; public class RoomProcessorIcePath2 extends GeneralRoomProcessor { - private boolean bugged = false; - private List<List<BlockPos>> solution = new CopyOnWriteArrayList<List<BlockPos>>(); private Queue<String> messageQueue = new ConcurrentLinkedQueue<String>(); @@ -31,7 +29,6 @@ public class RoomProcessorIcePath2 extends GeneralRoomProcessor { String levels = (String) dungeonRoom.getDungeonRoomInfo().getProperties().get("levels"); if (levels == null) { - bugged = true; return; } |