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

项目: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;
}
项目: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;
}