当前位置: 首页>>代码示例>>Java>>正文


Java EntityEquipment.setItemInHandDropChance方法代码示例

本文整理汇总了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);
}
 
开发者ID:josegrobles,项目名称:LuckyBlocksBukkit,代码行数:21,代码来源:LuckyBlocksActionController.java

示例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);
}
 
开发者ID:Samistine,项目名称:BloodMoon,代码行数:15,代码来源:ZombieWeaponListener.java

示例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);
            }
        }
    }
}
 
开发者ID:Samistine,项目名称:BloodMoon,代码行数:16,代码来源:ZombieWeaponListener.java

示例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));
		}
	}
}
 
开发者ID:Co0sh,项目名称:BetonQuest,代码行数:45,代码来源:SpawnMobEvent.java

示例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;
    }
}
 
开发者ID:RoyalDev,项目名称:RoyalSurvivors,代码行数:50,代码来源:ZombieSpawner.java


注:本文中的org.bukkit.inventory.EntityEquipment.setItemInHandDropChance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。