use of net.minecraft.server.v1_16_R2.Item in project TheAPI by TheDevTec.
the class v1_16_R2 method openGUI.
@Override
public void openGUI(Player player, Object container, String legacy, int size, String title, ItemStack[] items) {
EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle();
int id = ((Container) container).windowId;
net.minecraft.server.v1_16_R2.ItemStack[] nmsItems = new net.minecraft.server.v1_16_R2.ItemStack[items.length];
for (int i = 0; i < items.length; ++i) {
ItemStack is = items[i];
if (is == null || is.getType() == Material.AIR)
continue;
net.minecraft.server.v1_16_R2.ItemStack item = null;
((Container) container).setItem(i, item = (net.minecraft.server.v1_16_R2.ItemStack) asNMSItem(is));
nmsItems[i] = item;
}
BukkitLoader.getPacketHandler().send(player, packetOpenWindow(id, legacy, size, title));
int i = 0;
for (net.minecraft.server.v1_16_R2.ItemStack o : nmsItems) BukkitLoader.getPacketHandler().send(player, packetSetSlot(id, i++, o));
nmsPlayer.activeContainer.transferTo((Container) container, (CraftPlayer) player);
nmsPlayer.activeContainer = (Container) container;
((Container) container).addSlotListener(nmsPlayer);
((Container) container).checkReachable = false;
}
use of net.minecraft.server.v1_16_R2.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_16_R2.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_16_R2.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_16_R2.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