1717 */
1818package com .viaversion .viaversion .protocols .v1_21_9to1_21_11 ;
1919
20+ import com .viaversion .nbt .tag .ByteTag ;
21+ import com .viaversion .nbt .tag .CompoundTag ;
22+ import com .viaversion .nbt .tag .IntTag ;
23+ import com .viaversion .nbt .tag .NumberTag ;
24+ import com .viaversion .nbt .tag .Tag ;
2025import com .viaversion .viaversion .api .connection .UserConnection ;
2126import com .viaversion .viaversion .api .data .MappingData ;
2227import com .viaversion .viaversion .api .data .MappingDataBase ;
5055import com .viaversion .viaversion .rewriter .StatisticsRewriter ;
5156import com .viaversion .viaversion .rewriter .TagRewriter ;
5257import com .viaversion .viaversion .rewriter .text .NBTComponentRewriter ;
58+ import java .util .function .Function ;
59+ import org .checkerframework .checker .nullness .qual .Nullable ;
5360
5461import static com .viaversion .viaversion .util .ProtocolUtil .packetTypeMap ;
5562
@@ -71,6 +78,25 @@ public Protocol1_21_9To1_21_11() {
7178 protected void registerPackets () {
7279 super .registerPackets ();
7380
81+ registryDataRewriter .addHandler ("dimension_type" , (key , tag ) -> {
82+ final ByteTag trueTag = new ByteTag ((byte ) 1 );
83+ final CompoundTag attributes = new CompoundTag ();
84+ tag .put ("attributes" , attributes );
85+ moveAttribute (tag , attributes , "cloud_height" , "visual/cloud_height" , Function .identity (), null );
86+ moveAttribute (tag , attributes , "has_raids" , "gameplay/can_start_raid" , Function .identity (), trueTag );
87+ moveAttribute (tag , attributes , "piglin_safe" , "gameplay/piglins_zombify" , attributeTag -> ((NumberTag ) attributeTag ).asBoolean () ? ByteTag .ZERO : trueTag , ByteTag .ZERO );
88+ moveAttribute (tag , attributes , "respawn_anchor_works" , "gameplay/respawn_anchor_works" , Function .identity (), trueTag );
89+ moveAttribute (tag , attributes , "ultrawarm" , "gameplay/fast_lava" , Function .identity (), ByteTag .ZERO );
90+ moveAttribute (tag , attributes , "ultrawarm" , "gameplay/water_evaporates" , Function .identity (), ByteTag .ZERO );
91+ });
92+ registryDataRewriter .addHandler ("worldgen/biome" , (key , tag ) -> {
93+ final CompoundTag effects = tag .getCompoundTag ("effects" );
94+ final CompoundTag attributes = new CompoundTag ();
95+ tag .put ("attributes" , attributes );
96+ moveAttribute (effects , attributes , "sky_color" , "visual/sky_color" , Function .identity (), new IntTag (0 ));
97+ moveAttribute (effects , attributes , "water_fog_color" , "visual/water_fog_color" , Function .identity (), new IntTag (-16448205 ));
98+ moveAttribute (effects , attributes , "fog_color" , "visual/fog_color" , Function .identity (), new IntTag (0 ));
99+ });
74100 registerClientbound (ClientboundConfigurationPackets1_21_9 .REGISTRY_DATA , registryDataRewriter ::handle );
75101
76102 tagRewriter .registerGeneric (ClientboundPackets1_21_9 .UPDATE_TAGS );
@@ -149,6 +175,19 @@ protected void onMappingDataLoaded() {
149175 super .onMappingDataLoaded ();
150176 }
151177
178+ private void moveAttribute (
179+ final CompoundTag baseTag , final CompoundTag attributes ,
180+ final String key , final String mappedKey ,
181+ final Function <Tag , Tag > tagMapper , @ Nullable final Tag defaultTag
182+ ) {
183+ final Tag attributeTag = baseTag .get (key );
184+ if (attributeTag != null ) {
185+ attributes .put (mappedKey , tagMapper .apply (attributeTag ));
186+ } else if (defaultTag != null ) {
187+ attributes .put (mappedKey , defaultTag );
188+ }
189+ }
190+
152191 @ Override
153192 public void init (final UserConnection connection ) {
154193 addEntityTracker (connection , new EntityTrackerBase (connection , EntityTypes1_21_11 .PLAYER ));
0 commit comments