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


Java Block.getMetaFromState方法代码示例

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


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

示例1: pushEntity

import net.minecraft.block.Block; //导入方法依赖的package包/类
public static void pushEntity(IBlockState blockState, BlockPos blockPos, IBlockAccess blockAccess, VertexBuffer wrr)
{
    Block block = blockState.getBlock();
    int i;
    int j;

    if (blockState instanceof BlockStateBase)
    {
        BlockStateBase blockstatebase = (BlockStateBase)blockState;
        i = blockstatebase.getBlockId();
        j = blockstatebase.getMetadata();
    }
    else
    {
        i = Block.getIdFromBlock(block);
        j = block.getMetaFromState(blockState);
    }

    i = BlockAliases.getMappedBlockId(i, j);
    int i1 = block.getRenderType(blockState).ordinal();
    int k = ((i1 & 65535) << 16) + (i & 65535);
    int l = j & 65535;
    wrr.sVertexBuilder.pushEntity(((long)l << 32) + (long)k);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:25,代码来源:SVertexBuilder.java

示例2: getCrushResult

import net.minecraft.block.Block; //导入方法依赖的package包/类
public static ItemStack getCrushResult(Block broken, IBlockState state)
{
    if (broken == Blocks.STONE && broken.getMetaFromState(state) == 0)
    {
        return new ItemStack(Blocks.COBBLESTONE);
    }
    else if (broken == Blocks.COBBLESTONE)
    {
        return new ItemStack(Blocks.GRAVEL);
    }
    else if (broken == Blocks.GRAVEL)
    {
        return new ItemStack(Items.FLINT, 2);
    }
    else if (broken == Blocks.SANDSTONE)
    {
        return new ItemStack(Blocks.SAND);
    }
    else
    {
        return null;
    }
}
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:24,代码来源:ItemHammer.java

示例3: onAdd

import net.minecraft.block.Block; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void onAdd(Block block, int blockId, Map<ResourceLocation,?> slaves)
{
    ClearableObjectIntIdentityMap<IBlockState> blockstateMap = (ClearableObjectIntIdentityMap<IBlockState>)slaves.get(BLOCKSTATE_TO_ID);

    //So, due to blocks having more in-world states then metadata allows, we have to turn the map into a semi-milti-bimap.
    //We can do this however because the implementation of the map is last set wins. So we can add all states, then fix the meta bimap.
    //Multiple states -> meta. But meta to CORRECT state.

    final boolean[] usedMeta = new boolean[16]; //Hold a list of known meta from all states.
    for (IBlockState state : block.getBlockState().getValidStates())
    {
        final int meta = block.getMetaFromState(state);
        blockstateMap.put(state, blockId << 4 | meta); //Add ALL the things!
        usedMeta[meta] = true;
    }

    for (int meta = 0; meta < 16; meta++)
    {
        if (usedMeta[meta])
            blockstateMap.put(block.getStateFromMeta(meta), blockId << 4 | meta); // Put the CORRECT thing!
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:25,代码来源:GameData.java

示例4: getSilkTouchBlock

import net.minecraft.block.Block; //导入方法依赖的package包/类
@Nonnull
private static ItemStack getSilkTouchBlock(Block block, IBlockState state) {
    Item item = Item.getItemFromBlock(block);
    if (item == Items.AIR) {
        return ItemStack.EMPTY;
    } else {
        return new ItemStack(item, 1, block.getMetaFromState(state));
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:10,代码来源:DroneAIDig.java

示例5: canGrabChest

import net.minecraft.block.Block; //导入方法依赖的package包/类
@Override
public boolean canGrabChest(World world, BlockPos pos, IBlockState state, EntityPlayer player, ItemStack transporter)
{
    Block block = state.getBlock();
    int meta = block.getMetaFromState(state);

    return block == chestBlock && (chestMeta == -1 || chestMeta == meta);
}
 
开发者ID:cubex2,项目名称:chesttransporter,代码行数:9,代码来源:TransportableChestImpl.java

示例6: pushEntity

import net.minecraft.block.Block; //导入方法依赖的package包/类
public static void pushEntity(IBlockState blockState, BlockPos blockPos, IBlockAccess blockAccess, WorldRenderer wrr)
{
    Block block = blockState.getBlock();
    int i = Block.getIdFromBlock(block);
    int j = block.getRenderType();
    int k = block.getMetaFromState(blockState);
    int l = ((j & 65535) << 16) + (i & 65535);
    int i1 = k & 65535;
    wrr.sVertexBuilder.pushEntity(((long)i1 << 32) + (long)l);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:11,代码来源:SVertexBuilder.java

示例7: matches

import net.minecraft.block.Block; //导入方法依赖的package包/类
public boolean matches(World world, BlockPos center, boolean oldState) {
    lblPattern:
    for (Map.Entry<BlockPos, BlockInformation> entry : pattern.entrySet()) {
        BlockInformation info = entry.getValue();
        BlockPos at = center.add(entry.getKey());
        if(!world.isBlockLoaded(at)) { //We can't say if it's actually properly formed, but it didn't get changed from the last check so....
            return oldState;
        }

        if(info.matchingTag != null) {
            TileEntity te = world.getTileEntity(at);
            if(te != null && info.matchingTag.getSize() > 0) {
                NBTTagCompound cmp = new NBTTagCompound();
                te.writeToNBT(cmp);
                if(!NBTMatchingHelper.matchNBTCompound(info.matchingTag, cmp)) {
                    return false; //No match at this position.
                }
            }
        }

        IBlockState state = world.getBlockState(at);
        Block atBlock = state.getBlock();
        int atMeta = atBlock.getMetaFromState(state);

        for (IBlockStateDescriptor descriptor : info.matchingStates) {
            for (IBlockState applicable : descriptor.applicable) {
                Block type = applicable.getBlock();
                int meta = type.getMetaFromState(applicable);
                if(type.equals(state.getBlock()) && meta == atMeta) {
                    continue lblPattern; //Matches
                }
            }
        }
        return false;
    }
    return true;
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:38,代码来源:BlockArray.java

示例8: getRelativeMismatchPosition

import net.minecraft.block.Block; //导入方法依赖的package包/类
public BlockPos getRelativeMismatchPosition(World world, BlockPos center) {
    lblPattern:
    for (Map.Entry<BlockPos, BlockInformation> entry : pattern.entrySet()) {
        BlockInformation info = entry.getValue();
        BlockPos at = center.add(entry.getKey());

        if(info.matchingTag != null) {
            TileEntity te = world.getTileEntity(at);
            if(te != null && info.matchingTag.getSize() > 0) {
                NBTTagCompound cmp = new NBTTagCompound();
                te.writeToNBT(cmp);
                if(!NBTMatchingHelper.matchNBTCompound(info.matchingTag, cmp)) {
                    return entry.getKey();
                }
            }
        }

        IBlockState state = world.getBlockState(at);
        Block atBlock = state.getBlock();
        int atMeta = atBlock.getMetaFromState(state);

        for (IBlockStateDescriptor descriptor : info.matchingStates) {
            for (IBlockState applicable : descriptor.applicable) {
                Block type = applicable.getBlock();
                int meta = type.getMetaFromState(applicable);
                if(type.equals(state.getBlock()) && meta == atMeta) {
                    continue lblPattern; //Matches
                }
            }
        }
        return entry.getKey();
    }
    return null;
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:35,代码来源:BlockArray.java

示例9: IBlockStateDescriptor

import net.minecraft.block.Block; //导入方法依赖的package包/类
private IBlockStateDescriptor(Block block) {
    List<Integer> usedMetas = Lists.newArrayList();
    if(!(block instanceof BlockLiquid) && !(block instanceof BlockFluidBase)) {
        for (IBlockState state : block.getBlockState().getValidStates()) {
            int meta = block.getMetaFromState(state);
            if(!usedMetas.contains(meta)) {
                usedMetas.add(meta);
                this.applicable.add(state);
            }
        }
    }
    if(applicable.isEmpty()) {
        applicable.add(block.getDefaultState());
    }
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:16,代码来源:BlockArray.java

示例10: drawSlot

import net.minecraft.block.Block; //导入方法依赖的package包/类
protected void drawSlot(int entryID, int insideLeft, int yPos, int insideSlotHeight, int mouseXIn, int mouseYIn)
{
    FlatLayerInfo flatlayerinfo = (FlatLayerInfo)GuiCreateFlatWorld.this.theFlatGeneratorInfo.getFlatLayers().get(GuiCreateFlatWorld.this.theFlatGeneratorInfo.getFlatLayers().size() - entryID - 1);
    IBlockState iblockstate = flatlayerinfo.getLayerMaterial();
    Block block = iblockstate.getBlock();
    Item item = Item.getItemFromBlock(block);

    if (item == Items.field_190931_a)
    {
        if (block != Blocks.WATER && block != Blocks.FLOWING_WATER)
        {
            if (block == Blocks.LAVA || block == Blocks.FLOWING_LAVA)
            {
                item = Items.LAVA_BUCKET;
            }
        }
        else
        {
            item = Items.WATER_BUCKET;
        }
    }

    ItemStack itemstack = new ItemStack(item, 1, item.getHasSubtypes() ? block.getMetaFromState(iblockstate) : 0);
    String s = item.getItemStackDisplayName(itemstack);
    this.drawItem(insideLeft, yPos, itemstack);
    GuiCreateFlatWorld.this.fontRendererObj.drawString(s, insideLeft + 18 + 5, yPos + 3, 16777215);
    String s1;

    if (entryID == 0)
    {
        s1 = I18n.format("createWorld.customize.flat.layer.top", new Object[] {Integer.valueOf(flatlayerinfo.getLayerCount())});
    }
    else if (entryID == GuiCreateFlatWorld.this.theFlatGeneratorInfo.getFlatLayers().size() - 1)
    {
        s1 = I18n.format("createWorld.customize.flat.layer.bottom", new Object[] {Integer.valueOf(flatlayerinfo.getLayerCount())});
    }
    else
    {
        s1 = I18n.format("createWorld.customize.flat.layer", new Object[] {Integer.valueOf(flatlayerinfo.getLayerCount())});
    }

    GuiCreateFlatWorld.this.fontRendererObj.drawString(s1, insideLeft + 2 + 213 - GuiCreateFlatWorld.this.fontRendererObj.getStringWidth(s1), yPos + 3, 16777215);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:44,代码来源:GuiCreateFlatWorld.java


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