Solved EntityPlayer questions

Discussion in 'Spigot Plugin Development' started by Simagdo, May 29, 2018.

  1. Hey there,

    I am currently working with an EntityPlayer. I have the main thing done so far and now I want to work on the next thing i planned with it.
    Question 1:
    Is it somehow possible to make the EntityPlayer small. There is a method EntityPlayer#setSize(), but it doesn't change anything.
    My second question:
    Is it possible that I can set the created EntityPlayer as a Passenger on a Horse? If i try it like this:
    Code (Text):

    Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class);
    Test test = new Test();
    horse.setPassenger((Entity) test);
    I get this error:
    Code (Text):

    org.bukkit.command.CommandException: Unhandled exception executing command 'test' in plugin Test v1.0
            at org.bukkit.command.PluginCommand.execute( ~[spigot-1.12.2.jar:git-Spigot-2086bb0-d0a3620]
            at org.bukkit.command.SimpleCommandMap.dispatch( ~[spigot-1.12.2.jar:git-Spigot-2086bb0-d0a3620]
            at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchCommand( ~[spigot-1.12.2.jar:git-Spigot-2086bb0-d0a3620]
            at net.minecraft.server.v1_12_R1.PlayerConnection.handleCommand( [spigot-1.12.2.jar:git-Spigot-2086bb0-d0a3620]
            at net.minecraft.server.v1_12_R1.PlayerConnection.a( [spigot-1.12.2.jar:git-Spigot-2086bb0-d0a3620]
            at net.minecraft.server.v1_12_R1.PacketPlayInChat.a( [spigot-1.12.2.jar:git-Spigot-2086bb0-d0a3620]
            at net.minecraft.server.v1_12_R1.PacketPlayInChat.a( [spigot-1.12.2.jar:git-Spigot-2086bb0-d0a3620]
            at net.minecraft.server.v1_12_R1.PlayerConnectionUtils$ [spigot-1.12.2.jar:git-Spigot-2086bb0-d0a3620]
            at java.util.concurrent.Executors$ [?:?]
            at [?:?]
            at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [spigot-1.12.2.jar:git-Spigot-2086bb0-d0a3620]
            at net.minecraft.server.v1_12_R1.MinecraftServer.D( [spigot-1.12.2.jar:git-Spigot-2086bb0-d0a3620]
            at net.minecraft.server.v1_12_R1.DedicatedServer.D( [spigot-1.12.2.jar:git-Spigot-2086bb0-d0a3620]
            at net.minecraft.server.v1_12_R1.MinecraftServer.C( [spigot-1.12.2.jar:git-Spigot-2086bb0-d0a3620]
            at [spigot-1.12.2.jar:git-Spigot-2086bb0-d0a3620]
            at [?:?]
    Caused by: java.lang.ClassCastException: net.minecraft.server.v1_12_R1.EntityPlayer cannot be cast to org.bukkit.entity.Entity
            at de.simagdo.test.utils.Test.spawn( ~[?:?]
            at de.simagdo.test.commands.TestCommand.onCommand( ~[?:?]
            at org.bukkit.command.PluginCommand.execute( ~[spigot-1.12.2.jar:git-Spigot-2086bb0-d0a3620]
            ... 15 more
  2. The error you get is because you're trying to cast an EntityPlayer to a player. Instead you should use the getBukkitEntity method.
  3. For the first question there's no way, as far as I know, to make the player look smaller but you can set it as a passenger of a smaller entity like an arrow or a minecraft and make that entity invisible, but I don't think it's a good way to do it
  4. What exact method do you mean? I couldn't find a getBukkitEntity method.
  5. JanTuck


  6. The error is on the TestCommand class on the line 227. Can you send the code of these lines to check what is going wrong?
  7. I know, where the error comes from. I have already posted the code in the first post.
  8. test.getBukkitEntity

    /e The method does exist. I just checked.
    • Agree Agree x 1
    • Winner Winner x 1
  9. Thank you very much. It works as it should. :)