MagicPlugin icon indicating copy to clipboard operation
MagicPlugin copied to clipboard

Fix map IDs casted as shorts

Open YanisBft opened this issue 2 years ago • 5 comments

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:

  1. 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.
  2. Because of short casts, the given map has the ID -31891. So it's invalid and appears blank.
  3. Run /mmap give 33645. It doesn't work, the ID is considered invalid by Magic.
  4. Run /give @s minecraft:filled_map{map:33645}. It does work, because vanilla limit no longer exist.

After:

  1. 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.
  2. The given map has the right ID, 33645.
  3. Run /mmap give 33645. It does work.
  4. Run /give @s minecraft:filled_map{map:33645}. It does work as well!

YanisBft avatar Aug 24 '23 20:08 YanisBft

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.

NathanWolf avatar Aug 24 '23 20:08 NathanWolf

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

YanisBft avatar Aug 24 '23 20:08 YanisBft

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 :)

NathanWolf avatar Aug 24 '23 20:08 NathanWolf

Hey, any news on this?

YanisBft avatar Feb 26 '24 22:02 YanisBft

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.

NathanWolf avatar Feb 26 '24 23:02 NathanWolf