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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
package ganarchy.friendcode.mixin;
import ganarchy.friendcode.client.FriendCodeScreen;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.screen.OpenToLanScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(OpenToLanScreen.class)
public abstract class OpenToLanScreenMixin extends Screen {
protected OpenToLanScreenMixin(Text title) {
super(title);
}
@Shadow
private Screen parent;
@Inject(at = @At("HEAD"), method = "init()V")
private void init(CallbackInfo info) {
// title, meet button
this.addDrawableChild(new ButtonWidget(
this.width / 2 - 155,
50,
310,
20,
this.title,
button -> this.client.setScreen(new FriendCodeScreen(this.parent))
));
}
@Redirect(
method = "render(Lnet/minecraft/client/util/math/MatrixStack;IIF)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/gui/screen/OpenToLanScreen;drawCenteredText(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/Text;III)V",
ordinal = 0
)
)
private void removeTitle(
MatrixStack matrices,
TextRenderer renderer,
Text text,
int centerX,
int y,
int color
) {
// literally does nothing
}
}
|