Java Code Examples for net.minecraft.block.Block#getMetaFromState()
The following examples show how to use
net.minecraft.block.Block#getMetaFromState() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TargetData.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
public boolean isTargetBlockUnchanged() { MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); if (server == null) { return false; } World world = server.getWorld(this.dimension); if (world == null) { return false; } IBlockState iBlockState = world.getBlockState(this.pos); Block block = iBlockState.getBlock(); ResourceLocation rl = ForgeRegistries.BLOCKS.getKey(block); int meta = block.getMetaFromState(iBlockState); // The target block unique name and metadata matches what we have stored return this.blockMeta == meta && rl != null && this.blockName.equals(rl.toString()); }
Example 2
Source File: BlockCropsTest.java From customstuff4 with GNU General Public License v3.0 | 5 votes |
@Test public void test_ageProperty() { ContentBlockCrops content = new ContentBlockCrops(); content.id = "test_getSubtype"; Block block = content.createBlock(); // this use getAgeProperty which is protected block.getMetaFromState(block.getDefaultState()); }
Example 3
Source File: BlockUtils.java From GriefPrevention with MIT License | 5 votes |
public static int getBlockStateMeta(BlockState state) { Integer meta = BLOCKSTATE_META_CACHE.get(state); if (meta == null) { Block mcBlock = (net.minecraft.block.Block) state.getType(); meta = mcBlock.getMetaFromState((IBlockState) state); BLOCKSTATE_META_CACHE.put(state, meta); } return meta; }
Example 4
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public int getCombinedId4Data(ExtendedBlockStorage section, int x, int y, int z) { IBlockState ibd = section.getData().get(x & 15, y & 15, z & 15); Block block = ibd.getBlock(); int id = Block.getIdFromBlock(block); if (FaweCache.hasData(id)) { return (id << 4) + block.getMetaFromState(ibd); } else { return id << 4; } }
Example 5
Source File: SpongeQueue_1_11.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public int getCombinedId4Data(ExtendedBlockStorage section, int x, int y, int z) { IBlockState ibd = section.getData().get(x & 15, y & 15, z & 15); Block block = ibd.getBlock(); int id = Block.getIdFromBlock(block); if (FaweCache.hasData(id)) { return (id << 4) + block.getMetaFromState(ibd); } else { return id << 4; } }
Example 6
Source File: SpongeQueue_1_12.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public int getCombinedId4Data(ExtendedBlockStorage section, int x, int y, int z) { IBlockState ibd = section.getData().get(x & 15, y & 15, z & 15); Block block = ibd.getBlock(); int id = Block.getIdFromBlock(block); if (FaweCache.hasData(id)) { return (id << 4) + block.getMetaFromState(ibd); } else { return id << 4; } }
Example 7
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public int getCombinedId4Data(ExtendedBlockStorage section, int x, int y, int z) { IBlockState ibd = section.getData().get(x & 15, y & 15, z & 15); Block block = ibd.getBlock(); int id = Block.getIdFromBlock(block); if (FaweCache.hasData(id)) { return (id << 4) + block.getMetaFromState(ibd); } else { return id << 4; } }
Example 8
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public int getCombinedId4Data(ExtendedBlockStorage section, int x, int y, int z) { IBlockState ibd = section.getData().get(x & 15, y & 15, z & 15); Block block = ibd.getBlock(); int id = Block.getIdFromBlock(block); if (FaweCache.hasData(id)) { return (id << 4) + block.getMetaFromState(ibd); } else { return id << 4; } }
Example 9
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public int getCombinedId4Data(ExtendedBlockStorage section, int x, int y, int z) { IBlockState ibd = section.getData().get(x & 15, y & 15, z & 15); Block block = ibd.getBlock(); int id = Block.getIdFromBlock(block); if (FaweCache.hasData(id)) { return (id << 4) + block.getMetaFromState(ibd); } else { return id << 4; } }
Example 10
Source File: MethodGetGrowthStage.java From AgriCraft with MIT License | 5 votes |
@Override protected Object[] onMethodCalled(TileEntityCrop crop) { IBlockState state = crop.getWorld().getBlockState(crop.getPos()); Block block = state.getBlock(); int meta = block.getMetaFromState(state); double growthStage = (100.00 * meta) / 7; return new Object[]{growthStage}; }
Example 11
Source File: MethodGetCurrentSoil.java From AgriCraft with MIT License | 5 votes |
@Override protected Object[] onMethodCalled(TileEntityCrop crop) { IBlockState state = crop.getWorld().getBlockState(crop.getPos().add(0, -1, 0)); Block block = state.getBlock(); int meta = block.getMetaFromState(state); return new Object[]{(new ItemStack(block, 1, meta)).getDisplayName()}; }
Example 12
Source File: BlockInfo.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
public static BlockInfo getBlockInfo(World world, BlockPos pos) { IBlockState state = world.getBlockState(pos); IBlockState stateActual = state.getActualState(world, pos); Block block = state.getBlock(); @SuppressWarnings("deprecation") ItemStack stack = block.getItem(world, pos, state); return new BlockInfo(state, stateActual, block, block.getMetaFromState(state), stack.isEmpty() == false ? stack.getMetadata() : 0); }
Example 13
Source File: SyncableBlockState.java From OpenModsLib with MIT License | 5 votes |
@Override public void writeToNBT(NBTTagCompound nbt, String name) { final NBTTagCompound tag = new NBTTagCompound(); final Block block = state.getBlock(); final int meta = block.getMetaFromState(state); tag.setByte(TAG_BLOCK_META, (byte)meta); final ResourceLocation blockId = Block.REGISTRY.getNameForObject(block); tag.setString(TAG_BLOCK_ID, blockId.toString()); nbt.setTag(name, tag); }
Example 14
Source File: BlockHelper.java From ForgeHax with MIT License | 4 votes |
public boolean isEqual(BlockPos pos) { IBlockState state = getWorld().getBlockState(pos); Block bl = state.getBlock(); return Objects.equals(getBlock(), bl) && getMetadata() == bl.getMetaFromState(state); }
Example 15
Source File: ItemBuildersWand.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
private BlockPosEU checkPositionOnPlane(Mode mode, World world, BlockPosEU posIn, BlockPos posMin, BlockPos posMax, Set<BlockPosEU> visited, List<BlockPosEU> branches, List<BlockPosStateDist> positions, boolean continueThrough, boolean diagonals, int blockType, BlockInfo biTarget, BlockInfo biBound) { BlockPos posTmp = posIn.toBlockPos(); BlockPosEU continueTo = null; int sides = 0; if (visited.contains(posIn) || PositionUtils.isPositionInsideArea(posIn, posMin, posMax) == false) { return null; } if (world.getBlockState(posTmp).getBlock().isReplaceable(world, posTmp)) { if (mode == Mode.EXTEND_AREA || mode == Mode.EXTEND_CONTINUOUS) { BlockPos posTgt = posTmp.offset(posIn.getFacing(), -1); IBlockState state = world.getBlockState(posTgt); Block block = state.getBlock(); int meta = block.getMetaFromState(state); // The block on the back face must not be air and also it must not be fluid. // If the block type to work with is BLOCK_TYPE_TARGETED, then the block adjacent // to his position must match the targeted block. if (block.isAir(state, world, posTgt) == false && state.getMaterial().isLiquid() == false && (blockType == BLOCK_TYPE_ADJACENT || (blockType >= 0 && biBound != null) || (biTarget != null && biTarget.block == block && biTarget.blockMeta == meta))) { positions.add(new BlockPosStateDist(posIn, this.getBlockInfoForBlockType(world, posTmp, posIn.getFacing(), blockType, biTarget, biBound))); } // Extend Continuous can't continue past air blocks on the back face else if (mode == Mode.EXTEND_CONTINUOUS) { return null; } } else { positions.add(new BlockPosStateDist(posIn, this.getBlockInfoForBlockType(world, posTmp, posIn.getFacing(), blockType, biTarget, biBound))); } } else if (continueThrough == false) { return null; } visited.add(posIn); for (BlockPosEU pos : PositionUtils.getAdjacentPositions(posIn, posIn.getFacing(), diagonals)) { if (visited.contains(pos) || PositionUtils.isPositionInsideArea(pos, posMin, posMax) == false) { continue; } if (world.isAirBlock(pos.toBlockPos()) || continueThrough) { if (visited.contains(pos) == false) { if (sides == 0) { continueTo = pos; } else if (branches.contains(pos) == false) { branches.add(pos); } } sides++; } } return continueTo; }