Search in sources :

Example 21 with Material

use of net.minecraft.server.v1_15_R1.Material 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

HashMap (java.util.HashMap)8 IdentityHashMap (java.util.IdentityHashMap)7 DynmapBlockState (org.dynmap.renderer.DynmapBlockState)7 BukkitMaterial (org.dynmap.bukkit.helper.BukkitMaterial)3 IBlockData (net.minecraft.server.v1_13_R2.IBlockData)2 Material (net.minecraft.server.v1_13_R2.Material)2 IBlockData (net.minecraft.server.v1_15_R1.IBlockData)2 WorldServer (net.minecraft.server.v1_15_R1.WorldServer)2 Material (org.bukkit.Material)2 CraftWorld (org.bukkit.craftbukkit.v1_15_R1.CraftWorld)2 StringReader (com.mojang.brigadier.StringReader)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 NPC (net.citizensnpcs.api.npc.NPC)1 EntityHumanNPC (net.citizensnpcs.nms.v1_15_R1.entity.EntityHumanNPC)1 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)1 Block (net.minecraft.server.v1_10_R1.Block)1 BlockCobbleWall (net.minecraft.server.v1_10_R1.BlockCobbleWall)1 BlockDoor (net.minecraft.server.v1_10_R1.BlockDoor)1 BlockFence (net.minecraft.server.v1_10_R1.BlockFence)1