Следуйте инструкциям в видео ниже, чтобы узнать, как установить наш сайт как веб-приложение на главный экран вашего устройства.
Примечание: Эта функция может быть недоступна в некоторых браузерах.
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event){
Random rand = new Random();
LivingEntity ent = event.getEntity();
if (event.getEntityType() == EntityType.ZOMBIE) {
int i = 1;
int p = 90;
int level = 0;
int chans = rand.nextInt(100) + 1;
while(chans >= i){
chans = rand.nextInt(100) + 1;
if(i < 5)
i = i+1;
else
if(i < 17)
i = i+4;
else
if(i == 17)
i = 100;
p = p-10;
}
level = rand.nextInt(10) + 1 + p;
ent.setCustomName("Goblin " + ChatColor.GREEN + "[" + ChatColor.GOLD + level + " LVL" + ChatColor.GREEN + "]" );
((Zombie)ent).setVillager(true);
((Zombie)ent).setBaby(false);
ent.getEquipment().clear();
if (level < 10){
chans = rand.nextInt(100) + 1;
if(chans >= 80){
ent.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
}
ent.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS));
ent.getEquipment().setItemInHand(new ItemStack(Material.WOOD_SWORD));
}else..... //и т.п.
int number = rand.nextInt(100) + 1;
ent.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 48384000, 2));
if(number >= 40)
{
ent.removePotionEffect(PotionEffectType.SLOW);
ent.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 48384000, 3));
}
ent.setCanPickupItems(false);
}
}
while(chans >= i){
chans = rand.nextInt(100) + 1;
if(i < 5)
i = i+1;
else
if(i < 17)
i = i+4;
else
if(i == 17)
i = 100;
p = p-10;
}
Что?Код:while(chans >= i){ chans = rand.nextInt(100) + 1; if(i < 5) i = i+1; else if(i < 17) i = i+4; else if(i == 17) i = 100; p = p-10; }
Ничего не понял из вашего кода.
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event){
Random rand = new Random();
LivingEntity ent = event.getEntity();
if (event.getEntityType() == EntityType.ZOMBIE) {
int i = 1;
int p = 90;
int level = 0;
int chans = rand.nextInt(100) + 1;
//начало генирации рандомного уровня
while(chans >= i){
chans = rand.nextInt(100) + 1;
if(i < 5)
i = i+1;
else
if(i < 17)
i = i+4;
else
if(i == 17)
i = 100;
p = p-10;
}
level = rand.nextInt(10) + 1 + p;
//конец генирации
//дальше даем имя с уровнем
ent.setCustomName("Goblin " + ChatColor.GREEN + "[" + ChatColor.GOLD + level + " LVL" + ChatColor.GREEN + "]" );
//спавн только жителя зомби и не даем спавн мини зомби ,и не даем чтобы зомби подбирал вещи
((Zombie)ent).setVillager(true);
((Zombie)ent).setBaby(false);
ent.setCanPickupItems(false);
//если спавнится зомби с эквипом убрать эквип
ent.getEquipment().clear();
//даем эквип каждому 10 уровню
if (level < 10){
chans = rand.nextInt(100) + 1;
if(chans >= 80){
ent.getEquipment().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
}
ent.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS));
ent.getEquipment().setItemInHand(new ItemStack(Material.WOOD_SWORD));
}else..... //и т.п.
//даю зомюи поушен на его замедление
int number = rand.nextInt(100) + 1;
ent.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 48384000, 2));
if(number >= 40)
{
ent.removePotionEffect(PotionEffectType.SLOW);
ent.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 48384000, 3));
}
}
}
Ничего не понятно.мне надо если команда вводится то генирация не сробатывает и в переменную level идет цифра которую я даю командой
Не знаю. Вот по этому:
Ничего не понятно.
int i = 1;
int p = 90;
int level = 0;
int chans = rand.nextInt(100) + 1;
while(chans >= i){
chans = rand.nextInt(100) + 1;
if(i < 5)
i = i+1;
else
if(i < 17)
i = i+4;
else
if(i == 17)
i = 100;
p = p-10;
}
level = rand.nextInt(10) + 1 + p;
Определяйте уровень по нику. (getCustomName)
А, ну да. Тогда выдавайте экипировку сразу при спавне, какие проблемы?
Причем скорее всего метод getPlayer останется, это просто временная мера, чтобы все были в курсе перехода на UUID.getPlayer устарел потому что все переходят на UUID.