net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket Java Examples
The following examples show how to use
net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomPayloadHandler.java From multiconnect with MIT License | 5 votes |
public static void handleCustomPayload(CustomPayloadS2CPacket packet) { String str; synchronized (stringCustomPayloadChannels) { str = stringCustomPayloadChannels.remove(packet.getChannel()); } if (str != null) { handleStringCustomPayload(str, packet.getData()); } else { handleIdentifierCustomPayload(packet); } }
Example #2
Source File: MixinClientPlayNetworkHandler.java From multiconnect with MIT License | 5 votes |
@Inject(method = "onCustomPayload", at = @At("HEAD"), cancellable = true) private void onOnCustomPayload(CustomPayloadS2CPacket packet, CallbackInfo ci) { NetworkThreadUtils.forceMainThread(packet, (ClientPlayNetworkHandler) (Object) this, MinecraftClient.getInstance()); if (packet.getChannel().equals(CustomPayloadHandler.DROP_ID)) { ci.cancel(); } else if (ConnectionInfo.protocolVersion != SharedConstants.getGameVersion().getProtocolVersion() && !CustomPayloadHandler.VANILLA_CHANNELS.contains(packet.getChannel())) { CustomPayloadHandler.handleCustomPayload(packet); ci.cancel(); } }
Example #3
Source File: ServerNetworkHandler.java From fabric-carpet with MIT License | 5 votes |
public static void onPlayerJoin(ServerPlayerEntity playerEntity) { if (!playerEntity.networkHandler.connection.isLocal()) { playerEntity.networkHandler.sendPacket(new CustomPayloadS2CPacket( CarpetClient.CARPET_CHANNEL, (new PacketByteBuf(Unpooled.buffer())).writeVarInt(CarpetClient.HI).writeString(CarpetSettings.carpetVersion) )); } else { validCarpetPlayers.add(playerEntity); } }
Example #4
Source File: ServerNetworkHandler.java From fabric-carpet with MIT License | 5 votes |
public static void onHello(ServerPlayerEntity playerEntity, PacketByteBuf packetData) { validCarpetPlayers.add(playerEntity); String clientVersion = packetData.readString(64); remoteCarpetPlayers.put(playerEntity, clientVersion); if (clientVersion.equals(CarpetSettings.carpetVersion)) CarpetSettings.LOG.info("Player "+playerEntity.getName().getString()+" joined with a matching carpet client"); else CarpetSettings.LOG.warn("Player "+playerEntity.getName().getString()+" joined with another carpet version: "+clientVersion); DataBuilder data = DataBuilder.create().withTickRate(); CarpetServer.settingsManager.getRules().forEach(data::withRule); playerEntity.networkHandler.sendPacket(new CustomPayloadS2CPacket(CarpetClient.CARPET_CHANNEL, data.build() )); }
Example #5
Source File: ServerNetworkHandler.java From fabric-carpet with MIT License | 5 votes |
public static void updateRuleWithConnectedClients(ParsedRule<?> rule) { if (CarpetSettings.superSecretSetting) return; for (ServerPlayerEntity player : remoteCarpetPlayers.keySet()) { player.networkHandler.sendPacket(new CustomPayloadS2CPacket( CarpetClient.CARPET_CHANNEL, DataBuilder.create().withRule(rule).build() )); } }
Example #6
Source File: ServerNetworkHandler.java From fabric-carpet with MIT License | 5 votes |
public static void updateTickSpeedToConnectedPlayers() { if (CarpetSettings.superSecretSetting) return; for (ServerPlayerEntity player : remoteCarpetPlayers.keySet()) { player.networkHandler.sendPacket(new CustomPayloadS2CPacket( CarpetClient.CARPET_CHANNEL, DataBuilder.create().withTickRate().build() )); } }
Example #7
Source File: ServerNetworkHandler.java From fabric-carpet with MIT License | 5 votes |
public static void broadcastCustomCommand(String command, Tag data) { if (CarpetSettings.superSecretSetting) return; for (ServerPlayerEntity player : validCarpetPlayers) { player.networkHandler.sendPacket(new CustomPayloadS2CPacket( CarpetClient.CARPET_CHANNEL, DataBuilder.create().withCustomNbt(command, data).build() )); } }
Example #8
Source File: ServerNetworkHandler.java From fabric-carpet with MIT License | 5 votes |
public static void sendCustomCommand(ServerPlayerEntity player, String command, Tag data) { if (isValidCarpetPlayer(player)) { player.networkHandler.sendPacket(new CustomPayloadS2CPacket( CarpetClient.CARPET_CHANNEL, DataBuilder.create().withCustomNbt(command, data).build() )); } }
Example #9
Source File: ClientPlayNetworkHandlerMixin.java From fabric-carpet with MIT License | 5 votes |
@Inject(method = "onCustomPayload", at = @At("HEAD"), cancellable = true) private void onOnCustomPayload(CustomPayloadS2CPacket packet, CallbackInfo ci) { if (CarpetClient.CARPET_CHANNEL.equals(packet.getChannel())) { ClientNetworkHandler.handleData(packet.getData(), client.player); ci.cancel(); } }
Example #10
Source File: CustomPayloadHandler.java From multiconnect with MIT License | 4 votes |
private static void handleIdentifierCustomPayload(CustomPayloadS2CPacket packet) { identifierCustomPayloadListeners.forEach(listener -> listener.onCustomPayload(ConnectionInfo.protocolVersion, packet.getChannel(), packet.getData())); }
Example #11
Source File: MixinClientPlayNetworkHandler.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
@Inject(method = "onCustomPayload", at = @At("HEAD"), cancellable = true) private void patchwork$hookCustomPayload(CustomPayloadS2CPacket packet, CallbackInfo callback) { if (NetworkHooks.onCustomPayload((ICustomPacket<?>) packet, getConnection())) { callback.cancel(); } }
Example #12
Source File: MixinCustomPayloadS2CPacket.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
@Override public CustomPayloadS2CPacket getThis() { return (CustomPayloadS2CPacket) (Object) this; }
Example #13
Source File: CustomPayloadS2CPacketAccessor.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
@SuppressWarnings("PublicStaticMixinMember") @Invoker("<init>") static CustomPayloadS2CPacket patchwork$create() { throw new AssertionError("Mixin not applied"); }