KoryuObihiro/ModDamage — Issue #138: [Important] Error with setHealth since 1.0
Author: TerraNetworkOrg
Created: 2011-12-15 14:14:31+00:00
State: open

@KoryuObihiro

Yeah that's what i thougt:

[CODE]2011-12-15 15:07:28 [SEVERE] Could not pass event CREATURE_SPAWN to ModDamage

java.lang.IllegalArgumentException: Health must be between 0 and 10

at org.bukkit.craftbukkit.entity.CraftLivingEntity.setHealth(CraftLivingEntity.java:42)

at com.KoryuObihiro.bukkit.ModDamage.ModDamageEventHandler$ModDamageEntityListener.onCreatureSpawn(Unknown Source)

at org.bukkit.plugin.java.JavaPluginLoader$72.execute(JavaPluginLoader.java:767)

at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:58)

at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:339)

at org.bukkit.craftbukkit.event.CraftEventFactory.callCreatureSpawnEvent(CraftEventFactory.java:259)

at net.minecraft.server.World.addEntity(World.java:883)

at org.bukkit.craftbukkit.CraftWorld.spawn(CraftWorld.java:820)

at org.bukkit.craftbukkit.CraftWorld.spawn(CraftWorld.java:655)

at org.bukkit.craftbukkit.CraftWorld.spawnCreature(CraftWorld.java:323)

at com.sk89q.commandbook.commands.FunCommands.spawn(FunCommands.java:115)

at com.sk89q.commandbook.commands.FunCommands.spawnMob(FunCommands.java:102)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at com.sk89q.minecraft.util.commands.CommandsManager.invokeMethod(CommandsManager.java:455)

at com.sk89q.minecraft.util.commands.CommandsManager.executeMethod(CommandsManager.java:448)

at com.sk89q.minecraft.util.commands.CommandsManager.execute(CommandsManager.java:348)

at com.sk89q.commandbook.CommandBookPlugin.onCommand(CommandBookPlugin.java:266)

at org.bukkit.command.PluginCommand.execute(PluginCommand.java:40)

at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:165)

at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:378)

at net.minecraft.server.NetServerHandler.handleCommand(NetServerHandler.java:757)

at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:722)

at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:715)

at org.getspout.spout.SpoutNetServerHandler.a(SpoutNetServerHandler.java:180)

at net.minecraft.server.Packet3Chat.a(Packet3Chat.java:33)

at net.minecraft.server.NetworkManager.b(NetworkManager.java:226)

at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:93)

at org.getspout.spout.SpoutNetServerHandler.a(SpoutNetServerHandler.java:550)

at net.minecraft.server.NetworkListenThread.a(SourceFile:108)

at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:527)

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:425)

at net.minecraft.server.ThreadServerApplication.run(SourceFile:457)[/CODE]

Mojang hardcoded the health-value.

Before you spawn a mob, you surely use "setHealth(value)"

If value is higher than the allowed value (use: entity.getMaxHealth() ) it will throw this error.

Either you will do a comparison with getMaxHealth, but this will reduce the feature to set mobs health higher than normal, or you have to use a CustomEntity event.

I can provide you two links for this problem:

http://forums.bukkit.org/threads/solved-need-some-help-with-extending-off-of-entityzombie.46564/

http://forums.bukkit.org/threads/changing-maximum-entity-health.48175/#post-834802

I hate this, but what should we do ...

The easiest way (i know you remaining lime is limited) would be to get MaxHealth and limit the player value, this works great.

If you find the time you could rewrite the Entitys with Custom Entitys :(