本文整理汇总了Java中org.bukkit.inventory.EntityEquipment.setItemInHandDropChance方法的典型用法代码示例。如果您正苦于以下问题:Java EntityEquipment.setItemInHandDropChance方法的具体用法?Java EntityEquipment.setItemInHandDropChance怎么用?Java EntityEquipment.setItemInHandDropChance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.EntityEquipment
的用法示例。
在下文中一共展示了EntityEquipment.setItemInHandDropChance方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ZombieSpawn
import org.bukkit.inventory.EntityEquipment; //导入方法依赖的package包/类
public void ZombieSpawn(BlockBreakEvent event){
Location loc = event.getBlock().getLocation();
World world = loc.getWorld();
Zombie zombie = (Zombie) world.spawnEntity(loc,EntityType.ZOMBIE);
zombie.setCustomName("Bob the Zombie");
zombie.setCustomNameVisible(true);
zombie.setMaxHealth(90);
zombie.setHealth(90);
zombie.setVillager(true);
zombie.setTarget(event.getPlayer());
EntityEquipment zombieEquipment = zombie.getEquipment();
zombieEquipment.setHelmet(new ItemStack(Material.DIAMOND_HELMET));
zombieEquipment.setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS));
zombieEquipment.setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE));
zombieEquipment.setBoots(new ItemStack(Material.GOLD_BOOTS));
ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 4);
zombieEquipment.setItemInHand(sword);
zombieEquipment.setItemInHandDropChance(0.5F);
}
示例2: giveWeapon
import org.bukkit.inventory.EntityEquipment; //导入方法依赖的package包/类
private void giveWeapon(LivingEntity entity, PluginConfig worldConfig) {
String name = ListUtils.getRandom(worldConfig.getStringList(Config.FEATURE_ZOMBIE_WEAPON_WEAPONS)).toUpperCase();
Material type = Material.getMaterial(name);
if (type == null || type.isBlock()) {
plugin.getLogger().log(Level.WARNING, "{0} is not a valid item name", name);
return;
}
EntityEquipment equipment = entity.getEquipment();
equipment.setItemInHand(new ItemStack(type));
equipment.setItemInHandDropChance(worldConfig.getInt(Config.FEATURE_ZOMBIE_WEAPON_DROP_CHANCE) / 100.0f);
}
示例3: 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_WEAPON)) {
for (LivingEntity entity : world.getLivingEntities()) {
if (entity.getType() == EntityType.ZOMBIE) {
EntityEquipment equipment = entity.getEquipment();
equipment.setItemInHand(null);
equipment.setItemInHandDropChance(0.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;
}
}