Search in sources :

Example 31 with Item

use of net.minecraft.server.v1_15_R1.DataWatcher.Item in project PublicCrafters by BananaPuncher714.

the class CustomInventoryCrafting method setItem.

@Override
public void setItem(int index, ItemStack item) {
    // Instead of updating one container, update all the containers
    // That are looking at the table, basically the viewers
    items.set(index, item);
    for (Container container : containers) {
        container.a(this);
    }
    // Update the armorstand grid
    display.update();
}
Also used : Container(net.minecraft.server.v1_15_R1.Container) SelfContainer(io.github.bananapuncher714.crafters.implementation.v1_15_R1.ContainerManager_v1_15_R1.SelfContainer)

Example 32 with Item

use of net.minecraft.server.v1_15_R1.DataWatcher.Item in project SilkSpawners by timbru31.

the class NMSHandler method newEggItem.

@SuppressWarnings("deprecation")
@Override
public ItemStack newEggItem(final String entityID, final int amount, final String displayName) {
    Material spawnEgg = Material.matchMaterial(entityID.toUpperCase() + "_SPAWN_EGG");
    if (spawnEgg == null) {
        spawnEgg = Material.LEGACY_MONSTER_EGG;
    }
    final ItemStack item = new ItemStack(spawnEgg, amount);
    if (displayName != null) {
        final ItemMeta itemMeta = item.getItemMeta();
        itemMeta.setDisplayName(displayName);
        item.setItemMeta(itemMeta);
    }
    net.minecraft.server.v1_15_R1.ItemStack itemStack = null;
    final CraftItemStack craftStack = CraftItemStack.asCraftCopy(item);
    itemStack = CraftItemStack.asNMSCopy(craftStack);
    final NBTTagCompound tag = itemStack.getOrCreateTag();
    if (!tag.hasKey("SilkSpawners")) {
        tag.set("SilkSpawners", new NBTTagCompound());
    }
    tag.getCompound("SilkSpawners").setString("entity", entityID);
    if (!tag.hasKey("EntityTag")) {
        tag.set("EntityTag", new NBTTagCompound());
    }
    String prefixedEntity;
    if (!entityID.startsWith("minecraft:")) {
        prefixedEntity = "minecraft:" + entityID;
    } else {
        prefixedEntity = entityID;
    }
    tag.getCompound("EntityTag").setString("id", prefixedEntity);
    return CraftItemStack.asCraftMirror(itemStack);
}
Also used : CraftItemStack(org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack) NBTTagCompound(net.minecraft.server.v1_15_R1.NBTTagCompound) Material(org.bukkit.Material) CraftItemStack(org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Aggregations

CraftItemStack (org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack)12 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)8 ChannelOutboundHandlerAdapter (io.netty.channel.ChannelOutboundHandlerAdapter)8 ChannelPromise (io.netty.channel.ChannelPromise)8 NBTTagCompound (net.minecraft.server.v1_15_R1.NBTTagCompound)8 ItemStack (org.bukkit.inventory.ItemStack)7 ArrayList (java.util.ArrayList)5 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)4 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)3 Container (net.minecraft.server.v1_15_R1.Container)3 CraftPlayer (org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer)3 ISoliniaSpell (com.solinia.solinia.Interfaces.ISoliniaSpell)2 Field (java.lang.reflect.Field)2 Timestamp (java.sql.Timestamp)2 UUID (java.util.UUID)2 Nullable (javax.annotation.Nullable)2 ContainerAnvil (net.minecraft.server.v1_15_R1.ContainerAnvil)2 EntityPlayer (net.minecraft.server.v1_15_R1.EntityPlayer)2 Item (net.minecraft.server.v1_15_R1.Item)2 ItemStack (net.minecraft.server.v1_15_R1.ItemStack)2