use of org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack in project EverNifeCore by EverNife.
the class NMSUtils_v1_7_R4 method setHandle.
private void setHandle(org.bukkit.inventory.ItemStack mcStack, ItemStack handle) {
Validate.notNull(mcStack, "mcStack can not be null!");
Validate.notNull(handle, "handle can not be null!");
try {
CraftItemStack craftItemStack = (CraftItemStack) mcStack;
handle_field.set(craftItemStack, handle);
} catch (Exception e) {
Class c = mcStack.getClass();
EverNifeCore.warning("ItemStack Class:\n\n Package: " + c.getPackage() + "\nClass: " + c.getSimpleName() + "\nFull Identifier: " + c.getName());
e.printStackTrace();
throw new RuntimeException(e);
}
}
use of org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack in project EverNifeCore by EverNife.
the class NMSUtils_v1_7_R4 method getHandle.
private ItemStack getHandle(org.bukkit.inventory.ItemStack itemStack) {
Validate.notNull(itemStack, "itemStack can not be null!");
try {
CraftItemStack craftItemStack = (CraftItemStack) itemStack;
ItemStack mcStack = handle_field.get(craftItemStack);
return mcStack;
} catch (Exception e) {
Class c = itemStack.getClass();
EverNifeCore.warning("Failed to get ItemStack Handle for:" + "\n" + "\nPackage: " + c.getPackage() + "" + "\nClass: " + c.getSimpleName() + "" + "\nFull Identifier: " + c.getName());
e.printStackTrace();
throw new RuntimeException(e);
}
}
use of org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack in project Magma by magmafoundation.
the class CraftEventFactory method callEntityShootBowEvent.
/**
* EntityShootBowEvent
*/
public static EntityShootBowEvent callEntityShootBowEvent(EntityLivingBase who, ItemStack itemstack, EntityArrow entityArrow, float force) {
LivingEntity shooter = (LivingEntity) who.getBukkitEntity();
CraftItemStack itemInHand = CraftItemStack.asCraftMirror(itemstack);
Arrow arrow = (Arrow) entityArrow.getBukkitEntity();
if (itemInHand != null && (itemInHand.getType() == Material.AIR || itemInHand.getAmount() == 0)) {
itemInHand = null;
}
EntityShootBowEvent event = new EntityShootBowEvent(shooter, itemInHand, arrow, force);
Bukkit.getPluginManager().callEvent(event);
return event;
}
use of org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack in project Magma by magmafoundation.
the class CraftEventFactory method callBlockDamageEvent.
/**
* BlockDamageEvent
*/
public static BlockDamageEvent callBlockDamageEvent(EntityPlayer who, int x, int y, int z, ItemStack itemstack, boolean instaBreak) {
Player player = (who == null) ? null : (Player) who.getBukkitEntity();
CraftItemStack itemInHand = CraftItemStack.asCraftMirror(itemstack);
CraftWorld craftWorld = (CraftWorld) player.getWorld();
CraftServer craftServer = (CraftServer) player.getServer();
Block blockClicked = craftWorld.getBlockAt(x, y, z);
BlockDamageEvent event = new BlockDamageEvent(player, blockClicked, itemInHand, instaBreak);
craftServer.getPluginManager().callEvent(event);
return event;
}
use of org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack in project Magma by magmafoundation.
the class FactoryItemMaterialTest method itemStack.
@Test
public void itemStack() {
ItemStack bukkitStack = new ItemStack(material);
CraftItemStack craftStack = CraftItemStack.asCraftCopy(bukkitStack);
ItemMeta meta = factory.getItemMeta(material);
if (meta == null) {
assertThat(material, is(Material.AIR));
} else {
assertTrue(factory.isApplicable(meta, bukkitStack));
assertTrue(factory.isApplicable(meta, craftStack));
}
}
Aggregations