Hi So I’m trying to make it so that I take a way a lot of Lines of code…so I’m trying to make the following:
public class NaturalSpawning {
public void onEntitySpawn(SpawnEntityEvent event){
//This is the testing code v\
}
int test = DayCounter.getWeeklyConfig();
public String Config = "Config" + test;
public void Hostiles(Location<World> spawnLocation) {
//removed from list below ,"CAVE_SPIDER","CREEPER","ENDER_CRYSTAL","ENDERMAN","GHAST","MAGMA_CUBE","PIG_ZOMBIE","SILVERFISH","SKELETON","SLIME","SPIDER","WITCH","ZOMBIE"
//List<String> list = Arrays.asList("BLAZE","NONE");
List<Class<? extends Entity>> classes = ImmutableList.of(
Monster.class
);
Collection<EntityType> cet = Sponge.getRegistry().getAllOf(EntityType.class).stream().filter(x -> classes.stream().anyMatch(y -> y.isAssignableFrom(x.getEntityClass()))).collect(Collectors.toList());
List<EntityType>list = Arrays.asList(cet.iterator().next());
Random rand = new Random();
EntityType listResult = list.get(rand.nextInt(list.size()));
String week = "Week " + DayCounter.getCustWeek();
for (int i = 0; i< (ConfigurationManager.getInstance().getSpawnControl().getNode(listResult, week, "==========Natural Spawning==========", "# of Attempts: ").getInt()); i++){
Sponge.getServer().getBroadcastChannel().send(Text.of("Attempt " + i));
Random roll = new Random();
int answer = roll.nextInt(100) + 1;
if (answer <= (ConfigurationManager.getInstance().getSpawnControl().getNode(listResult, week, "==========Natural Spawning==========", "% per Attempt: ").getInt())){
Extent extent = spawnLocation.getExtent();
Entity entity = extent.createEntity(listResult, spawnLocation.getPosition());
Entity creeper = entity;
extent.spawnEntity(creeper);
Sponge.getServer().getBroadcastChannel().send(Text.of("with a chance of " + answer));
}
}
};
}
Pretty much I’m trying to as you can see 'Randomly Select an Entity from the list of Monsters…however.it doesn’t seeem to be doing anything…so I need some help pointing out where the flaw is in the logic? as there is no Error message. Thanks!