本文整理汇总了Java中org.bukkit.craftbukkit.util.CraftMagicNumbers.getItem方法的典型用法代码示例。如果您正苦于以下问题:Java CraftMagicNumbers.getItem方法的具体用法?Java CraftMagicNumbers.getItem怎么用?Java CraftMagicNumbers.getItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.craftbukkit.util.CraftMagicNumbers
的用法示例。
在下文中一共展示了CraftMagicNumbers.getItem方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setPlaying
import org.bukkit.craftbukkit.util.CraftMagicNumbers; //导入方法依赖的package包/类
@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());
}
示例2: setTypeId
import org.bukkit.craftbukkit.util.CraftMagicNumbers; //导入方法依赖的package包/类
@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);
}
示例3: addToCraftingManager
import org.bukkit.craftbukkit.util.CraftMagicNumbers; //导入方法依赖的package包/类
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);
}
示例4: addToCraftingManager
import org.bukkit.craftbukkit.util.CraftMagicNumbers; //导入方法依赖的package包/类
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.server.ItemStack(CraftMagicNumbers.getItem(id), 1, dmg);
i++;
}
CraftingManager.getInstance().registerShapedRecipe(CraftItemStack.asNMSCopy(this.getResult()), data);
}
示例5: setPlaying
import org.bukkit.craftbukkit.util.CraftMagicNumbers; //导入方法依赖的package包/类
@Override
public void setPlaying(Material record) {
if (record == null || CraftMagicNumbers.getItem(record) == null) {
record = Material.AIR;
jukebox.setRecord(null);
} else {
jukebox.setRecord(new ItemStack(CraftMagicNumbers.getItem(record), 1));
}
jukebox.update();
if (record == Material.AIR) {
world.getHandle().setData(getX(), getY(), getZ(), 0, 3);
} else {
world.getHandle().setData(getX(), getY(), getZ(), 1, 3);
}
world.playEffect(getLocation(), Effect.RECORD_PLAY, record.getId());
}
示例6: addToCraftingManager
import org.bukkit.craftbukkit.util.CraftMagicNumbers; //导入方法依赖的package包/类
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];
}*/
System.arraycopy(shape, 0, data, 0, shape.length);i=shape.length;//FFoKC
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);
}
示例7: addToCraftingManager
import org.bukkit.craftbukkit.util.CraftMagicNumbers; //导入方法依赖的package包/类
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);
}
示例8: canMineBlock
import org.bukkit.craftbukkit.util.CraftMagicNumbers; //导入方法依赖的package包/类
/**
* 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())));
}