-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The first turns the title screen splash texts green. The second cycles a new random splash text every 20 seconds. The third adds a button to the main menu which connects you to 2b2t. These are disabled by default, and can be changed in your Meteor config settings.
- Loading branch information
Showing
4 changed files
with
147 additions
and
10 deletions.
There are no files selected for viewing
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
31 changes: 31 additions & 0 deletions
31
src/main/java/dev/stardust/mixin/SplashTextRendererMixin.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,31 @@ | ||
package dev.stardust.mixin; | ||
|
||
import dev.stardust.Stardust; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import net.minecraft.client.gui.DrawContext; | ||
import net.minecraft.client.font.TextRenderer; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.ModifyArg; | ||
import net.minecraft.client.gui.screen.SplashTextRenderer; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
|
||
/** | ||
* @author Tas [0xTas] <[email protected]> | ||
**/ | ||
@Mixin(SplashTextRenderer.class) | ||
public class SplashTextRendererMixin { | ||
@Unique private int trackAlpha = 0; | ||
|
||
@Inject(method = "render", at = @At("HEAD")) | ||
private void mixinRender(DrawContext context, int width, TextRenderer textRenderer, int alpha, CallbackInfo ci) { | ||
this.trackAlpha = alpha; | ||
} | ||
|
||
@ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawCenteredTextWithShadow(Lnet/minecraft/client/font/TextRenderer;Ljava/lang/String;III)V"), index = 4) | ||
private int modifyRenderArg(int color) { | ||
return Stardust.greenSplashTextSetting.get() ? 0x54FB54 | this.trackAlpha : color; | ||
} | ||
} |
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,74 @@ | ||
package dev.stardust.mixin; | ||
|
||
import dev.stardust.Stardust; | ||
import net.minecraft.text.Text; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import net.minecraft.client.network.ServerInfo; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import net.minecraft.client.network.ServerAddress; | ||
import net.minecraft.client.gui.screen.TitleScreen; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import net.minecraft.client.gui.widget.ButtonWidget; | ||
import net.minecraft.client.gui.screen.ConnectScreen; | ||
import net.minecraft.client.gui.screen.SplashTextRenderer; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
|
||
/** | ||
* @author Tas [0xTas] <[email protected]> | ||
**/ | ||
@Mixin(TitleScreen.class) | ||
public abstract class TitleScreenMixin extends Screen { | ||
@Unique | ||
private static final ServerInfo OLD_SERVER = new ServerInfo("2builders2tools", "2b2t.org", false); | ||
|
||
@Shadow | ||
private @Nullable SplashTextRenderer splashText; | ||
|
||
protected TitleScreenMixin(Text title) { | ||
super(title); | ||
} | ||
|
||
@Unique | ||
private int timer = 0; | ||
@Unique | ||
private @Nullable MinecraftClient mc = null; | ||
|
||
@Unique | ||
private void onClick2b2tButton(ButtonWidget btn) { | ||
if (mc == null) mc = MinecraftClient.getInstance(); | ||
ConnectScreen.connect(mc.currentScreen, mc, | ||
ServerAddress.parse(OLD_SERVER.address), OLD_SERVER, true | ||
); | ||
} | ||
|
||
@Inject(method = "init", at = @At("TAIL")) | ||
private void mixinInit(CallbackInfo ci) { | ||
if (Stardust.directConnectButtonSetting.get()) { | ||
this.addDrawableChild(ButtonWidget.builder( | ||
Text.of("§c§l2§a§lB"), this::onClick2b2tButton) | ||
.dimensions(this.width / 2 + 104, (this.height / 4 + 48) + 72, 20, 20) | ||
.build() | ||
); | ||
} | ||
} | ||
|
||
@Inject(method = "tick", at = @At("HEAD")) | ||
private void mixinTick(CallbackInfo ci) { | ||
if (mc == null) { | ||
mc = MinecraftClient.getInstance(); | ||
return; | ||
} | ||
|
||
++timer; | ||
if (timer >= 420 && Stardust.rotateSplashTextSetting.get()) { | ||
timer = 0; | ||
splashText = mc.getSplashTextLoader().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