Solved Getting Error on EntityType().setHealth(1500);

Discussion in 'Plugin Development' started by kayc01, Apr 8, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    kayc01

    Hey, wondering if anyone knew the cause of this error?

    I try set the health of the entity (wither) to 1500 upon it being spawned.
    However, it does not change the health and only gives me an error.

    Here is the error:


    Code:
    [16:50:12 ERROR]: Could not pass event CreatureSpawnEvent to MazeRunner v1.0
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:294) ~[Craftbukkit.jar:git-Bukkit-1.7.9-R0.2-10-ge6cd8c0-b3096jnks]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[Craftbukkit.jar:git-Bukkit-1.7.9-R0.2-10-ge6cd8c0-b3096jnks]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:501) [Craftbukkit.jar:git-Bukkit-1.7.9-R0.2-10-ge6cd8c0-b3096jnks]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:486) [Craftbukkit.jar:git-Bukkit-1.7.9-R0.2-10-ge6cd8c0-b3096jnks]
            at org.bukkit.craftbukkit.v1_7_R3.event.CraftEventFactory.callCreatureSpawnEvent(CraftEventFactory.java:275) [Craftbukkit.jar:git-Bukkit-1.7.9-R0.2-10-ge6cd8c0-b3096jnks]
            at net.minecraft.server.v1_7_R3.World.addEntity(World.java:975) [Craftbukkit.jar:git-Bukkit-1.7.9-R0.2-10-ge6cd8c0-b3096jnks]
            at net.minecraft.server.v1_7_R3.BlockSkull.a(BlockSkull.java:168) [Craftbukkit.jar:git-Bukkit-1.7.9-R0.2-10-ge6cd8c0-b3096jnks]
            at net.minecraft.server.v1_7_R3.ItemSkull.interactWith(SourceFile:78) [Craftbukkit.jar:git-Bukkit-1.7.9-R0.2-10-ge6cd8c0-b3096jnks]
            at net.minecraft.server.v1_7_R3.ItemStack.placeItem(ItemStack.java:102) [Craftbukkit.jar:git-Bukkit-1.7.9-R0.2-10-ge6cd8c0-b3096jnks]
            at net.minecraft.server.v1_7_R3.PlayerInteractManager.interact(PlayerInteractManager.java:390) [Craftbukkit.jar:git-Bukkit-1.7.9-R0.2-10-ge6cd8c0-b3096jnks]
            at net.minecraft.server.v1_7_R3.PlayerConnection.a(PlayerConnection.java:629) [Craftbukkit.jar:git-Bukkit-1.7.9-R0.2-10-ge6cd8c0-b3096jnks]
            at net.minecraft.server.v1_7_R3.PacketPlayInBlockPlace.a(SourceFile:60) [Craftbukkit.jar:git-Bukkit-1.7.9-R0.2-10-ge6cd8c0-b3096jnks]
            at net.minecraft.server.v1_7_R3.PacketPlayInBlockPlace.handle(SourceFile:9) [Craftbukkit.jar:git-Bukkit-1.7.9-R0.2-10-ge6cd8c0-b3096jnks]
            at net.minecraft.server.v1_7_R3.NetworkManager.a(NetworkManager.java:157) [Craftbukkit.jar:git-Bukkit-1.7.9-R0.2-10-ge6cd8c0-b3096jnks]
            at net.minecraft.server.v1_7_R3.ServerConnection.c(SourceFile:134) [Craftbukkit.jar:git-Bukkit-1.7.9-R0.2-10-ge6cd8c0-b3096jnks]
            at net.minecraft.server.v1_7_R3.MinecraftServer.v(MinecraftServer.java:667) [Craftbukkit.jar:git-Bukkit-1.7.9-R0.2-10-ge6cd8c0-b3096jnks]
            at net.minecraft.server.v1_7_R3.DedicatedServer.v(DedicatedServer.java:260) [Craftbukkit.jar:git-Bukkit-1.7.9-R0.2-10-ge6cd8c0-b3096jnks]
            at net.minecraft.server.v1_7_R3.MinecraftServer.u(MinecraftServer.java:558) [Craftbukkit.jar:git-Bukkit-1.7.9-R0.2-10-ge6cd8c0-b3096jnks]
            at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:469) [Craftbukkit.jar:git-Bukkit-1.7.9-R0.2-10-ge6cd8c0-b3096jnks]
            at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [Craftbukkit.jar:git-Bukkit-1.7.9-R0.2-10-ge6cd8c0-b3096jnks]
    Caused by: java.lang.IllegalArgumentException: Health must be between 0 and 300.0
            at org.bukkit.craftbukkit.v1_7_R3.entity.CraftLivingEntity.setHealth(CraftLivingEntity.java:81) ~[Craftbukkit.jar:git-Bukkit-1.7.9-R0.2-10-ge6cd8c0-b3096jnks]
            at me.Ckay.pvp.Main.onCreatureSpawn(Main.java:704) ~[?:?]
            at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source) ~[?:?]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_73]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_73]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:292) ~[Craftbukkit.jar:git-Bukkit-1.7.9-R0.2-10-ge6cd8c0-b3096jnks]
            ... 19 more
    Here is my code:

    Code:
        @EventHandler
        public void onCreatureSpawn(CreatureSpawnEvent event) {
            if(event.getEntityType() == EntityType.WITHER) {
                event.getEntity().setHealth(1500);
            }
        }
    The error occurs on this line:
    Code:
    event.getEntity().setHealth(1500);
    Any help will be appreciated. Know what I should change it to ?
     
  2. Offline

    Lordloss

    Carefully read your stacktrace... its not that hard to figure out.
     
  3. Offline

    kayc01

    event.getEntity().setMaxHealth(1500);

    xD

    Answers your comment? aha
    Thanks. Normally error's are not that obvious.
     
  4. Offline

    WolfMage1

    IllegalArgumentException: Health must be between 0 and 300.0 < I wonder what the problem could be

    There's already threads telling you how to read stack traces, read them.

    EDIT: Reply'd to the wrong quote, sorry @Lordloss
     
Thread Status:
Not open for further replies.

Share This Page