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


Java CraftMagicNumbers类代码示例

本文整理汇总了Java中org.bukkit.craftbukkit.util.CraftMagicNumbers的典型用法代码示例。如果您正苦于以下问题:Java CraftMagicNumbers类的具体用法?Java CraftMagicNumbers怎么用?Java CraftMagicNumbers使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: setPlaying

import org.bukkit.craftbukkit.util.CraftMagicNumbers; //导入依赖的package包/类
@Override
public void setPlaying(Material record) {
    if (record == null || CraftMagicNumbers.getItem(record) == null) {
        record = Material.AIR;
        jukebox.func_145857_a(null);
    } else {
        jukebox.func_145857_a(new ItemStack(CraftMagicNumbers.getItem(record), 1));
    }
    jukebox.markDirty();
    if (record == Material.AIR) {
        world.getHandle().setBlockMetadataWithNotify(getX(), getY(), getZ(), 0, 3);
    } else {
        world.getHandle().setBlockMetadataWithNotify(getX(), getY(), getZ(), 1, 3);
    }
    world.playEffect(getLocation(), Effect.RECORD_PLAY, record.getId());
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:17,代码来源:CraftJukebox.java

示例2: setTypeId

import org.bukkit.craftbukkit.util.CraftMagicNumbers; //导入依赖的package包/类
@Override
public void setTypeId(int type) {
    if (getTypeId() == type) {
        return;
    } else if (type == 0) {
        handle = null;
    } else if (CraftMagicNumbers.getItem(type) == null) { // :(
        handle = null;
    } else if (handle == null) {
        handle = new net.minecraft.item.ItemStack(CraftMagicNumbers.getItem(type), 1, 0);
    } else {
        handle.func_150996_a(CraftMagicNumbers.getItem(type));
        if (hasItemMeta()) {
            // This will create the appropriate item meta, which will contain all the data we intend to keep
            setItemMeta(handle, getItemMeta(handle));
        }
    }
    setData(null);
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:20,代码来源:CraftItemStack.java

示例3: addToCraftingManager

import org.bukkit.craftbukkit.util.CraftMagicNumbers; //导入依赖的package包/类
public void addToCraftingManager() {
    Object[] data;
    String[] shape = this.getShape();
    Map<Character, ItemStack> ingred = this.getIngredientMap();
    int datalen = shape.length;
    datalen += ingred.size() * 2;
    int i = 0;
    data = new Object[datalen];
    for (; i < shape.length; i++) {
        data[i] = shape[i];
    }
    for (char c : ingred.keySet()) {
        ItemStack mdata = ingred.get(c);
        if (mdata == null) continue;
        data[i] = c;
        i++;
        int id = mdata.getTypeId();
        short dmg = mdata.getDurability();
        data[i] = new net.minecraft.item.ItemStack(CraftMagicNumbers.getItem(id), 1, dmg);
        i++;
    }
    net.minecraft.item.crafting.CraftingManager.getInstance().addRecipe(CraftItemStack.asNMSCopy(this.getResult()), data);
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:24,代码来源:CraftShapedRecipe.java

示例4: getPlayerBucketEvent

import org.bukkit.craftbukkit.util.CraftMagicNumbers; //导入依赖的package包/类
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 = CraftMagicNumbers.getMaterial(itemstack.getItem());

    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;
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:25,代码来源:CraftEventFactory.java

示例5: setTypeId

import org.bukkit.craftbukkit.util.CraftMagicNumbers; //导入依赖的package包/类
@Override
public void setTypeId(int type) {
    if (getTypeId() == type) {
        return;
    } else if (type == 0) {
        handle = null;
    } else if (CraftMagicNumbers.getItem(type) == null) { // :(
        handle = null;
    } else if (handle == null) {
        handle = new net.minecraft.server.ItemStack(CraftMagicNumbers.getItem(type), 1, 0);
    } else {
        handle.setItem(CraftMagicNumbers.getItem(type));
        if (hasItemMeta()) {
            // This will create the appropriate item meta, which will contain all the data we intend to keep
            setItemMeta(handle, getItemMeta(handle));
        }
    }
    setData(null);
}
 
开发者ID:tgnmc,项目名称:Craftbukkit,代码行数:20,代码来源:CraftItemStack.java

示例6: addToCraftingManager

import org.bukkit.craftbukkit.util.CraftMagicNumbers; //导入依赖的package包/类
public void addToCraftingManager() {
    Object[] data;
    String[] shape = this.getShape();
    Map<Character, ItemStack> ingred = this.getIngredientMap();
    int datalen = shape.length;
    datalen += ingred.size() * 2;
    int i = 0;
    data = new Object[datalen];
    /*for (; i < shape.length; i++) {
        data[i] = shape[i];
    }*/
    System.arraycopy(shape, 0, data, 0, shape.length);i=shape.length;//FFoKC
    for (char c : ingred.keySet()) {
        ItemStack mdata = ingred.get(c);
        if (mdata == null) continue;
        data[i] = c;
        i++;
        int id = mdata.getTypeId();
        short dmg = mdata.getDurability();
        data[i] = new net.minecraft.item.ItemStack(CraftMagicNumbers.getItem(id), 1, dmg);
        i++;
    }
    net.minecraft.item.crafting.CraftingManager.getInstance().addRecipe(CraftItemStack.asNMSCopy(this.getResult()), data);
}
 
开发者ID:Bogdan-G,项目名称:FFoKC,代码行数:25,代码来源:CraftShapedRecipe.java

示例7: maxStackSize

import org.bukkit.craftbukkit.util.CraftMagicNumbers; //导入依赖的package包/类
@Test
public void maxStackSize() {
    if (INVALIDATED_MATERIALS.contains(material)) return;

    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(CraftMagicNumbers.getItem(material).getMaxStackSize()));
        assertThat(bukkit.getMaxStackSize(), is(material.getMaxStackSize()));
        assertThat(craft.getMaxStackSize(), is(material.getMaxStackSize()));
    }
}
 
开发者ID:tgnmc,项目名称:Craftbukkit,代码行数:18,代码来源:PerMaterialTest.java

示例8: getPlayerBucketEvent

import org.bukkit.craftbukkit.util.CraftMagicNumbers; //导入依赖的package包/类
private static PlayerEvent getPlayerBucketEvent(boolean isFilling, EntityHuman who, int clickedX, int clickedY, int clickedZ, EnumDirection clickedFace, ItemStack itemstack, net.minecraft.server.Item item) {
    Player player = (who == null) ? null : (Player) who.getBukkitEntity();
    CraftItemStack itemInHand = CraftItemStack.asNewCraftStack(item);
    Material bucket = CraftMagicNumbers.getMaterial(itemstack.getItem());

    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;
}
 
开发者ID:tgnmc,项目名称:Craftbukkit,代码行数:25,代码来源:CraftEventFactory.java

示例9: sendBlockChange

import org.bukkit.craftbukkit.util.CraftMagicNumbers; //导入依赖的package包/类
@Override
public void sendBlockChange(Location loc, int material, byte data) {
    if (getHandle().playerNetServerHandler == null) return;

    S23PacketBlockChange packet = new S23PacketBlockChange(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), ((CraftWorld) loc.getWorld()).getHandle());

    packet.field_148883_d = CraftMagicNumbers.getBlock(material);
    packet.field_148884_e = data;
    getHandle().playerNetServerHandler.sendPacket(packet);
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:11,代码来源:CraftPlayer.java

示例10: getDrops

import org.bukkit.craftbukkit.util.CraftMagicNumbers; //导入依赖的package包/类
public Collection<ItemStack> getDrops() {
    List<ItemStack> drops = new ArrayList<ItemStack>();

    net.minecraft.block.Block block = this.getNMSBlock();
    if (block != Blocks.air) {
        byte data = getData();
        // based on nms.Block.dropNaturally
        int count = block.quantityDroppedWithBonus(0, chunk.getHandle().worldObj.rand);
        for (int i = 0; i < count; ++i) {
            Item item = block.getItemDropped(data, chunk.getHandle().worldObj.rand, 0);
            if (item != null) {
                // Skulls are special, their data is based on the tile entity
                if (Blocks.skull == block) {
                    net.minecraft.item.ItemStack nmsStack = new net.minecraft.item.ItemStack(item, 1, block.getDamageValue(chunk.getHandle().worldObj, x, y, z));
                    TileEntitySkull tileentityskull = (TileEntitySkull) chunk.getHandle().worldObj.getTileEntity(x, y, z);

                    if (tileentityskull.func_145904_a() == 3 && tileentityskull.func_152108_a() != null) {
                        nmsStack.setTagCompound(new NBTTagCompound());
                        NBTTagCompound nbttagcompound = new NBTTagCompound();

                        NBTUtil.func_152460_a(nbttagcompound, tileentityskull.func_152108_a());
                        nmsStack.getTagCompound().setTag("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.func_149987_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.damageDropped(data)));
                }
            }
        }
    }
    return drops;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:40,代码来源:CraftBlock.java

示例11: getPlaying

import org.bukkit.craftbukkit.util.CraftMagicNumbers; //导入依赖的package包/类
@Override
public Material getPlaying() {
    ItemStack record = jukebox.func_145856_a();
    if (record == null) {
        return Material.AIR;
    }
    return CraftMagicNumbers.getMaterial(record.getItem());
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:9,代码来源:CraftJukebox.java

示例12: play

import org.bukkit.craftbukkit.util.CraftMagicNumbers; //导入依赖的package包/类
@Override
public boolean play(byte instrument, byte note) {
    Block block = getBlock();

    if (block.getType() == Material.NOTE_BLOCK) {
        world.getHandle().addBlockEvent(getX(), getY(), getZ(), CraftMagicNumbers.getBlock(block), instrument, note);
        return true;
    } else {
        return false;
    }
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:12,代码来源:CraftNoteBlock.java

示例13: addToCraftingManager

import org.bukkit.craftbukkit.util.CraftMagicNumbers; //导入依赖的package包/类
public void addToCraftingManager() {
    List<ItemStack> ingred = this.getIngredientList();
    Object[] data = new Object[ingred.size()];
    int i = 0;
    for (ItemStack mdata : ingred) {
        int id = mdata.getTypeId();
        short dmg = mdata.getDurability();
        data[i] = new net.minecraft.item.ItemStack(CraftMagicNumbers.getItem(id), 1, dmg);
        i++;
    }
    net.minecraft.item.crafting.CraftingManager.getInstance().addShapelessRecipe(CraftItemStack.asNMSCopy(this.getResult()), data);
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:13,代码来源:CraftShapelessRecipe.java

示例14: playBlockPlaceSound

import org.bukkit.craftbukkit.util.CraftMagicNumbers; //导入依赖的package包/类
public static void playBlockPlaceSound(World bukkitWorld, Vector pos, Material material, float volume) {
    if (!material.isBlock()) {
        return;
    }
    playCustomSound(bukkitWorld,
                    pos.toLocation(bukkitWorld),
                    CraftMagicNumbers.getBlock(material).getStepSound().placeSound(),
                    SoundCategory.BLOCKS,
                    volume,
                    1f);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:12,代码来源:NMSHacks.java

示例15: canMineBlock

import org.bukkit.craftbukkit.util.CraftMagicNumbers; //导入依赖的package包/类
/**
 * 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())));
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:17,代码来源:NMSHacks.java


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