Search in sources :

Example 26 with Item

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

the class CustomInventoryCrafting method setItems.

protected void setItems(List<org.bukkit.inventory.ItemStack> items) {
    int index = 0;
    for (org.bukkit.inventory.ItemStack item : items) {
        this.items.set(index++, CraftItemStack.asNMSCopy(item));
    }
    // Want to update the result without having to use a real player
    if (this.resultInventory instanceof InventoryCraftResult) {
        CustomContainerWorkbench container = new CustomContainerWorkbench(0, manager.mockPlayer.getBukkitEntity(), bloc, this, (InventoryCraftResult) resultInventory);
        container.a(this);
        CraftingInventory crafting = (CraftingInventory) container.getBukkitView().getTopInventory();
        Bukkit.getPluginManager().callEvent(new PrepareItemCraftEvent(crafting, container.getBukkitView(), false));
    }
    display.forceUpdate();
}
Also used : CraftingInventory(org.bukkit.inventory.CraftingInventory) PublicCraftingInventory(io.github.bananapuncher714.crafters.implementation.api.PublicCraftingInventory) PrepareItemCraftEvent(org.bukkit.event.inventory.PrepareItemCraftEvent) InventoryCraftResult(net.minecraft.server.v1_14_R1.InventoryCraftResult)

Example 27 with Item

use of net.minecraft.server.v1_14_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 == null ? ItemStack.a : item);
    for (Container container : containers) {
        container.a(this);
    }
    // Update the armorstand grid
    display.update();
}
Also used : Container(net.minecraft.server.v1_14_R1.Container) SelfContainer(io.github.bananapuncher714.crafters.implementation.v1_14_R1.ContainerManager_v1_14_R1.SelfContainer)

Example 28 with Item

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

the class NMSHandler method getVanillaEggNBTEntityID.

@Override
public String getVanillaEggNBTEntityID(final ItemStack item) {
    net.minecraft.server.v1_14_R1.ItemStack itemStack = null;
    final CraftItemStack craftStack = CraftItemStack.asCraftCopy(item);
    itemStack = CraftItemStack.asNMSCopy(craftStack);
    NBTTagCompound tag = itemStack.getTag();
    if (tag == null || !tag.hasKey("EntityTag")) {
        final MinecraftKey vanillaKey = IRegistry.ITEM.getKey(itemStack.getItem());
        if (vanillaKey != null) {
            return vanillaKey.getKey().replace("minecraft:", "").replace("_spawn_egg", "");
        }
    } else {
        tag = tag.getCompound("EntityTag");
        if (tag.hasKey("id")) {
            return tag.getString("id").replace("minecraft:", "");
        }
    }
    return null;
}
Also used : CraftItemStack(org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack) NBTTagCompound(net.minecraft.server.v1_14_R1.NBTTagCompound) MinecraftKey(net.minecraft.server.v1_14_R1.MinecraftKey)

Aggregations

CraftItemStack (org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack)10 NBTTagCompound (net.minecraft.server.v1_14_R1.NBTTagCompound)9 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)8 ChannelOutboundHandlerAdapter (io.netty.channel.ChannelOutboundHandlerAdapter)8 ChannelPromise (io.netty.channel.ChannelPromise)8 ItemStack (org.bukkit.inventory.ItemStack)4 Container (net.minecraft.server.v1_14_R1.Container)3 CraftPlayer (org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer)3 ArrayList (java.util.ArrayList)2 Nullable (javax.annotation.Nullable)2 ContainerAnvil (net.minecraft.server.v1_14_R1.ContainerAnvil)2 EntityPlayer (net.minecraft.server.v1_14_R1.EntityPlayer)2 Item (net.minecraft.server.v1_14_R1.Item)2 ItemStack (net.minecraft.server.v1_14_R1.ItemStack)2 MinecraftKey (net.minecraft.server.v1_14_R1.MinecraftKey)2 Item (net.minecraft.server.v1_16_R2.DataWatcher.Item)2 Item (net.minecraft.server.v1_16_R3.DataWatcher.Item)2 CraftContainer (org.bukkit.craftbukkit.v1_14_R1.inventory.CraftContainer)2 CraftPlayer (org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer)2 CraftPlayer (org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer)2