Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @SuppressWarnings("deprecation")
- @EventHandler(priority = EventPriority.HIGH)
- public void onCreatureSpawn(CreatureSpawnEvent e){
- Entity en = e.getEntity();
- int x = 0;
- for (Entity ent:en.getNearbyEntities(25, 25, 25)){
- if(ent.getType() == en.getType()){
- x++;
- }
- }
- if(x >= 18){
- e.setCancelled(true);
- }
- if (en.getType() != EntityType.SLIME){
- if (e.getSpawnReason() == SpawnReason.NATURAL){
- if(en instanceof LivingEntity){
- Block bl = en.getLocation().getBlock().getRelative(BlockFace.DOWN);
- if (bl.getType() == Material.DIRT && bl.getData() == 2){
- en.remove();
- en.getWorld().spawnEntity(en.getLocation(), EntityType.SLIME);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment