本文整理汇总了Java中org.bukkit.inventory.EntityEquipment.setChestplateDropChance方法的典型用法代码示例。如果您正苦于以下问题:Java EntityEquipment.setChestplateDropChance方法的具体用法?Java EntityEquipment.setChestplateDropChance怎么用?Java EntityEquipment.setChestplateDropChance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.EntityEquipment
的用法示例。
在下文中一共展示了EntityEquipment.setChestplateDropChance方法的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;
}
}