Ir para conteúdo
  • 0

getNearbyEntities pegar apenas Entidade de Vaca


yLR111

Pergunta

Como faço para pegar quantidade de vacas em uma região utilizando getNearbyEntities.

	public static void spawnarBosses() {
		
		Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.plugin, new Runnable() {
			@Override
			public void run() {
				
				List<Entity> nearbyEntites = (List<Entity>) Bukkit.getWorld("arena").getNearbyEntities(Bukkit.getWorld("arena").getSpawnLocation(), 17, 17, 17);
				
				
				Random random = new Random();
				int minx = 2;
				int maxx = 29;
				int minz = -8;
				int maxz = 18;
				 
				int x = random.nextInt(maxx - (minx) + 1) + (minx);
				int z = random.nextInt(maxz - (minz) + 1) + (minz);
				Location loc = new Location(Bukkit.getWorld("arena"), x,43,z);
				
				
			    if(nearbyEntites.size() <= 15) {
			    	for(Entity e : nearbyEntites) {
			    		
			    		if(e instanceof Cow) {
							boss(loc);
							Bukkit.broadcastMessage("§aEntidades: §e" + nearbyEntites.size());
			    		}else {
			    			e.remove();
			    		}
			    	}
			    }
				
			    
			    
			    Bukkit.broadcastMessage("§aEntidades: §e" + nearbyEntites);
			}
		}, 20L, 20L);
	}

 

Link para o comentário
Compartilhar em outros sites

5 respostass a esta questão

Posts Recomendados

  • 0
1 hora atrás, yLR111 disse:

Como faço para pegar quantidade de vacas em uma região utilizando getNearbyEntities.


	public static void spawnarBosses() {
		
		Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.plugin, new Runnable() {
			@Override
			public void run() {
				
				List<Entity> nearbyEntites = (List<Entity>) Bukkit.getWorld("arena").getNearbyEntities(Bukkit.getWorld("arena").getSpawnLocation(), 17, 17, 17);
				
				
				Random random = new Random();
				int minx = 2;
				int maxx = 29;
				int minz = -8;
				int maxz = 18;
				 
				int x = random.nextInt(maxx - (minx) + 1) + (minx);
				int z = random.nextInt(maxz - (minz) + 1) + (minz);
				Location loc = new Location(Bukkit.getWorld("arena"), x,43,z);
				
				
			    if(nearbyEntites.size() <= 15) {
			    	for(Entity e : nearbyEntites) {
			    		
			    		if(e instanceof Cow) {
							boss(loc);
							Bukkit.broadcastMessage("§aEntidades: §e" + nearbyEntites.size());
			    		}else {
			    			e.remove();
			    		}
			    	}
			    }
				
			    
			    
			    Bukkit.broadcastMessage("§aEntidades: §e" + nearbyEntites);
			}
		}, 20L, 20L);
	}

 

 

                                long quant =0;   
                                for(Entity e : nearbyEntites) {
			    		
			    		if(e instanceof Cow) {
							boss(loc);
							Bukkit.broadcastMessage("§aEntidades: §e" + nearbyEntites.size());
                                                        quant++;
			    		}else {
			    			e.remove();
			    		}
			    	}
Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...