Skip to content

Commit

Permalink
Merge branch '1.20.1' into 1.19.4
Browse files Browse the repository at this point in the history
  • Loading branch information
rfresh2 committed Jul 21, 2024
2 parents 9595028 + d423cea commit 7e2ff66
Show file tree
Hide file tree
Showing 15 changed files with 197 additions and 92 deletions.
49 changes: 26 additions & 23 deletions common/src/main/java/xaeroplus/mixin/client/MixinGuiMap.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package xaeroplus.mixin.client;

import baritone.api.BaritoneAPI;
import baritone.api.pathing.goals.GoalXZ;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.WrapWithCondition;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
Expand Down Expand Up @@ -41,13 +39,15 @@
import xaero.map.graphics.renderer.multitexture.MultiTextureRenderTypeRendererProvider;
import xaero.map.gui.*;
import xaero.map.gui.dropdown.rightclick.RightClickOption;
import xaero.map.misc.Misc;
import xaero.map.misc.OptimizedMath;
import xaero.map.mods.SupportMods;
import xaero.map.world.MapDimension;
import xaeroplus.Globals;
import xaeroplus.XaeroPlus;
import xaeroplus.mixin.client.mc.AccessorGameOptions;
import xaeroplus.settings.XaeroPlusSettingRegistry;
import xaeroplus.util.BaritoneExecutor;
import xaeroplus.util.BaritoneHelper;
import xaeroplus.util.ChunkUtils;

Expand Down Expand Up @@ -571,48 +571,51 @@ public void onInputPress(final int code, final int scanCode, final int modifiers
if (code == 257) {
onGotoCoordinatesButton(null);
cir.setReturnValue(true);
return;
}
}
if (BaritoneHelper.isBaritonePresent()) {
if (XaeroPlusSettingRegistry.worldMapBaritoneGoalHereKeybindSetting.getKeyBinding().matches(code, scanCode)) {
BaritoneExecutor.goal(mouseBlockPosX, mouseBlockPosZ);
cir.setReturnValue(true);
} else if (XaeroPlusSettingRegistry.worldMapBaritonePathHereKeybindSetting.getKeyBinding().matches(code, scanCode)) {
BaritoneExecutor.path(mouseBlockPosX, mouseBlockPosZ);
cir.setReturnValue(true);
} else if (BaritoneHelper.isBaritoneElytraPresent() && XaeroPlusSettingRegistry.worldMapBaritoneElytraHereKeybindSetting.getKeyBinding().matches(code, scanCode)) {
BaritoneExecutor.elytra(mouseBlockPosX, mouseBlockPosZ);
cir.setReturnValue(true);
}
}
}

@Inject(method = "getRightClickOptions", at = @At(value = "RETURN"), remap = false)
public void getRightClickOptionsInject(final CallbackInfoReturnable<ArrayList<RightClickOption>> cir) {
if (BaritoneHelper.isBaritonePresent()) {
ResourceKey<Level> customDim = Globals.getCurrentDimensionId();
ResourceKey<Level> actualDim = ChunkUtils.getActualDimension();
double customDimDiv = 1.0;
if (customDim != actualDim) {
if (customDim == NETHER && actualDim == OVERWORLD) {
customDimDiv = 8;
} else if (customDim == OVERWORLD && actualDim == NETHER) {
customDimDiv = 0.125;
}
}
int goalX = (int) (rightClickX * customDimDiv);
int goalZ = (int) (rightClickZ * customDimDiv);
final ArrayList<RightClickOption> options = cir.getReturnValue();
int goalX = rightClickX;
int goalZ = rightClickZ;
options.addAll(3, asList(
new RightClickOption(I18n.get("gui.world_map.baritone_goal_here"), options.size(), this) {
new RightClickOption("gui.world_map.baritone_goal_here", options.size(), this) {
@Override
public void onAction(Screen screen) {
BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoal(new GoalXZ(goalX, goalZ));
BaritoneExecutor.goal(goalX, goalZ);
}
},
new RightClickOption(I18n.get("gui.world_map.baritone_path_here"), options.size(), this) {
}.setNameFormatArgs(Misc.getKeyName(XaeroPlusSettingRegistry.worldMapBaritoneGoalHereKeybindSetting.getKeyBinding())),
new RightClickOption("gui.world_map.baritone_path_here", options.size(), this) {
@Override
public void onAction(Screen screen) {
BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalXZ(goalX, goalZ));
BaritoneExecutor.path(goalX, goalZ);
}
}
}.setNameFormatArgs(Misc.getKeyName(XaeroPlusSettingRegistry.worldMapBaritonePathHereKeybindSetting.getKeyBinding()))
));
if (BaritoneHelper.isBaritoneElytraPresent()) {
options.addAll(5, asList(
new RightClickOption(I18n.get("gui.world_map.baritone_elytra_here"), options.size(), this) {
new RightClickOption("gui.world_map.baritone_elytra_here", options.size(), this) {
@Override
public void onAction(Screen screen) {
BaritoneAPI.getProvider().getPrimaryBaritone().getElytraProcess().pathTo(new GoalXZ(goalX, goalZ));
BaritoneExecutor.elytra(goalX, goalZ);
}
}
}.setNameFormatArgs(Misc.getKeyName(XaeroPlusSettingRegistry.worldMapBaritoneElytraHereKeybindSetting.getKeyBinding()))
));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
package xaeroplus.mixin.client;

import baritone.api.BaritoneAPI;
import baritone.api.pathing.goals.GoalXZ;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import xaero.map.gui.IRightClickableElement;
import xaero.map.gui.dropdown.rightclick.RightClickOption;
import xaero.map.misc.Misc;
import xaero.map.mods.gui.Waypoint;
import xaero.map.mods.gui.WaypointReader;
import xaeroplus.feature.extensions.IWaypointDimension;
import xaeroplus.settings.XaeroPlusSettingRegistry;
import xaeroplus.util.BaritoneExecutor;
import xaeroplus.util.BaritoneHelper;
import xaeroplus.util.ChunkUtils;

import java.util.ArrayList;

import static java.util.Arrays.asList;
import static net.minecraft.world.level.Level.NETHER;
import static net.minecraft.world.level.Level.OVERWORLD;

@Mixin(value = WaypointReader.class, remap = false)
public class MixinWaypointReader {
Expand All @@ -33,43 +26,30 @@ public class MixinWaypointReader {
public void getRightClickOptionsReturn(final Waypoint element, final IRightClickableElement target, final CallbackInfoReturnable<ArrayList<RightClickOption>> cir) {
if (BaritoneHelper.isBaritonePresent()) {
final ArrayList<RightClickOption> options = cir.getReturnValue();
ResourceKey<Level> wpDimension = ((IWaypointDimension) element).getDimension();
if (wpDimension == null) {
wpDimension = OVERWORLD;
}
ResourceKey<Level> playerDimension = ChunkUtils.getActualDimension();
double dimDiv = 1.0;
if (wpDimension != playerDimension) {
if (wpDimension == NETHER && playerDimension == OVERWORLD) {
dimDiv = 8.0;
} else if (wpDimension == OVERWORLD && playerDimension == NETHER) {
dimDiv = 0.125;
}
}
int destX = (int) (element.getX() * dimDiv);
int destZ = (int) (element.getZ() * dimDiv);
int goalX = element.getX();
int goalZ = element.getZ();
options.addAll(3, asList(
new RightClickOption(I18n.get("gui.world_map.baritone_goal_here"), options.size(), target) {
new RightClickOption("gui.world_map.baritone_goal_here", options.size(), target) {
@Override
public void onAction(Screen screen) {
BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoal(new GoalXZ(destX, destZ));
BaritoneExecutor.goal(goalX, goalZ);
}
},
new RightClickOption(I18n.get("gui.world_map.baritone_path_here"), options.size(), target) {
}.setNameFormatArgs(Misc.getKeyName(XaeroPlusSettingRegistry.worldMapBaritoneGoalHereKeybindSetting.getKeyBinding())),
new RightClickOption("gui.world_map.baritone_path_here", options.size(), target) {
@Override
public void onAction(Screen screen) {
BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalXZ(destX, destZ));
BaritoneExecutor.path(goalX, goalZ);
}
}
}.setNameFormatArgs(Misc.getKeyName(XaeroPlusSettingRegistry.worldMapBaritonePathHereKeybindSetting.getKeyBinding()))
));
if (BaritoneHelper.isBaritoneElytraPresent()) {
options.addAll(5, asList(
new RightClickOption(I18n.get("gui.world_map.baritone_elytra_here"), options.size(), target) {
new RightClickOption("gui.world_map.baritone_elytra_here", options.size(), target) {
@Override
public void onAction(Screen screen) {
BaritoneAPI.getProvider().getPrimaryBaritone().getElytraProcess().pathTo(new GoalXZ(destX, destZ));
BaritoneExecutor.elytra(goalX, goalZ);
}
}
}.setNameFormatArgs(Misc.getKeyName(XaeroPlusSettingRegistry.worldMapBaritoneElytraHereKeybindSetting.getKeyBinding()))
));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,24 @@ public String getTranslationKey() {
(b) -> Globals.switchToDimension(END),
false,
SettingLocation.KEYBINDS);
public static final XaeroPlusBooleanSetting worldMapBaritoneGoalHereKeybindSetting = XaeroPlusBooleanSetting.create(
"WorldMap Baritone Goal Here",
"setting.keybinds.world_map_baritone_goal_here",
"setting.keybinds.world_map_baritone_goal_here.tooltip",
false,
SettingLocation.KEYBINDS);
public static final XaeroPlusBooleanSetting worldMapBaritonePathHereKeybindSetting = XaeroPlusBooleanSetting.create(
"WorldMap Baritone Path Here",
"setting.keybinds.world_map_baritone_path_here",
"setting.keybinds.world_map_baritone_path_here.tooltip",
false,
SettingLocation.KEYBINDS);
public static final XaeroPlusBooleanSetting worldMapBaritoneElytraHereKeybindSetting = XaeroPlusBooleanSetting.create(
"WorldMap Baritone Elytra Here",
"setting.keybinds.world_map_baritone_elytra_here",
"setting.keybinds.world_map_baritone_elytra_here.tooltip",
false,
SettingLocation.KEYBINDS);
public static final XaeroPlusBooleanSetting netherCaveFix = XaeroPlusBooleanSetting.create(
"Nether Cave Fix",
"setting.world_map.nether_cave_fix",
Expand Down
47 changes: 47 additions & 0 deletions common/src/main/java/xaeroplus/util/BaritoneExecutor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package xaeroplus.util;

import baritone.api.BaritoneAPI;
import baritone.api.pathing.goals.GoalXZ;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.Level;
import xaeroplus.Globals;

import static net.minecraft.world.level.Level.NETHER;
import static net.minecraft.world.level.Level.OVERWORLD;

// avoid classloading this unless baritone is actually present
// otherwise game crashes
public final class BaritoneExecutor {
private BaritoneExecutor() {}
public static GoalXZ getBaritoneGoalXZ(int x, int z) {
ResourceKey<Level> customDim = Globals.getCurrentDimensionId();
ResourceKey<Level> actualDim = ChunkUtils.getActualDimension();
double customDimDiv = 1.0;
if (customDim != actualDim) {
if (customDim == NETHER && actualDim == OVERWORLD) {
customDimDiv = 8;
} else if (customDim == OVERWORLD && actualDim == NETHER) {
customDimDiv = 0.125;
}
}
int goalX = (int) (x * customDimDiv);
int goalZ = (int) (z * customDimDiv);
return new GoalXZ(goalX, goalZ);
}

public static void goal(int x, int z) {
if (!BaritoneHelper.isBaritonePresent()) return;
BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoal(getBaritoneGoalXZ(x, z));
}

public static void path(int x, int z) {
if (!BaritoneHelper.isBaritonePresent()) return;
BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(getBaritoneGoalXZ(x, z));
}

public static void elytra(int x, int z) {
if (!BaritoneHelper.isBaritonePresent()) return;
if (!BaritoneHelper.isBaritoneElytraPresent()) return;
BaritoneAPI.getProvider().getPrimaryBaritone().getElytraProcess().pathTo(getBaritoneGoalXZ(x, z));
}
}
3 changes: 2 additions & 1 deletion common/src/main/java/xaeroplus/util/BaritoneHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import baritone.api.process.IElytraProcess;
import xaeroplus.XaeroPlus;

public class BaritoneHelper {
public final class BaritoneHelper {
private BaritoneHelper() {}
private static boolean isBaritonePresent = false;
private static boolean isBaritoneElytraPresent = false;
private static boolean checkedBaritone = false;
Expand Down
12 changes: 9 additions & 3 deletions common/src/main/resources/assets/xaeroplus/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@
"setting.keybinds.switch_to_overworld.tooltip": "Switches to the overworld map.",
"setting.keybinds.switch_to_end": "Switch to End",
"setting.keybinds.switch_to_end.tooltip": "Switches to the end map.",
"setting.keybinds.world_map_baritone_goal_here": "Baritone Goal Here (WorldMap)",
"setting.keybinds.world_map_baritone_goal_here.tooltip": "If pressed while viewing the WorldMap, sets a Baritone goal",
"setting.keybinds.world_map_baritone_path_here": "Baritone Path Here (WorldMap)",
"setting.keybinds.world_map_baritone_path_here.tooltip": "If pressed while viewing the WorldMap, sets a Baritone goal and paths to it",
"setting.keybinds.world_map_baritone_elytra_here": "Baritone Elytra Here (WorldMap)",
"setting.keybinds.world_map_baritone_elytra_here.tooltip": "If pressed while viewing the WorldMap, sets a Baritone goal and starts elytra pathing to it",
"setting.world_map.nether_cave_fix": "Nether Cave Fix",
"setting.world_map.nether_cave_fix.tooltip": "Forces full cave maps to be written and rendered when cave mode is off in the nether. \n Without this, you have to manually move region files pre WorldMap 1.30.0 to the correct cave folder.",
"setting.minimap.always_render_player_name": "Always Render Player Name",
Expand Down Expand Up @@ -170,9 +176,9 @@
"gui.xaeroplus.minimap_incompatible.download_minimap": "Download Xaero's Minimap",
"gui.xaeroplus.minimap_incompatible.exit": "Exit",
"gui.world_map.go_to_coordinates": "Go to Coordinates",
"gui.world_map.baritone_goal_here": "Baritone Goal Here",
"gui.world_map.baritone_path_here": "Baritone Path Here",
"gui.world_map.baritone_elytra_here": "Baritone Elytra Here",
"gui.world_map.baritone_goal_here": "§2%s§r Baritone Goal Here",
"gui.world_map.baritone_path_here": "§2%s§r Baritone Path Here",
"gui.world_map.baritone_elytra_here": "§2%s§r Baritone Elytra Here",
"gui.xaeroplus.check_github_button": "Go to XaeroPlus Github for updates",
"gui.waypoints.toggle_enable_all": "Toggle Enable All",
"setting.world_map.waystones_sync": "Waystones Sync",
Expand Down
12 changes: 9 additions & 3 deletions common/src/main/resources/assets/xaeroplus/lang/es_ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@
"setting.keybinds.switch_to_overworld.tooltip": "Cambia al mapa del Overworld.",
"setting.keybinds.switch_to_end": "Cambiar al End",
"setting.keybinds.switch_to_end.tooltip": "Cambia al mapa del End.",
"setting.keybinds.world_map_baritone_goal_here": "Objetivo de Baritone Aquí (MapaMundial)",
"setting.keybinds.world_map_baritone_goal_here.tooltip": "Si se presiona mientras se visualiza el MapaMundial, establece un objetivo de Baritone",
"setting.keybinds.world_map_baritone_path_here": "Ruta de Baritone Aquí (MapaMundial)",
"setting.keybinds.world_map_baritone_path_here.tooltip": "Si se presiona mientras se visualiza el MapaMundial, establece un objetivo de Baritone y traza un camino hacia él",
"setting.keybinds.world_map_baritone_elytra_here": "Elytra de Baritone Aquí (MapaMundial)",
"setting.keybinds.world_map_baritone_elytra_here.tooltip": "Si se presiona mientras se visualiza el MapaMundial, establece un objetivo de Baritone y comienza a volar con Elytra hacia él",
"setting.world_map.nether_cave_fix": "Corrección Cueva Nether",
"setting.world_map.nether_cave_fix.tooltip": "Forzar que los mapas completos de cuevas se escriban y rendericen cuando el modo cueva está desactivado en el Nether. \n Sin esto, tendrás que mover manualmente archivos de región pre WorldMap 1.30.0 a la carpeta de cuevas correcta.",
"setting.minimap.always_render_player_name": "Siempre Representar Nombre Jugador",
Expand Down Expand Up @@ -170,9 +176,9 @@
"gui.xaeroplus.minimap_incompatible.download_minimap": "Descargar Xaero's Minimap",
"gui.xaeroplus.minimap_incompatible.exit": "Salir",
"gui.world_map.go_to_coordinates": "Ir a Coordenadas",
"gui.world_map.baritone_goal_here": "Objetivo Baritone Aca",
"gui.world_map.baritone_path_here": "Camino Baritone Aca",
"gui.world_map.baritone_elytra_here": "Elytra Baritone Aca",
"gui.world_map.baritone_goal_here": "§2%s§r Objetivo Baritone Aca",
"gui.world_map.baritone_path_here": "§2%s§r Camino Baritone Aca",
"gui.world_map.baritone_elytra_here": "§2%s§r Elytra Baritone Aca",
"gui.xaeroplus.check_github_button": "Ir al Github de XaeroPlus para ver actualizaciones",
"gui.waypoints.toggle_enable_all": "Alternar Habilitar Todo",
"setting.world_map.waystones_sync": "Sincronizar Waypoint de Waystones",
Expand Down
Loading

0 comments on commit 7e2ff66

Please sign in to comment.