-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
common/src/main/java/xaeroplus/mixin/client/MixinGuiWaypointsOptions.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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package xaeroplus.mixin.client; | ||
|
||
import net.minecraft.client.gui.components.AbstractWidget; | ||
import net.minecraft.client.gui.components.Button; | ||
import net.minecraft.client.gui.screens.Screen; | ||
import net.minecraft.network.chat.Component; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
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.IXaeroMinimap; | ||
import xaero.common.gui.GuiWaypointsOptions; | ||
import xaero.common.gui.MyBigButton; | ||
import xaero.common.gui.ScreenBase; | ||
import xaeroplus.settings.Settings; | ||
|
||
@Mixin(value = GuiWaypointsOptions.class, remap = false) | ||
public abstract class MixinGuiWaypointsOptions extends ScreenBase { | ||
@Unique | ||
private Button showWaypointDistancesButton; | ||
|
||
protected MixinGuiWaypointsOptions(final IXaeroMinimap modMain, final Screen parent, final Screen escape, final Component titleIn) { | ||
super(modMain, parent, escape, titleIn); | ||
} | ||
|
||
@Inject( | ||
method = "init", | ||
at = @At("RETURN"), | ||
remap = true | ||
) | ||
public void injectShowWaypointDistancesButton(final CallbackInfo ci) { | ||
int prevButtonY = this.children().stream() | ||
.filter(c -> c instanceof MyBigButton) | ||
.map(c -> (MyBigButton) c) | ||
.filter(c -> c.getId() == 203) | ||
.findFirst() | ||
.map(AbstractWidget::getY) | ||
.orElse(280); | ||
addRenderableWidget( | ||
showWaypointDistancesButton = new MyBigButton( | ||
999, | ||
this.width / 2 + 3, | ||
prevButtonY + 25, | ||
Component.literal(Settings.REGISTRY.showWaypointDistances.getTranslatedName()), | ||
(b) -> { | ||
Settings.REGISTRY.showWaypointDistances.setValue(!Settings.REGISTRY.showWaypointDistances.get()); | ||
} | ||
) | ||
); | ||
} | ||
} |
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
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
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