diff --git a/gradle.properties b/gradle.properties index 0ef2530..c7be718 100644 --- a/gradle.properties +++ b/gradle.properties @@ -34,7 +34,7 @@ mod_name=Sign Me Up # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=BSD-3-Clause # The mod version. See https://semver.org/ -mod_version=0.6.5 +mod_version=0.6.6 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/org/teacon/signmeup/gui/map/WayPointsPanel.java b/src/main/java/org/teacon/signmeup/gui/map/WayPointsPanel.java index c2966e7..65ca99e 100644 --- a/src/main/java/org/teacon/signmeup/gui/map/WayPointsPanel.java +++ b/src/main/java/org/teacon/signmeup/gui/map/WayPointsPanel.java @@ -9,9 +9,11 @@ import cn.ussshenzhou.t88.network.NetworkHelper; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.components.Tooltip; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.Level; import org.joml.Vector2i; import org.teacon.signmeup.SignMeUp; import org.teacon.signmeup.config.Waypoints; @@ -117,7 +119,11 @@ public boolean mouseClicked(double pMouseX, double pMouseY, int pButton) { long time = System.currentTimeMillis(); if (time - lastClickedTime <= 200) { lastClickedTime = 0; - NetworkHelper.sendToServer(new TeleportToWayPointPacket(logicWaypoints.inverse().get(this).name)); + Minecraft mc = Minecraft.getInstance(); + if (mc.level != null && mc.level.dimension() == Level.OVERWORLD) { + NetworkHelper.sendToServer(new TeleportToWayPointPacket(logicWaypoints.inverse().get(this).name)); + } + getTopParentScreenOptional().ifPresent(tScreen -> tScreen.onClose(false)); return true; } else { diff --git a/src/main/java/org/teacon/signmeup/gui/map/bp/WayPointsButtonPanel.java b/src/main/java/org/teacon/signmeup/gui/map/bp/WayPointsButtonPanel.java index 90c6835..875ce3b 100644 --- a/src/main/java/org/teacon/signmeup/gui/map/bp/WayPointsButtonPanel.java +++ b/src/main/java/org/teacon/signmeup/gui/map/bp/WayPointsButtonPanel.java @@ -9,6 +9,7 @@ import net.minecraft.client.gui.components.Tooltip; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.Level; import org.jetbrains.annotations.Nullable; import org.teacon.signmeup.SignMeUp; import org.teacon.signmeup.config.Waypoints; @@ -65,7 +66,11 @@ public WayPointsButtonPanel() { var button = new THoverSensitiveImageButtonImpl( wayPoint.name, b -> { - NetworkHelper.sendToServer(new TeleportToWayPointPacket(wayPoint.name)); + Minecraft mc = Minecraft.getInstance(); + if (mc.level != null && mc.level.dimension() == Level.OVERWORLD) { + NetworkHelper.sendToServer(new TeleportToWayPointPacket(wayPoint.name)); + } + getTopParentScreenOptional().ifPresent(tScreen -> tScreen.onClose(false)); }, SignMeUp.id("textures/gui/button_panel_button.png"), diff --git a/src/main/java/org/teacon/signmeup/hud/MiniMapPanel.java b/src/main/java/org/teacon/signmeup/hud/MiniMapPanel.java index a421274..509f666 100644 --- a/src/main/java/org/teacon/signmeup/hud/MiniMapPanel.java +++ b/src/main/java/org/teacon/signmeup/hud/MiniMapPanel.java @@ -6,13 +6,12 @@ import cn.ussshenzhou.t88.gui.widegt.TPanel; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.world.level.Level; import org.joml.Quaternionf; import org.teacon.signmeup.SignMeUp; import org.teacon.signmeup.config.MiniMap; import org.teacon.signmeup.gui.map.MapScreen; -import java.util.Set; - import static net.minecraft.util.Mth.PI; /** @@ -49,8 +48,10 @@ public MiniMapPanel() { public void tickT() { super.tickT(); Minecraft mc = Minecraft.getInstance(); + var visible = !mc.getDebugOverlay().showDebugScreen() && !mc.options.hideGui + && (mc.level != null && mc.level.dimension() == Level.OVERWORLD) && MiniMapAPI.INSTANCE.visible() && !(mc.screen instanceof MapScreen); children.forEach(childTComponent -> childTComponent.setVisibleT(visible)); diff --git a/src/main/java/org/teacon/signmeup/input/ModKeyInput.java b/src/main/java/org/teacon/signmeup/input/ModKeyInput.java index 7a3c350..4204963 100644 --- a/src/main/java/org/teacon/signmeup/input/ModKeyInput.java +++ b/src/main/java/org/teacon/signmeup/input/ModKeyInput.java @@ -3,6 +3,7 @@ import com.mojang.blaze3d.platform.InputConstants; import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; +import net.minecraft.world.level.Level; import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.common.EventBusSubscriber; @@ -20,7 +21,8 @@ public class ModKeyInput { public static final KeyMapping OPEN_MAP = new KeyMapping( "key.sign_up.open_map", KeyConflictContext.IN_GAME, KeyModifier.NONE, InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_M, "key.categories.sign_up" - ); public static final KeyMapping OPEN_NEW_MAP = new KeyMapping( + ); + public static final KeyMapping OPEN_NEW_MAP = new KeyMapping( "key.sign_up.open_new_map", KeyConflictContext.IN_GAME, KeyModifier.NONE, InputConstants.Type.KEYSYM, -1, "key.categories.sign_up" ); @@ -28,15 +30,18 @@ public class ModKeyInput { @SubscribeEvent public static void onKeyInput(InputEvent.Key event) { - MapScreen screen; - if (OPEN_NEW_MAP.consumeClick()) { - screen = MapScreen.getNewInstance(); - } else if (OPEN_MAP.consumeClick()) { - screen = MapScreen.getInstance(); - } else { - return; + Minecraft mc = Minecraft.getInstance(); + if (mc.level != null && mc.level.dimension() == Level.OVERWORLD) { + MapScreen screen; + if (OPEN_NEW_MAP.consumeClick()) { + screen = MapScreen.getNewInstance(); + } else if (OPEN_MAP.consumeClick()) { + screen = MapScreen.getInstance(); + } else { + return; + } + mc.setScreen(screen); + screen.layout(); } - Minecraft.getInstance().setScreen(screen); - screen.layout(); } }