Solved I can't increase the mob spawn rate

Discussion in 'Plugin Development' started by ocomobock, Nov 30, 2017.

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


    I'm trying to make it so when 1 monster spawns, a copy of it appears at the same location. Here is my code:

    55    @EventHandler
    56         public void CreatureSpawn(CreatureSpawnEvent e)
    57         {
    58             if(e.getEntity() instanceof Monster)
    59             {
    60                 LivingEntity m = e.getEntity();
    61                 m.getWorld().spawnEntity(e.getLocation(),e.getEntityType());
    62             }
    63         }
    Here is my error:

    [12:10:37] [Server thread/ERROR]: Could not pass event CreatureSpawnEvent to HiLo v1.0
    org.bukkit.event.EventException: null
        at$1.execute( ~[craftbukkit.jar:git-Bukkit-809c399]
        at org.bukkit.plugin.RegisteredListener.callEvent( ~[craftbukkit.jar:git-Bukkit-809c399]
        at org.bukkit.plugin.SimplePluginManager.fireEvent( ~[craftbukkit.jar:git-Bukkit-809c399]
        at org.bukkit.plugin.SimplePluginManager.callEvent( ~[craftbukkit.jar:git-Bukkit-809c399]
        at org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory.callCreatureSpawnEvent( ~[craftbukkit.jar:git-Bukkit-809c399]
        at net.minecraft.server.v1_12_R1.World.addEntity( ~[craftbukkit.jar:git-Bukkit-809c399]
        at net.minecraft.server.v1_12_R1.WorldServer.addEntity( ~[craftbukkit.jar:git-Bukkit-809c399]
        at org.bukkit.craftbukkit.v1_12_R1.CraftWorld.addEntity( ~[craftbukkit.jar:git-Bukkit-809c399]
        at org.bukkit.craftbukkit.v1_12_R1.CraftWorld.spawn( ~[craftbukkit.jar:git-Bukkit-809c399]
        at org.bukkit.craftbukkit.v1_12_R1.CraftWorld.spawn( ~[craftbukkit.jar:git-Bukkit-809c399]
        at org.bukkit.craftbukkit.v1_12_R1.CraftWorld.spawnEntity( ~[craftbukkit.jar:git-Bukkit-809c399]
        at io.github.ocomobock.hilo.Main.CreatureSpawn( ~[?:?]
        at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_144]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_144]
        at$1.execute( ~[craftbukkit.jar:git-Bukkit-809c399]
  2. Offline


    What is the error cause ?

    Your code will create a loop until the server crash, or may be cancel it. When you use the spawnEntity method, the event is called back.
  3. Offline


    I have realized the error of my ways. I found out I had to check to see if SpawnReason != SpawnReason.CUSTOM. Problem solved
  4. Offline


    mark as solved
Thread Status:
Not open for further replies.

Share This Page