Skip to content

Commit

Permalink
Compat ommc 0.5.323+
Browse files Browse the repository at this point in the history
  • Loading branch information
Hendrix-Shen committed Oct 28, 2023
1 parent e3b3a53 commit 85478ec
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 32 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ mod_version=0.2
magiclib_dependency=0.7.387
magiclib_version=0.7.387
# Oh My Minecraft Client
ommc_dependency=0.5.319
ommc_version=nyan-work~dev.43
ommc_dependency=0.5.323
ommc_version=nyan-work~dev.45

# Annotation processor
lombok_version=1.18.30
10 changes: 6 additions & 4 deletions src/main/java/com/plusls/xma/ButtonUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import net.minecraft.client.gui.screens.ConfirmScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.core.BlockPos;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import xaero.common.AXaeroMinimap;
import xaero.common.minimap.waypoints.Waypoint;
import xaero.common.minimap.waypoints.WaypointWorld;
Expand Down Expand Up @@ -43,12 +45,12 @@ public static Button.OnPress getDirectDeleteButtonOnPress(
}, ModInfo.translatable("gui.title.direct_delete"), ModInfo.translatable("gui.message.direct_delete")));
}

public static Button.OnPress getHighlightButtonOnPress(Supplier<ArrayList<Waypoint>> getSelectedWaypointsList) {
@Contract(pure = true)
public static Button.@NotNull OnPress getHighlightButtonOnPress(Supplier<ArrayList<Waypoint>> getSelectedWaypointsList) {
return buttonWidget -> {
if (getSelectedWaypointsList.get().size() >= 1) {
if (!getSelectedWaypointsList.get().isEmpty()) {
Waypoint w = getSelectedWaypointsList.get().get(0);
HighlightWaypointUtil.highlightPos = new BlockPos(w.getX(), w.getY(), w.getZ());
HighlightWaypointUtil.lastBeamTime = System.currentTimeMillis() + 10000L;
HighlightWaypointUtil.setHighlightPos(new BlockPos(w.getX(), w.getY(), w.getZ()), true);
}
};
}
Expand Down
30 changes: 20 additions & 10 deletions src/main/java/com/plusls/xma/mixin/MixinGuiMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Player;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
Expand Down Expand Up @@ -72,10 +73,9 @@ private void addHighlightOption(CallbackInfoReturnable<ArrayList<RightClickOptio
options.add(new RightClickOption(ModInfo.getModIdentifier() + ".gui.xaero_right_click_map_highlight_location",
options.size(), this) {
public void onAction(Screen screen) {
HighlightWaypointUtil.highlightPos = new BlockPos(MixinGuiMap.this.rightClickX,
HighlightWaypointUtil.setHighlightPos(new BlockPos(MixinGuiMap.this.rightClickX,
MixinGuiMap.this.rightClickY == 32767 ? playerY : MixinGuiMap.this.rightClickY + 1,
MixinGuiMap.this.rightClickZ);
HighlightWaypointUtil.lastBeamTime = System.currentTimeMillis() + 10000L;
MixinGuiMap.this.rightClickZ), true);
}
});
}
Expand All @@ -88,26 +88,36 @@ private void renderHighlightWaypoint(
//$$ PoseStack matrixStack,
//#endif
int scaledMouseX, int scaledMouseY, float partialTicks, CallbackInfo ci) {
if (!Configs.worldMapHighlightWaypoint || HighlightWaypointUtil.highlightPos == null) {
if (!Configs.worldMapHighlightWaypoint) {
return;
}

Minecraft mc = Minecraft.getInstance();
Player player = mc.player;

if (player == null) {
return;
}

BlockPos pos = HighlightWaypointUtil.getHighlightPos(player);

if (pos == null) {
return;
}
//#if MC <= 11502

//#if MC < 11600
//$$ PoseStack matrixStack = new PoseStack();
//#endif
//#if MC > 11904
PoseStack matrixStack = guiGraphics.pose();
//#endif

Minecraft mc = Minecraft.getInstance();

matrixStack.pushPose();

matrixStack.scale((float) (1.0 / this.screenScale), (float) (1.0 / this.screenScale), 1.0F);
matrixStack.translate((double) mc.getWindow().getWidth() / 2, (double) mc.getWindow().getHeight() / 2, 0.0);
matrixStack.scale((float) this.scale, (float) this.scale, 1.0F);

matrixStack.translate(HighlightWaypointUtil.highlightPos.getX() - this.cameraX,
HighlightWaypointUtil.highlightPos.getZ() - this.cameraZ, 0);
matrixStack.translate(pos.getX() - this.cameraX, pos.getZ() - this.cameraZ, 0);

double minGuiScale = 4.0D;
float guiBasedScale = 1.0F;
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/com/plusls/xma/mixin/MixinGuiWaypoints_List.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import com.plusls.ommc.feature.highlithtWaypoint.HighlightWaypointUtil;
import com.plusls.xma.RenderWaypointUtil;
import com.plusls.xma.config.Configs;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Player;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -31,6 +33,13 @@ private void drawHighlightWaypoint(
if (!Configs.minimapHighlightWaypoint || w == null) {
return;
}

Player player = Minecraft.getInstance().player;

if (player == null) {
return;
}

//#if MC <= 11502
//$$ PoseStack matrixStack = new PoseStack();
//#endif
Expand All @@ -39,7 +48,7 @@ private void drawHighlightWaypoint(
//#endif

BlockPos pos = new BlockPos(w.getX(), w.getY(), w.getZ());
if (pos.equals(HighlightWaypointUtil.highlightPos)) {
if (pos.equals(HighlightWaypointUtil.getHighlightPos(player))) {
matrixStack.pushPose();
matrixStack.translate(x + 200, y + 7, 1.0D);
RenderWaypointUtil.drawHighlightWaypointPTC(matrixStack.last().pose());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.plusls.xma.mixin;

import com.plusls.xma.config.Configs;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos;
import org.spongepowered.asm.mixin.Mixin;

//#if MC > 11502
Expand Down Expand Up @@ -50,16 +52,29 @@ private void postRender(
MultiBufferSource.BufferSource renderTypeBuffers, Font font,
MultiTextureRenderTypeRendererProvider multiTextureRenderTypeRenderers, int specW, int specH,
int halfViewW, int halfViewH, boolean circle, float minimapScale, CallbackInfo ci) {
if (!Configs.minimapHighlightWaypoint || HighlightWaypointUtil.highlightPos == null) {
if (!Configs.minimapHighlightWaypoint) {
return;
}

Player pLayer = Minecraft.getInstance().player;

if (player == null) {
return;
}

BlockPos pos = HighlightWaypointUtil.getHighlightPos(player);

if (pos == null) {
return;
}

//#if MC > 11904
PoseStack matrixStack = guiGraphics.pose();
//#endif
matrixStack.pushPose();
matrixStack.translate(0.0D, 0.0D, -980.0D);
double offx = (double) HighlightWaypointUtil.highlightPos.getX() + 0.5D - renderX;
double offz = (double) HighlightWaypointUtil.highlightPos.getZ() + 0.5D - renderZ;
double offx = (double) pos.getX() + 0.5D - renderX;
double offz = (double) pos.getZ() + 0.5D - renderZ;

matrixStack.translate(0.0D, 0.0D, 0.1D);
RenderWaypointUtil.translatePositionCompat(matrixStack, specW, specH, ps, pc, offx, offz, zoom, circle);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/plusls/xma/mixin/MixinWaypoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import top.hendrixshen.magiclib.dependency.api.annotation.Dependency;
import xaero.map.mods.gui.Waypoint;

//#if MC <= 11502
//#if MC < 11600
//$$ import com.plusls.ommc.feature.highlithtWaypoint.HighlightWaypointUtil;
//$$ import com.plusls.xma.config.Configs;
//$$ import net.minecraft.client.gui.screens.Screen;
Expand Down Expand Up @@ -36,10 +36,10 @@ public abstract class MixinWaypoint {
//$$ if (!Configs.worldMapHighlightWaypoint) {
//$$ return;
//$$ }
//$$
//$$ rightClickOptions.add(new RightClickOption("xaero_map_addition.gui.xaero_right_click_map_highlight_waypoint", rightClickOptions.size(), (IRightClickableElement) this) {
//$$ public void onAction(Screen screen) {
//$$ HighlightWaypointUtil.highlightPos = new BlockPos(x, y, z);
//$$ HighlightWaypointUtil.lastBeamTime = System.currentTimeMillis() + 10000L;
//$$ HighlightWaypointUtil.setHighlightPos(new BlockPos(x, y, z), true);
//$$ }
//$$ });
//$$ }
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/com/plusls/xma/mixin/MixinWaypointReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ private void addHighlightOption(Waypoint element, IRightClickableElement target,
options.add(new RightClickOption(ModInfo.getModIdentifier() + ".gui.xaero_right_click_map_highlight_waypoint",
options.size(), target) {
public void onAction(Screen screen) {
HighlightWaypointUtil.highlightPos = new BlockPos(element.getX(),
element.getY() == 32767 ? playerY : element.getY() + 1,
element.getZ());
HighlightWaypointUtil.lastBeamTime = System.currentTimeMillis() + 10000L;
HighlightWaypointUtil.setHighlightPos(new BlockPos(element.getX(),
element.getY() == 32767 ? playerY : element.getY() + 1, element.getZ()), true);
}
});
}
Expand Down
27 changes: 22 additions & 5 deletions src/main/java/com/plusls/xma/mixin/MixinWaypointsGuiRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@
import top.hendrixshen.magiclib.dependency.api.annotation.Dependency;
import xaero.common.minimap.waypoints.render.WaypointsGuiRenderer;

//#if MC <= 11502
//#if MC < 11600
//$$ import com.mojang.blaze3d.vertex.PoseStack;
//$$ import com.plusls.ommc.feature.highlithtWaypoint.HighlightWaypointUtil;
//$$ import com.plusls.xma.RenderWaypointUtil;
//$$ import com.plusls.xma.config.Configs;
//$$ import net.minecraft.client.Minecraft;
//$$ import net.minecraft.client.renderer.MultiBufferSource;
//$$ import net.minecraft.core.BlockPos;
//$$ import net.minecraft.world.entity.player.Player;
//$$ import org.spongepowered.asm.mixin.injection.At;
//$$ import org.spongepowered.asm.mixin.injection.Inject;
//$$ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
//$$ import xaero.common.XaeroMinimapSession;
//$$ import xaero.common.minimap.render.MinimapRendererHelper;
//#endif

@Dependencies(or = {@Dependency("xaerominimap"), @Dependency("xaerobetterpvp")})
@Mixin(value = WaypointsGuiRenderer.class, remap = false)
public abstract class MixinWaypointsGuiRenderer {
Expand All @@ -28,14 +32,27 @@ public abstract class MixinWaypointsGuiRenderer {
//$$ MultiBufferSource.BufferSource textRenderTypeBuffer,
//$$ boolean safeMode,
//$$ CallbackInfo ci) {
//$$ if (!Configs.minimapHighlightWaypoint || HighlightWaypointUtil.highlightPos == null) {
//$$ if (!Configs.minimapHighlightWaypoint) {
//$$ return;
//$$ }
//$$
//$$ Player player = Minecraft.getInstance().player;
//$$
//$$ if (player == null) {
//$$ return;
//$$ }
//$$
//$$ BlockPos pos = HighlightWaypointUtil.getHighlightPos(player);
//$$
//$$ if (pos == null) {
//$$ return;
//$$ }
//$$ PoseStack matrixStack = new PoseStack();
//$$
//$$ PoseStack matrixStack = new PoseStack();
//$$ matrixStack.pushPose();
//$$ matrixStack.translate(0.0D, 0.0D, -980.0D);
//$$ double offx = (double) HighlightWaypointUtil.highlightPos.getX() + 0.5D - playerX;
//$$ double offz = (double) HighlightWaypointUtil.highlightPos.getZ() + 0.5D - playerZ;
//$$ double offx = pos.getX() + 0.5D - playerX;
//$$ double offz = pos.getZ() + 0.5D - playerZ;
//$$ matrixStack.translate(0.0D, 0.0D, 0.1D);
//$$ RenderWaypointUtil.translatePositionCompat(matrixStack, specW, specH, ps, pc, offx, offz, zoom, circle);
//$$ matrixStack.scale(minimapScale * 0.5f, minimapScale * 0.5f, 1.0F);
Expand Down

0 comments on commit 85478ec

Please sign in to comment.