NMS: Making Creeper Not Explode

Discussion in 'Spigot Plugin Development' started by Bladian, May 8, 2015.

Thread Status:
Not open for further replies.
  1. I'm currently using NMS to try make creepers not explode but I can't seem to find the correct method to override.

    I tried decompiling the spigot.jar and found that t_() was the most probably method.

    I tried overriding it but no use, any ideas.

    I'm currently using:

    CraftBukkit version git-Spigot-dbe012b-61ef214 (MC: 1.8.3) (Implementing API version 1.8.3-R0.1-SNAPSHOT)
     
  2. Why would you be using NMS for this? Just cancel the event
     
  3. Cancel the event
    Like SystemUpdate_ said
     
  4. I know there is a way but I'm trying to keep everything compact
     
  5. NMS won't make it compact
     
  6. I tried it out but unfortunately it's not working:

    Code (Text):
    @EventHandler
        public void onExplode(EntityExplodeEvent e) {

            if(e.getEntity() instanceof CustomCreeper) {
                e.setCancelled(true);
            }
        }
    }
     
  7. Hm... Then I am not sure sorry.
     
  8. I'll try it out with a normal creeper. Maybe it's something with my entity.
     
  9. Ok
     
  10. Okay, it works with creepers, it doesn't stop the explosion, but it stops the breaking of the blocks. Hmmmm
     
  11. Maybe when the creeper is going to explode kill it and spawn another one in the same spot? I don't know how though
     
  12. e.getEntity() return a Bukkit creeper object and CustomCreeper is a nms object so the statement will never be true
     
  13. Post your register class for the listener and your custom entity class
     
  14. getEntity returns a entity, if his custom creeper class implements entity it'll compare just fine
     
  15. -snip-
     
    #16 Bladian, May 8, 2015
    Last edited: May 8, 2015
  16. When I get home I'll have a go at fixing the issue
     
  17. Try this
    Code (Text):
     
        public void onExplode(EntityExplodeEvent e) {

            if(((CraftCreeper)e.getEntity()).getHandle() instanceof CustomCreeper) {
                e.setCancelled(true);
            }
        }
    }
     
  18. I'll just try this with NMS:

    this.goalSelector.a(2, new PathfinderGoalMeleeAttack(this, null, 1.0D, false));
     
Thread Status:
Not open for further replies.