本文整理匯總了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);
}
示例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());
}
示例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
}
示例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);
}
示例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);
}
}
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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());
}
示例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());
}
示例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);
}
示例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));
}
}
}
示例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;
}
示例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;
}
}
示例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);
}