100100import java .util .logging .Level ;
101101import org .checkerframework .checker .nullness .qual .Nullable ;
102102
103- public final class ComponentRewriter1_20_5 <C extends ClientboundPacketType > extends ComponentRewriter <C > {
103+ public class ComponentRewriter1_20_5 <C extends ClientboundPacketType > extends ComponentRewriter <C > {
104104
105- private final Map <StructuredDataKey <?>, ConverterPair <?>> converters = new Reference2ObjectOpenHashMap <>();
106- private final StructuredDataType structuredDataType ;
105+ protected final Map <StructuredDataKey <?>, ConverterPair <?>> converters = new Reference2ObjectOpenHashMap <>();
106+ protected final StructuredDataType structuredDataType ;
107107
108108 /**
109109 * @param protocol protocol
@@ -327,7 +327,7 @@ public StructuredData<?> readFromTag(final String identifier, final Tag tag) {
327327 return readFromTag (key , id , tag );
328328 }
329329
330- private <T > StructuredData <T > readFromTag (final StructuredDataKey <T > key , final int id , final Tag tag ) {
330+ protected <T > StructuredData <T > readFromTag (final StructuredDataKey <T > key , final int id , final Tag tag ) {
331331 final TagConverter <T > converter = tagConverter (key );
332332 Preconditions .checkNotNull (converter , "No converter found for: %s" , key );
333333 return StructuredData .of (key , converter .convert (tag ), id );
@@ -338,7 +338,6 @@ private String mappedIdentifier(final int id) {
338338 }
339339
340340 // ---------------------------------------------------------------------------------------
341- // Conversion methods, can be overridden in future protocols to handle new changes
342341
343342 protected CompoundTag convertCustomData (final CompoundTag value ) {
344343 return value ;
@@ -601,8 +600,15 @@ protected CompoundTag convertPotionContents(final PotionContents value) {
601600 if (value .customColor () != null ) {
602601 tag .putInt ("custom_color" , value .customColor ());
603602 }
603+ final ListTag <CompoundTag > customEffects = new ListTag <>(CompoundTag .class );
604604 for (final PotionEffect effect : value .customEffects ()) {
605- convertPotionEffect (tag , effect );
605+ final CompoundTag effectTag = new CompoundTag ();
606+ convertPotionEffect (effectTag , effect );
607+ customEffects .add (effectTag );
608+ }
609+ tag .put ("custom_effects" , customEffects );
610+ if (value .customName () != null ) {
611+ tag .putString ("custom_name" , value .customName ());
606612 }
607613 return tag ;
608614 }
@@ -645,15 +651,14 @@ protected CompoundTag convertWritableBookContent(final FilterableString[] value)
645651
646652 protected CompoundTag convertWrittenBookContent (final WrittenBook value ) {
647653 final CompoundTag tag = new CompoundTag ();
648- convertFilterableString (tag , value .title (), 32 );
649- tag .putString ("author" , value .author ());
650- if (value .generation () != 0 ) {
651- tag .put ("generation" , convertIntRange (value .generation (), 0 , 3 ));
652- }
653654
654655 final CompoundTag title = new CompoundTag ();
655656 convertFilterableString (title , value .title (), 32 );
656657 tag .put ("title" , title );
658+ tag .putString ("author" , value .author ());
659+ if (value .generation () != 0 ) {
660+ tag .put ("generation" , convertIntRange (value .generation (), 0 , 3 ));
661+ }
657662
658663 final ListTag <CompoundTag > pagesTag = new ListTag <>(CompoundTag .class );
659664 for (final FilterableComponent page : value .pages ()) {
@@ -1123,17 +1128,17 @@ protected StringTag convertDyeColor(final Integer value) {
11231128
11241129 // ---------------------------------------------------------------------------------------
11251130
1126- private int checkIntRange (final int min , final int max , final int value ) {
1131+ protected int checkIntRange (final int min , final int max , final int value ) {
11271132 Preconditions .checkArgument (value >= min && value <= max , "Value out of range: " + value );
11281133 return value ;
11291134 }
11301135
1131- private float checkFloatRange (final float min , final float max , final float value ) {
1136+ protected float checkFloatRange (final float min , final float max , final float value ) {
11321137 Preconditions .checkArgument (value >= min && value <= max , "Value out of range: " + value );
11331138 return value ;
11341139 }
11351140
1136- private String checkStringRange (final int min , final int max , final String value ) {
1141+ protected String checkStringRange (final int min , final int max , final String value ) {
11371142 final int length = value .length ();
11381143 Preconditions .checkArgument (length >= min && length <= max , "Value out of range: " + value );
11391144 return value ;
0 commit comments