HiddenByteBuf .java

net.minecraft.network.HiddenByteBuf (record): members: contents, refCnt, retain, touch, release, unpack, pack. imports: ReferenceCounted, ByteBufUtil.

net.minecraft.networkrecord55 linescommon1.2 KB

Implements

API Surface (9)

Object pack(final Object msg)
Object unpack(final Object msg)
int refCnt()
HiddenByteBuf retain()
HiddenByteBuf retain(final int increment)
HiddenByteBuf touch()
HiddenByteBuf touch(final Object hint)
boolean release()
boolean release(final int decrement)

Full Source

HiddenByteBuf.java55 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.network;
2
3
import io.netty.buffer.ByteBuf;
4
import io.netty.buffer.ByteBufUtil;
5
import io.netty.util.ReferenceCounted;
6
7
public record HiddenByteBuf(ByteBuf contents) implements ReferenceCounted {
8
	public HiddenByteBuf(final ByteBuf contents) {
9
		this.contents = ByteBufUtil.ensureAccessible(contents);
10
	}
11
12
	public static Object pack(final Object msg) {
13
		return msg instanceof ByteBuf buf ? new HiddenByteBuf(buf) : msg;
14
	}
15
16
	public static Object unpack(final Object msg) {
17
		return msg instanceof HiddenByteBuf buf ? ByteBufUtil.ensureAccessible(buf.contents) : msg;
18
	}
19
20
	@Override
21
	public int refCnt() {
22
		return this.contents.refCnt();
23
	}
24
25
	public HiddenByteBuf retain() {
26
		this.contents.retain();
27
		return this;
28
	}
29
30
	public HiddenByteBuf retain(final int increment) {
31
		this.contents.retain(increment);
32
		return this;
33
	}
34
35
	public HiddenByteBuf touch() {
36
		this.contents.touch();
37
		return this;
38
	}
39
40
	public HiddenByteBuf touch(final Object hint) {
41
		this.contents.touch(hint);
42
		return this;
43
	}
44
45
	@Override
46
	public boolean release() {
47
		return this.contents.release();
48
	}
49
50
	@Override
51
	public boolean release(final int decrement) {
52
		return this.contents.release(decrement);
53
	}
54
}
55

Decompiled Minecraft 26.3 source of HiddenByteBuf (net/minecraft/network/HiddenByteBuf.java) with Mojang official mappings, stored verbatim on the site.