Setting creeper fuse and explosion radius

Discussion in 'Plugin Development' started by stirante, Oct 28, 2012.

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

    stirante

    Don't use this class, this is handled by API now.

    I wrote simple example, how to customize creeper fuse and radius of explosion
    Code:java
    1.  
    2. public void customizeCreeper(Creeper creeper, int fuse, int radius){
    3. EntityCreeper entCreeper = ((CraftCreeper)creeper).getHandle();
    4. Field fuseF = null;
    5. Field radiusF = null;
    6. try {
    7. fuseF = EntityCreeper.class.getDeclaredField("maxFuseTicks");
    8. radiusF = EntityCreeper.class.getDeclaredField("explosionRadius");
    9. }
    10. e.printStackTrace();
    11. }
    12. catch (SecurityException e) {
    13. e.printStackTrace();
    14. }
    15. fuseF.setAccessible(true);
    16. radiusF.setAccessible(true);
    17. try {
    18. fuseF.setInt(entCreeper, fuse);
    19. radiusF.setInt(entCreeper, radius);
    20. }
    21. e.printStackTrace();
    22. }
    23. e.printStackTrace();
    24. }
    25. }

    I hope someone will find it usefull :).
     
    ResistantUK and DSH105 like this.
Thread Status:
Not open for further replies.

Share This Page