1818package com .viaversion .viaversion .protocols .v1_21_5to1_21_6 .rewriter ;
1919
2020import com .viaversion .nbt .tag .CompoundTag ;
21+ import com .viaversion .viaversion .api .connection .UserConnection ;
2122import com .viaversion .viaversion .api .minecraft .RegistryEntry ;
2223import com .viaversion .viaversion .api .minecraft .entities .EntityType ;
2324import com .viaversion .viaversion .api .minecraft .entities .EntityTypes1_21_6 ;
3435import com .viaversion .viaversion .protocols .v1_21_5to1_21_6 .storage .SneakStorage ;
3536import com .viaversion .viaversion .rewriter .EntityRewriter ;
3637import com .viaversion .viaversion .rewriter .RegistryDataRewriter ;
38+ import com .viaversion .viaversion .util .Key ;
3739
3840public final class EntityPacketRewriter1_21_6 extends EntityRewriter <ClientboundPacket1_21_5 , Protocol1_21_5To1_21_6 > {
3941
@@ -51,7 +53,32 @@ public void registerPackets() {
5153 registerLogin1_20_5 (ClientboundPackets1_21_5 .LOGIN );
5254 registerRespawn1_20_5 (ClientboundPackets1_21_5 .RESPAWN );
5355
54- final RegistryDataRewriter registryDataRewriter = new RegistryDataRewriter (protocol );
56+ final RegistryDataRewriter registryDataRewriter = new RegistryDataRewriter (protocol ) {
57+ @ Override
58+ public RegistryEntry [] handle (final UserConnection connection , final String key , final RegistryEntry [] entries ) {
59+ if (!"dimension_type" .equals (key )) {
60+ return super .handle (connection , key , entries );
61+ }
62+ for (final RegistryEntry entry : entries ) {
63+ if (entry .tag () == null ) {
64+ continue ; // client will use its own defaults
65+ }
66+ // the client will render clouds if effects aren't set to either the_nether or the_end
67+ final CompoundTag tag = (CompoundTag ) entry .tag ();
68+ String effects = tag .getString ("effects" );
69+ if (effects != null ) {
70+ effects = Key .stripMinecraftNamespace (effects );
71+ if ("the_nether" .equals (effects ) || "the_end" .equals (effects )) {
72+ continue ; // don't show clouds
73+ }
74+ }
75+ if (!tag .contains ("cloud_height" )) {
76+ tag .putInt ("cloud_height" , 192 );
77+ }
78+ }
79+ return super .handle (connection , key , entries );
80+ }
81+ };
5582 protocol .registerClientbound (ClientboundConfigurationPackets1_21 .REGISTRY_DATA , registryDataRewriter ::handle );
5683
5784 protocol .registerFinishConfiguration (ClientboundConfigurationPackets1_21 .FINISH_CONFIGURATION , wrapper -> {
0 commit comments