Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-6646

MapPalette Valid Ranges Need Updating Again

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • Tested on Unbuntu and macOS

    • CraftBukkit version 3180-Spigot-38e6c03-ca0fe5b (MC: 1.17.1) (Implementing API version 1.17.1-R0.1-SNAPSHOT)
    • Yes

      I believe this is the same issue as SPIGOT-3365 from 1.12, but now in 1.17

      Additional colors were added to MapPalette, but the mathy range check in getColor wasn't updated to account for the new colors.

      Similar to last time I have no idea what the new range should be, but I will try to figure it out if no one can see an easy fix.

      It seems like matchColor would also need fixing, but that wasn't part of my PR last time so I'm not sure.

      The main issue here is that color indexes returned by matchColor (via imageToBytes in my case) will throw an exception if used in getColor to look up the color from the palette.

      Also, I know it probably wasn't Spigot that originally deprecated this API, but is there a reason it is still deprecated? I think spraying the "magic value" hose on it maybe was a bit harsh, these are just palette indexes, not really magic numbers. 

      The error: 

      java.lang.IndexOutOfBoundsException: null
      	at org.bukkit.map.MapPalette.getColor(MapPalette.java:267) ~[spigot-1.17.1-R0.1-SNAPSHOT.jar:3180-Spigot-38e6c03-ca0fe5b]
      	at com.elmakers.mine.bukkit.maps.BufferedMapCanvas.setPixel(BufferedMapCanvas.java:62) ~[?:?]
      	at com.elmakers.mine.bukkit.maps.BufferedMapCanvas.drawImage(BufferedMapCanvas.java:112) ~[?:?]
      	at com.elmakers.mine.bukkit.maps.URLMap.render(URLMap.java:204) ~[?:?]
      	at com.elmakers.mine.bukkit.block.MaterialBrush.update(MaterialBrush.java:597) ~[?:?]
      	at com.elmakers.mine.bukkit.batch.FillBatch.process(FillBatch.java:92) ~[?:?]
      	at com.elmakers.mine.bukkit.magic.Mage.processPendingBatches(Mage.java:1892) ~[?:?]
      	at com.elmakers.mine.bukkit.magic.MagicController.processPendingBatches(MagicController.java:1521) ~[?:?]
      	at com.elmakers.mine.bukkit.tasks.BatchUpdateTask.run(BatchUpdateTask.java:14) ~[?:?]
      	at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftTask.run(CraftTask.java:81) ~[spigot-1.17.1-R0.1-SNAPSHOT.jar:3180-Spigot-38e6c03-ca0fe5b]
      	at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:400) ~[spigot-1.17.1-R0.1-SNAPSHOT.jar:3180-Spigot-38e6c03-ca0fe5b]
      	at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1254) ~[spigot-1.17.1-R0.1-SNAPSHOT.jar:3180-Spigot-38e6c03-ca0fe5b]
      	at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:438) ~[spigot-1.17.1-R0.1-SNAPSHOT.jar:3180-Spigot-38e6c03-ca0fe5b]
      	at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1202) ~[spigot-1.17.1-R0.1-SNAPSHOT.jar:3180-Spigot-38e6c03-ca0fe5b]
      	at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1035) ~[spigot-1.17.1-R0.1-SNAPSHOT.jar:3180-Spigot-38e6c03-ca0fe5b]
      	at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:303) ~[spigot-1.17.1-R0.1-SNAPSHOT.jar:3180-Spigot-38e6c03-ca0fe5b]
      	at java.lang.Thread.run(Thread.java:831) [?:?]
       

            Unassigned Unassigned
            NathanWolf Nathan Wolf
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: