ClientboundMerchantOffersPacket .java

net.minecraft.network.protocol.game.ClientboundMerchantOffersPacket (class): members: getVillagerLevel, villagerLevel, showProgress, villagerXp, offers.

net.minecraft.network.protocol.gameclass82 linescommon2.5 KB

Implements

API Surface (8)

PacketType<ClientboundMerchantOffersPacket> type()
void handle(final ClientGamePacketListener listener)
int getContainerId()
MerchantOffers getOffers()
int getVillagerLevel()
int getVillagerXp()
boolean showProgress()
boolean canRestock()

Fields & Constants (7)

STREAM_CODEC
containerId
offers
villagerLevel
villagerXp
showProgress
canRestock

Same Package (197)

Full Source

ClientboundMerchantOffersPacket.java82 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.network.protocol.game;
2
3
import net.minecraft.network.RegistryFriendlyByteBuf;
4
import net.minecraft.network.codec.StreamCodec;
5
import net.minecraft.network.protocol.Packet;
6
import net.minecraft.network.protocol.PacketType;
7
import net.minecraft.world.item.trading.MerchantOffers;
8
9
public class ClientboundMerchantOffersPacket implements Packet<ClientGamePacketListener> {
10
	public static final StreamCodec<RegistryFriendlyByteBuf, ClientboundMerchantOffersPacket> STREAM_CODEC = Packet.codec(
11
		ClientboundMerchantOffersPacket::write, ClientboundMerchantOffersPacket::new
12
	);
13
	private final int containerId;
14
	private final MerchantOffers offers;
15
	private final int villagerLevel;
16
	private final int villagerXp;
17
	private final boolean showProgress;
18
	private final boolean canRestock;
19
20
	public ClientboundMerchantOffersPacket(
21
		final int containerId, final MerchantOffers offers, final int merchantLevel, final int merchantXp, final boolean showProgress, final boolean canRestock
22
	) {
23
		this.containerId = containerId;
24
		this.offers = offers.copy();
25
		this.villagerLevel = merchantLevel;
26
		this.villagerXp = merchantXp;
27
		this.showProgress = showProgress;
28
		this.canRestock = canRestock;
29
	}
30
31
	private ClientboundMerchantOffersPacket(final RegistryFriendlyByteBuf input) {
32
		this.containerId = input.readContainerId();
33
		this.offers = MerchantOffers.STREAM_CODEC.decode(input);
34
		this.villagerLevel = input.readVarInt();
35
		this.villagerXp = input.readVarInt();
36
		this.showProgress = input.readBoolean();
37
		this.canRestock = input.readBoolean();
38
	}
39
40
	private void write(final RegistryFriendlyByteBuf output) {
41
		output.writeContainerId(this.containerId);
42
		MerchantOffers.STREAM_CODEC.encode(output, this.offers);
43
		output.writeVarInt(this.villagerLevel);
44
		output.writeVarInt(this.villagerXp);
45
		output.writeBoolean(this.showProgress);
46
		output.writeBoolean(this.canRestock);
47
	}
48
49
	@Override
50
	public PacketType<ClientboundMerchantOffersPacket> type() {
51
		return GamePacketTypes.CLIENTBOUND_MERCHANT_OFFERS;
52
	}
53
54
	public void handle(final ClientGamePacketListener listener) {
55
		listener.handleMerchantOffers(this);
56
	}
57
58
	public int getContainerId() {
59
		return this.containerId;
60
	}
61
62
	public MerchantOffers getOffers() {
63
		return this.offers;
64
	}
65
66
	public int getVillagerLevel() {
67
		return this.villagerLevel;
68
	}
69
70
	public int getVillagerXp() {
71
		return this.villagerXp;
72
	}
73
74
	public boolean showProgress() {
75
		return this.showProgress;
76
	}
77
78
	public boolean canRestock() {
79
		return this.canRestock;
80
	}
81
}
82

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