-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Still need to investigate 1.20.5's networking system, should already work but who knows...
- Loading branch information
Showing
7 changed files
with
95 additions
and
21 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
17 changes: 4 additions & 13 deletions
17
...va/io/github/null2264/cobblegen/mixin/network/ServerConfigurationPacketListenerMixin.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 |
---|---|---|
@@ -1,27 +1,18 @@ | ||
//#if MC>=1.20.2 | ||
//$$ package io.github.null2264.cobblegen.mixin.network; | ||
//$$ | ||
//$$ import io.github.null2264.cobblegen.network.payload.CGPingS2CPayload; | ||
//$$ import io.netty.buffer.Unpooled; | ||
//$$ import net.minecraft.network.FriendlyByteBuf; | ||
//$$ import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket; | ||
|
||
//$$ import io.github.null2264.cobblegen.network.CGServerPlayNetworkHandler; | ||
//$$ import net.minecraft.server.network.ServerConfigurationPacketListenerImpl; | ||
//$$ 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; | ||
//$$ | ||
//$$ import static io.github.null2264.cobblegen.util.Constants.CG_PING; | ||
//$$ | ||
|
||
//$$ @Mixin(ServerConfigurationPacketListenerImpl.class) | ||
//$$ public abstract class ServerConfigurationPacketListenerMixin { | ||
//$$ @Inject(method = "startConfiguration", at = @At("HEAD")) | ||
//$$ private void syncCG(CallbackInfo ci) { | ||
//$$ FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer()); | ||
//$$ buf.writeResourceLocation(CG_PING.toMC()); | ||
//$$ ((ServerConfigurationPacketListenerImpl) (Object) this).send( | ||
//$$ new ClientboundCustomPayloadPacket(new CGPingS2CPayload(false)) | ||
//$$ ); | ||
//$$ CGServerPlayNetworkHandler.trySync((ServerConfigurationPacketListenerImpl) (Object) this); | ||
//$$ } | ||
//$$ } | ||
//#endif |
42 changes: 42 additions & 0 deletions
42
...o/github/null2264/cobblegen/mixin/network/packet/ClientboundCustomPayloadPacketMixin.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,42 @@ | ||
package io.github.null2264.cobblegen.mixin.network.packet; | ||
|
||
//#if MC<1.20.2 | ||
import net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket; | ||
//#else | ||
//#if MC<1.20.5 | ||
//$$ import io.github.null2264.cobblegen.data.CGIdentifier; | ||
//$$ import io.github.null2264.cobblegen.network.payload.CGPacketPayload; | ||
//$$ import io.github.null2264.cobblegen.network.payload.CGPayloadReader; | ||
//$$ import io.netty.buffer.Unpooled; | ||
//$$ import net.minecraft.network.FriendlyByteBuf; | ||
//$$ import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket; | ||
//$$ import net.minecraft.network.protocol.common.custom.CustomPacketPayload; | ||
//$$ import net.minecraft.resources.ResourceLocation; | ||
//$$ import org.spongepowered.asm.mixin.injection.At; | ||
//$$ import org.spongepowered.asm.mixin.injection.Inject; | ||
//$$ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
//$$ | ||
//$$ import static io.github.null2264.cobblegen.util.Constants.KNOWN_CLIENT_PAYLOADS; | ||
//$$ import static io.github.null2264.cobblegen.CobbleGen.MOD_ID; | ||
//#endif | ||
//#endif | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
|
||
@Mixin(value = ClientboundCustomPayloadPacket.class, priority = 999) | ||
public abstract class ClientboundCustomPayloadPacketMixin { | ||
//#if MC>=1.20.2 | ||
//#if MC<1.20.5 | ||
//$$ @Inject(method = "readPayload", at = @At("HEAD"), cancellable = true) | ||
//$$ private static void read(ResourceLocation id, FriendlyByteBuf buf, CallbackInfoReturnable<CustomPacketPayload> cir) { | ||
//$$ if (!id.getNamespace().equals(MOD_ID)) | ||
//$$ return; | ||
//$$ | ||
//$$ CGPayloadReader<? extends CGPacketPayload> reader = KNOWN_CLIENT_PAYLOADS.get(CGIdentifier.fromMC(id)); | ||
//$$ if (reader == null) return; | ||
//$$ | ||
//$$ cir.setReturnValue(reader.apply(buf)); | ||
//$$ } | ||
//#endif | ||
//#endif | ||
} |
41 changes: 41 additions & 0 deletions
41
...o/github/null2264/cobblegen/mixin/network/packet/ServerboundCustomPayloadPacketMixin.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,41 @@ | ||
package io.github.null2264.cobblegen.mixin.network.packet; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
//#if MC<1.20.2 | ||
import net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket; | ||
//#else | ||
//#if MC<1.20.5 | ||
//$$ import io.github.null2264.cobblegen.data.CGIdentifier; | ||
//$$ import io.github.null2264.cobblegen.network.payload.CGPacketPayload; | ||
//$$ import io.github.null2264.cobblegen.network.payload.CGPayloadReader; | ||
//$$ import io.netty.buffer.Unpooled; | ||
//$$ import net.minecraft.network.FriendlyByteBuf; | ||
//$$ import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket; | ||
//$$ import net.minecraft.network.protocol.common.custom.CustomPacketPayload; | ||
//$$ import net.minecraft.resources.ResourceLocation; | ||
//$$ import org.spongepowered.asm.mixin.injection.At; | ||
//$$ import org.spongepowered.asm.mixin.injection.Inject; | ||
//$$ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
//$$ | ||
//$$ import static io.github.null2264.cobblegen.util.Constants.KNOWN_SERVER_PAYLOADS; | ||
//$$ import static io.github.null2264.cobblegen.CobbleGen.MOD_ID; | ||
//#endif | ||
//#endif | ||
|
||
@Mixin(value = ServerboundCustomPayloadPacket.class, priority = 999) | ||
public abstract class ServerboundCustomPayloadPacketMixin { | ||
//#if MC>=1.20.2 | ||
//#if MC<1.20.5 | ||
//$$ @Inject(method = "readPayload", at = @At("HEAD"), cancellable = true) | ||
//$$ private static void read(ResourceLocation id, FriendlyByteBuf buf, CallbackInfoReturnable<CustomPacketPayload> cir) { | ||
//$$ if (!id.getNamespace().equals(MOD_ID)) | ||
//$$ return; | ||
//$$ | ||
//$$ CGPayloadReader<? extends CGPacketPayload> reader = KNOWN_SERVER_PAYLOADS.get(CGIdentifier.fromMC(id)); | ||
//$$ if (reader == null) return; | ||
//$$ | ||
//$$ cir.setReturnValue(reader.apply(buf)); | ||
//$$ } | ||
//#endif | ||
//#endif | ||
} |
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
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
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