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


Java EntityEquipment.setItemInHand方法代码示例

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


在下文中一共展示了EntityEquipment.setItemInHand方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: holdOperation

import org.bukkit.inventory.EntityEquipment; //导入方法依赖的package包/类
public static Parameter holdOperation(org.bukkit.entity.LivingEntity le, Context ctx, Parameter set) {
	EntityEquipment pent = le.getEquipment();
	if ( set != null ) {
		if ( set instanceof ItemParameter) {
			pent.setItemInHand(((ItemParameter) set).asItemStack(ctx));
		} else if ( set instanceof MaterialParameter ) {
			pent.setItemInHand(new ItemStack(((MaterialParameter) set).asMaterial(ctx), 1));

		} else {
			ItemStack s = Item.createItemstackFromString(set.asString(ctx));
			pent.setItemInHand(s);
		}
	}
	
	return Parameter.from(pent.getItemInHand());
}
 
开发者ID:basicer,项目名称:parchment,代码行数:17,代码来源:LEntity.java

示例3: set

import org.bukkit.inventory.EntityEquipment; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void set(final EntityEquipment e, final @Nullable ItemStack item) {
	if (Skript.isRunningMinecraft(1, 9))
		e.setItemInMainHand(item);
	else
		e.setItemInHand(item); //Compatibility reasons
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:9,代码来源:EquipmentSlot.java

示例4: 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

示例5: 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

示例6: restoreLiving

import org.bukkit.inventory.EntityEquipment; //导入方法依赖的package包/类
private void restoreLiving(final LivingEntity entity) {
    if (this.lived.loot) {
        entity.setCanPickupItems(this.lived.loot);
    }
    if (this.lived.name != null) {
        entity.setCustomName(this.lived.name);
        entity.setCustomNameVisible(this.lived.visible);
    }
    if ((this.lived.potions != null) && (this.lived.potions.size() > 0)) {
        entity.addPotionEffects(this.lived.potions);
    }
    entity.setRemainingAir(this.lived.air);
    entity.setRemoveWhenFarAway(this.lived.persistent);
    if (this.lived.equipped) {
        final EntityEquipment equipment = entity.getEquipment();
        equipment.setItemInHand(this.lived.hands);
        equipment.setHelmet(this.lived.helmet);
        equipment.setChestplate(this.lived.chestplate);
        equipment.setLeggings(this.lived.leggings);
        equipment.setBoots(this.lived.boots);
    }
    if (this.lived.leashed) {
        // TODO leashes
        //            World world = entity.getWorld();
        //            Entity leash = world.spawnEntity(new Location(world, Math.floor(x) + lived.leash_x, Math.floor(y) + lived.leash_y, Math.floor(z) + lived.leash_z), EntityType.LEASH_HITCH);
        //            entity.setLeashHolder(leash);
    }
}
 
开发者ID:Mayomi,项目名称:PlotSquared-Chinese,代码行数:29,代码来源:EntityWrapper.java

示例7: DroneShocktroop

import org.bukkit.inventory.EntityEquipment; //导入方法依赖的package包/类
public DroneShocktroop(Player target){
	this.target = target;
	Location l = getSafeLocationNearTarget();
	if(l == null) l = target.getLocation();
	mySkeleton = (Skeleton) target.getWorld().spawnEntity(l, EntityType.SKELETON);
	target.playSound(mySkeleton.getLocation(), Sound.PORTAL_TRAVEL, 2.0F, 2.0F);
	mySkeleton.setCustomName("Skywatch Shock Trooper");
	mySkeleton.setCustomNameVisible(true);
	EntityEquipment e = mySkeleton.getEquipment();
	ItemStack hat = new ItemStack(Material.DISPENSER, 1);
	ItemStack chest = new ItemStack(Material.DIAMOND_CHESTPLATE, 1);
	ItemStack leggings = new ItemStack(Material.DIAMOND_LEGGINGS, 1);
	ItemStack boots = new ItemStack(Material.DIAMOND_BOOTS, 1);
	chest.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, SQSkywatch.protectionLevel);
	leggings.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, SQSkywatch.protectionLevel);
	boots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, SQSkywatch.protectionLevel);
	e.setHelmet(hat);
	e.setChestplate(chest);
	e.setLeggings(leggings);
	e.setBoots(boots);
	

	ItemStack bow = new ItemStack(Material.BOW, 1);
	bow.addEnchantment(Enchantment.ARROW_DAMAGE, SQSkywatch.powerLevel);
	bow.addEnchantment(Enchantment.ARROW_KNOCKBACK, SQSkywatch.knockbackLevel);
	if(SQSkywatch.flameBows){
		bow.addEnchantment(Enchantment.ARROW_FIRE, 1);
	}
	e.setItemInHand(bow);
	mySkeleton.setTarget(target);
	mySkeleton.getWorld().playEffect(mySkeleton.getLocation(), Effect.ENDER_SIGNAL, 0);
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:33,代码来源:DroneShocktroop.java

示例8: restoreEquipment

import org.bukkit.inventory.EntityEquipment; //导入方法依赖的package包/类
void restoreEquipment(LivingEntity entity) {
    EntityEquipment equipment = entity.getEquipment();
    if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_9_0)) {
        equipment.setItemInMainHand(this.lived.mainHand);
        equipment.setItemInOffHand(this.lived.offHand);
    } else {
        equipment.setItemInHand(this.lived.mainHand);
    }
    equipment.setHelmet(this.lived.helmet);
    equipment.setChestplate(this.lived.chestplate);
    equipment.setLeggings(this.lived.leggings);
    equipment.setBoots(this.lived.boots);
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:14,代码来源:EntityWrapper.java

示例9: copyInventory

import org.bukkit.inventory.EntityEquipment; //导入方法依赖的package包/类
/**
 * Copies the inventory from the given player to the inventory of this entity.
 *
 * @param inPlayer			Player to copy inventory from
 * @param inIgnoreArmor		If armor should not be copied or if it should
 */
public void copyInventory(Player inPlayer, boolean inIgnoreArmor)
{
	this.copyInventory(inPlayer.getInventory());
	EntityEquipment equip = this.getBukkitEntity().getEquipment();
	if(!inIgnoreArmor)
		equip.setArmorContents(inPlayer.getInventory().getArmorContents());

	if(this.getInventory() instanceof CraftInventoryPlayer)
		((CraftInventoryPlayer)this.getInventory()).setHeldItemSlot(inPlayer.getInventory().getHeldItemSlot());
	else
		equip.setItemInHand(inPlayer.getItemInHand());
}
 
开发者ID:kumpelblase2,项目名称:remote-entities-nxt,代码行数:19,代码来源:RemoteBaseEntity.java

示例10: copyInventory

import org.bukkit.inventory.EntityEquipment; //导入方法依赖的package包/类
/**
 * Copies the inventory from the given player to the inventory of this entity.
 *
 * @param inPlayer      Player to copy inventory from
 * @param inIgnoreArmor If armor should not be copied or if it should
 */
public void copyInventory(Player inPlayer, boolean inIgnoreArmor)
{
	this.copyInventory(inPlayer.getInventory());
	EntityEquipment equip = this.getBukkitEntity().getEquipment();
	if(!inIgnoreArmor)
		equip.setArmorContents(inPlayer.getInventory().getArmorContents());

	if(this.getInventory() instanceof CraftInventoryPlayer)
		((CraftInventoryPlayer)this.getInventory()).setHeldItemSlot(inPlayer.getInventory().getHeldItemSlot());
	else
		equip.setItemInHand(inPlayer.getItemInHand());
}
 
开发者ID:MeRPG2,项目名称:EndHQ-Libraries,代码行数:19,代码来源:RemoteBaseEntity.java

示例11: setHand

import org.bukkit.inventory.EntityEquipment; //导入方法依赖的package包/类
public void setHand(LivingEntity e)
{
	ItemStack hand = new ItemStack(Material.CAKE,1);
	ItemMeta meta = hand.getItemMeta();
	meta.setDisplayName("Christmas Pudding");
	hand.setItemMeta(meta);

	EntityEquipment ee = e.getEquipment();
	ee.setItemInHand(hand);
}
 
开发者ID:EmilHernvall,项目名称:tregmine,代码行数:11,代码来源:SpawnListener.java

示例12: 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

示例13: equip

import org.bukkit.inventory.EntityEquipment; //导入方法依赖的package包/类
@Override
public boolean equip(Entity entity, ItemStack item) {
    PreCon.notNull(entity);
    PreCon.notNull(item);

    if (entity instanceof LivingEntity) {

        LivingEntity livingEntity = (LivingEntity)entity;

        EntityEquipment equipment = livingEntity.getEquipment();

        if (entity instanceof HumanEntity) {

            Set<MaterialProperty> properties = Materials.getProperties(item.getType());

            if (properties.contains(MaterialProperty.ARMOR)) {

                if (properties.contains(MaterialProperty.HELMET)) {
                    equipment.setHelmet(item);
                }
                else if (properties.contains(MaterialProperty.CHESTPLATE)) {
                    equipment.setChestplate(item);
                }
                else if (properties.contains(MaterialProperty.LEGGINGS)) {
                    equipment.setLeggings(item);
                }
                else if (properties.contains(MaterialProperty.BOOTS)) {
                    equipment.setBoots(item);
                }
            }
            else {
                equipment.setItemInHand(item);
            }

        } else {
            equipment.setItemInHand(item);
        }

        return true;
    }

    return false;
}
 
开发者ID:JCThePants,项目名称:NucleusFramework,代码行数:44,代码来源:DefaultEquipper.java

示例14: 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

示例15: clear

import org.bukkit.inventory.EntityEquipment; //导入方法依赖的package包/类
@Override
public List<ItemStack> clear(Entity entity) {
    PreCon.notNull(entity);

    if (entity instanceof LivingEntity) {

        LivingEntity livingEntity = (LivingEntity)entity;

        EntityEquipment equipment = livingEntity.getEquipment();

        List<ItemStack> result = new ArrayList<>(5);

        addItemToList(result, equipment.getItemInHand());
        equipment.setItemInHand(null);

        if (entity instanceof HumanEntity) {

            addItemToList(result, equipment.getHelmet());
            equipment.setHelmet(null);

            addItemToList(result, equipment.getChestplate());
            equipment.setChestplate(null);

            addItemToList(result, equipment.getLeggings());
            equipment.setLeggings(null);

            addItemToList(result, equipment.getBoots());
            equipment.setBoots(null);
        }

        return result;
    }

    return new ArrayList<>(0);
}
 
开发者ID:JCThePants,项目名称:NucleusFramework,代码行数:36,代码来源:DefaultEquipper.java


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