Search in sources :

Example 21 with Item

use of net.minecraft.server.v1_16_R3.DataWatcher.Item in project DragonsOnline by UniverseCraft.

the class PlayerNPC116R3 method setEquipment.

public void setEquipment(EquipmentSlot slot, org.bukkit.inventory.ItemStack item) {
    PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment();
    this.setField(packet, "a", handle.getId());
    this.setField(packet, "b", CraftEquipmentSlot.getNMS(slot));
    this.setField(packet, "c", CraftItemStack.asNMSCopy(item));
    this.sendPacket(packet);
}
Also used : PacketPlayOutEntityEquipment(net.minecraft.server.v1_16_R3.PacketPlayOutEntityEquipment)

Example 22 with Item

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

the class CustomInventoryCrafting method remove.

@Override
public void remove() {
    display.stop();
    for (ItemStack item : items) {
        org.bukkit.inventory.ItemStack is = CraftItemStack.asBukkitCopy(item);
        if (is.getType() != Material.AIR) {
            bloc.getWorld().dropItem(bloc.clone().add(.5, .9, .5), is);
        }
    }
    items.clear();
}
Also used : ItemStack(net.minecraft.server.v1_16_R3.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack)

Example 23 with Item

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

the class NMSHandler method getSilkSpawnersNBTEntityID.

@Override
@Nullable
public String getSilkSpawnersNBTEntityID(final ItemStack item) {
    net.minecraft.server.v1_16_R3.ItemStack itemStack = null;
    final CraftItemStack craftStack = CraftItemStack.asCraftCopy(item);
    itemStack = CraftItemStack.asNMSCopy(craftStack);
    final NBTTagCompound tag = itemStack.getTag();
    if (tag == null || !tag.hasKey("SilkSpawners")) {
        return null;
    }
    return tag.getCompound("SilkSpawners").getString("entity");
}
Also used : CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack) NBTTagCompound(net.minecraft.server.v1_16_R3.NBTTagCompound) Nullable(javax.annotation.Nullable)

Example 24 with Item

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

the class NMSHandler method setSpawnersUnstackable.

@Override
public void setSpawnersUnstackable() {
    try {
        final Item spawner = IRegistry.ITEM.get(new MinecraftKey(NAMESPACED_SPAWNER_ID));
        final Field maxStackSize = Item.class.getDeclaredField("maxStackSize");
        maxStackSize.setAccessible(true);
        maxStackSize.set(spawner, 1);
    } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
        e.printStackTrace();
    }
}
Also used : Item(net.minecraft.server.v1_16_R3.Item) Field(java.lang.reflect.Field) MinecraftKey(net.minecraft.server.v1_16_R3.MinecraftKey)

Example 25 with Item

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

the class NMSHandler method getVanillaEggNBTEntityID.

@Override
public String getVanillaEggNBTEntityID(final ItemStack item) {
    net.minecraft.server.v1_16_R3.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_16_R3.inventory.CraftItemStack) NBTTagCompound(net.minecraft.server.v1_16_R3.NBTTagCompound) MinecraftKey(net.minecraft.server.v1_16_R3.MinecraftKey)

Aggregations

CraftItemStack (org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack)10 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)8 ChannelOutboundHandlerAdapter (io.netty.channel.ChannelOutboundHandlerAdapter)8 ChannelPromise (io.netty.channel.ChannelPromise)8 NBTTagCompound (net.minecraft.server.v1_16_R3.NBTTagCompound)6 ArrayList (java.util.ArrayList)3 ItemStack (net.minecraft.server.v1_16_R3.ItemStack)3 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)3 CraftPlayer (org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer)3 ItemStack (org.bukkit.inventory.ItemStack)3 CraftFakePlayerImpl (com.denizenscript.denizen.nms.v1_16.impl.entities.CraftFakePlayerImpl)2 EntityItemProjectileImpl (com.denizenscript.denizen.nms.v1_16.impl.entities.EntityItemProjectileImpl)2 EntityTag (com.denizenscript.denizen.objects.EntityTag)2 ItemTag (com.denizenscript.denizen.objects.ItemTag)2 PlayerTag (com.denizenscript.denizen.objects.PlayerTag)2 FakeEntity (com.denizenscript.denizen.utilities.entity.FakeEntity)2 Mechanism (com.denizenscript.denizencore.objects.Mechanism)2 Nullable (javax.annotation.Nullable)2 Item (net.minecraft.server.v1_16_R2.DataWatcher.Item)2 Item (net.minecraft.server.v1_16_R3.DataWatcher.Item)2