Java Code Examples for net.minecraft.network.PacketByteBuf#readVarInt()
The following examples show how to use
net.minecraft.network.PacketByteBuf#readVarInt() .
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: ShapedCompressingRecipeSerializer.java From Galacticraft-Rewoven with MIT License | 5 votes |
@Override public T read(Identifier identifier_1, PacketByteBuf packet) { int int_1 = packet.readVarInt(); int int_2 = packet.readVarInt(); String group = packet.readString(32767); DefaultedList<Ingredient> defaultedList_1 = DefaultedList.ofSize(int_1 * int_2, Ingredient.EMPTY); for (int int_3 = 0; int_3 < defaultedList_1.size(); ++int_3) { defaultedList_1.set(int_3, Ingredient.fromPacket(packet)); } ItemStack itemStack_1 = packet.readItemStack(); return factory.create(identifier_1, group, int_1, int_2, defaultedList_1, itemStack_1); }
Example 2
Source File: ShapelessCompressingRecipeSerializer.java From Galacticraft-Rewoven with MIT License | 5 votes |
@Override public T read(Identifier id, PacketByteBuf packet) { // String group = packet.readString(32767); int ingredientCount = packet.readVarInt(); DefaultedList<Ingredient> ingredients = DefaultedList.ofSize(ingredientCount, Ingredient.EMPTY); for (int index = 0; index < ingredients.size(); ++index) { ingredients.set(index, Ingredient.fromPacket(packet)); } ItemStack result = packet.readItemStack(); return factory.create(id, /*group, */result, ingredients); }
Example 3
Source File: EntitySpawnGlobalS2CPacket_1_15_2.java From multiconnect with MIT License | 5 votes |
@Override public void read(PacketByteBuf buf) { buf.readVarInt(); // id entityTypeId = buf.readByte(); x = buf.readDouble(); y = buf.readDouble(); z = buf.readDouble(); }
Example 4
Source File: Protocol_1_12_2.java From multiconnect with MIT License | 5 votes |
@SuppressWarnings("unchecked") @Override public <T> T readTrackedData(TrackedDataHandler<T> handler, PacketByteBuf buf) { if (handler == TrackedDataHandlerRegistry.OPTIONAL_BLOCK_STATE) { int stateId = buf.readVarInt(); if (stateId == 0) return (T) Optional.empty(); return (T) Optional.ofNullable(Block.STATE_IDS.get(Blocks_1_12_2.convertToStateRegistryId(stateId))); } return super.readTrackedData(handler, buf); }
Example 5
Source File: ChunkData.java From multiconnect with MIT License | 5 votes |
public static int skipPalette(PacketByteBuf buf) { int paletteSize = buf.readByte(); if (paletteSize <= 8) { // array and bimap palette data look the same enough to use the same code here int size = buf.readVarInt(); for (int i = 0; i < size; i++) buf.readVarInt(); // state id } return paletteSize; }
Example 6
Source File: MixinPacketInflater.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@Inject(at = @At("HEAD"), method = "decode(Lio/netty/channel/ChannelHandlerContext;Lio/netty/buffer/ByteBuf;Ljava/util/List;)V", cancellable = true) protected void decode(ChannelHandlerContext channelHandlerContext_1, ByteBuf byteBuf_1, List<Object> list_1, CallbackInfo info) throws Exception { if (!ModuleManager.getModule(AntiChunkBan.class).isToggled()) return; info.cancel(); if (byteBuf_1.readableBytes() != 0) { PacketByteBuf packetByteBuf_1 = new PacketByteBuf(byteBuf_1); int int_1 = packetByteBuf_1.readVarInt(); if (int_1 == 0) { list_1.add(packetByteBuf_1.readBytes(packetByteBuf_1.readableBytes())); } else { if (int_1 > 51200000) { throw new DecoderException("Badly compressed packet - size of " + (int_1 / 1000000) + "MB is larger than protocol maximum of 50 MB"); } byte[] bytes_1 = new byte[packetByteBuf_1.readableBytes()]; packetByteBuf_1.readBytes(bytes_1); this.inflater.setInput(bytes_1); byte[] bytes_2 = new byte[int_1]; this.inflater.inflate(bytes_2); list_1.add(Unpooled.wrappedBuffer(bytes_2)); this.inflater.reset(); } } }
Example 7
Source File: UseBedS2CPacket.java From multiconnect with MIT License | 4 votes |
@Override public void read(PacketByteBuf buf) { playerId = buf.readVarInt(); bedPos = buf.readBlockPos(); }