BlackBeltPanda

slimes

Jul 17th, 2014
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. @SuppressWarnings("deprecation")
  2. @EventHandler(priority = EventPriority.HIGH)
  3. public void onCreatureSpawn(CreatureSpawnEvent e){
  4. Entity en = e.getEntity();
  5. int x = 0;
  6. for (Entity ent:en.getNearbyEntities(25, 25, 25)){
  7. if(ent.getType() == en.getType()){
  8. x++;
  9. }
  10. }
  11. if(x >= 18){
  12. e.setCancelled(true);
  13. }
  14. if (en.getType() != EntityType.SLIME){
  15. if (e.getSpawnReason() == SpawnReason.NATURAL){
  16. if(en instanceof LivingEntity){
  17. Block bl = en.getLocation().getBlock().getRelative(BlockFace.DOWN);
  18. if (bl.getType() == Material.DIRT && bl.getData() == 2){
  19. en.remove();
  20. en.getWorld().spawnEntity(en.getLocation(), EntityType.SLIME);
  21. }
  22. }
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment