Skip to content
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

Open
wants to merge 4 commits into
base: 2.0
Choose a base branch
from

Conversation

ShadowOfHeaven-Me
Copy link

The title explains it

Copy link
Contributor

@booky10 booky10 left a 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
Copy link
Contributor

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

Copy link
Author

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
image

Copy link
Author

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

Copy link
Contributor

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)

Copy link
Contributor

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());
Copy link
Contributor

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

Copy link
Contributor

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)

Comment on lines 77 to 81
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;
Copy link
Contributor

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);
Copy link
Contributor

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)since 1.13 (see last comment for reason)
    before that, this is just a byte: the first 4 bits determine the type (mask 0xF0) and the last 4 bits determine the direction (mask 0x0F)
  • you should maybe add & 0xF after the last this.readByte(), like done in vanilla
    also, this is only present since 1.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 since 1.13
  • maybe split this up into multiple lines with comments stating what you're reading

Comment on lines 103 to 104
writeVarInt(icons.length);
for (MapIcon icon : icons) {
Copy link
Contributor

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;
Copy link
Contributor

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() {
Copy link
Contributor

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) {
Copy link
Contributor

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

Comment on lines 182 to 218
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;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 41 to 45
//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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is wrong

Copy link
Author

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

@retrooper
Copy link
Owner

@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. 👍

@booky10
Copy link
Contributor

booky10 commented May 9, 2024

I can also PR to his fork

@retrooper
Copy link
Owner

If he grants you permission to write to it.

@booky10
Copy link
Contributor

booky10 commented May 10, 2024

@ShadowOfHeaven-Me I've created a PR on your fork: ShadowOfHeaven-Me#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants