Skip to content

Commit

Permalink
copy coordinates right click option
Browse files Browse the repository at this point in the history
  • Loading branch information
rfresh2 committed Oct 10, 2024
1 parent becad4e commit 8e52dd9
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 20 deletions.
29 changes: 16 additions & 13 deletions common/src/main/java/xaeroplus/mixin/client/MixinGuiMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import java.util.List;
import java.util.stream.Collectors;

import static java.util.Arrays.asList;
import static java.util.Objects.isNull;
import static net.minecraft.world.level.Level.*;
import static org.lwjgl.glfw.GLFW.*;
Expand Down Expand Up @@ -96,6 +95,7 @@ public abstract class MixinGuiMap extends ScreenBase implements IRightClickableE
@Shadow private Button keybindingsButton;
@Shadow private Button dimensionToggleButton;
@Shadow private int rightClickX;
@Shadow private int rightClickY;
@Shadow private int rightClickZ;
@Shadow private int mouseBlockPosX;
@Shadow private int mouseBlockPosZ;
Expand Down Expand Up @@ -538,38 +538,41 @@ public void onInputPress(final int code, final int scanCode, final int modifiers

@Inject(method = "getRightClickOptions", at = @At(value = "RETURN"), remap = false)
public void getRightClickOptionsInject(final CallbackInfoReturnable<ArrayList<RightClickOption>> cir) {
final ArrayList<RightClickOption> options = cir.getReturnValue();
int index = 3;
options.add(index++, new RightClickOption("xaeroplus.gui.world_map.copy_coordinates", options.size(), this) {
@Override
public void onAction(final Screen screen) {
Minecraft.getInstance().keyboardHandler.setClipboard(rightClickX + " " + rightClickY + " " + rightClickZ);
}
});
if (BaritoneHelper.isBaritonePresent()) {
final ArrayList<RightClickOption> options = cir.getReturnValue();
int goalX = rightClickX;
int goalZ = rightClickZ;
options.addAll(3, asList(
new RightClickOption("xaeroplus.gui.world_map.baritone_goal_here", options.size(), this) {
options.add(index++, new RightClickOption("xaeroplus.gui.world_map.baritone_goal_here", options.size(), this) {
@Override
public void onAction(Screen screen) {
BaritoneExecutor.goal(goalX, goalZ);
}
}.setNameFormatArgs(Misc.getKeyName(Settings.REGISTRY.worldMapBaritoneGoalHereKeybindSetting.getKeyBinding())),
new RightClickOption("xaeroplus.gui.world_map.baritone_path_here", options.size(), this) {
}.setNameFormatArgs(Misc.getKeyName(Settings.REGISTRY.worldMapBaritoneGoalHereKeybindSetting.getKeyBinding())));
options.add(index++, new RightClickOption("xaeroplus.gui.world_map.baritone_path_here", options.size(), this) {
@Override
public void onAction(Screen screen) {
BaritoneExecutor.path(goalX, goalZ);
}
}.setNameFormatArgs(Misc.getKeyName(Settings.REGISTRY.worldMapBaritonePathHereKeybindSetting.getKeyBinding()))
));
}.setNameFormatArgs(Misc.getKeyName(Settings.REGISTRY.worldMapBaritonePathHereKeybindSetting.getKeyBinding())));
if (BaritoneHelper.isBaritoneElytraPresent()) {
options.addAll(5, asList(
new RightClickOption("xaeroplus.gui.world_map.baritone_elytra_here", options.size(), this) {
options.add(index++, new RightClickOption("xaeroplus.gui.world_map.baritone_elytra_here", options.size(), this) {
@Override
public void onAction(Screen screen) {
BaritoneExecutor.elytra(goalX, goalZ);
}
}.setNameFormatArgs(Misc.getKeyName(Settings.REGISTRY.worldMapBaritoneElytraHereKeybindSetting.getKeyBinding()))
));
}.setNameFormatArgs(Misc.getKeyName(Settings.REGISTRY.worldMapBaritoneElytraHereKeybindSetting.getKeyBinding())));
}
}

if (Settings.REGISTRY.disableWaypointSharing.get()) {
cir.getReturnValue().removeIf(option -> ((AccessorRightClickOption) option).getName().equals("gui.xaero_right_click_map_share_location"));
options.removeIf(option -> ((AccessorRightClickOption) option).getName().equals("gui.xaero_right_click_map_share_location"));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package xaeroplus.mixin.client;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -24,24 +25,30 @@ public class MixinWaypointReader {
@Inject(method = "getRightClickOptions(Lxaero/map/mods/gui/Waypoint;Lxaero/map/gui/IRightClickableElement;)Ljava/util/ArrayList;",
at = @At("RETURN"))
public void getRightClickOptionsReturn(final Waypoint element, final IRightClickableElement target, final CallbackInfoReturnable<ArrayList<RightClickOption>> cir) {
final ArrayList<RightClickOption> options = cir.getReturnValue();
int index = 3;
options.add(index++, new RightClickOption("xaeroplus.gui.world_map.copy_coordinates", options.size(), target) {
@Override
public void onAction(final Screen screen) {
Minecraft.getInstance().keyboardHandler.setClipboard(element.getX() + " " + element.getY() + " " + element.getZ());
}
});
if (BaritoneHelper.isBaritonePresent()) {
final ArrayList<RightClickOption> options = cir.getReturnValue();
int goalX = element.getX();
int goalZ = element.getZ();
options.addAll(3, asList(
options.add(index++,
new RightClickOption("xaeroplus.gui.world_map.baritone_goal_here", options.size(), target) {
@Override
public void onAction(Screen screen) {
BaritoneExecutor.goal(goalX, goalZ);
}
}.setNameFormatArgs(Misc.getKeyName(Settings.REGISTRY.worldMapBaritoneGoalHereKeybindSetting.getKeyBinding())),
new RightClickOption("xaeroplus.gui.world_map.baritone_path_here", options.size(), target) {
}.setNameFormatArgs(Misc.getKeyName(Settings.REGISTRY.worldMapBaritoneGoalHereKeybindSetting.getKeyBinding())));
options.add(index++, new RightClickOption("xaeroplus.gui.world_map.baritone_path_here", options.size(), target) {
@Override
public void onAction(Screen screen) {
BaritoneExecutor.path(goalX, goalZ);
}
}.setNameFormatArgs(Misc.getKeyName(Settings.REGISTRY.worldMapBaritonePathHereKeybindSetting.getKeyBinding()))
));
}.setNameFormatArgs(Misc.getKeyName(Settings.REGISTRY.worldMapBaritonePathHereKeybindSetting.getKeyBinding())));
if (BaritoneHelper.isBaritoneElytraPresent()) {
options.addAll(5, asList(
new RightClickOption("xaeroplus.gui.world_map.baritone_elytra_here", options.size(), target) {
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/assets/xaeroplus/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
"xaeroplus.gui.minimap_incompatible.required_version": "Required Version: ",
"xaeroplus.gui.minimap_incompatible.download_minimap": "Download Xaero's Minimap",
"xaeroplus.gui.minimap_incompatible.exit": "Exit",
"xaeroplus.gui.world_map.copy_coordinates": "Copy Coordinates",
"xaeroplus.gui.world_map.go_to_coordinates": "Go to Coordinates",
"xaeroplus.gui.world_map.baritone_goal_here": "§2%s§r Baritone Goal Here",
"xaeroplus.gui.world_map.baritone_path_here": "§2%s§r Baritone Path Here",
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/assets/xaeroplus/lang/es_ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
"xaeroplus.gui.minimap_incompatible.required_version": "Versión Requerida: ",
"xaeroplus.gui.minimap_incompatible.download_minimap": "Descargar Xaero's Minimap",
"xaeroplus.gui.minimap_incompatible.exit": "Salir",
"xaeroplus.gui.world_map.copy_coordinates": "Copiar coordenadas",
"xaeroplus.gui.world_map.go_to_coordinates": "Ir a Coordenadas",
"xaeroplus.gui.world_map.baritone_goal_here": "§2%s§r Objetivo Baritone Aca",
"xaeroplus.gui.world_map.baritone_path_here": "§2%s§r Camino Baritone Aca",
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/assets/xaeroplus/lang/fr_ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
"xaeroplus.gui.minimap_incompatible.required_version": "Version requise: ",
"xaeroplus.gui.minimap_incompatible.download_minimap": "Téléchargez la mini-carte de Xaero",
"xaeroplus.gui.minimap_incompatible.exit": "Sortie",
"xaeroplus.gui.world_map.copy_coordinates": "Copier les coordonnées",
"xaeroplus.gui.world_map.go_to_coordinates": "Aller aux coordonnées",
"xaeroplus.gui.world_map.baritone_goal_here": "§2%s§r Baryton Ciblez ici",
"xaeroplus.gui.world_map.baritone_path_here": "§2%s§r Chemin du baryton ici",
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/assets/xaeroplus/lang/fr_fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
"xaeroplus.gui.minimap_incompatible.required_version": "Version requise: ",
"xaeroplus.gui.minimap_incompatible.download_minimap": "Téléchargez la mini-carte de Xaero",
"xaeroplus.gui.minimap_incompatible.exit": "Sortie",
"xaeroplus.gui.world_map.copy_coordinates": "Copier les coordonnées",
"xaeroplus.gui.world_map.go_to_coordinates": "Aller aux coordonnées",
"xaeroplus.gui.world_map.baritone_goal_here": "§2%s§r Baryton Ciblez ici",
"xaeroplus.gui.world_map.baritone_path_here": "§2%s§r Chemin du baryton ici",
Expand Down
3 changes: 2 additions & 1 deletion common/src/main/resources/assets/xaeroplus/lang/ja_jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@
"xaeroplus.gui.minimap_incompatible.currently_installed_version": "現在のバージョン: ",
"xaeroplus.gui.minimap_incompatible.required_version": "必要なバージョン: ",
"xaeroplus.gui.minimap_incompatible.download_minimap": "Xaero's Minimapをダウンロード",
"xaeroplus.gui.minimap_incompatible.exit": "Exit",
"xaeroplus.gui.minimap_incompatible.exit": "出口",
"xaeroplus.gui.world_map.copy_coordinates": "座標をコピー",
"xaeroplus.gui.world_map.go_to_coordinates": "この座標に行く",
"xaeroplus.gui.world_map.baritone_goal_here": "§2%s§r Baritoneのゴール",
"xaeroplus.gui.world_map.baritone_path_here": "§2%s§r Baritoneのルート",
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/assets/xaeroplus/lang/pl_pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
"xaeroplus.gui.minimap_incompatible.required_version": "Wymagana wersja: ",
"xaeroplus.gui.minimap_incompatible.download_minimap": "Pobierz minimapę Xaero",
"xaeroplus.gui.minimap_incompatible.exit": "Wyjście",
"xaeroplus.gui.world_map.copy_coordinates": "Kopiuj współrzędne",
"xaeroplus.gui.world_map.go_to_coordinates": "Idź na Koordynaty",
"xaeroplus.gui.world_map.baritone_goal_here": "§2%s§r Cel Baritone Tutaj",
"xaeroplus.gui.world_map.baritone_path_here": "§2%s§r Ścieżka Baritone Tutaj",
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/assets/xaeroplus/lang/pt_pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
"xaeroplus.gui.minimap_incompatible.required_version": "Versão Necessária: ",
"xaeroplus.gui.minimap_incompatible.download_minimap": "Transferir Xaero's Minimap",
"xaeroplus.gui.minimap_incompatible.exit": "Sair",
"xaeroplus.gui.world_map.copy_coordinates": "Copiar coordenadas",
"xaeroplus.gui.world_map.go_to_coordinates": "Ir para Coordenadas",
"xaeroplus.gui.world_map.baritone_goal_here": "§2%s§r Destino Baritone Aqui",
"xaeroplus.gui.world_map.baritone_path_here": "§2%s§r Caminho Baritone Aqui",
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/assets/xaeroplus/lang/ru_ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
"xaeroplus.gui.minimap_incompatible.required_version": "Требуемая версия: ",
"xaeroplus.gui.minimap_incompatible.download_minimap": "Скачать миникарту Xaero",
"xaeroplus.gui.minimap_incompatible.exit": "Выход",
"xaeroplus.gui.world_map.copy_coordinates": "Копировать координаты",
"xaeroplus.gui.world_map.go_to_coordinates": "Идти на координаты",
"xaeroplus.gui.world_map.baritone_goal_here": "§2%s§r Baritone Цель тут",
"xaeroplus.gui.world_map.baritone_path_here": "§2%s§r Baritone Путь тут",
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/assets/xaeroplus/lang/vi_vn.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
"xaeroplus.gui.minimap_incompatible.required_version": "Phiên Bản Yêu Cầu: ",
"xaeroplus.gui.minimap_incompatible.download_minimap": "Tải Xuống Xaero's Minimap",
"xaeroplus.gui.minimap_incompatible.exit": "Thoát",
"xaeroplus.gui.world_map.copy_coordinates": "Sao chép tọa độ",
"xaeroplus.gui.world_map.go_to_coordinates": "Đi Đến Tọa Độ",
"xaeroplus.gui.world_map.baritone_goal_here": "§2%s§r Mục Tiêu Baritone Tại Đây",
"xaeroplus.gui.world_map.baritone_path_here": "§2%s§r Đường Đi Baritone Tại Đây",
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/assets/xaeroplus/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
"xaeroplus.gui.minimap_incompatible.required_version": "所需版本:",
"xaeroplus.gui.minimap_incompatible.download_minimap": "下载 Xaero 的小地图",
"xaeroplus.gui.minimap_incompatible.exit": "出口",
"xaeroplus.gui.world_map.copy_coordinates": "复制坐标",
"xaeroplus.gui.world_map.go_to_coordinates": "转到坐标",
"xaeroplus.gui.world_map.baritone_goal_here": "§2%s§r 设置 Baritone 目标点",
"xaeroplus.gui.world_map.baritone_path_here": "§2%s§r 通过 Baritone 寻路至此处",
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/assets/xaeroplus/lang/zh_tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
"xaeroplus.gui.minimap_incompatible.required_version": "需要的版本:",
"xaeroplus.gui.minimap_incompatible.download_minimap": "下載 Xaero 的小地圖",
"xaeroplus.gui.minimap_incompatible.exit": "退出",
"xaeroplus.gui.world_map.copy_coordinates": "複製座標",
"xaeroplus.gui.world_map.go_to_coordinates": "前往座標",
"xaeroplus.gui.world_map.baritone_goal_here": "§2%s§r Baritone 行動目標到此處",
"xaeroplus.gui.world_map.baritone_path_here": "§2%s§r Baritone 尋路到此處",
Expand Down

0 comments on commit 8e52dd9

Please sign in to comment.