Skip to content

Commit

Permalink
Use less brittle mixin type for map-options tooltip injection
Browse files Browse the repository at this point in the history
  • Loading branch information
Protonull committed Nov 30, 2024
1 parent 0ad910b commit fef20d7
Showing 1 changed file with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,37 +1,30 @@
package uk.protonull.civvoxelmap.mixins.settings;

import com.llamalad7.mixinextras.sugar.Local;
import com.mamiyaotaru.voxelmap.gui.GuiMinimapOptions;
import com.mamiyaotaru.voxelmap.gui.overridden.GuiOptionButtonMinimap;
import net.minecraft.client.gui.components.Tooltip;
import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.NotNull;
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.CallbackInfo;
import org.spongepowered.asm.mixin.injection.ModifyVariable;

@Mixin(GuiMinimapOptions.class)
public abstract class GuiMinimapOptionsMixin {
// ============================================================
// Warnings
// ============================================================

@Inject(
@ModifyVariable(
method = "init",
at = @At(
value = "INVOKE",
target = "Lcom/mamiyaotaru/voxelmap/gui/GuiMinimapOptions;addRenderableWidget(Lnet/minecraft/client/gui/components/events/GuiEventListener;)Lnet/minecraft/client/gui/components/events/GuiEventListener;",
ordinal = 0,
shift = At.Shift.BEFORE
)
at = @At("STORE")
)
private void cvm$init$addTooltipWarnings(
final @NotNull CallbackInfo ci,
final @NotNull @Local GuiOptionButtonMinimap button
protected @NotNull GuiOptionButtonMinimap civvoxelmap$addTooltipWarnings(
final @NotNull GuiOptionButtonMinimap button
) {
switch (button.returnEnumOptions()) {
case CAVEMODE -> button.setTooltip(Tooltip.create(Component.translatable("civvoxelmap.feature.illegal.tooltip.off")));
}
return button;
}
}

0 comments on commit fef20d7

Please sign in to comment.