| 1 | package net.minecraft.network;
|
| 2 |
|
| 3 | import com.google.gson.Gson;
|
| 4 | import com.google.gson.JsonElement;
|
| 5 | import com.mojang.datafixers.util.Either;
|
| 6 | import com.mojang.serialization.Codec;
|
| 7 | import com.mojang.serialization.DataResult;
|
| 8 | import com.mojang.serialization.DynamicOps;
|
| 9 | import com.mojang.serialization.JsonOps;
|
| 10 | import io.netty.buffer.ByteBuf;
|
| 11 | import io.netty.buffer.ByteBufAllocator;
|
| 12 | import io.netty.buffer.ByteBufInputStream;
|
| 13 | import io.netty.buffer.ByteBufOutputStream;
|
| 14 | import io.netty.handler.codec.DecoderException;
|
| 15 | import io.netty.handler.codec.EncoderException;
|
| 16 | import io.netty.util.ByteProcessor;
|
| 17 | import java.io.IOException;
|
| 18 | import java.io.InputStream;
|
| 19 | import java.io.OutputStream;
|
| 20 | import java.nio.ByteBuffer;
|
| 21 | import java.nio.ByteOrder;
|
| 22 | import java.nio.channels.FileChannel;
|
| 23 | import java.nio.channels.GatheringByteChannel;
|
| 24 | import java.nio.channels.ScatteringByteChannel;
|
| 25 | import java.nio.charset.Charset;
|
| 26 | import java.util.Arrays;
|
| 27 | import java.util.BitSet;
|
| 28 | import java.util.EnumSet;
|
| 29 | import java.util.Optional;
|
| 30 | import java.util.UUID;
|
| 31 | import java.util.function.Consumer;
|
| 32 | import java.util.function.IntFunction;
|
| 33 | import java.util.function.ToIntFunction;
|
| 34 | import net.minecraft.core.BlockPos;
|
| 35 | import net.minecraft.core.GlobalPos;
|
| 36 | import net.minecraft.core.Registry;
|
| 37 | import net.minecraft.core.registries.Registries;
|
| 38 | import net.minecraft.nbt.CompoundTag;
|
| 39 | import net.minecraft.nbt.EndTag;
|
| 40 | import net.minecraft.nbt.NbtAccounter;
|
| 41 | import net.minecraft.nbt.NbtIo;
|
| 42 | import net.minecraft.nbt.Tag;
|
| 43 | import net.minecraft.network.codec.StreamDecoder;
|
| 44 | import net.minecraft.network.codec.StreamEncoder;
|
| 45 | import net.minecraft.resources.Identifier;
|
| 46 | import net.minecraft.resources.ResourceKey;
|
| 47 | import net.minecraft.util.LenientJsonParser;
|
| 48 | import net.minecraft.util.Mth;
|
| 49 | import net.minecraft.world.level.ChunkPos;
|
| 50 | import net.minecraft.world.level.Level;
|
| 51 | import org.joml.Quaternionf;
|
| 52 | import org.joml.Quaternionfc;
|
| 53 | import org.joml.Vector3f;
|
| 54 | import org.joml.Vector3fc;
|
| 55 | import org.jspecify.annotations.Nullable;
|
| 56 |
|
| 57 | public class FriendlyByteBuf extends ByteBuf {
|
| 58 | private final ByteBuf source;
|
| 59 | public static final short MAX_STRING_LENGTH = 32767;
|
| 60 | public static final int MAX_COMPONENT_STRING_LENGTH = 262144;
|
| 61 | private static final Gson GSON = new Gson();
|
| 62 |
|
| 63 | public FriendlyByteBuf(final ByteBuf source) {
|
| 64 | this.source = source;
|
| 65 | }
|
| 66 |
|
| 67 | @Deprecated
|
| 68 | public <T> T readWithCodecTrusted(final DynamicOps<Tag> ops, final Codec<T> codec) {
|
| 69 | return this.readWithCodec(ops, codec, NbtAccounter.unlimitedHeap());
|
| 70 | }
|
| 71 |
|
| 72 | @Deprecated
|
| 73 | public <T> T readWithCodec(final DynamicOps<Tag> ops, final Codec<T> codec, final NbtAccounter accounter) {
|
| 74 | Tag tag = this.readNbt(accounter);
|
| 75 | return codec.parse(ops, tag).getOrThrow(msg -> new DecoderException("Failed to decode: " + msg + " " + tag));
|
| 76 | }
|
| 77 |
|
| 78 | @Deprecated
|
| 79 | public <T> FriendlyByteBuf writeWithCodec(final DynamicOps<Tag> ops, final Codec<T> codec, final T value) {
|
| 80 | Tag tag = codec.encodeStart(ops, value).getOrThrow(msg -> new EncoderException("Failed to encode: " + msg + " " + value));
|
| 81 | this.writeNbt(tag);
|
| 82 | return this;
|
| 83 | }
|
| 84 |
|
| 85 | public <T> T readLenientJsonWithCodec(final Codec<T> codec) {
|
| 86 | JsonElement json = LenientJsonParser.parse(this.readUtf());
|
| 87 | DataResult<T> result = codec.parse(JsonOps.INSTANCE, json);
|
| 88 | return result.getOrThrow(error -> new DecoderException("Failed to decode JSON: " + error));
|
| 89 | }
|
| 90 |
|
| 91 | public <T> void writeJsonWithCodec(final Codec<T> codec, final T value) {
|
| 92 | DataResult<JsonElement> result = codec.encodeStart(JsonOps.INSTANCE, value);
|
| 93 | this.writeUtf(GSON.toJson(result.getOrThrow(error -> new EncoderException("Failed to encode: " + error + " " + value))));
|
| 94 | }
|
| 95 |
|
| 96 | public void readWithCount(final Consumer<FriendlyByteBuf> reader) {
|
| 97 | int count = this.readVarInt();
|
| 98 |
|
| 99 | for (int i = 0; i < count; i++) {
|
| 100 | reader.accept(this);
|
| 101 | }
|
| 102 | }
|
| 103 |
|
| 104 | public <E extends Enum<E>> void writeEnumSet(final EnumSet<E> set, final Class<E> clazz) {
|
| 105 | E[] values = (E[])clazz.getEnumConstants();
|
| 106 | BitSet mask = new BitSet(values.length);
|
| 107 |
|
| 108 | for (int i = 0; i < values.length; i++) {
|
| 109 | mask.set(i, set.contains(values[i]));
|
| 110 | }
|
| 111 |
|
| 112 | this.writeFixedBitSet(mask, values.length);
|
| 113 | }
|
| 114 |
|
| 115 | public <E extends Enum<E>> EnumSet<E> readEnumSet(final Class<E> clazz) {
|
| 116 | E[] values = (E[])clazz.getEnumConstants();
|
| 117 | BitSet mask = this.readFixedBitSet(values.length);
|
| 118 | EnumSet<E> result = EnumSet.noneOf(clazz);
|
| 119 |
|
| 120 | for (int i = 0; i < values.length; i++) {
|
| 121 | if (mask.get(i)) {
|
| 122 | result.add(values[i]);
|
| 123 | }
|
| 124 | }
|
| 125 |
|
| 126 | return result;
|
| 127 | }
|
| 128 |
|
| 129 | public <T> void writeOptional(final Optional<T> value, final StreamEncoder<? super FriendlyByteBuf, T> valueWriter) {
|
| 130 | if (value.isPresent()) {
|
| 131 | this.writeBoolean(true);
|
| 132 | valueWriter.encode(this, value.get());
|
| 133 | } else {
|
| 134 | this.writeBoolean(false);
|
| 135 | }
|
| 136 | }
|
| 137 |
|
| 138 | public <T> Optional<T> readOptional(final StreamDecoder<? super FriendlyByteBuf, T> valueReader) {
|
| 139 | return this.readBoolean() ? Optional.of(valueReader.decode(this)) : Optional.empty();
|
| 140 | }
|
| 141 |
|
| 142 | public <L, R> void writeEither(
|
| 143 | final Either<L, R> value, final StreamEncoder<? super FriendlyByteBuf, L> leftWriter, final StreamEncoder<? super FriendlyByteBuf, R> rightWriter
|
| 144 | ) {
|
| 145 | value.ifLeft(left -> {
|
| 146 | this.writeBoolean(true);
|
| 147 | leftWriter.encode(this, (L)left);
|
| 148 | }).ifRight(right -> {
|
| 149 | this.writeBoolean(false);
|
| 150 | rightWriter.encode(this, (R)right);
|
| 151 | });
|
| 152 | }
|
| 153 |
|
| 154 | public <L, R> Either<L, R> readEither(final StreamDecoder<? super FriendlyByteBuf, L> leftReader, final StreamDecoder<? super FriendlyByteBuf, R> rightReader) {
|
| 155 | return this.readBoolean() ? Either.left(leftReader.decode(this)) : Either.right(rightReader.decode(this));
|
| 156 | }
|
| 157 |
|
| 158 | public <T> @Nullable T readNullable(final StreamDecoder<? super FriendlyByteBuf, T> valueDecoder) {
|
| 159 | return readNullable(this, valueDecoder);
|
| 160 | }
|
| 161 |
|
| 162 | public static <T, B extends ByteBuf> @Nullable T readNullable(final B input, final StreamDecoder<? super B, T> valueDecoder) {
|
| 163 | return input.readBoolean() ? valueDecoder.decode(input) : null;
|
| 164 | }
|
| 165 |
|
| 166 | public <T> void writeNullable(final @Nullable T value, final StreamEncoder<? super FriendlyByteBuf, T> valueEncoder) {
|
| 167 | writeNullable(this, value, valueEncoder);
|
| 168 | }
|
| 169 |
|
| 170 | public static <T, B extends ByteBuf> void writeNullable(final B output, final @Nullable T value, final StreamEncoder<? super B, T> valueEncoder) {
|
| 171 | if (value != null) {
|
| 172 | output.writeBoolean(true);
|
| 173 | valueEncoder.encode(output, value);
|
| 174 | } else {
|
| 175 | output.writeBoolean(false);
|
| 176 | }
|
| 177 | }
|
| 178 |
|
| 179 | public byte[] readByteArray() {
|
| 180 | return readByteArray(this);
|
| 181 | }
|
| 182 |
|
| 183 | public static byte[] readByteArray(final ByteBuf input) {
|
| 184 | return readByteArray(input, input.readableBytes());
|
| 185 | }
|
| 186 |
|
| 187 | public FriendlyByteBuf writeByteArray(final byte[] bytes) {
|
| 188 | writeByteArray(this, bytes);
|
| 189 | return this;
|
| 190 | }
|
| 191 |
|
| 192 | public static void writeByteArray(final ByteBuf output, final byte[] bytes) {
|
| 193 | VarInt.write(output, bytes.length);
|
| 194 | output.writeBytes(bytes);
|
| 195 | }
|
| 196 |
|
| 197 | public byte[] readByteArray(final int maxSize) {
|
| 198 | return readByteArray(this, maxSize);
|
| 199 | }
|
| 200 |
|
| 201 | public static byte[] readByteArray(final ByteBuf input, final int maxSize) {
|
| 202 | int size = VarInt.read(input);
|
| 203 | if (size > maxSize) {
|
| 204 | throw new DecoderException("ByteArray with size " + size + " is bigger than allowed " + maxSize);
|
| 205 | }
|
| 206 |
|
| 207 | byte[] bytes = new byte[size];
|
| 208 | input.readBytes(bytes);
|
| 209 | return bytes;
|
| 210 | }
|
| 211 |
|
| 212 | public FriendlyByteBuf writeVarIntArray(final int[] ints) {
|
| 213 | this.writeVarInt(ints.length);
|
| 214 |
|
| 215 | for (int i : ints) {
|
| 216 | this.writeVarInt(i);
|
| 217 | }
|
| 218 |
|
| 219 | return this;
|
| 220 | }
|
| 221 |
|
| 222 | public int[] readVarIntArray() {
|
| 223 | return this.readVarIntArray(this.readableBytes());
|
| 224 | }
|
| 225 |
|
| 226 | public int[] readVarIntArray(final int maxSize) {
|
| 227 | int size = this.readVarInt();
|
| 228 | if (size > maxSize) {
|
| 229 | throw new DecoderException("VarIntArray with size " + size + " is bigger than allowed " + maxSize);
|
| 230 | }
|
| 231 |
|
| 232 | int[] ints = new int[size];
|
| 233 |
|
| 234 | for (int i = 0; i < ints.length; i++) {
|
| 235 | ints[i] = this.readVarInt();
|
| 236 | }
|
| 237 |
|
| 238 | return ints;
|
| 239 | }
|
| 240 |
|
| 241 | public FriendlyByteBuf writeLongArray(final long[] longs) {
|
| 242 | writeLongArray(this, longs);
|
| 243 | return this;
|
| 244 | }
|
| 245 |
|
| 246 | public static void writeLongArray(final ByteBuf output, final long[] longs) {
|
| 247 | VarInt.write(output, longs.length);
|
| 248 | writeFixedSizeLongArray(output, longs);
|
| 249 | }
|
| 250 |
|
| 251 | public FriendlyByteBuf writeFixedSizeLongArray(final long[] longs) {
|
| 252 | writeFixedSizeLongArray(this, longs);
|
| 253 | return this;
|
| 254 | }
|
| 255 |
|
| 256 | public static void writeFixedSizeLongArray(final ByteBuf output, final long[] longs) {
|
| 257 | for (long l : longs) {
|
| 258 | output.writeLong(l);
|
| 259 | }
|
| 260 | }
|
| 261 |
|
| 262 | public long[] readLongArray() {
|
| 263 | return readLongArray(this);
|
| 264 | }
|
| 265 |
|
| 266 | public long[] readFixedSizeLongArray(final long[] output) {
|
| 267 | return readFixedSizeLongArray(this, output);
|
| 268 | }
|
| 269 |
|
| 270 | public static long[] readLongArray(final ByteBuf input) {
|
| 271 | int size = VarInt.read(input);
|
| 272 | int maxSize = input.readableBytes() / 8;
|
| 273 | if (size > maxSize) {
|
| 274 | throw new DecoderException("LongArray with size " + size + " is bigger than allowed " + maxSize);
|
| 275 | } else {
|
| 276 | return readFixedSizeLongArray(input, new long[size]);
|
| 277 | }
|
| 278 | }
|
| 279 |
|
| 280 | public static long[] readFixedSizeLongArray(final ByteBuf input, final long[] output) {
|
| 281 | for (int i = 0; i < output.length; i++) {
|
| 282 | output[i] = input.readLong();
|
| 283 | }
|
| 284 |
|
| 285 | return output;
|
| 286 | }
|
| 287 |
|
| 288 | public BlockPos readBlockPos() {
|
| 289 | return readBlockPos(this);
|
| 290 | }
|
| 291 |
|
| 292 | public static BlockPos readBlockPos(final ByteBuf input) {
|
| 293 | return BlockPos.of(input.readLong());
|
| 294 | }
|
| 295 |
|
| 296 | public FriendlyByteBuf writeBlockPos(final BlockPos pos) {
|
| 297 | writeBlockPos(this, pos);
|
| 298 | return this;
|
| 299 | }
|
| 300 |
|
| 301 | public static void writeBlockPos(final ByteBuf output, final BlockPos pos) {
|
| 302 | output.writeLong(pos.asLong());
|
| 303 | }
|
| 304 |
|
| 305 | public ChunkPos readChunkPos() {
|
| 306 | return ChunkPos.unpack(this.readLong());
|
| 307 | }
|
| 308 |
|
| 309 | public FriendlyByteBuf writeChunkPos(final ChunkPos pos) {
|
| 310 | this.writeLong(pos.pack());
|
| 311 | return this;
|
| 312 | }
|
| 313 |
|
| 314 | public static ChunkPos readChunkPos(final ByteBuf input) {
|
| 315 | return ChunkPos.unpack(input.readLong());
|
| 316 | }
|
| 317 |
|
| 318 | public static void writeChunkPos(final ByteBuf output, final ChunkPos chunkPos) {
|
| 319 | output.writeLong(chunkPos.pack());
|
| 320 | }
|
| 321 |
|
| 322 | public GlobalPos readGlobalPos() {
|
| 323 | ResourceKey<Level> dimension = this.readResourceKey(Registries.DIMENSION);
|
| 324 | BlockPos pos = this.readBlockPos();
|
| 325 | return GlobalPos.of(dimension, pos);
|
| 326 | }
|
| 327 |
|
| 328 | public void writeGlobalPos(final GlobalPos globalPos) {
|
| 329 | this.writeResourceKey(globalPos.dimension());
|
| 330 | this.writeBlockPos(globalPos.pos());
|
| 331 | }
|
| 332 |
|
| 333 | public Vector3f readVector3f() {
|
| 334 | return readVector3f(this);
|
| 335 | }
|
| 336 |
|
| 337 | public static Vector3f readVector3f(final ByteBuf input) {
|
| 338 | return new Vector3f(input.readFloat(), input.readFloat(), input.readFloat());
|
| 339 | }
|
| 340 |
|
| 341 | public void writeVector3f(final Vector3f v) {
|
| 342 | writeVector3f(this, v);
|
| 343 | }
|
| 344 |
|
| 345 | public static void writeVector3f(final ByteBuf output, final Vector3fc v) {
|
| 346 | output.writeFloat(v.x());
|
| 347 | output.writeFloat(v.y());
|
| 348 | output.writeFloat(v.z());
|
| 349 | }
|
| 350 |
|
| 351 | public Quaternionf readQuaternion() {
|
| 352 | return readQuaternion(this);
|
| 353 | }
|
| 354 |
|
| 355 | public static Quaternionf readQuaternion(final ByteBuf input) {
|
| 356 | return new Quaternionf(input.readFloat(), input.readFloat(), input.readFloat(), input.readFloat());
|
| 357 | }
|
| 358 |
|
| 359 | public void writeQuaternion(final Quaternionf q) {
|
| 360 | writeQuaternion(this, q);
|
| 361 | }
|
| 362 |
|
| 363 | public static void writeQuaternion(final ByteBuf output, final Quaternionfc value) {
|
| 364 | output.writeFloat(value.x());
|
| 365 | output.writeFloat(value.y());
|
| 366 | output.writeFloat(value.z());
|
| 367 | output.writeFloat(value.w());
|
| 368 | }
|
| 369 |
|
| 370 | @Deprecated
|
| 371 | public <T extends Enum<T>> T readEnum(final Class<T> clazz) {
|
| 372 | return clazz.getEnumConstants()[this.readVarInt()];
|
| 373 | }
|
| 374 |
|
| 375 | @Deprecated
|
| 376 | public FriendlyByteBuf writeEnum(final Enum<?> value) {
|
| 377 | return this.writeVarInt(value.ordinal());
|
| 378 | }
|
| 379 |
|
| 380 | public <T> T readById(final IntFunction<T> converter) {
|
| 381 | int id = this.readVarInt();
|
| 382 | return converter.apply(id);
|
| 383 | }
|
| 384 |
|
| 385 | public <T> FriendlyByteBuf writeById(final ToIntFunction<T> converter, final T value) {
|
| 386 | int id = converter.applyAsInt(value);
|
| 387 | return this.writeVarInt(id);
|
| 388 | }
|
| 389 |
|
| 390 | public int readVarInt() {
|
| 391 | return VarInt.read(this.source);
|
| 392 | }
|
| 393 |
|
| 394 | public long readVarLong() {
|
| 395 | return VarLong.read(this.source);
|
| 396 | }
|
| 397 |
|
| 398 | public FriendlyByteBuf writeUUID(final UUID uuid) {
|
| 399 | writeUUID(this, uuid);
|
| 400 | return this;
|
| 401 | }
|
| 402 |
|
| 403 | public static void writeUUID(final ByteBuf output, final UUID uuid) {
|
| 404 | output.writeLong(uuid.getMostSignificantBits());
|
| 405 | output.writeLong(uuid.getLeastSignificantBits());
|
| 406 | }
|
| 407 |
|
| 408 | public UUID readUUID() {
|
| 409 | return readUUID(this);
|
| 410 | }
|
| 411 |
|
| 412 | public static UUID readUUID(final ByteBuf input) {
|
| 413 | return new UUID(input.readLong(), input.readLong());
|
| 414 | }
|
| 415 |
|
| 416 | public FriendlyByteBuf writeVarInt(final int value) {
|
| 417 | VarInt.write(this.source, value);
|
| 418 | return this;
|
| 419 | }
|
| 420 |
|
| 421 | public FriendlyByteBuf writeVarLong(final long value) {
|
| 422 | VarLong.write(this.source, value);
|
| 423 | return this;
|
| 424 | }
|
| 425 |
|
| 426 | public FriendlyByteBuf writeNbt(final @Nullable Tag tag) {
|
| 427 | writeNbt(this, tag);
|
| 428 | return this;
|
| 429 | }
|
| 430 |
|
| 431 | public static void writeNbt(final ByteBuf output, @Nullable Tag tag) {
|
| 432 | if (tag == null) {
|
| 433 | tag = EndTag.INSTANCE;
|
| 434 | }
|
| 435 |
|
| 436 | try {
|
| 437 | NbtIo.writeAnyTag(tag, new ByteBufOutputStream(output));
|
| 438 | } catch (IOException e) {
|
| 439 | throw new EncoderException(e);
|
| 440 | }
|
| 441 | }
|
| 442 |
|
| 443 | public @Nullable CompoundTag readNbt() {
|
| 444 | return readNbt(this);
|
| 445 | }
|
| 446 |
|
| 447 | public static @Nullable CompoundTag readNbt(final ByteBuf input) {
|
| 448 | Tag result = readNbt(input, NbtAccounter.defaultQuota());
|
| 449 | if (result != null && !(result instanceof CompoundTag)) {
|
| 450 | throw new DecoderException("Not a compound tag: " + result);
|
| 451 | } else {
|
| 452 | return (CompoundTag)result;
|
| 453 | }
|
| 454 | }
|
| 455 |
|
| 456 | public static @Nullable Tag readNbt(final ByteBuf input, final NbtAccounter accounter) {
|
| 457 | try {
|
| 458 | Tag tag = NbtIo.readAnyTag(new ByteBufInputStream(input), accounter);
|
| 459 | return tag.getId() == 0 ? null : tag;
|
| 460 | } catch (IOException e) {
|
| 461 | throw new EncoderException(e);
|
| 462 | }
|
| 463 | }
|
| 464 |
|
| 465 | public @Nullable Tag readNbt(final NbtAccounter accounter) {
|
| 466 | return readNbt(this, accounter);
|
| 467 | }
|
| 468 |
|
| 469 | public String readUtf() {
|
| 470 | return this.readUtf(32767);
|
| 471 | }
|
| 472 |
|
| 473 | public String readUtf(final int maxLength) {
|
| 474 | return Utf8String.read(this.source, maxLength);
|
| 475 | }
|
| 476 |
|
| 477 | public FriendlyByteBuf writeUtf(final String value) {
|
| 478 | return this.writeUtf(value, 32767);
|
| 479 | }
|
| 480 |
|
| 481 | public FriendlyByteBuf writeUtf(final String value, final int maxLength) {
|
| 482 | Utf8String.write(this.source, value, maxLength);
|
| 483 | return this;
|
| 484 | }
|
| 485 |
|
| 486 | public Identifier readIdentifier() {
|
| 487 | return Identifier.parse(this.readUtf(32767));
|
| 488 | }
|
| 489 |
|
| 490 | public FriendlyByteBuf writeIdentifier(final Identifier identifier) {
|
| 491 | this.writeUtf(identifier.toString());
|
| 492 | return this;
|
| 493 | }
|
| 494 |
|
| 495 | public <T> ResourceKey<T> readResourceKey(final ResourceKey<? extends Registry<T>> registry) {
|
| 496 | Identifier id = this.readIdentifier();
|
| 497 | return ResourceKey.create(registry, id);
|
| 498 | }
|
| 499 |
|
| 500 | public void writeResourceKey(final ResourceKey<?> key) {
|
| 501 | this.writeIdentifier(key.identifier());
|
| 502 | }
|
| 503 |
|
| 504 | public <T> ResourceKey<? extends Registry<T>> readRegistryKey() {
|
| 505 | Identifier id = this.readIdentifier();
|
| 506 | return ResourceKey.createRegistryKey(id);
|
| 507 | }
|
| 508 |
|
| 509 | public BitSet readBitSet() {
|
| 510 | return BitSet.valueOf(this.readLongArray());
|
| 511 | }
|
| 512 |
|
| 513 | public void writeBitSet(final BitSet bitSet) {
|
| 514 | this.writeLongArray(bitSet.toLongArray());
|
| 515 | }
|
| 516 |
|
| 517 | public BitSet readFixedBitSet(final int size) {
|
| 518 | return readFixedBitSet(this, size);
|
| 519 | }
|
| 520 |
|
| 521 | public void writeFixedBitSet(final BitSet bitSet, final int size) {
|
| 522 | writeFixedBitSet(this, bitSet, size);
|
| 523 | }
|
| 524 |
|
| 525 | public static BitSet readFixedBitSet(final ByteBuf input, final int size) {
|
| 526 | byte[] bytes = new byte[Mth.positiveCeilDiv(size, 8)];
|
| 527 | input.readBytes(bytes);
|
| 528 | return BitSet.valueOf(bytes);
|
| 529 | }
|
| 530 |
|
| 531 | public static void writeFixedBitSet(final ByteBuf output, final BitSet bitSet, final int size) {
|
| 532 | if (bitSet.length() > size) {
|
| 533 | throw new EncoderException("BitSet is larger than expected size (" + bitSet.length() + ">" + size + ")");
|
| 534 | }
|
| 535 |
|
| 536 | byte[] bytes = bitSet.toByteArray();
|
| 537 | output.writeBytes(Arrays.copyOf(bytes, Mth.positiveCeilDiv(size, 8)));
|
| 538 | }
|
| 539 |
|
| 540 | public static int readContainerId(final ByteBuf input) {
|
| 541 | return VarInt.read(input);
|
| 542 | }
|
| 543 |
|
| 544 | public int readContainerId() {
|
| 545 | return readContainerId(this.source);
|
| 546 | }
|
| 547 |
|
| 548 | public static void writeContainerId(final ByteBuf output, final int id) {
|
| 549 | VarInt.write(output, id);
|
| 550 | }
|
| 551 |
|
| 552 | public void writeContainerId(final int id) {
|
| 553 | writeContainerId(this.source, id);
|
| 554 | }
|
| 555 |
|
| 556 | @Override
|
| 557 | public boolean isContiguous() {
|
| 558 | return this.source.isContiguous();
|
| 559 | }
|
| 560 |
|
| 561 | @Override
|
| 562 | public int maxFastWritableBytes() {
|
| 563 | return this.source.maxFastWritableBytes();
|
| 564 | }
|
| 565 |
|
| 566 | @Override
|
| 567 | public int capacity() {
|
| 568 | return this.source.capacity();
|
| 569 | }
|
| 570 |
|
| 571 | public FriendlyByteBuf capacity(final int newCapacity) {
|
| 572 | this.source.capacity(newCapacity);
|
| 573 | return this;
|
| 574 | }
|
| 575 |
|
| 576 | @Override
|
| 577 | public int maxCapacity() {
|
| 578 | return this.source.maxCapacity();
|
| 579 | }
|
| 580 |
|
| 581 | @Override
|
| 582 | public ByteBufAllocator alloc() {
|
| 583 | return this.source.alloc();
|
| 584 | }
|
| 585 |
|
| 586 | @Override
|
| 587 | public ByteOrder order() {
|
| 588 | return this.source.order();
|
| 589 | }
|
| 590 |
|
| 591 | @Override
|
| 592 | public ByteBuf order(final ByteOrder endianness) {
|
| 593 | return this.source.order(endianness);
|
| 594 | }
|
| 595 |
|
| 596 | @Override
|
| 597 | public ByteBuf unwrap() {
|
| 598 | return this.source;
|
| 599 | }
|
| 600 |
|
| 601 | @Override
|
| 602 | public boolean isDirect() {
|
| 603 | return this.source.isDirect();
|
| 604 | }
|
| 605 |
|
| 606 | @Override
|
| 607 | public boolean isReadOnly() {
|
| 608 | return this.source.isReadOnly();
|
| 609 | }
|
| 610 |
|
| 611 | @Override
|
| 612 | public ByteBuf asReadOnly() {
|
| 613 | return this.source.asReadOnly();
|
| 614 | }
|
| 615 |
|
| 616 | @Override
|
| 617 | public int readerIndex() {
|
| 618 | return this.source.readerIndex();
|
| 619 | }
|
| 620 |
|
| 621 | public FriendlyByteBuf readerIndex(final int readerIndex) {
|
| 622 | this.source.readerIndex(readerIndex);
|
| 623 | return this;
|
| 624 | }
|
| 625 |
|
| 626 | @Override
|
| 627 | public int writerIndex() {
|
| 628 | return this.source.writerIndex();
|
| 629 | }
|
| 630 |
|
| 631 | public FriendlyByteBuf writerIndex(final int writerIndex) {
|
| 632 | this.source.writerIndex(writerIndex);
|
| 633 | return this;
|
| 634 | }
|
| 635 |
|
| 636 | public FriendlyByteBuf setIndex(final int readerIndex, final int writerIndex) {
|
| 637 | this.source.setIndex(readerIndex, writerIndex);
|
| 638 | return this;
|
| 639 | }
|
| 640 |
|
| 641 | @Override
|
| 642 | public int readableBytes() {
|
| 643 | return this.source.readableBytes();
|
| 644 | }
|
| 645 |
|
| 646 | @Override
|
| 647 | public int writableBytes() {
|
| 648 | return this.source.writableBytes();
|
| 649 | }
|
| 650 |
|
| 651 | @Override
|
| 652 | public int maxWritableBytes() {
|
| 653 | return this.source.maxWritableBytes();
|
| 654 | }
|
| 655 |
|
| 656 | @Override
|
| 657 | public boolean isReadable() {
|
| 658 | return this.source.isReadable();
|
| 659 | }
|
| 660 |
|
| 661 | @Override
|
| 662 | public boolean isReadable(final int size) {
|
| 663 | return this.source.isReadable(size);
|
| 664 | }
|
| 665 |
|
| 666 | @Override
|
| 667 | public boolean isWritable() {
|
| 668 | return this.source.isWritable();
|
| 669 | }
|
| 670 |
|
| 671 | @Override
|
| 672 | public boolean isWritable(final int size) {
|
| 673 | return this.source.isWritable(size);
|
| 674 | }
|
| 675 |
|
| 676 | public FriendlyByteBuf clear() {
|
| 677 | this.source.clear();
|
| 678 | return this;
|
| 679 | }
|
| 680 |
|
| 681 | public FriendlyByteBuf markReaderIndex() {
|
| 682 | this.source.markReaderIndex();
|
| 683 | return this;
|
| 684 | }
|
| 685 |
|
| 686 | public FriendlyByteBuf resetReaderIndex() {
|
| 687 | this.source.resetReaderIndex();
|
| 688 | return this;
|
| 689 | }
|
| 690 |
|
| 691 | public FriendlyByteBuf markWriterIndex() {
|
| 692 | this.source.markWriterIndex();
|
| 693 | return this;
|
| 694 | }
|
| 695 |
|
| 696 | public FriendlyByteBuf resetWriterIndex() {
|
| 697 | this.source.resetWriterIndex();
|
| 698 | return this;
|
| 699 | }
|
| 700 |
|
| 701 | public FriendlyByteBuf discardReadBytes() {
|
| 702 | this.source.discardReadBytes();
|
| 703 | return this;
|
| 704 | }
|
| 705 |
|
| 706 | public FriendlyByteBuf discardSomeReadBytes() {
|
| 707 | this.source.discardSomeReadBytes();
|
| 708 | return this;
|
| 709 | }
|
| 710 |
|
| 711 | public FriendlyByteBuf ensureWritable(final int minWritableBytes) {
|
| 712 | this.source.ensureWritable(minWritableBytes);
|
| 713 | return this;
|
| 714 | }
|
| 715 |
|
| 716 | @Override
|
| 717 | public int ensureWritable(final int minWritableBytes, final boolean force) {
|
| 718 | return this.source.ensureWritable(minWritableBytes, force);
|
| 719 | }
|
| 720 |
|
| 721 | @Override
|
| 722 | public boolean getBoolean(final int index) {
|
| 723 | return this.source.getBoolean(index);
|
| 724 | }
|
| 725 |
|
| 726 | @Override
|
| 727 | public byte getByte(final int index) {
|
| 728 | return this.source.getByte(index);
|
| 729 | }
|
| 730 |
|
| 731 | @Override
|
| 732 | public short getUnsignedByte(final int index) {
|
| 733 | return this.source.getUnsignedByte(index);
|
| 734 | }
|
| 735 |
|
| 736 | @Override
|
| 737 | public short getShort(final int index) {
|
| 738 | return this.source.getShort(index);
|
| 739 | }
|
| 740 |
|
| 741 | @Override
|
| 742 | public short getShortLE(final int index) {
|
| 743 | return this.source.getShortLE(index);
|
| 744 | }
|
| 745 |
|
| 746 | @Override
|
| 747 | public int getUnsignedShort(final int index) {
|
| 748 | return this.source.getUnsignedShort(index);
|
| 749 | }
|
| 750 |
|
| 751 | @Override
|
| 752 | public int getUnsignedShortLE(final int index) {
|
| 753 | return this.source.getUnsignedShortLE(index);
|
| 754 | }
|
| 755 |
|
| 756 | @Override
|
| 757 | public int getMedium(final int index) {
|
| 758 | return this.source.getMedium(index);
|
| 759 | }
|
| 760 |
|
| 761 | @Override
|
| 762 | public int getMediumLE(final int index) {
|
| 763 | return this.source.getMediumLE(index);
|
| 764 | }
|
| 765 |
|
| 766 | @Override
|
| 767 | public int getUnsignedMedium(final int index) {
|
| 768 | return this.source.getUnsignedMedium(index);
|
| 769 | }
|
| 770 |
|
| 771 | @Override
|
| 772 | public int getUnsignedMediumLE(final int index) {
|
| 773 | return this.source.getUnsignedMediumLE(index);
|
| 774 | }
|
| 775 |
|
| 776 | @Override
|
| 777 | public int getInt(final int index) {
|
| 778 | return this.source.getInt(index);
|
| 779 | }
|
| 780 |
|
| 781 | @Override
|
| 782 | public int getIntLE(final int index) {
|
| 783 | return this.source.getIntLE(index);
|
| 784 | }
|
| 785 |
|
| 786 | @Override
|
| 787 | public long getUnsignedInt(final int index) {
|
| 788 | return this.source.getUnsignedInt(index);
|
| 789 | }
|
| 790 |
|
| 791 | @Override
|
| 792 | public long getUnsignedIntLE(final int index) {
|
| 793 | return this.source.getUnsignedIntLE(index);
|
| 794 | }
|
| 795 |
|
| 796 | @Override
|
| 797 | public long getLong(final int index) {
|
| 798 | return this.source.getLong(index);
|
| 799 | }
|
| 800 |
|
| 801 | @Override
|
| 802 | public long getLongLE(final int index) {
|
| 803 | return this.source.getLongLE(index);
|
| 804 | }
|
| 805 |
|
| 806 | @Override
|
| 807 | public char getChar(final int index) {
|
| 808 | return this.source.getChar(index);
|
| 809 | }
|
| 810 |
|
| 811 | @Override
|
| 812 | public float getFloat(final int index) {
|
| 813 | return this.source.getFloat(index);
|
| 814 | }
|
| 815 |
|
| 816 | @Override
|
| 817 | public double getDouble(final int index) {
|
| 818 | return this.source.getDouble(index);
|
| 819 | }
|
| 820 |
|
| 821 | public FriendlyByteBuf getBytes(final int index, final ByteBuf dst) {
|
| 822 | this.source.getBytes(index, dst);
|
| 823 | return this;
|
| 824 | }
|
| 825 |
|
| 826 | public FriendlyByteBuf getBytes(final int index, final ByteBuf dst, final int length) {
|
| 827 | this.source.getBytes(index, dst, length);
|
| 828 | return this;
|
| 829 | }
|
| 830 |
|
| 831 | public FriendlyByteBuf getBytes(final int index, final ByteBuf dst, final int dstIndex, final int length) {
|
| 832 | this.source.getBytes(index, dst, dstIndex, length);
|
| 833 | return this;
|
| 834 | }
|
| 835 |
|
| 836 | public FriendlyByteBuf getBytes(final int index, final byte[] dst) {
|
| 837 | this.source.getBytes(index, dst);
|
| 838 | return this;
|
| 839 | }
|
| 840 |
|
| 841 | public FriendlyByteBuf getBytes(final int index, final byte[] dst, final int dstIndex, final int length) {
|
| 842 | this.source.getBytes(index, dst, dstIndex, length);
|
| 843 | return this;
|
| 844 | }
|
| 845 |
|
| 846 | public FriendlyByteBuf getBytes(final int index, final ByteBuffer dst) {
|
| 847 | this.source.getBytes(index, dst);
|
| 848 | return this;
|
| 849 | }
|
| 850 |
|
| 851 | public FriendlyByteBuf getBytes(final int index, final OutputStream out, final int length) throws IOException {
|
| 852 | this.source.getBytes(index, out, length);
|
| 853 | return this;
|
| 854 | }
|
| 855 |
|
| 856 | @Override
|
| 857 | public int getBytes(final int index, final GatheringByteChannel out, final int length) throws IOException {
|
| 858 | return this.source.getBytes(index, out, length);
|
| 859 | }
|
| 860 |
|
| 861 | @Override
|
| 862 | public int getBytes(final int index, final FileChannel out, final long position, final int length) throws IOException {
|
| 863 | return this.source.getBytes(index, out, position, length);
|
| 864 | }
|
| 865 |
|
| 866 | @Override
|
| 867 | public CharSequence getCharSequence(final int index, final int length, final Charset charset) {
|
| 868 | return this.source.getCharSequence(index, length, charset);
|
| 869 | }
|
| 870 |
|
| 871 | public FriendlyByteBuf setBoolean(final int index, final boolean value) {
|
| 872 | this.source.setBoolean(index, value);
|
| 873 | return this;
|
| 874 | }
|
| 875 |
|
| 876 | public FriendlyByteBuf setByte(final int index, final int value) {
|
| 877 | this.source.setByte(index, value);
|
| 878 | return this;
|
| 879 | }
|
| 880 |
|
| 881 | public FriendlyByteBuf setShort(final int index, final int value) {
|
| 882 | this.source.setShort(index, value);
|
| 883 | return this;
|
| 884 | }
|
| 885 |
|
| 886 | public FriendlyByteBuf setShortLE(final int index, final int value) {
|
| 887 | this.source.setShortLE(index, value);
|
| 888 | return this;
|
| 889 | }
|
| 890 |
|
| 891 | public FriendlyByteBuf setMedium(final int index, final int value) {
|
| 892 | this.source.setMedium(index, value);
|
| 893 | return this;
|
| 894 | }
|
| 895 |
|
| 896 | public FriendlyByteBuf setMediumLE(final int index, final int value) {
|
| 897 | this.source.setMediumLE(index, value);
|
| 898 | return this;
|
| 899 | }
|
| 900 |
|
| 901 | public FriendlyByteBuf setInt(final int index, final int value) {
|
| 902 | this.source.setInt(index, value);
|
| 903 | return this;
|
| 904 | }
|
| 905 |
|
| 906 | public FriendlyByteBuf setIntLE(final int index, final int value) {
|
| 907 | this.source.setIntLE(index, value);
|
| 908 | return this;
|
| 909 | }
|
| 910 |
|
| 911 | public FriendlyByteBuf setLong(final int index, final long value) {
|
| 912 | this.source.setLong(index, value);
|
| 913 | return this;
|
| 914 | }
|
| 915 |
|
| 916 | public FriendlyByteBuf setLongLE(final int index, final long value) {
|
| 917 | this.source.setLongLE(index, value);
|
| 918 | return this;
|
| 919 | }
|
| 920 |
|
| 921 | public FriendlyByteBuf setChar(final int index, final int value) {
|
| 922 | this.source.setChar(index, value);
|
| 923 | return this;
|
| 924 | }
|
| 925 |
|
| 926 | public FriendlyByteBuf setFloat(final int index, final float value) {
|
| 927 | this.source.setFloat(index, value);
|
| 928 | return this;
|
| 929 | }
|
| 930 |
|
| 931 | public FriendlyByteBuf setDouble(final int index, final double value) {
|
| 932 | this.source.setDouble(index, value);
|
| 933 | return this;
|
| 934 | }
|
| 935 |
|
| 936 | public FriendlyByteBuf setBytes(final int index, final ByteBuf src) {
|
| 937 | this.source.setBytes(index, src);
|
| 938 | return this;
|
| 939 | }
|
| 940 |
|
| 941 | public FriendlyByteBuf setBytes(final int index, final ByteBuf src, final int length) {
|
| 942 | this.source.setBytes(index, src, length);
|
| 943 | return this;
|
| 944 | }
|
| 945 |
|
| 946 | public FriendlyByteBuf setBytes(final int index, final ByteBuf src, final int srcIndex, final int length) {
|
| 947 | this.source.setBytes(index, src, srcIndex, length);
|
| 948 | return this;
|
| 949 | }
|
| 950 |
|
| 951 | public FriendlyByteBuf setBytes(final int index, final byte[] src) {
|
| 952 | this.source.setBytes(index, src);
|
| 953 | return this;
|
| 954 | }
|
| 955 |
|
| 956 | public FriendlyByteBuf setBytes(final int index, final byte[] src, final int srcIndex, final int length) {
|
| 957 | this.source.setBytes(index, src, srcIndex, length);
|
| 958 | return this;
|
| 959 | }
|
| 960 |
|
| 961 | public FriendlyByteBuf setBytes(final int index, final ByteBuffer src) {
|
| 962 | this.source.setBytes(index, src);
|
| 963 | return this;
|
| 964 | }
|
| 965 |
|
| 966 | @Override
|
| 967 | public int setBytes(final int index, final InputStream in, final int length) throws IOException {
|
| 968 | return this.source.setBytes(index, in, length);
|
| 969 | }
|
| 970 |
|
| 971 | @Override
|
| 972 | public int setBytes(final int index, final ScatteringByteChannel in, final int length) throws IOException {
|
| 973 | return this.source.setBytes(index, in, length);
|
| 974 | }
|
| 975 |
|
| 976 | @Override
|
| 977 | public int setBytes(final int index, final FileChannel in, final long position, final int length) throws IOException {
|
| 978 | return this.source.setBytes(index, in, position, length);
|
| 979 | }
|
| 980 |
|
| 981 | public FriendlyByteBuf setZero(final int index, final int length) {
|
| 982 | this.source.setZero(index, length);
|
| 983 | return this;
|
| 984 | }
|
| 985 |
|
| 986 | @Override
|
| 987 | public int setCharSequence(final int index, final CharSequence sequence, final Charset charset) {
|
| 988 | return this.source.setCharSequence(index, sequence, charset);
|
| 989 | }
|
| 990 |
|
| 991 | @Override
|
| 992 | public boolean readBoolean() {
|
| 993 | return this.source.readBoolean();
|
| 994 | }
|
| 995 |
|
| 996 | @Override
|
| 997 | public byte readByte() {
|
| 998 | return this.source.readByte();
|
| 999 | }
|
| 1000 |
|
| 1001 | @Override
|
| 1002 | public short readUnsignedByte() {
|
| 1003 | return this.source.readUnsignedByte();
|
| 1004 | }
|
| 1005 |
|
| 1006 | @Override
|
| 1007 | public short readShort() {
|
| 1008 | return this.source.readShort();
|
| 1009 | }
|
| 1010 |
|
| 1011 | @Override
|
| 1012 | public short readShortLE() {
|
| 1013 | return this.source.readShortLE();
|
| 1014 | }
|
| 1015 |
|
| 1016 | @Override
|
| 1017 | public int readUnsignedShort() {
|
| 1018 | return this.source.readUnsignedShort();
|
| 1019 | }
|
| 1020 |
|
| 1021 | @Override
|
| 1022 | public int readUnsignedShortLE() {
|
| 1023 | return this.source.readUnsignedShortLE();
|
| 1024 | }
|
| 1025 |
|
| 1026 | @Override
|
| 1027 | public int readMedium() {
|
| 1028 | return this.source.readMedium();
|
| 1029 | }
|
| 1030 |
|
| 1031 | @Override
|
| 1032 | public int readMediumLE() {
|
| 1033 | return this.source.readMediumLE();
|
| 1034 | }
|
| 1035 |
|
| 1036 | @Override
|
| 1037 | public int readUnsignedMedium() {
|
| 1038 | return this.source.readUnsignedMedium();
|
| 1039 | }
|
| 1040 |
|
| 1041 | @Override
|
| 1042 | public int readUnsignedMediumLE() {
|
| 1043 | return this.source.readUnsignedMediumLE();
|
| 1044 | }
|
| 1045 |
|
| 1046 | @Override
|
| 1047 | public int readInt() {
|
| 1048 | return this.source.readInt();
|
| 1049 | }
|
| 1050 |
|
| 1051 | @Override
|
| 1052 | public int readIntLE() {
|
| 1053 | return this.source.readIntLE();
|
| 1054 | }
|
| 1055 |
|
| 1056 | @Override
|
| 1057 | public long readUnsignedInt() {
|
| 1058 | return this.source.readUnsignedInt();
|
| 1059 | }
|
| 1060 |
|
| 1061 | @Override
|
| 1062 | public long readUnsignedIntLE() {
|
| 1063 | return this.source.readUnsignedIntLE();
|
| 1064 | }
|
| 1065 |
|
| 1066 | @Override
|
| 1067 | public long readLong() {
|
| 1068 | return this.source.readLong();
|
| 1069 | }
|
| 1070 |
|
| 1071 | @Override
|
| 1072 | public long readLongLE() {
|
| 1073 | return this.source.readLongLE();
|
| 1074 | }
|
| 1075 |
|
| 1076 | @Override
|
| 1077 | public char readChar() {
|
| 1078 | return this.source.readChar();
|
| 1079 | }
|
| 1080 |
|
| 1081 | @Override
|
| 1082 | public float readFloat() {
|
| 1083 | return this.source.readFloat();
|
| 1084 | }
|
| 1085 |
|
| 1086 | @Override
|
| 1087 | public double readDouble() {
|
| 1088 | return this.source.readDouble();
|
| 1089 | }
|
| 1090 |
|
| 1091 | @Override
|
| 1092 | public ByteBuf readBytes(final int length) {
|
| 1093 | return this.source.readBytes(length);
|
| 1094 | }
|
| 1095 |
|
| 1096 | @Override
|
| 1097 | public ByteBuf readSlice(final int length) {
|
| 1098 | return this.source.readSlice(length);
|
| 1099 | }
|
| 1100 |
|
| 1101 | @Override
|
| 1102 | public ByteBuf readRetainedSlice(final int length) {
|
| 1103 | return this.source.readRetainedSlice(length);
|
| 1104 | }
|
| 1105 |
|
| 1106 | public FriendlyByteBuf readBytes(final ByteBuf dst) {
|
| 1107 | this.source.readBytes(dst);
|
| 1108 | return this;
|
| 1109 | }
|
| 1110 |
|
| 1111 | public FriendlyByteBuf readBytes(final ByteBuf dst, final int length) {
|
| 1112 | this.source.readBytes(dst, length);
|
| 1113 | return this;
|
| 1114 | }
|
| 1115 |
|
| 1116 | public FriendlyByteBuf readBytes(final ByteBuf dst, final int dstIndex, final int length) {
|
| 1117 | this.source.readBytes(dst, dstIndex, length);
|
| 1118 | return this;
|
| 1119 | }
|
| 1120 |
|
| 1121 | public FriendlyByteBuf readBytes(final byte[] dst) {
|
| 1122 | this.source.readBytes(dst);
|
| 1123 | return this;
|
| 1124 | }
|
| 1125 |
|
| 1126 | public FriendlyByteBuf readBytes(final byte[] dst, final int dstIndex, final int length) {
|
| 1127 | this.source.readBytes(dst, dstIndex, length);
|
| 1128 | return this;
|
| 1129 | }
|
| 1130 |
|
| 1131 | public FriendlyByteBuf readBytes(final ByteBuffer dst) {
|
| 1132 | this.source.readBytes(dst);
|
| 1133 | return this;
|
| 1134 | }
|
| 1135 |
|
| 1136 | public FriendlyByteBuf readBytes(final OutputStream out, final int length) throws IOException {
|
| 1137 | this.source.readBytes(out, length);
|
| 1138 | return this;
|
| 1139 | }
|
| 1140 |
|
| 1141 | @Override
|
| 1142 | public int readBytes(final GatheringByteChannel out, final int length) throws IOException {
|
| 1143 | return this.source.readBytes(out, length);
|
| 1144 | }
|
| 1145 |
|
| 1146 | @Override
|
| 1147 | public CharSequence readCharSequence(final int length, final Charset charset) {
|
| 1148 | return this.source.readCharSequence(length, charset);
|
| 1149 | }
|
| 1150 |
|
| 1151 | @Override
|
| 1152 | public String readString(final int length, final Charset charset) {
|
| 1153 | return this.source.readString(length, charset);
|
| 1154 | }
|
| 1155 |
|
| 1156 | @Override
|
| 1157 | public int readBytes(final FileChannel out, final long position, final int length) throws IOException {
|
| 1158 | return this.source.readBytes(out, position, length);
|
| 1159 | }
|
| 1160 |
|
| 1161 | public FriendlyByteBuf skipBytes(final int length) {
|
| 1162 | this.source.skipBytes(length);
|
| 1163 | return this;
|
| 1164 | }
|
| 1165 |
|
| 1166 | public FriendlyByteBuf writeBoolean(final boolean value) {
|
| 1167 | this.source.writeBoolean(value);
|
| 1168 | return this;
|
| 1169 | }
|
| 1170 |
|
| 1171 | public FriendlyByteBuf writeByte(final int value) {
|
| 1172 | this.source.writeByte(value);
|
| 1173 | return this;
|
| 1174 | }
|
| 1175 |
|
| 1176 | public FriendlyByteBuf writeShort(final int value) {
|
| 1177 | this.source.writeShort(value);
|
| 1178 | return this;
|
| 1179 | }
|
| 1180 |
|
| 1181 | public FriendlyByteBuf writeShortLE(final int value) {
|
| 1182 | this.source.writeShortLE(value);
|
| 1183 | return this;
|
| 1184 | }
|
| 1185 |
|
| 1186 | public FriendlyByteBuf writeMedium(final int value) {
|
| 1187 | this.source.writeMedium(value);
|
| 1188 | return this;
|
| 1189 | }
|
| 1190 |
|
| 1191 | public FriendlyByteBuf writeMediumLE(final int value) {
|
| 1192 | this.source.writeMediumLE(value);
|
| 1193 | return this;
|
| 1194 | }
|
| 1195 |
|
| 1196 | public FriendlyByteBuf writeInt(final int value) {
|
| 1197 | this.source.writeInt(value);
|
| 1198 | return this;
|
| 1199 | }
|
| 1200 |
|
| 1201 | public FriendlyByteBuf writeIntLE(final int value) {
|
| 1202 | this.source.writeIntLE(value);
|
| 1203 | return this;
|
| 1204 | }
|
| 1205 |
|
| 1206 | public FriendlyByteBuf writeLong(final long value) {
|
| 1207 | this.source.writeLong(value);
|
| 1208 | return this;
|
| 1209 | }
|
| 1210 |
|
| 1211 | public FriendlyByteBuf writeLongLE(final long value) {
|
| 1212 | this.source.writeLongLE(value);
|
| 1213 | return this;
|
| 1214 | }
|
| 1215 |
|
| 1216 | public FriendlyByteBuf writeChar(final int value) {
|
| 1217 | this.source.writeChar(value);
|
| 1218 | return this;
|
| 1219 | }
|
| 1220 |
|
| 1221 | public FriendlyByteBuf writeFloat(final float value) {
|
| 1222 | this.source.writeFloat(value);
|
| 1223 | return this;
|
| 1224 | }
|
| 1225 |
|
| 1226 | public FriendlyByteBuf writeDouble(final double value) {
|
| 1227 | this.source.writeDouble(value);
|
| 1228 | return this;
|
| 1229 | }
|
| 1230 |
|
| 1231 | public FriendlyByteBuf writeBytes(final ByteBuf src) {
|
| 1232 | this.source.writeBytes(src);
|
| 1233 | return this;
|
| 1234 | }
|
| 1235 |
|
| 1236 | public FriendlyByteBuf writeBytes(final ByteBuf src, final int length) {
|
| 1237 | this.source.writeBytes(src, length);
|
| 1238 | return this;
|
| 1239 | }
|
| 1240 |
|
| 1241 | public FriendlyByteBuf writeBytes(final ByteBuf src, final int srcIndex, final int length) {
|
| 1242 | this.source.writeBytes(src, srcIndex, length);
|
| 1243 | return this;
|
| 1244 | }
|
| 1245 |
|
| 1246 | public FriendlyByteBuf writeBytes(final byte[] src) {
|
| 1247 | this.source.writeBytes(src);
|
| 1248 | return this;
|
| 1249 | }
|
| 1250 |
|
| 1251 | public FriendlyByteBuf writeBytes(final byte[] src, final int srcIndex, final int length) {
|
| 1252 | this.source.writeBytes(src, srcIndex, length);
|
| 1253 | return this;
|
| 1254 | }
|
| 1255 |
|
| 1256 | public FriendlyByteBuf writeBytes(final ByteBuffer src) {
|
| 1257 | this.source.writeBytes(src);
|
| 1258 | return this;
|
| 1259 | }
|
| 1260 |
|
| 1261 | @Override
|
| 1262 | public int writeBytes(final InputStream in, final int length) throws IOException {
|
| 1263 | return this.source.writeBytes(in, length);
|
| 1264 | }
|
| 1265 |
|
| 1266 | @Override
|
| 1267 | public int writeBytes(final ScatteringByteChannel in, final int length) throws IOException {
|
| 1268 | return this.source.writeBytes(in, length);
|
| 1269 | }
|
| 1270 |
|
| 1271 | @Override
|
| 1272 | public int writeBytes(final FileChannel in, final long position, final int length) throws IOException {
|
| 1273 | return this.source.writeBytes(in, position, length);
|
| 1274 | }
|
| 1275 |
|
| 1276 | public FriendlyByteBuf writeZero(final int length) {
|
| 1277 | this.source.writeZero(length);
|
| 1278 | return this;
|
| 1279 | }
|
| 1280 |
|
| 1281 | @Override
|
| 1282 | public int writeCharSequence(final CharSequence sequence, final Charset charset) {
|
| 1283 | return this.source.writeCharSequence(sequence, charset);
|
| 1284 | }
|
| 1285 |
|
| 1286 | @Override
|
| 1287 | public int indexOf(final int fromIndex, final int toIndex, final byte value) {
|
| 1288 | return this.source.indexOf(fromIndex, toIndex, value);
|
| 1289 | }
|
| 1290 |
|
| 1291 | @Override
|
| 1292 | public int bytesBefore(final byte value) {
|
| 1293 | return this.source.bytesBefore(value);
|
| 1294 | }
|
| 1295 |
|
| 1296 | @Override
|
| 1297 | public int bytesBefore(final int length, final byte value) {
|
| 1298 | return this.source.bytesBefore(length, value);
|
| 1299 | }
|
| 1300 |
|
| 1301 | @Override
|
| 1302 | public int bytesBefore(final int index, final int length, final byte value) {
|
| 1303 | return this.source.bytesBefore(index, length, value);
|
| 1304 | }
|
| 1305 |
|
| 1306 | @Override
|
| 1307 | public int forEachByte(final ByteProcessor processor) {
|
| 1308 | return this.source.forEachByte(processor);
|
| 1309 | }
|
| 1310 |
|
| 1311 | @Override
|
| 1312 | public int forEachByte(final int index, final int length, final ByteProcessor processor) {
|
| 1313 | return this.source.forEachByte(index, length, processor);
|
| 1314 | }
|
| 1315 |
|
| 1316 | @Override
|
| 1317 | public int forEachByteDesc(final ByteProcessor processor) {
|
| 1318 | return this.source.forEachByteDesc(processor);
|
| 1319 | }
|
| 1320 |
|
| 1321 | @Override
|
| 1322 | public int forEachByteDesc(final int index, final int length, final ByteProcessor processor) {
|
| 1323 | return this.source.forEachByteDesc(index, length, processor);
|
| 1324 | }
|
| 1325 |
|
| 1326 | @Override
|
| 1327 | public ByteBuf copy() {
|
| 1328 | return this.source.copy();
|
| 1329 | }
|
| 1330 |
|
| 1331 | @Override
|
| 1332 | public ByteBuf copy(final int index, final int length) {
|
| 1333 | return this.source.copy(index, length);
|
| 1334 | }
|
| 1335 |
|
| 1336 | @Override
|
| 1337 | public ByteBuf slice() {
|
| 1338 | return this.source.slice();
|
| 1339 | }
|
| 1340 |
|
| 1341 | @Override
|
| 1342 | public ByteBuf retainedSlice() {
|
| 1343 | return this.source.retainedSlice();
|
| 1344 | }
|
| 1345 |
|
| 1346 | @Override
|
| 1347 | public ByteBuf slice(final int index, final int length) {
|
| 1348 | return this.source.slice(index, length);
|
| 1349 | }
|
| 1350 |
|
| 1351 | @Override
|
| 1352 | public ByteBuf retainedSlice(final int index, final int length) {
|
| 1353 | return this.source.retainedSlice(index, length);
|
| 1354 | }
|
| 1355 |
|
| 1356 | @Override
|
| 1357 | public ByteBuf duplicate() {
|
| 1358 | return this.source.duplicate();
|
| 1359 | }
|
| 1360 |
|
| 1361 | @Override
|
| 1362 | public ByteBuf retainedDuplicate() {
|
| 1363 | return this.source.retainedDuplicate();
|
| 1364 | }
|
| 1365 |
|
| 1366 | @Override
|
| 1367 | public int nioBufferCount() {
|
| 1368 | return this.source.nioBufferCount();
|
| 1369 | }
|
| 1370 |
|
| 1371 | @Override
|
| 1372 | public ByteBuffer nioBuffer() {
|
| 1373 | return this.source.nioBuffer();
|
| 1374 | }
|
| 1375 |
|
| 1376 | @Override
|
| 1377 | public ByteBuffer nioBuffer(final int index, final int length) {
|
| 1378 | return this.source.nioBuffer(index, length);
|
| 1379 | }
|
| 1380 |
|
| 1381 | @Override
|
| 1382 | public ByteBuffer internalNioBuffer(final int index, final int length) {
|
| 1383 | return this.source.internalNioBuffer(index, length);
|
| 1384 | }
|
| 1385 |
|
| 1386 | @Override
|
| 1387 | public ByteBuffer[] nioBuffers() {
|
| 1388 | return this.source.nioBuffers();
|
| 1389 | }
|
| 1390 |
|
| 1391 | @Override
|
| 1392 | public ByteBuffer[] nioBuffers(final int index, final int length) {
|
| 1393 | return this.source.nioBuffers(index, length);
|
| 1394 | }
|
| 1395 |
|
| 1396 | @Override
|
| 1397 | public boolean hasArray() {
|
| 1398 | return this.source.hasArray();
|
| 1399 | }
|
| 1400 |
|
| 1401 | @Override
|
| 1402 | public byte[] array() {
|
| 1403 | return this.source.array();
|
| 1404 | }
|
| 1405 |
|
| 1406 | @Override
|
| 1407 | public int arrayOffset() {
|
| 1408 | return this.source.arrayOffset();
|
| 1409 | }
|
| 1410 |
|
| 1411 | @Override
|
| 1412 | public boolean hasMemoryAddress() {
|
| 1413 | return this.source.hasMemoryAddress();
|
| 1414 | }
|
| 1415 |
|
| 1416 | @Override
|
| 1417 | public long memoryAddress() {
|
| 1418 | return this.source.memoryAddress();
|
| 1419 | }
|
| 1420 |
|
| 1421 | @Override
|
| 1422 | public String toString(final Charset charset) {
|
| 1423 | return this.source.toString(charset);
|
| 1424 | }
|
| 1425 |
|
| 1426 | @Override
|
| 1427 | public String toString(final int index, final int length, final Charset charset) {
|
| 1428 | return this.source.toString(index, length, charset);
|
| 1429 | }
|
| 1430 |
|
| 1431 | @Override
|
| 1432 | public int hashCode() {
|
| 1433 | return this.source.hashCode();
|
| 1434 | }
|
| 1435 |
|
| 1436 | @Override
|
| 1437 | public boolean equals(final Object obj) {
|
| 1438 | return this.source.equals(obj);
|
| 1439 | }
|
| 1440 |
|
| 1441 | @Override
|
| 1442 | public int compareTo(final ByteBuf buffer) {
|
| 1443 | return this.source.compareTo(buffer);
|
| 1444 | }
|
| 1445 |
|
| 1446 | @Override
|
| 1447 | public String toString() {
|
| 1448 | return this.source.toString();
|
| 1449 | }
|
| 1450 |
|
| 1451 | public FriendlyByteBuf retain(final int increment) {
|
| 1452 | this.source.retain(increment);
|
| 1453 | return this;
|
| 1454 | }
|
| 1455 |
|
| 1456 | public FriendlyByteBuf retain() {
|
| 1457 | this.source.retain();
|
| 1458 | return this;
|
| 1459 | }
|
| 1460 |
|
| 1461 | public FriendlyByteBuf touch() {
|
| 1462 | this.source.touch();
|
| 1463 | return this;
|
| 1464 | }
|
| 1465 |
|
| 1466 | public FriendlyByteBuf touch(final Object hint) {
|
| 1467 | this.source.touch(hint);
|
| 1468 | return this;
|
| 1469 | }
|
| 1470 |
|
| 1471 | @Override
|
| 1472 | public int refCnt() {
|
| 1473 | return this.source.refCnt();
|
| 1474 | }
|
| 1475 |
|
| 1476 | @Override
|
| 1477 | public boolean release() {
|
| 1478 | return this.source.release();
|
| 1479 | }
|
| 1480 |
|
| 1481 | @Override
|
| 1482 | public boolean release(final int decrement) {
|
| 1483 | return this.source.release(decrement);
|
| 1484 | }
|
| 1485 | }
|
| 1486 |
|