当前位置: 首页>>代码示例>>Java>>正文


Java TileEntitySkull.getSkullType方法代码示例

本文整理汇总了Java中net.minecraft.server.TileEntitySkull.getSkullType方法的典型用法代码示例。如果您正苦于以下问题:Java TileEntitySkull.getSkullType方法的具体用法?Java TileEntitySkull.getSkullType怎么用?Java TileEntitySkull.getSkullType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.server.TileEntitySkull的用法示例。


在下文中一共展示了TileEntitySkull.getSkullType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDrops

import net.minecraft.server.TileEntitySkull; //导入方法依赖的package包/类
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;
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:40,代码来源:CraftBlock.java

示例2: getDrops

import net.minecraft.server.TileEntitySkull; //导入方法依赖的package包/类
public Collection<ItemStack> getDrops() {
    List<ItemStack> drops = new ArrayList<ItemStack>();

    net.minecraft.server.Block block = net.minecraft.server.Block.byId[this.getTypeId()];
    if (block != null) {
        byte data = getData();
        // based on nms.Block.dropNaturally
        int count = block.getDropCount(0, chunk.getHandle().world.random);
        for (int i = 0; i < count; ++i) {
            int item = block.getDropType(data, chunk.getHandle().world.random, 0);
            if (item > 0) {
                // Skulls are special, their data is based on the tile entity
                if (net.minecraft.server.Block.SKULL.id == this.getTypeId()) {
                    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.getExtraType() != null && tileentityskull.getExtraType().length() > 0) {
                        nmsStack.setTag(new NBTTagCompound());
                        nmsStack.getTag().setString("SkullOwner", tileentityskull.getExtraType());
                    }

                    drops.add(CraftItemStack.asBukkitCopy(nmsStack));
                } else {
                    drops.add(new ItemStack(item, 1, (short) block.getDropData(data)));
                }
            }
        }
    }
    return drops;
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:31,代码来源:CraftBlock.java


注:本文中的net.minecraft.server.TileEntitySkull.getSkullType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。