net.minecraft.client.network.ClientPlayNetworkHandler Java Examples
The following examples show how to use
net.minecraft.client.network.ClientPlayNetworkHandler.
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: UseBedS2CPacket.java From multiconnect with MIT License | 5 votes |
@Override public void apply(ClientPlayNetworkHandler handler) { NetworkThreadUtils.forceMainThread(this, handler, MinecraftClient.getInstance()); Entity entity = MinecraftClient.getInstance().world.getEntityById(playerId); if (entity instanceof PlayerEntity) { ((PlayerEntity) entity).trySleep(bedPos); } }
Example #2
Source File: GuiOpenS2CPacket_1_13_2.java From multiconnect with MIT License | 5 votes |
@Override public void apply(ClientPlayNetworkHandler handler) { if ("minecraft:container".equals(type)) { handler.onOpenScreen(new OpenScreenS2CPacket(syncId, slotCount <= 27 ? ScreenHandlerType.GENERIC_9X3 : ScreenHandlerType.GENERIC_9X6, title)); } else if ("minecraft:villager".equals(type)) { handler.onOpenScreen(new OpenScreenS2CPacket(syncId, ScreenHandlerType.MERCHANT, title)); } else if ("EntityHorse".equals(type)) { handler.onOpenHorseScreen(new OpenHorseScreenS2CPacket(syncId, slotCount, horseId)); } else if (slotCount <= 0) { if ("minecraft:crafting_table".equals(type)) { handler.onOpenScreen(new OpenScreenS2CPacket(syncId, ScreenHandlerType.CRAFTING, title)); } else if ("minecraft:enchanting_table".equals(type)) { handler.onOpenScreen(new OpenScreenS2CPacket(syncId, ScreenHandlerType.ENCHANTMENT, title)); } else if ("minecraft:anvil".equals(type)) { handler.onOpenScreen(new OpenScreenS2CPacket(syncId, ScreenHandlerType.ANVIL, title)); } } else { if ("minecraft:chest".equals(type)) { handler.onOpenScreen(new OpenScreenS2CPacket(syncId, slotCount <= 27 ? ScreenHandlerType.GENERIC_9X3 : ScreenHandlerType.GENERIC_9X6, title)); } else if ("minecraft:hopper".equals(type)) { handler.onOpenScreen(new OpenScreenS2CPacket(syncId, ScreenHandlerType.HOPPER, title)); } else if ("minecraft:furnace".equals(type)) { handler.onOpenScreen(new OpenScreenS2CPacket(syncId, ScreenHandlerType.FURNACE, title)); } else if ("minecraft:brewing_stand".equals(type)) { handler.onOpenScreen(new OpenScreenS2CPacket(syncId, ScreenHandlerType.BREWING_STAND, title)); } else if ("minecraft:beacon".equals(type)) { handler.onOpenScreen(new OpenScreenS2CPacket(syncId, ScreenHandlerType.BEACON, title)); } else if ("minecraft:dispenser".equals(type) || "minecraft:dropper".equals(type)) { handler.onOpenScreen(new OpenScreenS2CPacket(syncId, ScreenHandlerType.GENERIC_3X3, title)); } else if ("minecraft:shulker_box".equals(type)) { handler.onOpenScreen(new OpenScreenS2CPacket(syncId, ScreenHandlerType.SHULKER_BOX, title)); } else { handler.onOpenScreen(new OpenScreenS2CPacket(syncId, slotCount <= 27 ? ScreenHandlerType.GENERIC_9X3 : ScreenHandlerType.GENERIC_9X6, title)); } } }
Example #3
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 #4
Source File: VRPlatform.java From ViaFabric with MIT License | 5 votes |
@Environment(EnvType.CLIENT) private void sendMessageClient(String s) { ClientPlayNetworkHandler handler = MinecraftClient.getInstance().getNetworkHandler(); if (handler != null) { try { handler.onGameMessage(new GameMessageS2CPacket( Text.Serializer.fromJson(ChatRewriter.legacyTextToJson(s)), MessageType.SYSTEM, Util.NIL_UUID )); } catch (OffThreadException ignored) { } } }
Example #5
Source File: VRPlatform.java From ViaFabric with MIT License | 5 votes |
@Environment(EnvType.CLIENT) private boolean kickClient(String msg) { ClientPlayNetworkHandler handler = MinecraftClient.getInstance().getNetworkHandler(); if (handler != null) { try { handler.onDisconnect(new DisconnectS2CPacket( Text.Serializer.fromJson(ChatRewriter.legacyTextToJson(msg)) )); } catch (OffThreadException ignored) { } return true; } return false; }
Example #6
Source File: FabricClientSparkPlugin.java From spark with GNU General Public License v3.0 | 4 votes |
private CommandDispatcher<CommandSource> getPlayerCommandDispatcher() { return Optional.ofNullable(this.minecraft.player) .map(player -> player.networkHandler) .map(ClientPlayNetworkHandler::getCommandDispatcher) .orElse(null); }
Example #7
Source File: MixinMinecraftClient.java From multiconnect with MIT License | votes |
@Shadow public abstract ClientPlayNetworkHandler getNetworkHandler();