Java 类net.minecraft.server.Item 实例源码

项目:ProjectAres    文件:NMSHacks.java   
public static void showFakeItems(Plugin plugin, Player viewer, Location location, org.bukkit.inventory.ItemStack item, int count, Duration duration) {
    if(count <= 0) return;

    final EntityPlayer nmsPlayer = ((CraftPlayer) viewer).getHandle();
    final int[] entityIds = new int[count];

    for(int i = 0; i < count; i++) {
        final EntityItem entity = new EntityItem(nmsPlayer.getWorld(), location.getX(), location.getY(), location.getZ(), CraftItemStack.asNMSCopy(item));

        entity.motX = randomEntityVelocity();
        entity.motY = randomEntityVelocity();
        entity.motZ = randomEntityVelocity();

        sendPacket(viewer, new PacketPlayOutSpawnEntity(entity, ENTITY_TYPE_IDS.get(org.bukkit.entity.Item.class)));
        sendPacket(viewer, new PacketPlayOutEntityMetadata(entity.getId(), entity.getDataWatcher(), true));

        entityIds[i] = entity.getId();
    }

    scheduleEntityDestroy(plugin, viewer.getUniqueId(), duration, entityIds);
}
项目:Craftbukkit    文件:CraftStatistic.java   
public static Material getMaterialFromStatistic(net.minecraft.server.Statistic statistic) {
    String statisticString = statistic.name;
    String val = statisticString.substring(statisticString.lastIndexOf(".") + 1);
    Item item = (Item) Item.REGISTRY.get(new MinecraftKey(val));
    if (item != null) {
        return Material.getMaterial(Item.getId(item));
    }
    Block block = (Block) Block.REGISTRY.get(new MinecraftKey(val));
    if (block != null) {
        return Material.getMaterial(Block.getId(block));
    }
    try {
        return Material.getMaterial(Integer.parseInt(val));
    } catch (NumberFormatException e) {
        return null;
    }
}
项目:Almura-Server    文件:CraftEventFactory.java   
private static PlayerEvent getPlayerBucketEvent(boolean isFilling, EntityHuman who, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemstack, net.minecraft.server.Item item) {
    Player player = (who == null) ? null : (Player) who.getBukkitEntity();
    CraftItemStack itemInHand = CraftItemStack.asNewCraftStack(item);
    Material bucket = Material.getMaterial(itemstack.id);

    CraftWorld craftWorld = (CraftWorld) player.getWorld();
    CraftServer craftServer = (CraftServer) player.getServer();

    Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ);
    BlockFace blockFace = CraftBlock.notchToBlockFace(clickedFace);

    PlayerEvent event = null;
    if (isFilling) {
        event = new PlayerBucketFillEvent(player, blockClicked, blockFace, bucket, itemInHand);
        ((PlayerBucketFillEvent) event).setCancelled(!canBuild(craftWorld, player, clickedX, clickedZ));
    } else {
        event = new PlayerBucketEmptyEvent(player, blockClicked, blockFace, bucket, itemInHand);
        ((PlayerBucketEmptyEvent) event).setCancelled(!canBuild(craftWorld, player, clickedX, clickedZ));
    }

    craftServer.getPluginManager().callEvent(event);

    return event;
}
项目:Almura-Server    文件:CraftEventFactory.java   
public static void handleEditBookEvent(EntityPlayer player, ItemStack newBookItem) {
    int itemInHandIndex = player.inventory.itemInHandIndex;

    PlayerEditBookEvent editBookEvent = new PlayerEditBookEvent(player.getBukkitEntity(), player.inventory.itemInHandIndex, (BookMeta) CraftItemStack.getItemMeta(player.inventory.getItemInHand()), (BookMeta) CraftItemStack.getItemMeta(newBookItem), newBookItem.id == Item.WRITTEN_BOOK.id);
    player.world.getServer().getPluginManager().callEvent(editBookEvent);
    ItemStack itemInHand = player.inventory.getItem(itemInHandIndex);

    // If they've got the same item in their hand, it'll need to be updated.
    if (itemInHand.id == Item.BOOK_AND_QUILL.id) {
        if (!editBookEvent.isCancelled()) {
            CraftItemStack.setItemMeta(itemInHand, editBookEvent.getNewBookMeta());
            if (editBookEvent.isSigning()) {
                itemInHand.id = Item.WRITTEN_BOOK.id;
            }
        }

        // Client will have updated its idea of the book item; we need to overwrite that
        Slot slot = player.activeContainer.a((IInventory) player.inventory, itemInHandIndex);
        player.playerConnection.sendPacket(new Packet103SetSlot(player.activeContainer.windowId, slot.g, itemInHand));
    }
}
项目:SpigotSource    文件:CraftStatistic.java   
public static Material getMaterialFromStatistic(net.minecraft.server.Statistic statistic) {
    String statisticString = statistic.name;
    String val = statisticString.substring(statisticString.lastIndexOf(".") + 1);
    Item item = (Item) Item.REGISTRY.get(new MinecraftKey(val));
    if (item != null) {
        return Material.getMaterial(Item.getId(item));
    }
    Block block = (Block) Block.REGISTRY.get(new MinecraftKey(val));
    if (block != null) {
        return Material.getMaterial(Block.getId(block));
    }
    try {
        return Material.getMaterial(Integer.parseInt(val));
    } catch (NumberFormatException e) {
        return null;
    }
}
项目:Craft-city    文件:CraftEventFactory.java   
private static PlayerEvent getPlayerBucketEvent(boolean isFilling, EntityHuman who, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemstack, net.minecraft.server.Item item) {
    Player player = (who == null) ? null : (Player) who.getBukkitEntity();
    CraftItemStack itemInHand = CraftItemStack.asNewCraftStack(item);
    Material bucket = Material.getMaterial(itemstack.id);

    CraftWorld craftWorld = (CraftWorld) player.getWorld();
    CraftServer craftServer = (CraftServer) player.getServer();

    Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ);
    BlockFace blockFace = CraftBlock.notchToBlockFace(clickedFace);

    PlayerEvent event = null;
    if (isFilling) {
        event = new PlayerBucketFillEvent(player, blockClicked, blockFace, bucket, itemInHand);
        ((PlayerBucketFillEvent) event).setCancelled(!canBuild(craftWorld, player, clickedX, clickedZ));
    } else {
        event = new PlayerBucketEmptyEvent(player, blockClicked, blockFace, bucket, itemInHand);
        ((PlayerBucketEmptyEvent) event).setCancelled(!canBuild(craftWorld, player, clickedX, clickedZ));
    }

    craftServer.getPluginManager().callEvent(event);

    return event;
}
项目:ProjectAres    文件:NMSHacks.java   
public static Packet spawnPlayerPacket(int entityId, UUID uuid, Location location, List<DataWatcher.Item<?>> metadata) {
    return new PacketPlayOutNamedEntitySpawn(entityId,
                                             uuid,
                                             location.getX(), location.getY(), location.getZ(),
                                             encodeAngle(location.getYaw()),
                                             encodeAngle(location.getPitch()),
                                             metadata);
}
项目:ProjectAres    文件:NMSHacks.java   
/**
 * Test if the given tool is capable of "efficiently" mining the given block.
 *
 * Derived from CraftBlock.itemCausesDrops()
 */
public static boolean canMineBlock(MaterialData blockMaterial, org.bukkit.inventory.ItemStack tool) {
    if(!blockMaterial.getItemType().isBlock()) {
        throw new IllegalArgumentException("Material '" + blockMaterial + "' is not a block");
    }

    net.minecraft.server.Block nmsBlock = CraftMagicNumbers.getBlock(blockMaterial.getItemType());
    net.minecraft.server.Item nmsTool = tool == null ? null : CraftMagicNumbers.getItem(tool.getType());

    return nmsBlock != null && (nmsBlock.getBlockData().getMaterial().isAlwaysDestroyable() ||
                                (nmsTool != null && nmsTool.canDestroySpecialBlock(nmsBlock.getBlockData())));
}
项目:ProjectAres    文件:NMSHacks.java   
public static void playDeathAnimation(Player player) {
    EntityPlayer handle = ((CraftPlayer) player).getHandle();
    PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(handle.getId(), handle.getDataWatcher(), false);

    // Add/replace health to zero
    boolean replaced = false;
    DataWatcher.Item<Float> zeroHealth = new DataWatcher.Item<>(EntityPlayer.class, EntityLiving.HEALTH, 0f);

    if(packet.b != null) {
        for(int i = 0; i < packet.b.size(); i++) {
            DataWatcher.Item<?> item = packet.b.get(i);
            if(EntityLiving.HEALTH.equals(item.a())) {
                packet.b.set(i, zeroHealth);
                replaced = true;
            }
        }
    }

    if(!replaced) {
        if(packet.b == null) {
            packet.b = Collections.singletonList(zeroHealth);
        } else {
            packet.b.add(zeroHealth);
        }
    }

    sendPacketToViewers(player, packet);
}
项目:CraftBukkit    文件:CraftBlock.java   
public Collection<ItemStack> getDrops() {
    List<ItemStack> drops = new ArrayList<ItemStack>();

    net.minecraft.server.Block block = this.getNMSBlock();
    if (block != Blocks.AIR) {
        byte data = getData();
        // based on nms.Block.dropNaturally
        int count = block.getDropCount(0, chunk.getHandle().world.random);
        for (int i = 0; i < count; ++i) {
            Item item = block.getDropType(data, chunk.getHandle().world.random, 0);
            if (item != null) {
                // Skulls are special, their data is based on the tile entity
                if (Blocks.SKULL == block) {
                    net.minecraft.server.ItemStack nmsStack = new net.minecraft.server.ItemStack(item, 1, block.getDropData(chunk.getHandle().world, x, y, z));
                    TileEntitySkull tileentityskull = (TileEntitySkull) chunk.getHandle().world.getTileEntity(x, y, z);

                    if (tileentityskull.getSkullType() == 3 && tileentityskull.getGameProfile() != null) {
                        nmsStack.setTag(new NBTTagCompound());
                        NBTTagCompound nbttagcompound = new NBTTagCompound();

                        GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile());
                        nmsStack.getTag().set("SkullOwner", nbttagcompound);
                    }

                    drops.add(CraftItemStack.asBukkitCopy(nmsStack));
                    // We don't want to drop cocoa blocks, we want to drop cocoa beans.
                } else if (Blocks.COCOA == block) {
                    int dropAmount = (BlockCocoa.c(data) >= 2 ? 3 : 1);
                    for (int j = 0; j < dropAmount; ++j) {
                        drops.add(new ItemStack(Material.INK_SACK, 1, (short) 3));
                    }
                } else {
                    drops.add(new ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), 1, (short) block.getDropData(data)));
                }
            }
        }
    }
    return drops;
}
项目:CraftBukkit    文件:CraftMagicNumbers.java   
public static Material getMaterial(Item item) {
    // TODO: Don't use ID
    Material material = Material.getMaterial(Item.getId(item));

    if (material == null) {
        return Material.AIR;
    }

    return material;
}
项目:CraftBukkit    文件:PerMaterialTest.java   
@Test
public void maxDurability() {
    if (material == Material.AIR) {
        assertThat((int) material.getMaxDurability(), is(0));
    } else if (material.isBlock()){
        Item item = CraftMagicNumbers.getItem(material);
        assertThat((int) material.getMaxDurability(), is(item.getMaxDurability()));
    }
}
项目:Craftbukkit    文件:CraftMagicNumbers.java   
public static Material getMaterial(Item item) {
    // TODO: Don't use ID
    Material material = Material.getMaterial(Item.getId(item));

    if (material == null) {
        return Material.AIR;
    }

    return material;
}
项目:Craftbukkit    文件:CraftMagicNumbers.java   
@Override
public List<String> tabCompleteInternalMaterialName(String token, List<String> completions) {
    ArrayList<String> results = Lists.newArrayList();
    for (MinecraftKey key : (Set<MinecraftKey>)Item.REGISTRY.keySet()) {
        results.add(key.toString());
    }
    return StringUtil.copyPartialMatches(token, results, completions);
}
项目:Craftbukkit    文件:PerMaterialTest.java   
@Test
public void maxDurability() {
    if (INVALIDATED_MATERIALS.contains(material)) return;

    if (material == Material.AIR) {
        assertThat((int) material.getMaxDurability(), is(0));
    } else if (material.isBlock()){
        Item item = CraftMagicNumbers.getItem(material);
        assertThat((int) material.getMaxDurability(), is(item.getMaxDurability()));
    }
}
项目:Almura-Server    文件:CraftJukebox.java   
public void setPlaying(Material record) {
    if (record == null || Item.byId[record.getId()] == null) {
        record = Material.AIR;
        jukebox.setRecord(null);
    } else {
        jukebox.setRecord(new ItemStack(Item.byId[record.getId()], 1));
    }
    jukebox.update();
    if (record == Material.AIR) {
        world.getHandle().setData(getX(), getY(), getZ(), 0, 3);
    } else {
        world.getHandle().setData(getX(), getY(), getZ(), 1, 3);
    }
    world.playEffect(getLocation(), Effect.RECORD_PLAY, record.getId());
}
项目:Almura-Server    文件:CraftEventFactory.java   
/**
 * ItemSpawnEvent
 */
public static ItemSpawnEvent callItemSpawnEvent(EntityItem entityitem) {
    org.bukkit.entity.Item entity = (org.bukkit.entity.Item) entityitem.getBukkitEntity();
    CraftServer craftServer = (CraftServer) entity.getServer();

    ItemSpawnEvent event = new ItemSpawnEvent(entity, entity.getLocation());

    craftServer.getPluginManager().callEvent(event);
    return event;
}
项目:Almura-Server    文件:CraftEventFactory.java   
/**
 * ItemDespawnEvent
 */
public static ItemDespawnEvent callItemDespawnEvent(EntityItem entityitem) {
    org.bukkit.entity.Item entity = (org.bukkit.entity.Item) entityitem.getBukkitEntity();

    ItemDespawnEvent event = new ItemDespawnEvent(entity, entity.getLocation());

    entity.getServer().getPluginManager().callEvent(event);
    return event;
}
项目:Almura-Server    文件:CraftServer.java   
public CraftMapView createMap(World world) {
    Validate.notNull(world, "World cannot be null");

    net.minecraft.server.ItemStack stack = new net.minecraft.server.ItemStack(Item.MAP, 1, -1);
    WorldMap worldmap = Item.MAP.getSavedMap(stack, ((CraftWorld) world).getHandle());
    return worldmap.mapView;
}
项目:Almura-Server    文件:PerMaterialTest.java   
@Test
public void maxDurability() {
    if (material == Material.AIR) {
        assertThat((int) material.getMaxDurability(), is(0));
    } else {
        assertThat((int) material.getMaxDurability(), is(Item.byId[material.getId()].getMaxDurability()));
    }
}
项目:Almura-Server    文件:PerMaterialTest.java   
@Test
public void maxStackSize() {
    final ItemStack bukkit = new ItemStack(material);
    final CraftItemStack craft = CraftItemStack.asCraftCopy(bukkit);
    if (material == Material.AIR) {
        final int MAX_AIR_STACK = 0 /* Why can't I hold all of these AIR? */;
        assertThat(material.getMaxStackSize(), is(MAX_AIR_STACK));
        assertThat(bukkit.getMaxStackSize(), is(MAX_AIR_STACK));
        assertThat(craft.getMaxStackSize(), is(MAX_AIR_STACK));
    } else {
        assertThat(material.getMaxStackSize(), is(Item.byId[material.getId()].getMaxStackSize()));
        assertThat(bukkit.getMaxStackSize(), is(material.getMaxStackSize()));
        assertThat(craft.getMaxStackSize(), is(material.getMaxStackSize()));
    }
}
项目:Tweakkit-Server    文件:CraftBlock.java   
public Collection<ItemStack> getDrops() {
    List<ItemStack> drops = new ArrayList<ItemStack>();

    net.minecraft.server.Block block = this.getNMSBlock();
    if (block != Blocks.AIR) {
        byte data = getData();
        // based on nms.Block.dropNaturally
        int count = block.getDropCount(0, chunk.getHandle().world.random);
        for (int i = 0; i < count; ++i) {
            Item item = block.getDropType(data, chunk.getHandle().world.random, 0);
            if (item != null) {
                // Skulls are special, their data is based on the tile entity
                if (Blocks.SKULL == block) {
                    net.minecraft.server.ItemStack nmsStack = new net.minecraft.server.ItemStack(item, 1, block.getDropData(chunk.getHandle().world, x, y, z));
                    TileEntitySkull tileentityskull = (TileEntitySkull) chunk.getHandle().world.getTileEntity(x, y, z);

                    if (tileentityskull.getSkullType() == 3 && tileentityskull.getGameProfile() != null) {
                        nmsStack.setTag(new NBTTagCompound());
                        NBTTagCompound nbttagcompound = new NBTTagCompound();

                        GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile());
                        nmsStack.getTag().set("SkullOwner", nbttagcompound);
                    }

                    drops.add(CraftItemStack.asBukkitCopy(nmsStack));
                    // We don't want to drop cocoa blocks, we want to drop cocoa beans.
                } else if (Blocks.COCOA == block) {
                    int dropAmount = (BlockCocoa.c(data) >= 2 ? 3 : 1);
                    for (int j = 0; j < dropAmount; ++j) {
                        drops.add(new ItemStack(Material.INK_SACK, 1, (short) 3));
                    }
                } else {
                    drops.add(new ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), 1, (short) block.getDropData(data)));
                }
            }
        }
    }
    return drops;
}
项目:Tweakkit-Server    文件:CraftMagicNumbers.java   
public static Material getMaterial(Item item) {
    // TODO: Don't use ID
    Material material = Material.getMaterial(Item.getId(item));

    if (material == null) {
        return Material.AIR;
    }

    return material;
}
项目:Tweakkit-Server    文件:PerMaterialTest.java   
@Test
public void maxDurability() {
    if (material == Material.AIR) {
        assertThat((int) material.getMaxDurability(), is(0));
    } else if (material.isBlock()){
        Item item = CraftMagicNumbers.getItem(material);
        assertThat((int) material.getMaxDurability(), is(item.getMaxDurability()));
    }
}
项目:CardinalPGM    文件:CardinalNotifications.java   
public void UpdateNotificationAndBook(){
    Bukkit.getScheduler().runTaskAsynchronously(Cardinal.getInstance(), new Runnable() {
        @Override
        public void run() {
            try {
                chat = ComponentSerializer.parse(GitUtil.getUpdateMessage(notificationUrl));

                ItemStack NMSbook = new ItemStack(Item.getById(387));
                try {
                    NBTBase nbtbase = MojangsonParser.parse(ChatColor.translateAlternateColorCodes('`', GitUtil.getUpdateMessage(bookUrl)));
                    NMSbook.setTag((NBTTagCompound) nbtbase);
                } catch (MojangsonParseException mojangsonparseexception) {
                    Bukkit.getConsoleSender().sendMessage(mojangsonparseexception.getMessage());
                    return;
                }
                book = CraftItemStack.asBukkitCopy(NMSbook);
            } catch (IOException ignored) {
            }
        }
    });
}
项目:CardinalPGM    文件:Watchers.java   
public static List<DataWatcher.Item<?>> getDamageIndicator(double damage) {
    Class<EntityArmorStand> cl = EntityArmorStand.class;
    return Lists.newArrayList(
            INVISIBLE,                                                                          // (0) Sets invisible
            new DataWatcher.Item<>(cl, getDataWatcher(Entity.class, "aA", String.class), "" +
                    ChatColor.RED + ChatColor.BOLD + Math.round(damage / 0.2)),                 // (2) Custom Name
            new DataWatcher.Item<>(cl, getDataWatcher(Entity.class, "aB", Boolean.class), true),// (3) Custom Name visible
            new DataWatcher.Item<>(cl, EntityArmorStand.a, (byte) 0x10));                       // (11) Marker Armor Stand
}
项目:SpigotSource    文件:CraftMagicNumbers.java   
public static Material getMaterial(Item item) {
    // TODO: Don't use ID
    Material material = Material.getMaterial(Item.getId(item));

    if (material == null) {
        return Material.AIR;
    }

    return material;
}
项目:SpigotSource    文件:CraftMagicNumbers.java   
@Override
public List<String> tabCompleteInternalMaterialName(String token, List<String> completions) {
    ArrayList<String> results = Lists.newArrayList();
    for (MinecraftKey key : (Set<MinecraftKey>)Item.REGISTRY.keySet()) {
        results.add(key.toString());
    }
    return StringUtil.copyPartialMatches(token, results, completions);
}
项目:SpigotSource    文件:PerMaterialTest.java   
@Test
public void maxDurability() {
    if (INVALIDATED_MATERIALS.contains(material)) return;

    if (material == Material.AIR) {
        assertThat((int) material.getMaxDurability(), is(0));
    } else if (material.isBlock()){
        Item item = CraftMagicNumbers.getItem(material);
        assertThat((int) material.getMaxDurability(), is(item.getMaxDurability()));
    }
}
项目:Craft-city    文件:CraftJukebox.java   
public void setPlaying(Material record) {
    if (record == null || Item.byId[record.getId()] == null) {
        record = Material.AIR;
        jukebox.setRecord(null);
    } else {
        jukebox.setRecord(new ItemStack(Item.byId[record.getId()], 1));
    }
    jukebox.update();
    if (record == Material.AIR) {
        world.getHandle().setData(getX(), getY(), getZ(), 0, 3);
    } else {
        world.getHandle().setData(getX(), getY(), getZ(), 1, 3);
    }
    world.playEffect(getLocation(), Effect.RECORD_PLAY, record.getId());
}
项目:Craft-city    文件:CraftEventFactory.java   
/**
 * ItemSpawnEvent
 */
public static ItemSpawnEvent callItemSpawnEvent(EntityItem entityitem) {
    org.bukkit.entity.Item entity = (org.bukkit.entity.Item) entityitem.getBukkitEntity();
    CraftServer craftServer = (CraftServer) entity.getServer();

    ItemSpawnEvent event = new ItemSpawnEvent(entity, entity.getLocation());

    craftServer.getPluginManager().callEvent(event);
    return event;
}
项目:Craft-city    文件:CraftEventFactory.java   
/**
 * ItemDespawnEvent
 */
public static ItemDespawnEvent callItemDespawnEvent(EntityItem entityitem) {
    org.bukkit.entity.Item entity = (org.bukkit.entity.Item) entityitem.getBukkitEntity();

    ItemDespawnEvent event = new ItemDespawnEvent(entity, entity.getLocation());

    entity.getServer().getPluginManager().callEvent(event);
    return event;
}
项目:Craft-city    文件:CraftServer.java   
public CraftMapView createMap(World world) {
    Validate.notNull(world, "World cannot be null");

    net.minecraft.server.ItemStack stack = new net.minecraft.server.ItemStack(Item.MAP, 1, -1);
    WorldMap worldmap = Item.MAP.getSavedMap(stack, ((CraftWorld) world).getHandle());
    return worldmap.mapView;
}
项目:Craft-city    文件:PerMaterialTest.java   
@Test
public void maxDurability() {
    if (material == Material.AIR) {
        assertThat((int) material.getMaxDurability(), is(0));
    } else {
        assertThat((int) material.getMaxDurability(), is(Item.byId[material.getId()].getMaxDurability()));
    }
}
项目:Craft-city    文件:PerMaterialTest.java   
@Test
public void maxStackSize() {
    final ItemStack bukkit = new ItemStack(material);
    final CraftItemStack craft = CraftItemStack.asCraftCopy(bukkit);
    if (material == Material.AIR) {
        final int MAX_AIR_STACK = 0 /* Why can't I hold all of these AIR? */;
        assertThat(material.getMaxStackSize(), is(MAX_AIR_STACK));
        assertThat(bukkit.getMaxStackSize(), is(MAX_AIR_STACK));
        assertThat(craft.getMaxStackSize(), is(MAX_AIR_STACK));
    } else {
        assertThat(material.getMaxStackSize(), is(Item.byId[material.getId()].getMaxStackSize()));
        assertThat(bukkit.getMaxStackSize(), is(material.getMaxStackSize()));
        assertThat(craft.getMaxStackSize(), is(material.getMaxStackSize()));
    }
}
项目:ProjectAres    文件:NMSHacks.java   
private static List<DataWatcher.Item<?>> copyEntityMetadata(Entity entity) {
    final List<DataWatcher.Item<?>> metadata = ((CraftEntity) entity).getHandle().getDataWatcher().c();
    DataWatcher.deepCopy(metadata);
    return metadata;
}
项目:ProjectAres    文件:NMSHacks.java   
public static String getKey(Material material) {
    MinecraftKey key = Item.REGISTRY.b(CraftMagicNumbers.getItem(material));
    return key == null ? null : key.toString();
}
项目:ProjectAres    文件:NMSHacks.java   
public static @Nullable Material materialByKey(String key) {
    final Item item = Item.REGISTRY.get(new MinecraftKey(key));
    return item == null ? null : CraftMagicNumbers.getMaterial(item);
}
项目:Skript    文件:EffFertilize.java   
@Override
public void execute(final Event e) {
    for (final Block b : blocks.getArray(e)) {
        Item.INK_SACK.interactWith(CraftItemStack.createNMSItemStack(new ItemStack(Material.INK_SACK, 1, Color.WHITE.getDye())), null, ((CraftWorld) b.getWorld()).getHandle(), b.getX(), b.getY(), b.getZ(), 0, 0, 0, 0);
    }
}
项目:CraftBukkit    文件:CraftBlock.java   
private boolean itemCausesDrops(ItemStack item) {
    net.minecraft.server.Block block = this.getNMSBlock();
    net.minecraft.server.Item itemType = item != null ? net.minecraft.server.Item.getById(item.getTypeId()) : null;
    return block != null && (block.getMaterial().isAlwaysDestroyable() || (itemType != null && itemType.canDestroySpecialBlock(block)));
}