use of org.bukkit.inventory.EntityEquipment in project Essentials by drtshock.
the class SpawnMob method defaultMobData.
private static void defaultMobData(final EntityType type, final Entity spawned) {
if (type == EntityType.SKELETON) {
final EntityEquipment invent = ((LivingEntity) spawned).getEquipment();
InventoryWorkaround.setItemInMainHand(invent, new ItemStack(Material.BOW, 1));
InventoryWorkaround.setItemInMainHandDropChance(invent, 0.1f);
invent.setBoots(new ItemStack(Material.GOLD_BOOTS, 1));
invent.setBootsDropChance(0.0f);
}
if (type == EntityType.PIG_ZOMBIE) {
final PigZombie zombie = ((PigZombie) spawned);
setVillager(zombie, false);
final EntityEquipment invent = zombie.getEquipment();
InventoryWorkaround.setItemInMainHand(invent, new ItemStack(Material.GOLD_SWORD, 1));
InventoryWorkaround.setItemInMainHandDropChance(invent, 0.1f);
invent.setBoots(new ItemStack(Material.GOLD_BOOTS, 1));
invent.setBootsDropChance(0.0f);
}
if (type == EntityType.ZOMBIE) {
final Zombie zombie = ((Zombie) spawned);
setVillager(zombie, false);
final EntityEquipment invent = zombie.getEquipment();
invent.setBoots(new ItemStack(Material.GOLD_BOOTS, 1));
invent.setBootsDropChance(0.0f);
}
if (type == EntityType.HORSE) {
((Horse) spawned).setJumpStrength(1.2);
}
}
use of org.bukkit.inventory.EntityEquipment in project InfernalMobs by NyaaCat.
the class AbilityArmoured method onMobSpawn.
@Override
public void onMobSpawn(InfernalMobSpawnEvent ev) {
Mob mob = ev.mob;
LivingEntity mobEntity = ev.mobEntity;
mobEntity.setCanPickupItems(false);
EntityEquipment ee = mobEntity.getEquipment();
boolean isCloaked = mob.abilityList.contains(EnumAbilities.CLOAKED);
// helmet & chestplate required for all mobs
ee.setHelmetDropChance(0.0f);
ee.setChestplateDropChance(0.0f);
ee.setHelmet(new ItemStack(Material.DIAMOND_HELMET, 1));
ee.setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE, 1));
// leggings & boots for all visible mobs
ee.setLeggingsDropChance(0.0f);
ee.setBootsDropChance(0.0f);
ee.setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS, 1));
ee.setBoots(new ItemStack(Material.DIAMOND_BOOTS, 1));
// skeletons use bow
if (mobEntity.getType() == EntityType.SKELETON) {
ee.setItemInMainHand(new ItemStack(Material.BOW, 1));
ee.setItemInMainHandDropChance(0);
} else {
// else use sword
ItemStack sword = new ItemStack(Material.DIAMOND_SWORD, 1);
sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 4);
ee.setItemInMainHand(sword);
ee.setItemInMainHandDropChance(0);
}
}
use of org.bukkit.inventory.EntityEquipment in project MagicPlugin by elBukkit.
the class TakeItemAction method perform.
@Override
public SpellResult perform(CastContext context) {
Entity target = context.getTargetEntity();
if (target == null) {
return SpellResult.NO_TARGET;
}
ItemStack item = null;
if (target instanceof LivingEntity) {
LivingEntity livingEntity = (LivingEntity) target;
if (displayName == null) {
EntityEquipment equipment = livingEntity.getEquipment();
item = equipment.getItemInMainHand();
;
equipment.setItemInMainHand(null);
} else {
if (!(target instanceof Player)) {
return SpellResult.PLAYER_REQUIRED;
}
Player targetPlayer = (Player) target;
PlayerInventory playerInventory = targetPlayer.getInventory();
for (int i = 0; i < playerInventory.getSize(); i++) {
ItemStack inventoryItem = playerInventory.getItem(i);
if (InventoryUtils.isEmpty(inventoryItem))
continue;
ItemMeta meta = inventoryItem.getItemMeta();
if (meta == null || !meta.hasDisplayName())
continue;
if (meta.getDisplayName().equals(displayName)) {
item = inventoryItem;
playerInventory.setItem(i, null);
break;
}
}
}
} else if (target instanceof Item) {
Item itemEntity = (Item) target;
item = itemEntity.getItemStack();
if (displayName != null) {
ItemMeta itemMeta = item.getItemMeta();
if (itemMeta == null || !itemMeta.hasDisplayName() || !itemMeta.getDisplayName().equals(displayName)) {
item = null;
}
}
if (item != null) {
itemEntity.remove();
}
}
if (InventoryUtils.isEmpty(item)) {
return SpellResult.NO_TARGET;
}
context.getMage().giveItem(item);
return SpellResult.CAST;
}
use of org.bukkit.inventory.EntityEquipment in project InfernalMobs by NyaaCat.
the class AbilityArmoured method onMobSpawn.
@Override
public void onMobSpawn(InfernalMobSpawnEvent ev) {
Mob mob = ev.mob;
LivingEntity mobEntity = ev.mobEntity;
mobEntity.setCanPickupItems(false);
EntityEquipment ee = mobEntity.getEquipment();
boolean isCloaked = mob.abilityList.contains(EnumAbilities.CLOAKED);
// helmet & chestplate required for all mobs
ee.setHelmetDropChance(0.0f);
ee.setChestplateDropChance(0.0f);
ee.setHelmet(new ItemStack(Material.DIAMOND_HELMET, 1));
ee.setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE, 1));
// leggings & boots for all visible mobs
ee.setLeggingsDropChance(0.0f);
ee.setBootsDropChance(0.0f);
ee.setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS, 1));
ee.setBoots(new ItemStack(Material.DIAMOND_BOOTS, 1));
// skeletons use bow
if (mobEntity.getType() == EntityType.SKELETON) {
ee.setItemInMainHand(new ItemStack(Material.BOW, 1));
ee.setItemInMainHandDropChance(0);
} else {
// else use sword
ItemStack sword = new ItemStack(Material.DIAMOND_SWORD, 1);
sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 4);
ee.setItemInMainHand(sword);
ee.setItemInMainHandDropChance(0);
}
}
use of org.bukkit.inventory.EntityEquipment in project CitizensAPI by CitizensDev.
the class Equipment method onSpawn.
@Override
@SuppressWarnings("deprecation")
public void onSpawn() {
if (!(npc.getEntity() instanceof LivingEntity) && !(npc.getEntity() instanceof ArmorStand))
return;
if (npc.getEntity() instanceof Enderman) {
Enderman enderman = (Enderman) npc.getEntity();
if (equipment[0] != null) {
if (SpigotUtil.isUsing1_13API()) {
enderman.setCarriedBlock(equipment[0].getType().createBlockData());
} else {
enderman.setCarriedMaterial(equipment[0].getData());
}
}
} else {
EntityEquipment equip = getEquipmentFromEntity(npc.getEntity());
if (equipment[0] != null) {
equip.setItemInHand(equipment[0]);
}
equip.setHelmet(equipment[1]);
equip.setChestplate(equipment[2]);
equip.setLeggings(equipment[3]);
equip.setBoots(equipment[4]);
try {
equip.setItemInOffHand(equipment[5]);
} catch (NoSuchMethodError e) {
}
}
if (npc.getEntity() instanceof Player) {
((Player) npc.getEntity()).updateInventory();
}
}
Aggregations