本文整理匯總了Java中org.bukkit.inventory.EntityEquipment.setLeggingsDropChance方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityEquipment.setLeggingsDropChance方法的具體用法?Java EntityEquipment.setLeggingsDropChance怎麽用?Java EntityEquipment.setLeggingsDropChance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.inventory.EntityEquipment
的用法示例。
在下文中一共展示了EntityEquipment.setLeggingsDropChance方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: giveArmor
import org.bukkit.inventory.EntityEquipment; //導入方法依賴的package包/類
private void giveArmor(LivingEntity entity, PluginConfig worldConfig) {
String name = ListUtils.getRandom(worldConfig.getStringList(Config.FEATURE_ZOMBIE_ARMOR_ARMOR)).toUpperCase();
if (Material.getMaterial(name + "_BOOTS") == null) {
plugin.getLogger().log(Level.WARNING, "{0} is not a valid armor name", name);
return;
}
EntityEquipment equipment = entity.getEquipment();
equipment.setBoots(new ItemStack(Material.getMaterial(name + "_BOOTS")));
equipment.setLeggings(new ItemStack(Material.getMaterial(name + "_LEGGINGS")));
equipment.setChestplate(new ItemStack(Material.getMaterial(name + "_CHESTPLATE")));
equipment.setHelmet(new ItemStack(Material.getMaterial(name + "_HELMET")));
float dropChance = worldConfig.getInt(Config.FEATURE_ZOMBIE_ARMOR_DROP_CHANCE) / 100.0f;
equipment.setBootsDropChance(dropChance);
equipment.setLeggingsDropChance(dropChance);
equipment.setChestplateDropChance(dropChance);
equipment.setHelmetDropChance(dropChance);
}
示例2: onStop
import org.bukkit.inventory.EntityEquipment; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onStop(BloodMoonEndEvent event) {
World world = event.getWorld();
if (plugin.isFeatureEnabled(world, Feature.ZOMBIE_ARMOR)) {
for (LivingEntity entity : event.getWorld().getLivingEntities()) {
if (entity.getType() == EntityType.ZOMBIE) {
EntityEquipment equipment = entity.getEquipment();
equipment.setBoots(null);
equipment.setLeggings(null);
equipment.setChestplate(null);
equipment.setHelmet(null);
equipment.setBootsDropChance(0.0f);
equipment.setLeggingsDropChance(0.0f);
equipment.setChestplateDropChance(0.0f);
equipment.setHelmetDropChance(0.0f);
}
}
}
}
示例3: zombify
import org.bukkit.inventory.EntityEquipment; //導入方法依賴的package包/類
@EventHandler
public void zombify(PlayerDeathEvent e) {
Player p = e.getEntity();
if (!RUtils.isInInfectedWorld(p)) return;
if (!Config.spawnZombie) return;
Zombie z = ZombieSpawner.spawnLeveledZombie(p.getLocation());
if (z == null) return;
EntityEquipment ze = z.getEquipment();
EntityEquipment pe = p.getEquipment();
if (ze == null || pe == null) return;
ze.setArmorContents(pe.getArmorContents());
ze.setHelmetDropChance(0F);
ze.setChestplateDropChance(0F);
ze.setLeggingsDropChance(0F);
ze.setBootsDropChance(0F);
}
示例4: run
import org.bukkit.inventory.EntityEquipment; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@Override
public void run(String playerID) throws QuestRuntimeException {
Location location = loc.getLocation(playerID);
int a = amount.getInt(playerID);
for (int i = 0; i < a; i++) {
Entity entity = location.getWorld().spawnEntity(location, type);
if (entity instanceof LivingEntity) {
LivingEntity living = (LivingEntity) entity;
EntityEquipment eq = living.getEquipment();
eq.setHelmet(helmet == null ? null : helmet.generate(1));
eq.setHelmetDropChance(0);
eq.setChestplate(chestplate == null ? null : chestplate.generate(1));
eq.setChestplateDropChance(0);
eq.setLeggings(leggings == null ? null : leggings.generate(1));
eq.setLeggingsDropChance(0);
eq.setBoots(boots == null ? null : boots.generate(1));
eq.setBootsDropChance(0);
try {
eq.setItemInMainHand(mainHand == null ? null : mainHand.generate(1));
eq.setItemInMainHandDropChance(0);
eq.setItemInOffHand(offHand == null ? null : offHand.generate(1));
eq.setItemInOffHandDropChance(0);
} catch (LinkageError e) {
eq.setItemInHand(mainHand.generate(1));
eq.setItemInHandDropChance(0);
}
}
int j = 0;
for (Item item : drops) {
entity.setMetadata("betonquest-drops-" + j,
new FixedMetadataValue(BetonQuest.getInstance(), item.getID().getFullID() + ":"
+ item.getAmount().getInt(playerID)));
j++;
}
if (name != null && entity instanceof LivingEntity) {
LivingEntity livingEntity = (LivingEntity) entity;
livingEntity.setCustomName(name);
}
if (marked != null) {
entity.setMetadata("betonquest-marked", new FixedMetadataValue(BetonQuest.getInstance(), marked));
}
}
}
示例5: setEntityEquipment
import org.bukkit.inventory.EntityEquipment; //導入方法依賴的package包/類
private static void setEntityEquipment(EntityEquipment ee, int level) {
ee.setHelmetDropChance(r.nextFloat());
ee.setChestplateDropChance(r.nextFloat());
ee.setLeggingsDropChance(r.nextFloat());
ee.setBootsDropChance(r.nextFloat());
ee.setItemInHandDropChance(r.nextFloat());
switch (level) {
case 1:
// 4% chance
if (nextInt(1, 25) == 10) ee.setChestplate(getRandomItemStack(EquipmentType.LEGGINGS));
break;
case 2:
// 8.3% chance
if (nextInt(1, 12) == 8) {
ee.setChestplate(getRandomItemStack(EquipmentType.LEGGINGS));
ee.setItemInHand(getRandomItemStack(EquipmentType.WEAPON));
}
break;
case 3:
// 14.29% chance
if (nextInt(1, 7) == 4) {
ee.setChestplate(getRandomItemStack(EquipmentType.CHESTPLATE));
ee.setItemInHand(getRandomItemStack(EquipmentType.WEAPON));
ee.setLeggings(getRandomItemStack(EquipmentType.LEGGINGS));
}
break;
case 4:
// 33.3% chance
if (nextInt(1, 3) == 2) {
ee.setChestplate(getRandomItemStack(EquipmentType.CHESTPLATE));
ee.setItemInHand(getRandomItemStack(EquipmentType.WEAPON));
ee.setLeggings(getRandomItemStack(EquipmentType.LEGGINGS));
ee.setHelmet(getRandomItemStack(EquipmentType.HELM));
}
break;
case 5:
case 6:
case 7:
// 50% chance
if (r.nextBoolean()) {
ee.setChestplate(getRandomItemStack(EquipmentType.CHESTPLATE));
ee.setItemInHand(getRandomItemStack(EquipmentType.WEAPON));
ee.setLeggings(getRandomItemStack(EquipmentType.LEGGINGS));
ee.setHelmet(getRandomItemStack(EquipmentType.HELM));
ee.setBoots(getRandomItemStack(EquipmentType.BOOTS));
}
break;
}
}