From ed314d96f7f1bde3f366d722eb5413d43e24f306 Mon Sep 17 00:00:00 2001 From: shartte Date: Mon, 20 Sep 2021 17:51:29 +0200 Subject: [PATCH] Mappings for new BlockEntity update packet logic (#2692) * Mappings for new BlockEntity update packet logic * Apply suggestions from code review Co-authored-by: liach <7806504+liach@users.noreply.github.com> Co-authored-by: liach <7806504+liach@users.noreply.github.com> --- .../net/minecraft/block/entity/BlockEntity.mapping | 10 ++++++++++ .../packet/s2c/play/BlockEntityUpdateS2CPacket.mapping | 3 +++ 2 files changed, 13 insertions(+) diff --git a/mappings/net/minecraft/block/entity/BlockEntity.mapping b/mappings/net/minecraft/block/entity/BlockEntity.mapping index 8d6bd29bdb..9ca18c22df 100644 --- a/mappings/net/minecraft/block/entity/BlockEntity.mapping +++ b/mappings/net/minecraft/block/entity/BlockEntity.mapping @@ -34,6 +34,8 @@ CLASS net/minecraft/class_2586 net/minecraft/block/entity/BlockEntity METHOD method_11016 getPos ()Lnet/minecraft/class_2338; METHOD method_11017 getType ()Lnet/minecraft/class_2591; METHOD method_16887 toInitialChunkDataNbt ()Lnet/minecraft/class_2487; + COMMENT Serializes the state of this block entity that is observable by clients. It is sent alongside the initial chunk data, + COMMENT as well as when the block entity implements {@link #toUpdatePacket} and decides to use the default {@link BlockEntityUpdateS2CPacket}. METHOD method_31662 setWorld (Lnet/minecraft/class_1937;)V ARG 1 world METHOD method_31663 markDirty (Lnet/minecraft/class_1937;Lnet/minecraft/class_2338;Lnet/minecraft/class_2680;)V @@ -42,6 +44,14 @@ CLASS net/minecraft/class_2586 net/minecraft/block/entity/BlockEntity ARG 2 state METHOD method_31664 setCachedState (Lnet/minecraft/class_2680;)V ARG 1 state + METHOD method_38235 toUpdatePacket ()Lnet/minecraft/class_2596; + COMMENT Implement and return a packet that should be sent to players nearby when the observable state of + COMMENT this block entity changes. Return null to not send an update packet. + COMMENT

+ COMMENT If the data returned by {@link #toInitialChunkDataNbt initial chunk data} is suitable for updates, + COMMENT the following shortcut can be used to create an update packet: {@code BlockEntityUpdateS2CPacket.create(this)}. + COMMENT

+ COMMENT The NBT will be passed to {@link #readNbt} on the client. METHOD method_38238 writeIdToNbt (Lnet/minecraft/class_2487;Lnet/minecraft/class_2591;)V ARG 0 nbt ARG 1 type diff --git a/mappings/net/minecraft/network/packet/s2c/play/BlockEntityUpdateS2CPacket.mapping b/mappings/net/minecraft/network/packet/s2c/play/BlockEntityUpdateS2CPacket.mapping index 4a9c141da5..ac121645c9 100644 --- a/mappings/net/minecraft/network/packet/s2c/play/BlockEntityUpdateS2CPacket.mapping +++ b/mappings/net/minecraft/network/packet/s2c/play/BlockEntityUpdateS2CPacket.mapping @@ -4,9 +4,12 @@ CLASS net/minecraft/class_2622 net/minecraft/network/packet/s2c/play/BlockEntity FIELD field_12040 pos Lnet/minecraft/class_2338; METHOD (Lnet/minecraft/class_2338;Lnet/minecraft/class_2591;Lnet/minecraft/class_2487;)V ARG 1 pos + ARG 2 blockEntityType ARG 3 nbt METHOD (Lnet/minecraft/class_2540;)V ARG 1 buf METHOD method_11290 getNbt ()Lnet/minecraft/class_2487; METHOD method_11291 getBlockEntityType ()Lnet/minecraft/class_2591; METHOD method_11293 getPos ()Lnet/minecraft/class_2338; + METHOD method_38585 create (Lnet/minecraft/class_2586;)Lnet/minecraft/class_2622; + ARG 0 blockEntity