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


Java EntityEquipment.setHelmetDropChance方法代码示例

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


在下文中一共展示了EntityEquipment.setHelmetDropChance方法的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);
}
 
开发者ID:Samistine,项目名称:BloodMoon,代码行数:23,代码来源:ZombieArmorListener.java

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

示例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);
}
 
开发者ID:RoyalDev,项目名称:RoyalSurvivors,代码行数:17,代码来源:SurvivorsListener.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.setHelmetDropChance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。