use of org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack in project Magma by magmafoundation.
the class CraftEventFactory method callEntityBreedEvent.
public static EntityBreedEvent callEntityBreedEvent(EntityLivingBase child, EntityLivingBase mother, EntityLivingBase father, EntityLivingBase breeder, ItemStack bredWith, int experience) {
LivingEntity breederEntity = (LivingEntity) (breeder == null ? null : breeder.getBukkitEntity());
CraftItemStack bredWithStack = bredWith == null ? null : CraftItemStack.asCraftMirror(bredWith).clone();
EntityBreedEvent event = new EntityBreedEvent((LivingEntity) child.getBukkitEntity(), (LivingEntity) mother.getBukkitEntity(), (LivingEntity) father.getBukkitEntity(), breederEntity, bredWithStack, experience);
child.world.getServer().getPluginManager().callEvent(event);
return event;
}
use of org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack in project Magma by magmafoundation.
the class PerMaterialTest method maxStackSize.
@Test
public void maxStackSize() {
if (INVALIDATED_MATERIALS.contains(material)) {
return;
}
final ItemStack bukkit = new ItemStack(material);
final CraftItemStack craft = CraftItemStack.asCraftCopy(bukkit);
if (material == Material.AIR) {
final int MAX_AIR_STACK = 0;
assertThat(material.getMaxStackSize(), is(MAX_AIR_STACK));
assertThat(bukkit.getMaxStackSize(), is(MAX_AIR_STACK));
assertThat(craft.getMaxStackSize(), is(MAX_AIR_STACK));
} else {
assertThat(material.getMaxStackSize(), is(CraftMagicNumbers.getItem(material).getItemStackLimit()));
assertThat(bukkit.getMaxStackSize(), is(material.getMaxStackSize()));
assertThat(craft.getMaxStackSize(), is(material.getMaxStackSize()));
}
}
use of org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack in project Magma by magmafoundation.
the class ItemMetaTest method testCrazyEquality.
@Test
public void testCrazyEquality() {
CraftItemStack craft = CraftItemStack.asCraftCopy(new ItemStack(1));
craft.setItemMeta(craft.getItemMeta());
ItemStack bukkit = new ItemStack(craft);
assertThat(craft, is(bukkit));
assertThat(bukkit, is(craft));
}
use of org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack in project LoliServer by Loli-Server.
the class CraftEventFactory method callPlayerItemBreakEvent.
public static void callPlayerItemBreakEvent(PlayerEntity human, ItemStack brokenItem) {
CraftItemStack item = CraftItemStack.asCraftMirror(brokenItem);
PlayerItemBreakEvent event = new PlayerItemBreakEvent((Player) human.getBukkitEntity(), item);
Bukkit.getPluginManager().callEvent(event);
}
use of org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack in project LoliServer by Loli-Server.
the class CraftEventFactory method callEntityDeathEvent.
public static EntityDeathEvent callEntityDeathEvent(LivingEntity victim, List<org.bukkit.inventory.ItemStack> drops) {
CraftLivingEntity entity = (CraftLivingEntity) victim.getBukkitEntity();
EntityDeathEvent event = new EntityDeathEvent(entity, drops, victim.expToDrop);
CraftWorld world = (CraftWorld) entity.getWorld();
Bukkit.getServer().getPluginManager().callEvent(event);
victim.expToDrop = event.getDroppedExp();
for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
if (stack == null || stack.getType() == Material.AIR || stack.getAmount() == 0)
continue;
// Paper - note: dropItem already clones due to this being bukkit -> NMS
world.dropItem(entity.getLocation(), stack);
if (stack instanceof CraftItemStack)
// Paper - destroy this item - if this ever leaks due to game bugs, ensure it doesn't dupe, but don't nuke bukkit stacks of manually added items
stack.setAmount(0);
}
victim.dropExperience();
return event;
}
Aggregations