blob: 9ae5bf92d7f26589d30ffc5ff747e87f158a118b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
package me.xmrvizzy.skyblocker.mixin;
import me.xmrvizzy.skyblocker.config.SkyblockerConfig;
import me.xmrvizzy.skyblocker.skyblock.quicknav.QuickNav;
import me.xmrvizzy.skyblocker.skyblock.quicknav.QuickNavButton;
import me.xmrvizzy.skyblocker.utils.Utils;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.List;
@Mixin(HandledScreen.class)
public abstract class HandledScreenMixin extends Screen {
@Shadow protected int backgroundWidth;
@Shadow protected int backgroundHeight;
protected HandledScreenMixin(Text title) {
super(title);
}
@Inject(method = "init()V", at = @At("TAIL"))
private void init(CallbackInfo ci) {
// quicknav
if (Utils.isSkyblock && SkyblockerConfig.get().general.quicknav.enableQuicknav) {
String title = super.getTitle().getString().trim();
int left_x = (super.width - this.backgroundWidth) / 2 + 4;
int right_x = (super.width + this.backgroundWidth) / 2 - 3;
int top_y = (super.height - this.backgroundHeight) / 2 - 28;
int bottom_y = (super.height + this.backgroundHeight) / 2 - 4;
if (this.backgroundHeight > 166) --bottom_y; // why is this even a thing
List<QuickNavButton> buttons = QuickNav.init(title, left_x, right_x, top_y, bottom_y);
for (QuickNavButton button : buttons) super.addDrawableChild(button);
}
}
}
|