diff options
Diffstat (limited to 'src')
6 files changed, 80 insertions, 31 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java index daf1c00f..459c963a 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java @@ -5,7 +5,9 @@ import kr.syeyoung.dungeonsguide.commands.CommandLoadData; import kr.syeyoung.dungeonsguide.commands.CommandSaveData; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry; import lombok.Getter; +import net.minecraft.client.Minecraft; import net.minecraft.init.Blocks; +import net.minecraft.util.IChatComponent; import net.minecraftforge.client.ClientCommandHandler; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.Mod; @@ -25,6 +27,13 @@ public class DungeonsGuide private static DungeonsGuide dungeonsGuide; + public static boolean DEBUG = false; + + public static void sendDebugChat(IChatComponent iChatComponent) { + if (DEBUG) + Minecraft.getMinecraft().thePlayer.addChatMessage(iChatComponent); + } + @EventHandler public void init(FMLInitializationEvent event) { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java b/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java index 2dd1646b..9ded79ef 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java @@ -70,13 +70,14 @@ public class EventListener { public void onRender(RenderGameOverlayEvent.Post postRender) { SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); if (!skyblockStatus.isOnDungeon()) return; - int[] textureData = dynamicTexture.getTextureData(); - MapUtils.getImage().getRGB(0,0,128,128, textureData, 0, 128); - dynamicTexture.updateDynamicTexture(); - Minecraft.getMinecraft().getTextureManager().bindTexture(location); - - GlStateManager.enableAlpha(); - GuiScreen.drawModalRectWithCustomSizedTexture(0,0, 0, 0, 128, 128, 128, 128); + if (DungeonsGuide.DEBUG) { + int[] textureData = dynamicTexture.getTextureData(); + MapUtils.getImage().getRGB(0, 0, 128, 128, textureData, 0, 128); + dynamicTexture.updateDynamicTexture(); + Minecraft.getMinecraft().getTextureManager().bindTexture(location); + GlStateManager.enableAlpha(); + GuiScreen.drawModalRectWithCustomSizedTexture(0, 0, 0, 0, 128, 128, 128, 128); + } if (skyblockStatus.getContext() != null) { DungeonContext context = skyblockStatus.getContext(); @@ -86,11 +87,14 @@ public class EventListener { DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; if (dungeonRoom == null) { - fontRenderer.drawString("Where are you?!", 5, 128, 0xFFFFFF); + if (DungeonsGuide.DEBUG) + fontRenderer.drawString("Where are you?!", 5, 128, 0xFFFFFF); } else { - fontRenderer.drawString("you're in the room... "+dungeonRoom.getColor()+" / "+dungeonRoom.getShape(), 5, 128, 0xFFFFFF); - fontRenderer.drawString("room uuid: "+dungeonRoom.getDungeonRoomInfo().getUuid() + (dungeonRoom.getDungeonRoomInfo().isRegistered() ?"":" (not registered)"), 5, 138, 0xFFFFFF); - fontRenderer.drawString("room name: "+dungeonRoom.getDungeonRoomInfo().getName(), 5, 148, 0xFFFFFF); + if (DungeonsGuide.DEBUG) { + fontRenderer.drawString("you're in the room... " + dungeonRoom.getColor() + " / " + dungeonRoom.getShape(), 5, 128, 0xFFFFFF); + fontRenderer.drawString("room uuid: " + dungeonRoom.getDungeonRoomInfo().getUuid() + (dungeonRoom.getDungeonRoomInfo().isRegistered() ? "" : " (not registered)"), 5, 138, 0xFFFFFF); + fontRenderer.drawString("room name: " + dungeonRoom.getDungeonRoomInfo().getName(), 5, 148, 0xFFFFFF); + } if (dungeonRoom.getRoomProcessor() != null) dungeonRoom.getRoomProcessor().drawScreen(postRender.partialTicks); } @@ -105,10 +109,11 @@ public class EventListener { DungeonContext context = skyblockStatus.getContext(); if (context == null) return; - - for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) { - for(DungeonDoor door : dungeonRoom.getDoors()) { - RenderUtils.renderDoor(door, renderWorldLastEvent.partialTicks); + if (DungeonsGuide.DEBUG) { + for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) { + for(DungeonDoor door : dungeonRoom.getDoors()) { + RenderUtils.renderDoor(door, renderWorldLastEvent.partialTicks); + } } } @@ -148,7 +153,7 @@ public class EventListener { public void onKeyInput(InputEvent.KeyInputEvent keyInputEvent) { if (Keybinds.opengui.isKeyDown()){ EditingContext ec = EditingContext.getEditingContext(); - if (ec == null) Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("No Editing session is open right now")); + if (ec == null) DungeonsGuide.sendDebugChat(new ChatComponentText("No Editing session is open right now")); else ec.reopen(); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandToggleDebug.java b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandToggleDebug.java new file mode 100644 index 00000000..6a17fba6 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandToggleDebug.java @@ -0,0 +1,29 @@ +package kr.syeyoung.dungeonsguide.commands; + +import kr.syeyoung.dungeonsguide.DungeonsGuide; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.util.ChatComponentText; + +public class CommandToggleDebug extends CommandBase { + @Override + public String getCommandName() { + return "debugtoggle"; + } + + @Override + public String getCommandUsage(ICommandSender sender) { + return "debugtoggle"; + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + DungeonsGuide.DEBUG = !DungeonsGuide.DEBUG; + sender.addChatMessage(new ChatComponentText("Toggled Debug mode to "+DungeonsGuide.DEBUG)); + } + @Override + public int getRequiredPermissionLevel() { + return 0; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java index 7dc25774..a88c0e43 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/MapProcessor.java @@ -43,7 +43,7 @@ public class MapProcessor { private void buildMap(final byte[] mapData) { final Point startroom = MapUtils.findFirstColorWithIn(mapData, (byte) 30, new Rectangle(0,0,128,128)); if (startroom == null){ - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("BUGGED MAP")); + DungeonsGuide.sendDebugChat(new ChatComponentText("BUGGED MAP")); bugged = true; return; } @@ -67,7 +67,7 @@ public class MapProcessor { } if (doorDir == null) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("BUGGED MAP, no connected door found")); + DungeonsGuide.sendDebugChat(new ChatComponentText("BUGGED MAP, no connected door found")); bugged = true; return; } @@ -79,7 +79,7 @@ public class MapProcessor { int gap = MapUtils.getLengthOfColorExtending(mapData, (byte) 0, basePoint, doorDir); Point pt = MapUtils.findFirstColorWithInNegate(mapData, (byte)0, new Rectangle(basePoint.x, basePoint.y, (int)Math.abs(doorDir.y) * unitRoomDimension.width + 1, (int)Math.abs(doorDir.x) * unitRoomDimension.height + 1)); if (pt == null) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("BUGGED MAP, can't find door")); + DungeonsGuide.sendDebugChat(new ChatComponentText("BUGGED MAP, can't find door")); bugged = true; return; } @@ -98,18 +98,18 @@ public class MapProcessor { { StartDoorFinder doorFinder = DoorFinderRegistry.getDoorFinder(DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getDungeonName()); if (doorFinder == null) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Couldn't find door finder for :: "+DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getDungeonName())); + DungeonsGuide.sendDebugChat(new ChatComponentText("Couldn't find door finder for :: "+DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getDungeonName())); bugged = true; return; } BlockPos door = doorFinder.find(context.getWorld()); if (door == null) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Couldn't find door :: "+DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getDungeonName())); + DungeonsGuide.sendDebugChat(new ChatComponentText("Couldn't find door :: "+DungeonsGuide.getDungeonsGuide().getSkyblockStatus().getDungeonName())); bugged = true; return; } - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("door Pos:"+door)); + DungeonsGuide.sendDebugChat(new ChatComponentText("door Pos:"+door)); Point unitPoint = mapPointToRoomPoint(startroom); unitPoint.translate(unitPoint.x + 1, unitPoint.y + 1); @@ -125,12 +125,12 @@ public class MapProcessor { } - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Found Green room:"+startroom)); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Axis match:"+axisMatch)); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("World Min:"+context.getDungeonMin())); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Dimension:"+unitRoomDimension)); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("top Left:"+topLeftMapPoint)); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("door dimension:"+doorDimension)); + DungeonsGuide.sendDebugChat(new ChatComponentText("Found Green room:"+startroom)); + DungeonsGuide.sendDebugChat(new ChatComponentText("Axis match:"+axisMatch)); + DungeonsGuide.sendDebugChat(new ChatComponentText("World Min:"+context.getDungeonMin())); + DungeonsGuide.sendDebugChat(new ChatComponentText("Dimension:"+unitRoomDimension)); + DungeonsGuide.sendDebugChat(new ChatComponentText("top Left:"+topLeftMapPoint)); + DungeonsGuide.sendDebugChat(new ChatComponentText("door dimension:"+doorDimension)); } public Point mapPointToRoomPoint(Point mapPoint) { @@ -164,8 +164,8 @@ public class MapProcessor { if (color != 0 && color != 85) { MapUtils.record(mapData, mapPoint.x, mapPoint.y, new Color(0,255,255,80)); DungeonRoom rooms = buildRoom(mapData, new Point(x,y)); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("New Map discovered! shape: "+rooms.getShape()+ " color: "+rooms.getColor()+" unitPos: "+x+","+y)); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("New Map discovered! mapMin: "+rooms.getMin())); + DungeonsGuide.sendDebugChat(new ChatComponentText("New Map discovered! shape: "+rooms.getShape()+ " color: "+rooms.getColor()+" unitPos: "+x+","+y)); + DungeonsGuide.sendDebugChat(new ChatComponentText("New Map discovered! mapMin: "+rooms.getMin())); StringBuilder builder = new StringBuilder(); for (int dy =0;dy<4;dy++) { for (int dx = 0; dx < 4; dx ++) { @@ -174,7 +174,7 @@ public class MapProcessor { } builder.append("\n"); } - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Shape visual: "+builder.toString())); + DungeonsGuide.sendDebugChat(new ChatComponentText("Shape visual: "+builder.toString())); context.getDungeonRoomList().add(rooms); for (Point p:rooms.getUnitPoints()) { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java index f9472791..71664aa4 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/GeneralRoomProcessor.java @@ -29,6 +29,11 @@ public class GeneralRoomProcessor implements RoomProcessor { } + @Override + public void chatReceived(String chat) { + + } + 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 4498811a..cf7e9ff0 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java @@ -6,4 +6,5 @@ public interface RoomProcessor { void tick(); void drawScreen(float partialTicks); void drawWorld(float partialTicks); + void chatReceived(String chat); }
\ No newline at end of file |