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

Can not set net.minecraft.world.item.component.ResolvableProfile field org.bukkit.craftbukkit.v1_21_R1.block.CraftSkull.profile to com.mojang.authlib.GameProfile

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: Minor Minor
    • None
    • None
    • 4314-Spigot-a759b62-bbb30e7 (MC: 1.21.1)
    • GravesX
    • Yes

      As of recent updates this error now occurs when setting the profile field

      Error that occurs:

      [19:24:20] [Server thread/INFO]: Legoman99573 issued server command: /kill Legoman99573
      [19:24:20] [Server thread/ERROR]: Could not pass event PlayerDeathEvent to GravesX v4.9.3.17
      org.bukkit.event.EventException: null
              at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?]
              at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?]
              at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:601) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?]
              at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:588) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?]
              at org.bukkit.craftbukkit.v1_21_R1.event.CraftEventFactory.callPlayerDeathEvent(CraftEventFactory.java:940) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.server.level.EntityPlayer.a(EntityPlayer.java:914) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.world.entity.EntityLiving.a(EntityLiving.java:1528) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.world.entity.player.EntityHuman.a(EntityHuman.java:971) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.server.level.EntityPlayer.a(EntityPlayer.java:1069) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.world.entity.EntityLiving.ap(EntityLiving.java:343) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.server.commands.CommandKill.a(SourceFile:32) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.server.commands.CommandKill.a(SourceFile:25) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at com.mojang.brigadier.context.ContextChain.runExecutable(ContextChain.java:73) ~[brigadier-1.2.9.jar:?]
              at net.minecraft.commands.execution.tasks.ExecuteCommand.a(SourceFile:29) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.commands.execution.tasks.ExecuteCommand.execute(SourceFile:13) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.commands.execution.UnboundEntryAction.a(SourceFile:8) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.commands.execution.CommandQueueEntry.a(SourceFile:8) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.commands.execution.ExecutionContext.a(SourceFile:107) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.commands.CommandDispatcher.a(CommandDispatcher.java:414) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.commands.CommandDispatcher.performCommand(CommandDispatcher.java:336) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.commands.CommandDispatcher.a(CommandDispatcher.java:323) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.server.network.PlayerConnection.b(PlayerConnection.java:1842) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.server.network.PlayerConnection.lambda$handleChatCommand$7(PlayerConnection.java:1818) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.server.TickTask.run(SourceFile:18) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.util.thread.IAsyncTaskHandler.d(SourceFile:162) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.d(SourceFile:23) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1270) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:203) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.util.thread.IAsyncTaskHandler.B(SourceFile:136) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.server.MinecraftServer.bv(MinecraftServer.java:1249) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.server.MinecraftServer.B(MinecraftServer.java:1242) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.util.thread.IAsyncTaskHandler.bB(SourceFile:121) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.server.MinecraftServer.v_(MinecraftServer.java:1213) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.server.MinecraftServer.y(MinecraftServer.java:1078) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:318) ~[spigot-1.21.1-R0.1-SNAPSHOT.jar:4314-Spigot-a759b62-bbb30e7]
              at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]
      Caused by: java.lang.IllegalArgumentException: Can not set net.minecraft.world.item.component.ResolvableProfile field org.bukkit.craftbukkit.v1_21_R1.block.CraftSkull.profile to com.mojang.authlib.GameProfile
              at java.base/jdk.internal.reflect.FieldAccessorImpl.throwSetIllegalArgumentException(FieldAccessorImpl.java:228) ~[?:?]
              at java.base/jdk.internal.reflect.FieldAccessorImpl.throwSetIllegalArgumentException(FieldAccessorImpl.java:232) ~[?:?]
              at java.base/jdk.internal.reflect.MethodHandleObjectFieldAccessorImpl.set(MethodHandleObjectFieldAccessorImpl.java:115) ~[?:?]
              at java.base/java.lang.reflect.Field.set(Field.java:836) ~[?:?]
              at com.ranull.graves.util.SkinUtil.setSkullBlockTexture(SkinUtil.java:39) ~[?:?]
              at com.ranull.graves.compatibility.CompatibilityBlockData.applySkullData(CompatibilityBlockData.java:195) ~[?:?]
              at com.ranull.graves.compatibility.CompatibilityBlockData.updateSkullBlock(CompatibilityBlockData.java:172) ~[?:?]
              at com.ranull.graves.compatibility.CompatibilityBlockData.handleBlockPlacement(CompatibilityBlockData.java:86) ~[?:?]
              at com.ranull.graves.compatibility.CompatibilityBlockData.setBlockData(CompatibilityBlockData.java:48) ~[?:?]
              at com.ranull.graves.manager.BlockManager.createBlock(BlockManager.java:93) ~[?:?]
              at com.ranull.graves.manager.GraveManager.placeGrave(GraveManager.java:701) ~[?:?]
              at com.ranull.graves.listener.EntityDeathListener.placeGraveBlocks(EntityDeathListener.java:786) ~[?:?]
              at com.ranull.graves.listener.EntityDeathListener.notifyGraveCreation(EntityDeathListener.java:751) ~[?:?]
              at com.ranull.graves.listener.EntityDeathListener.placeGrave(EntityDeathListener.java:670) ~[?:?]
              at com.ranull.graves.listener.EntityDeathListener.createGrave(EntityDeathListener.java:497) ~[?:?]
              at com.ranull.graves.listener.EntityDeathListener.onEntityDeath(EntityDeathListener.java:128) ~[?:?]
              at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[?:?]
              at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[?:?]
              at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-api-1.21.1-R0.1-SNAPSHOT.jar:?]
              ... 35 more

      Code snippet to compare as this bug doesn't seem to occur with SkullMeta:

      /**
       * Sets the texture of a Skull block.
       *
       * @param skull  The Skull block.
       * @param name   The name associated with the texture.
       * @param base64 The Base64 encoded texture.
       */
      public static void setSkullBlockTexture(Skull skull, String name, String base64) {
          GameProfile gameProfile = new GameProfile(UUID.randomUUID(), name);
          gameProfile.getProperties().put("textures", new Property("textures", base64));
      
          try {
              Field profileField = skull.getClass().getDeclaredField("profile");
              profileField.setAccessible(true);
              profileField.set(skull, gameProfile); // This method is somehow broken
          } catch (NoSuchFieldException | IllegalAccessException exception) {
              exception.printStackTrace();
          }
      }
      
      /**
       * Sets the texture of a Skull item stack.
       *
       * @param skullMeta The SkullMeta item meta.
       * @param name      The name associated with the texture.
       * @param base64    The Base64 encoded texture.
       */
      public static void setSkullBlockTexture(SkullMeta skullMeta, String name, String base64) {
          GameProfile gameProfile = new GameProfile(UUID.randomUUID(), name);
          gameProfile.getProperties().put("textures", new Property("textures", base64));
      
          try {
              Field profileField = skullMeta.getClass().getDeclaredField("profile");
              profileField.setAccessible(true);
              profileField.set(skullMeta, gameProfile); // This however works just fine
          } catch (NoSuchFieldException | IllegalAccessException exception) {
              exception.printStackTrace();
          }
      }

            Unassigned Unassigned
            Legoman99573 Legoman99573
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: