Cleanup mixins

This commit is contained in:
FlorianMichael 2024-06-09 16:39:06 +02:00
parent 088290e352
commit a199f553af
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
5 changed files with 14 additions and 13 deletions

View File

@ -131,4 +131,5 @@ public class ViaFabricPlusProtocol extends AbstractSimpleProtocol {
void read(PacketWrapper wrapper);
}
}

View File

@ -97,7 +97,7 @@ public abstract class MixinClientConnection extends SimpleChannelInboundHandler<
// Minecraft 1.6.4 supports split encryption/decryption which means the server can only enable one side of the encryption
// So we only enable the encryption side and later enable the decryption side if the 1.7 -> 1.6 protocol
// tells us to do, therefore we need to store the cipher instance.
// tells us to do, therefore, we need to store the cipher instance.
this.viaFabricPlus$decryptionCipher = decryptionCipher;
// Enabling the encryption side

View File

@ -26,7 +26,7 @@ import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(GameOptions.class)
public class MixinGameOptions {
public abstract class MixinGameOptions {
@Shadow
public boolean useNativeTransport;

View File

@ -29,7 +29,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ClientConnection.class)
public class MixinClientConnection {
public abstract class MixinClientConnection {
@Inject(method = "exceptionCaught", at = @At("HEAD"))
private void printNetworkingErrors(ChannelHandlerContext context, Throwable ex, CallbackInfo ci) {

View File

@ -71,6 +71,16 @@ public abstract class MixinClientCommonNetworkHandler {
return null;
}
@Inject(method = "onResourcePackSend", at = @At("HEAD"), cancellable = true)
private void validateUrlInNetworkThread(ResourcePackSendS2CPacket packet, CallbackInfo ci) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20_2)) {
if (getParsedResourcePackUrl(packet.url()) == null) {
this.connection.send(new ResourcePackStatusC2SPacket(packet.id(), ResourcePackStatusC2SPacket.Status.INVALID_URL));
ci.cancel();
}
}
}
@Redirect(method = "onKeepAlive", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientCommonNetworkHandler;send(Lnet/minecraft/network/packet/Packet;Ljava/util/function/BooleanSupplier;Ljava/time/Duration;)V"))
private void forceSendKeepAlive(ClientCommonNetworkHandler instance, Packet<? extends ServerPacketListener> packet, BooleanSupplier sendCondition, Duration expiry) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19_3)) {
@ -108,14 +118,4 @@ public abstract class MixinClientCommonNetworkHandler {
}
}
@Inject(method = "onResourcePackSend", at = @At("HEAD"), cancellable = true)
private void validateUrlInNetworkThread(ResourcePackSendS2CPacket packet, CallbackInfo ci) {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20_2)) {
if (getParsedResourcePackUrl(packet.url()) == null) {
this.connection.send(new ResourcePackStatusC2SPacket(packet.id(), ResourcePackStatusC2SPacket.Status.INVALID_URL));
ci.cancel();
}
}
}
}