use of net.minecraft.server.v1_11_R1.Item in project PaperDev by Kamillaova.
the class CraftItemStack method asNMSCopy.
public static net.minecraft.server.v1_12_R1.ItemStack asNMSCopy(ItemStack original) {
if (original instanceof CraftItemStack) {
CraftItemStack stack = (CraftItemStack) original;
return stack.handle == null ? net.minecraft.server.v1_12_R1.ItemStack.a : stack.handle.cloneItemStack();
}
if (original == null || original.getTypeId() <= 0) {
return net.minecraft.server.v1_12_R1.ItemStack.a;
}
Item item = CraftMagicNumbers.getItem(original.getType());
if (item == null) {
return net.minecraft.server.v1_12_R1.ItemStack.a;
}
net.minecraft.server.v1_12_R1.ItemStack stack = new net.minecraft.server.v1_12_R1.ItemStack(item, original.getAmount(), original.getDurability(), false);
if (original.hasItemMeta()) {
setItemMeta(stack, original.getItemMeta());
} else {
// Converted after setItemMeta
stack.convertStack();
}
return stack;
}
use of net.minecraft.server.v1_11_R1.Item in project PaperDev by Kamillaova.
the class ItemMetaTest method testBlockStateMeta.
@Test
public void testBlockStateMeta() {
for (Item item : (Iterable<Item>) Item.REGISTRY) {
Block block = null;
if (item instanceof ItemBlock) {
block = ((ItemBlock) item).getBlock();
} else if (item instanceof ItemReed) {
block = ((ItemReed) item).a;
}
if (block != null) {
if (block instanceof ITileEntity) {
ItemStack stack = CraftItemStack.asNewCraftStack(Item.getItemOf(block));
// Command blocks aren't unit testable atm
if (stack.getType() == Material.AIR || stack.getType() == Material.COMMAND || stack.getType() == Material.COMMAND_CHAIN || stack.getType() == Material.COMMAND_REPEATING) {
return;
}
ItemMeta meta = stack.getItemMeta();
assertTrue(stack + " has meta of type " + meta + " expected BlockStateMeta", meta instanceof BlockStateMeta);
BlockStateMeta blockState = (BlockStateMeta) meta;
assertNotNull(stack + " has null block state", blockState.getBlockState());
blockState.setBlockState(blockState.getBlockState());
}
}
}
}
use of net.minecraft.server.v1_11_R1.Item in project acidisland by tastybento.
the class NMSHandler method getSpawnEgg.
/**
* Get spawn egg
* @param type
* @param amount
* @return
*/
public ItemStack getSpawnEgg(EntityType type, int amount) {
// Bukkit.getLogger().info("DEBUG: setting spawn egg " + type.toString());
ItemStack item = new ItemStack(Material.MONSTER_EGG, amount);
net.minecraft.server.v1_11_R1.ItemStack stack = CraftItemStack.asNMSCopy(item);
NBTTagCompound tagCompound = stack.getTag();
if (tagCompound == null) {
tagCompound = new NBTTagCompound();
}
// Bukkit.getLogger().info("DEBUG: tag = " + tagCompound);
NBTTagCompound id = new NBTTagCompound();
if (!bToMConversion.containsKey(type)) {
id.setString("id", "minecraft:" + type.toString().toLowerCase());
} else {
id.setString("id", "minecraft:" + bToMConversion.get(type));
}
tagCompound.set("EntityTag", id);
stack.setTag(tagCompound);
// Bukkit.getLogger().info("DEBUG: after tag = " + tagCompound);
return CraftItemStack.asBukkitCopy(stack);
}
use of net.minecraft.server.v1_11_R1.Item in project MyPet by xXKeyleXx.
the class ConfigItem method load.
public void load(MaterialHolder material, String data) {
MinecraftKey key = new MinecraftKey(material.getLegacyName().getName());
Item item = Item.REGISTRY.get(key);
if (item == null) {
return;
}
net.minecraft.server.v1_9_R2.ItemStack is = new net.minecraft.server.v1_9_R2.ItemStack(item, 1, material.getLegacyName().getData());
if (data != null) {
NBTTagCompound tag = null;
String nbtString = data.trim();
if (nbtString.startsWith("{") && nbtString.endsWith("}")) {
try {
tag = MojangsonParser.parse(nbtString);
} catch (Exception e) {
MyPetApi.getLogger().warning("Error" + ChatColor.RESET + " in config: " + ChatColor.UNDERLINE + e.getLocalizedMessage() + ChatColor.RESET + " caused by:");
MyPetApi.getLogger().warning(item.getName() + " " + nbtString);
}
if (tag != null) {
is.setTag(tag);
}
}
}
this.item = CraftItemStack.asCraftMirror(is);
}
use of net.minecraft.server.v1_11_R1.Item in project ORCID-Source by ORCID.
the class ProfileFundingManagerImpl method createItem.
private Item createItem(ProfileFundingEntity profileFundingEntity) {
Item item = new Item();
item.setItemName(profileFundingEntity.getTitle());
item.setItemType(ItemType.FUNDING);
item.setPutCode(String.valueOf(profileFundingEntity.getId()));
return item;
}
Aggregations