-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use less brittle mixin type for map-options tooltip injection
- Loading branch information
Showing
1 changed file
with
6 additions
and
13 deletions.
There are no files selected for viewing
19 changes: 6 additions & 13 deletions
19
src/main/java/uk/protonull/civvoxelmap/mixins/settings/GuiMinimapOptionsMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |