diff options
author | syeyoung <cyoung06@naver.com> | 2023-01-16 00:29:40 +0900 |
---|---|---|
committer | syeyoung <cyoung06@naver.com> | 2023-01-16 00:29:40 +0900 |
commit | 5553298dc18b89767ba99977545c9f7a284a76d8 (patch) | |
tree | 18e292deaaaf9d1ef2fc865c666c7948d712b21b /mod/src/main/java/kr/syeyoung/dungeonsguide | |
parent | 6d63af431489516c6d7df23866719f4acd866d46 (diff) | |
download | Skyblock-Dungeons-Guide-5553298dc18b89767ba99977545c9f7a284a76d8.tar.gz Skyblock-Dungeons-Guide-5553298dc18b89767ba99977545c9f7a284a76d8.tar.bz2 Skyblock-Dungeons-Guide-5553298dc18b89767ba99977545c9f7a284a76d8.zip |
- fix concurrent modification with debug
- positionSize to supplier
Signed-off-by: syeyoung <cyoung06@naver.com>
Diffstat (limited to 'mod/src/main/java/kr/syeyoung/dungeonsguide')
5 files changed, 66 insertions, 72 deletions
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/DungeonListener.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/DungeonListener.java index 4bafe9f0..0e1001ba 100755 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/DungeonListener.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/events/listener/DungeonListener.java @@ -273,66 +273,70 @@ public class DungeonListener { @SubscribeEvent public void onWorldRender(RenderWorldLastEvent renderWorldLastEvent) { if (!SkyblockStatus.isOnDungeon()) return; + try { - DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); - if (context == null) { - return; - } + DungeonContext context = DungeonsGuide.getDungeonsGuide().getDungeonFacade().getContext(); + if (context == null) { + return; + } - if (FeatureRegistry.DEBUG.isEnabled()) { - for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) { - for (DungeonDoor door : dungeonRoom.getDoors()) { - RenderUtils.renderDoor(door, renderWorldLastEvent.partialTicks); + if (FeatureRegistry.DEBUG.isEnabled()) { + for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) { + for (DungeonDoor door : dungeonRoom.getDoors()) { + RenderUtils.renderDoor(door, renderWorldLastEvent.partialTicks); + } } } - } - if (context.getBossfightProcessor() != null) { - context.getBossfightProcessor().drawWorld(renderWorldLastEvent.partialTicks); - } + if (context.getBossfightProcessor() != null) { + context.getBossfightProcessor().drawWorld(renderWorldLastEvent.partialTicks); + } - EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; - Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); + 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().drawWorld(renderWorldLastEvent.partialTicks); + DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); + if (dungeonRoom != null) { + if (dungeonRoom.getRoomProcessor() != null) { + dungeonRoom.getRoomProcessor().drawWorld(renderWorldLastEvent.partialTicks); + } } - } - if (FeatureRegistry.DEBUG.isEnabled() && dungeonRoom != null) { + if (FeatureRegistry.DEBUG.isEnabled() && dungeonRoom != null) { - Vec3 player = Minecraft.getMinecraft().thePlayer.getPositionVector(); - BlockPos real = new BlockPos(player.xCoord * 2, player.yCoord * 2, player.zCoord * 2); - for (BlockPos allInBox : BlockPos.getAllInBox(real.add(-1, -1, -1), real.add(1, 1, 1))) { - boolean blocked = dungeonRoom.isBlocked(allInBox.getX(), allInBox.getY(), allInBox.getZ()); + Vec3 player = Minecraft.getMinecraft().thePlayer.getPositionVector(); + BlockPos real = new BlockPos(player.xCoord * 2, player.yCoord * 2, player.zCoord * 2); + for (BlockPos allInBox : BlockPos.getAllInBox(real.add(-1, -1, -1), real.add(1, 1, 1))) { + boolean blocked = dungeonRoom.isBlocked(allInBox.getX(), allInBox.getY(), allInBox.getZ()); - RenderUtils.highlightBox( - AxisAlignedBB.fromBounds( - allInBox.getX() / 2.0 - 0.1, allInBox.getY() / 2.0 - 0.1, allInBox.getZ() / 2.0 - 0.1, - allInBox.getX() / 2.0 + 0.1, allInBox.getY() / 2.0 + 0.1, allInBox.getZ() / 2.0 + 0.1 - ), blocked ? new Color(0x55FF0000, true) : new Color(0x3300FF00, true), renderWorldLastEvent.partialTicks, false); + RenderUtils.highlightBox( + AxisAlignedBB.fromBounds( + allInBox.getX() / 2.0 - 0.1, allInBox.getY() / 2.0 - 0.1, allInBox.getZ() / 2.0 - 0.1, + allInBox.getX() / 2.0 + 0.1, allInBox.getY() / 2.0 + 0.1, allInBox.getZ() / 2.0 + 0.1 + ), blocked ? new Color(0x55FF0000, true) : new Color(0x3300FF00, true), renderWorldLastEvent.partialTicks, false); + } } - } - if (EditingContext.getEditingContext() != null) { - GuiScreen guiScreen = EditingContext.getEditingContext().getCurrent(); - if (guiScreen instanceof GuiDungeonParameterEdit) { - ValueEdit valueEdit = ((GuiDungeonParameterEdit) guiScreen).getValueEdit(); - if (valueEdit != null) { - valueEdit.renderWorld(renderWorldLastEvent.partialTicks); - } - } else if (guiScreen instanceof GuiDungeonValueEdit) { - ValueEdit valueEdit = ((GuiDungeonValueEdit) guiScreen).getValueEdit(); - if (valueEdit != null) { - valueEdit.renderWorld(renderWorldLastEvent.partialTicks); + if (EditingContext.getEditingContext() != null) { + GuiScreen guiScreen = EditingContext.getEditingContext().getCurrent(); + if (guiScreen instanceof GuiDungeonParameterEdit) { + ValueEdit valueEdit = ((GuiDungeonParameterEdit) guiScreen).getValueEdit(); + if (valueEdit != null) { + valueEdit.renderWorld(renderWorldLastEvent.partialTicks); + } + } else if (guiScreen instanceof GuiDungeonValueEdit) { + ValueEdit valueEdit = ((GuiDungeonValueEdit) guiScreen).getValueEdit(); + if (valueEdit != null) { + valueEdit.renderWorld(renderWorldLastEvent.partialTicks); + } + } else if (guiScreen instanceof GuiDungeonAddSet) { + ((GuiDungeonAddSet) guiScreen).onWorldRender(renderWorldLastEvent.partialTicks); } - } else if (guiScreen instanceof GuiDungeonAddSet) { - ((GuiDungeonAddSet) guiScreen).onWorldRender(renderWorldLastEvent.partialTicks); } + } catch (Exception e) { + e.printStackTrace(); } } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/GuiFeature.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/GuiFeature.java index f6fdc880..6b255f8d 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/GuiFeature.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/GuiFeature.java @@ -63,13 +63,6 @@ public abstract class GuiFeature extends AbstractFeature { public void setFeatureRect(GUIRectangle featureRect) { this.featureRect = featureRect; - - Rectangle loc = featureRect.getRectangleNoScale(); - widget = new OverlayWidget( - new WidgetFeatureWrapper(), - OverlayType.UNDER_CHAT, - new Rect(loc.x, loc.y, loc.width, loc.height) - ); OverlayManager.getInstance().updateOverlayPosition(widget); } @@ -91,11 +84,13 @@ public abstract class GuiFeature extends AbstractFeature { this.defaultRatio = defaultWidth / defaultHeight; this.featureRect = new GUIRectangle(0, 0, width, height); - Rectangle loc = featureRect.getRectangleNoScale(); widget = new OverlayWidget( new WidgetFeatureWrapper(), OverlayType.UNDER_CHAT, - new Rect(loc.x, loc.y, loc.width, loc.height) + () -> { + Rectangle loc = featureRect.getRectangleNoScale(); + return new Rect(loc.x, loc.y, loc.width, loc.height); + } ); OverlayManager.getInstance().addOverlay(widget); } @@ -147,13 +142,6 @@ public abstract class GuiFeature extends AbstractFeature { public void loadConfig(JsonObject jsonObject) { super.loadConfig(jsonObject); this.featureRect = TypeConverterRegistry.getTypeConverter("guirect",GUIRectangle.class).deserialize(jsonObject.get("$bounds")); - - Rectangle loc = featureRect.getRectangleNoScale(); - widget = new OverlayWidget( - new WidgetFeatureWrapper(), - OverlayType.UNDER_CHAT, - new Rect(loc.x, loc.y, loc.width, loc.height) - ); OverlayManager.getInstance().updateOverlayPosition(widget); } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayManager.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayManager.java index 30fcd96a..8e38e2a0 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayManager.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayManager.java @@ -63,7 +63,12 @@ public class OverlayManager { private OverlayManager() { this.mc = Minecraft.getMinecraft(); view = new RootDom(root); + guiResize(null); + view.setMounted(true); + } + @SubscribeEvent() + public void guiResize(GuiScreenEvent.InitGuiEvent.Post post){ view.setRelativeBound(new Rect(0,0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight)); view.setAbsBounds(new Rect(0,0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight)); view.setSize(new Size(Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight)); @@ -73,26 +78,23 @@ public class OverlayManager { Minecraft.getMinecraft().displayHeight, Minecraft.getMinecraft().displayHeight )); - view.setMounted(true); } @SubscribeEvent public void renderOverlay(RenderGameOverlayEvent.Post postRender) { if (!(postRender.type == RenderGameOverlayEvent.ElementType.EXPERIENCE || postRender.type == RenderGameOverlayEvent.ElementType.JUMPBAR)) return; - System.out.println("overlay"); view.getContext().CONTEXT.put(OVERLAY_TYPE_KEY, OverlayType.UNDER_CHAT); drawScreen(postRender.partialTicks); } @SubscribeEvent public void renderGui(GuiScreenEvent.DrawScreenEvent.Post postRender) { - System.out.println("gui: "+postRender.gui); - if (postRender.gui instanceof GuiChat) - view.getContext().CONTEXT.put(OVERLAY_TYPE_KEY, OverlayType.OVER_CHAT); - else - view.getContext().CONTEXT.put(OVERLAY_TYPE_KEY, OverlayType.OVER_ANY); - drawScreen(postRender.renderPartialTicks); +// if (postRender.gui instanceof GuiChat) +// view.getContext().CONTEXT.put(OVERLAY_TYPE_KEY, OverlayType.OVER_CHAT); +// else +// view.getContext().CONTEXT.put(OVERLAY_TYPE_KEY, OverlayType.OVER_ANY); +// drawScreen(postRender.renderPartialTicks); } @@ -113,7 +115,6 @@ public class OverlayManager { GlStateManager.alphaFunc(GL_GREATER, 0.1f); GlStateManager.popMatrix(); GlStateManager.enableDepth(); - GlStateManager.disableTexture2D(); GL11.glDisable(GL11.GL_SCISSOR_TEST); } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayManagerRootWidget.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayManagerRootWidget.java index 807472df..9d27f0b9 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayManagerRootWidget.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayManagerRootWidget.java @@ -41,7 +41,7 @@ public class OverlayManagerRootWidget extends Widget implements Layouter { DomElement domElement = overlayWidget.createDomElement(getDomElement()); getDomElement().addElement(domElement); - Rect posSize = overlayWidget.positionSize; + Rect posSize = overlayWidget.positionSize.get(); Size size = domElement.getLayouter().layout(domElement, new ConstraintBox(posSize.getWidth(), posSize.getWidth(), posSize.getHeight(), posSize.getHeight())); domElement.setRelativeBound(new Rect(posSize.getX(), posSize.getY(), size.getWidth(), size.getHeight())); } @@ -52,7 +52,7 @@ public class OverlayManagerRootWidget extends Widget implements Layouter { public void updateOverlayPosition(OverlayWidget overlayWidget) { DomElement domElement = overlayWidget.getDomElement(); - Rect posSize = overlayWidget.positionSize; + Rect posSize = overlayWidget.positionSize.get(); Size size = domElement.getLayouter().layout(domElement, new ConstraintBox(posSize.getWidth(), posSize.getWidth(), posSize.getHeight(), posSize.getHeight())); domElement.setRelativeBound(new Rect(posSize.getX(), posSize.getY(), size.getWidth(), size.getHeight())); } @@ -62,7 +62,7 @@ public class OverlayManagerRootWidget extends Widget implements Layouter { for (DomElement child : buildContext.getChildren()) { if (!(child.getWidget() instanceof OverlayWidget)) continue; - Rect posSize = ((OverlayWidget) child.getWidget()).positionSize; + Rect posSize = ((OverlayWidget) child.getWidget()).positionSize.get(); Size size = child.getLayouter().layout(child, new ConstraintBox(posSize.getWidth(), posSize.getWidth(), posSize.getHeight(), posSize.getHeight())); child.setRelativeBound(new Rect(posSize.getX(), posSize.getY(), size.getWidth(), size.getHeight())); } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayWidget.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayWidget.java index aef258ca..60d36f98 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayWidget.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayWidget.java @@ -33,12 +33,13 @@ import net.minecraft.client.renderer.GlStateManager; import java.util.Collections; import java.util.List; +import java.util.function.Supplier; @AllArgsConstructor public class OverlayWidget extends Widget implements Renderer, Layouter { public Widget wrappingWidget; public OverlayType overlayType; - public Rect positionSize; + public Supplier<Rect> positionSize; @Override public List<Widget> build(DomElement buildContext) { |