Fix map IDs casted as shorts
Before Minecraft 1.13, map IDs were limited to 32768. This is no longer the case. However, Magic still limit the IDs in the /mmap command.
This pull request removes the short casts around map IDs.
Demonstration below, assuming your server contains more than 32768 map IDs.
Before:
- Run
/mmap load https://upload.wikimedia.org/wikipedia/en/thumb/c/c3/Flag_of_France.svg/255px-Flag_of_France.svg.png. A map with id 33645 is loaded. - Because of
shortcasts, the given map has the ID -31891. So it's invalid and appears blank. - Run
/mmap give 33645. It doesn't work, the ID is considered invalid by Magic. - Run
/give @s minecraft:filled_map{map:33645}. It does work, because vanilla limit no longer exist.
After:
- Run
/mmap load https://upload.wikimedia.org/wikipedia/en/thumb/c/c3/Flag_of_France.svg/255px-Flag_of_France.svg.png. A map with id 33645 is loaded. - The given map has the right ID, 33645.
- Run
/mmap give 33645. It does work. - Run
/give @s minecraft:filled_map{map:33645}. It does work as well!
Thank you for the contribution!
What happens when this is run on a pre-1.13 server? I feel like backwards compatibility was the main reason I have not done this yet.
What happens when this is run on a pre-1.13 server? I feel like backwards compatibility was the main reason I have not done this yet.
I didn't test the PR on a pre-1.13 server tbh. A solution could be to check if ID exceeds the limit on load/player/slice, if version is below 1.13? EDIT: As of now, what I expect is just maps to be invalid over 32768
I think the best approach would be to work this into one of the CompatibilityUtils classes since those are versioned.
Otherwise, anything you do would probably hit a compile-ish error on one version or the other.
I'll take a look at this when I get a chance :)
Hey, any news on this?
No, I can't take this as-is without breaking backwards compatibility.
I'm not sure when I'll have time to fix this properly with version-specific abstraction layers, but I think that's what it needs.