Java Code Examples for org.bukkit.craftbukkit.util.CraftMagicNumbers#getItem()
The following examples show how to use
org.bukkit.craftbukkit.util.CraftMagicNumbers#getItem() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CraftItemStack.java From Kettle with GNU General Public License v3.0 | 6 votes |
@Override public void setTypeId(int type) { if (getTypeId() == type) { return; } else if (type == 0) { handle = null; } else if (CraftMagicNumbers.getItem(type) == null) { // :( handle = null; } else if (handle == null) { handle = new net.minecraft.item.ItemStack(CraftMagicNumbers.getItem(type), 1, 0); } else { handle.setItem(CraftMagicNumbers.getItem(type)); if (hasItemMeta()) { // This will create the appropriate item meta, which will contain all the data we intend to keep setItemMeta(handle, getItemMeta(handle)); } } setData(null); }
Example 2
Source File: CraftJukebox.java From Thermos with GNU General Public License v3.0 | 6 votes |
@Override public void setPlaying(Material record) { if (record == null || CraftMagicNumbers.getItem(record) == null) { record = Material.AIR; jukebox.func_145857_a(null); } else { jukebox.func_145857_a(new ItemStack(CraftMagicNumbers.getItem(record), 1)); } jukebox.markDirty(); if (record == Material.AIR) { world.getHandle().setBlockMetadataWithNotify(getX(), getY(), getZ(), 0, 3); } else { world.getHandle().setBlockMetadataWithNotify(getX(), getY(), getZ(), 1, 3); } world.playEffect(getLocation(), Effect.RECORD_PLAY, record.getId()); }
Example 3
Source File: CraftItemStack.java From Thermos with GNU General Public License v3.0 | 6 votes |
@Override public void setTypeId(int type) { if (getTypeId() == type) { return; } else if (type == 0) { handle = null; } else if (CraftMagicNumbers.getItem(type) == null) { // :( handle = null; } else if (handle == null) { handle = new net.minecraft.item.ItemStack(CraftMagicNumbers.getItem(type), 1, 0); } else { handle.func_150996_a(CraftMagicNumbers.getItem(type)); if (hasItemMeta()) { // This will create the appropriate item meta, which will contain all the data we intend to keep setItemMeta(handle, getItemMeta(handle)); } } setData(null); }
Example 4
Source File: CraftShapedRecipe.java From Thermos with GNU General Public License v3.0 | 6 votes |
public void addToCraftingManager() { Object[] data; String[] shape = this.getShape(); Map<Character, ItemStack> ingred = this.getIngredientMap(); int datalen = shape.length; datalen += ingred.size() * 2; int i = 0; data = new Object[datalen]; for (; i < shape.length; i++) { data[i] = shape[i]; } for (char c : ingred.keySet()) { ItemStack mdata = ingred.get(c); if (mdata == null) continue; data[i] = c; i++; int id = mdata.getTypeId(); short dmg = mdata.getDurability(); data[i] = new net.minecraft.item.ItemStack(CraftMagicNumbers.getItem(id), 1, dmg); i++; } net.minecraft.item.crafting.CraftingManager.getInstance().addRecipe(CraftItemStack.asNMSCopy(this.getResult()), data); }
Example 5
Source File: CraftJukebox.java From Kettle with GNU General Public License v3.0 | 5 votes |
@Override public void setPlaying(Material record) { if (record == null || CraftMagicNumbers.getItem(record) == null) { record = Material.AIR; } this.getSnapshot().setRecord(new ItemStack(CraftMagicNumbers.getItem(record), 1)); if (record == Material.AIR) { setRawData((byte) 0); } else { setRawData((byte) 1); } }
Example 6
Source File: NMSHacks.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
/** * Test if the given tool is capable of "efficiently" mining the given block. * * Derived from CraftBlock.itemCausesDrops() */ public static boolean canMineBlock(MaterialData blockMaterial, org.bukkit.inventory.ItemStack tool) { if(!blockMaterial.getItemType().isBlock()) { throw new IllegalArgumentException("Material '" + blockMaterial + "' is not a block"); } net.minecraft.server.Block nmsBlock = CraftMagicNumbers.getBlock(blockMaterial.getItemType()); net.minecraft.server.Item nmsTool = tool == null ? null : CraftMagicNumbers.getItem(tool.getType()); return nmsBlock != null && (nmsBlock.getBlockData().getMaterial().isAlwaysDestroyable() || (nmsTool != null && nmsTool.canDestroySpecialBlock(nmsBlock.getBlockData()))); }
Example 7
Source File: CraftShapelessRecipe.java From Thermos with GNU General Public License v3.0 | 5 votes |
public void addToCraftingManager() { List<ItemStack> ingred = this.getIngredientList(); Object[] data = new Object[ingred.size()]; int i = 0; for (ItemStack mdata : ingred) { int id = mdata.getTypeId(); short dmg = mdata.getDurability(); data[i] = new net.minecraft.item.ItemStack(CraftMagicNumbers.getItem(id), 1, dmg); i++; } net.minecraft.item.crafting.CraftingManager.getInstance().addShapelessRecipe(CraftItemStack.asNMSCopy(this.getResult()), data); }