Modernize and 1.19.4ify
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package moe.nea.notenoughupdates.mixins;
|
||||
|
||||
import moe.nea.notenoughupdates.events.WorldReadyEvent;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.network.packet.s2c.play.PlayerSpawnPositionS2CPacket;
|
||||
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;
|
||||
|
||||
@Mixin(ClientPlayNetworkHandler.class)
|
||||
public class MixinClientPlayNetworkHandler {
|
||||
@Inject(method = "onPlayerSpawnPosition", at = @At("RETURN"))
|
||||
public void onOnPlayerSpawnPosition(PlayerSpawnPositionS2CPacket packet, CallbackInfo ci) {
|
||||
WorldReadyEvent.Companion.publish(new WorldReadyEvent());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package moe.nea.notenoughupdates.mixins;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import moe.nea.notenoughupdates.events.ServerChatLineReceivedEvent;
|
||||
import net.minecraft.client.network.message.MessageHandler;
|
||||
import net.minecraft.network.message.MessageType;
|
||||
import net.minecraft.network.message.SignedMessage;
|
||||
import net.minecraft.text.Text;
|
||||
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;
|
||||
|
||||
@Mixin(MessageHandler.class)
|
||||
public class MixinMessageHandler {
|
||||
@Inject(method = "onChatMessage", cancellable = true, at = @At("HEAD"))
|
||||
public void onOnChatMessage(SignedMessage message, GameProfile sender, MessageType.Parameters params, CallbackInfo ci) {
|
||||
var decoratedText = params.applyChatDecoration(message.unsignedContent() != null ? message.unsignedContent() : message.getContent());
|
||||
var event = new ServerChatLineReceivedEvent(decoratedText);
|
||||
if (ServerChatLineReceivedEvent.Companion.publish(event).getCancelled()) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "onGameMessage", at = @At("HEAD"), cancellable = true)
|
||||
public void onOnGameMessage(Text message, boolean overlay, CallbackInfo ci) {
|
||||
if (!overlay) {
|
||||
var event = new ServerChatLineReceivedEvent(message);
|
||||
if (ServerChatLineReceivedEvent.Companion.publish(event).getCancelled()) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package moe.nea.notenoughupdates.mixins;
|
||||
|
||||
import moe.nea.notenoughupdates.events.ScreenOpenEvent;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
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;
|
||||
|
||||
@Mixin(MinecraftClient.class)
|
||||
public abstract class MixinMinecraft {
|
||||
@Shadow
|
||||
@Nullable
|
||||
public Screen currentScreen;
|
||||
|
||||
@Inject(method = "setScreen", at = @At("HEAD"), cancellable = true)
|
||||
public void onScreenChange(Screen screen, CallbackInfo ci) {
|
||||
var event = new ScreenOpenEvent(currentScreen, screen);
|
||||
if (ScreenOpenEvent.Companion.publish(event).getCancelled()) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package moe.nea.notenoughupdates.mixins;
|
||||
|
||||
import moe.nea.notenoughupdates.events.WorldRenderLastEvent;
|
||||
import net.minecraft.client.render.Camera;
|
||||
import net.minecraft.client.render.GameRenderer;
|
||||
import net.minecraft.client.render.LightmapTextureManager;
|
||||
import net.minecraft.client.render.WorldRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import org.joml.Matrix4f;
|
||||
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;
|
||||
|
||||
@Mixin(WorldRenderer.class)
|
||||
public class MixinWorldRenderer {
|
||||
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;renderChunkDebugInfo(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/render/Camera;)V", shift = At.Shift.AFTER))
|
||||
public void onWorldRenderLast(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f positionMatrix, CallbackInfo ci) {
|
||||
var event = new WorldRenderLastEvent(
|
||||
matrices, tickDelta, renderBlockOutline,
|
||||
camera, gameRenderer, lightmapTextureManager,
|
||||
positionMatrix
|
||||
);
|
||||
WorldRenderLastEvent.Companion.publish(event);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user