Solved Throwing an egg at a player will cause an explosion (wont break blocks)

Discussion in 'Plugin Development' started by Mr_Gibbles, Jan 18, 2014.

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

    Mr_Gibbles

    My current code is:
    Code:java
    1. @EventHandler
    2. public void onProjectileHit(ProjectileHitEvent e) {
    3. if (e.getEntity().getType() == EntityType.EGG) {
    4. Location l = e.getEntity().getLocation();
    5. e.getEntity().getWorld().createExplosion(l.getZ(), l.getY(), l.getZ(), 3F, false, false);
    6. }
    7. }

    When I throw an egg at a player it doesn't explode. I want it so that it would explode when it hits a player, but will only do explosive damage to the player and not effect blocks or anything. I've looked it up and tried many different ways but they aren't working.
     
  2. Offline

    Gater12

  3. Offline

    Mr_Gibbles

    Gater12
    [21:33:36 ERROR]: Could not pass event EntityDamageByEntityEvent to ChubbyKits v
    1.0
    org.bukkit.event.EventException
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:320) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:62) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
    ava:481) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:466) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    at org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callEvent(Craf
    tEventFactory.java:94) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jn
    ks]
    at org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callEntityDama
    geEvent(CraftEventFactory.java:382) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g53
    0fcb7-b2982jnks]
    at org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.handleEntityDa
    mageEvent(CraftEventFactory.java:410) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g
    530fcb7-b2982jnks]
    at net.minecraft.server.v1_7_R1.EntityLiving.damageEntity(EntityLiving.j
    ava:656) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    at net.minecraft.server.v1_7_R1.EntityHuman.damageEntity(EntityHuman.jav
    a:746) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    at net.minecraft.server.v1_7_R1.EntityPlayer.damageEntity(EntityPlayer.j
    ava:446) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    at net.minecraft.server.v1_7_R1.EntityEgg.a(EntityEgg.java:26) [craftbuk
    kit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    at net.minecraft.server.v1_7_R1.EntityProjectile.h(EntityProjectile.java
    :154) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    at net.minecraft.server.v1_7_R1.World.entityJoinedWorld(World.java:1338)
    [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    at net.minecraft.server.v1_7_R1.World.playerJoinedWorld(World.java:1319)
    [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    at net.minecraft.server.v1_7_R1.World.tickEntities(World.java:1207) [cra
    ftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    at net.minecraft.server.v1_7_R1.WorldServer.tickEntities(WorldServer.jav
    a:480) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:6
    37) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:2
    50) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:5
    45) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java
    :457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:6
    17) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_7_R1.entity.C
    raftEgg cannot be cast to org.bukkit.entity.Player
    at me.Mr_Gibbles.chubbykits.chubbykits.onHit(chubbykits.java:262) ~[?:?]

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0
    _17]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0
    _17]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1
    .7.0_17]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_17]
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:318) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    ... 20 more
    >
     
  4. Offline

    sgtcaze

    Read the error, it's not the projectile hit event.

     
    Gater12 likes this.
  5. Offline

    Gater12

    Mr_Gibbles My guess is that you mistaken Entity for the Egg. It should be getDamager()
     
  6. Offline

    Mr_Gibbles

    I fixed that, but it's still not working. The error went away, but it still doesnt explode.
     
  7. Offline

    xTigerRebornx

    Mr_Gibbles
    Code:
    (l.getZ(), l.getY(), l.getZ(), 3F, 
    First param here should be l.getX()
     
  8. Offline

    Mr_Gibbles

    OMG LOL... I'm a dumbass... Thanks xD
     
  9. Offline

    xTigerRebornx

    Mr_Gibbles We all make silly mistakes......Make sure to give your code a good re-read in the section its not working properly :p
     
Thread Status:
Not open for further replies.

Share This Page