-
-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added the missing WrapperPlayServerMapData #760
base: 2.0
Are you sure you want to change the base?
Added the missing WrapperPlayServerMapData #760
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are a few issues with this packet wrapper, especially regarding version compatibility
also, is this class being packaged in shadow.utils.holders.packet.custom
intended?
if (hasDisplayName) writeComponent(icon.getDisplayName()); | ||
} | ||
} else if (version.isOlderThanOrEquals(ServerVersion.V_1_19)) | ||
writeVarInt(0);//The array is not optional on 1.19 and below, so if it's missing, we have to at least write that it's length is 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its also optional in 1.19 and below, this is wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not wrong, in 1.19 and below you at least the array's size needs to be written if it's empty, unlike 1.19.2 and above.
https://wiki.vg/index.php?title=Protocol&oldid=17753#Map_Data 1.19
https://wiki.vg/index.php?title=Protocol&oldid=18067#Map_Data 1.19.2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but I guess the comment is "present only if previous boolean is true", so I'll delete that part
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wiki.vg is wrong there, there wasnt a single change to the packet between 1.19 and 1.19.2
it changed between 1.16.5 and 1.17 and you also dont account for it properly (you still write the optional boolean), see other comment #760 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see https://haste.pinofett.de/9n8fvvep52.diff for diff in decompiled source between 1.16.5 and 1.17
writeVarInt(icon.getType().getId()); | ||
writeByte(icon.getX()); | ||
writeByte(icon.getZ()); | ||
writeByte(icon.getDirection()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should maybe add & 0xF
, like done in vanilla
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, this is only present since 1.13
- in older versions this is OR-ed into the first value (see comment above)
int length = this.readVarInt(); | ||
MapIcon[] icons = new MapIcon[length]; | ||
for (int i = 0; i < length; i++) | ||
icons[i] = new MapIcon(MapIconType.ofId(this.readVarInt()), this.readByte(), this.readByte(), this.readByte(), this.readBoolean() ? this.readComponent() : null); | ||
this.icons = icons; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be converted to an readList
call, if you change the icons
field to List<MapIcon>
int length = this.readVarInt(); | ||
MapIcon[] icons = new MapIcon[length]; | ||
for (int i = 0; i < length; i++) | ||
icons[i] = new MapIcon(MapIconType.ofId(this.readVarInt()), this.readByte(), this.readByte(), this.readByte(), this.readBoolean() ? this.readComponent() : null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- the type can be read using
this.readMappedEntity(MapDecorationTypes::getById)
since1.13
(see last comment for reason)
before that, this is just a byte: the first 4 bits determine thetype
(mask0xF0
) and the last 4 bits determine thedirection
(mask0x0F
) - you should maybe add
& 0xF
after the lastthis.readByte()
, like done in vanilla
also, this is only present since1.13
- in older versions this is OR-ed into the first value (see comment above) - the name can be read using
this.readOptional(PacketWrapper::readComponent)
also, this is only present since1.13
- maybe split this up into multiple lines with comments stating what you're reading
writeVarInt(icons.length); | ||
for (MapIcon icon : icons) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be converted to an writeList
call, if you change the icons field to List<MapIcon>
|
||
private MapIconType type; | ||
private byte x, z, direction; | ||
private Component displayName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is an @Nullable
annotation missing here
this.type = type; | ||
} | ||
|
||
public Component getDisplayName() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is an @Nullable
annotation missing here
return displayName; | ||
} | ||
|
||
public void setDisplayName(Component displayName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is an @Nullable
annotation missing here
public enum MapIconType { | ||
WHITE_ARROW, | ||
GREEN_ARROW, | ||
RED_ARROW, | ||
BLUE_ARROW, | ||
WHITE_CROSS, | ||
RED_POINTER, | ||
WHITE_CIRCLE, | ||
SMALL_WHITE_CIRCLE, | ||
MANSION, | ||
TEMPLE, | ||
WHITE_BANNER, | ||
ORANGE_BANNER, | ||
MAGENTA_BANNER, | ||
LIGHT_BLUE_BANNER, | ||
YELLOW_BANNER, | ||
LIME_BANNER, | ||
PINK_BANNER, | ||
GRAY_BANNER, | ||
LIGHT_GRAY_BANNER, | ||
CYAN_BANNER, | ||
PURPLE_BANNER, | ||
BLUE_BANNER, | ||
BROWN_BANNER, | ||
GREEN_BANNER, | ||
RED_BANNER, | ||
BLACK_BANNER, | ||
TREASURE_MARKER; | ||
|
||
public int getId() { | ||
return this.ordinal(); | ||
} | ||
|
||
public static MapIconType ofId(int id) { | ||
return id < MapIconType.values().length && id >= 0 ? MapIconType.values()[id] : null; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this thing should not be added, there is already a registry for this: https://github.com/retrooper/packetevents/blob/ba21fa9a8b1055f8398d94c196c1d6a79cf04fbf/api/src/main/java/com/github/retrooper/packetevents/protocol/item/mapdecoration/MapDecorationTypes.java
//The only change occurred here, where the array's length became optional | ||
//https://wiki.vg/index.php?title=Protocol&oldid=17753#Map_Data 1.19 | ||
//https://wiki.vg/index.php?title=Protocol&oldid=18067#Map_Data 1.19.2 | ||
|
||
//hasIcons can also be called trackingPositions, but both ultimately do the same |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. I'll trust you'll handle the appriopriate changes, since you seem more acquainted with the version changes of this packet
@ShadowOfHeaven-Me Simplest is if you grant @booky10 permission to work on the PR (your fork), and booky if you have time you can work on it, if not I would. Let me know booky. 👍 |
I can also PR to his fork |
If he grants you permission to write to it. |
@ShadowOfHeaven-Me I've created a PR on your fork: ShadowOfHeaven-Me#1 |
Fix map data wrapper version compat
The title explains it