public static void registerBlockToState(Block b, int maxExclusive) { for(int i = 0; i < maxExclusive; i++) registerBlockToState(b, i, b.getStateFromMeta(i)); }
@Override public void readPacketNBT(NBTTagCompound cmp) { Block b = Block.getBlockFromName(cmp.getString(TAG_CAMO)); if (b != null) { camoState = b.getStateFromMeta(cmp.getInteger(TAG_CAMO_META)); } }
@Override public boolean doParticles(IManaBurst burst, ItemStack stack) { EntityThrowable entity = (EntityThrowable) burst; ItemStack lens = burst.getSourceLens(); String id = ItemNBTHelper.getString(lens, TAG_BLOCK_NAME, "minecraft:air"); Block b = Block.getBlockFromName(id); int meta = ItemNBTHelper.getInt(lens, TAG_META, 0); entity.world.spawnParticle(EnumParticleTypes.BLOCK_CRACK, entity.posX, entity.posY, entity.posZ, entity.motionX, entity.motionY, entity.motionZ, Block.getStateId(b.getStateFromMeta(meta))); return true; }
public ToolEntropyManipulator() { super( AEConfig.instance().getEntropyManipulatorBattery() ); this.heatUp = new HashMap<>(); this.coolDown = new HashMap<>(); this.coolDown.put( new InWorldToolOperationIngredient( Blocks.STONE.getDefaultState() ), new InWorldToolOperationResult( Blocks.COBBLESTONE.getDefaultState() ) ); this.coolDown.put( new InWorldToolOperationIngredient( Blocks.STONEBRICK.getDefaultState() ), new InWorldToolOperationResult( Blocks.STONEBRICK.getStateFromMeta( 2 ) ) ); this.coolDown.put( new InWorldToolOperationIngredient( Blocks.LAVA, true ), new InWorldToolOperationResult( Blocks.OBSIDIAN.getDefaultState() ) ); this.coolDown.put( new InWorldToolOperationIngredient( Blocks.FLOWING_LAVA, true ), new InWorldToolOperationResult( Blocks.OBSIDIAN.getDefaultState() ) ); this.coolDown.put( new InWorldToolOperationIngredient( Blocks.GRASS, true ), new InWorldToolOperationResult( Blocks.DIRT.getDefaultState() ) ); final List<ItemStack> snowBalls = new ArrayList<>(); snowBalls.add( new ItemStack( Items.SNOWBALL ) ); this.coolDown.put( new InWorldToolOperationIngredient( Blocks.FLOWING_WATER, true ), new InWorldToolOperationResult( null, snowBalls ) ); this.coolDown.put( new InWorldToolOperationIngredient( Blocks.WATER, true ), new InWorldToolOperationResult( Blocks.ICE.getDefaultState() ) ); this.heatUp.put( new InWorldToolOperationIngredient( Blocks.ICE.getDefaultState() ), new InWorldToolOperationResult( Blocks.WATER.getDefaultState() ) ); this.heatUp.put( new InWorldToolOperationIngredient( Blocks.FLOWING_WATER, true ), new InWorldToolOperationResult() ); this.heatUp.put( new InWorldToolOperationIngredient( Blocks.WATER, true ), new InWorldToolOperationResult() ); this.heatUp.put( new InWorldToolOperationIngredient( Blocks.SNOW, true ), new InWorldToolOperationResult( Blocks.FLOWING_WATER.getStateFromMeta( 7 ) ) ); }
Block targetBlock = getTargetBlock(stack); int targetMeta = getTargetBlockMeta(stack); List<BlockPos> swap = getBlocksToSwap(world, stack, block.getStateFromMeta(meta), new BlockPos(x, y, z), targetBlock.getStateFromMeta(targetMeta)); if(swap.size() == 0) { ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false); boolean exchange = exchange(world, player, coords, stack, block.getStateFromMeta(meta)); if(exchange) ManaItemHandler.requestManaExactForTool(stack, player, COST, true);
List<BlockPos> coordsList = getBlocksToSwap(player.world, stack, block.getStateFromMeta(meta), bPos, targetBlock == null ? null : targetBlock.getStateFromMeta(targetMeta)); for(BlockPos coords : coordsList) if(coords.equals(bPos)) {
if(data.progress <= 0) { if(!p.world.isRemote) { p.world.setBlockState(pos.getBlockPos(), Block.getBlockFromItem(result.getItem()).getStateFromMeta(result.getItemDamage()), 1 | 2); p.world.playSound(null, p.posX, p.posY, p.posZ, SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.PLAYERS, 0.6F, 1F); p.world.playSound(null, p.posX, p.posY, p.posZ, SoundEvents.BLOCK_FIRE_AMBIENT, SoundCategory.PLAYERS, 1F, 1F);
items.registerItemColorHandler((s, t) -> Minecraft.getMinecraft().getBlockColors().colorMultiplier(((ItemBlock)s.getItem()).getBlock().getStateFromMeta(s.getMetadata()), null, null, t), ModBlocks.petalBlock, ModBlocks.pool, ModBlocks.spreader);
IBlockState state = block.getStateFromMeta(meta); player.world.setBlockState(coords, state, 1 | 2); player.world.playEvent(2001, coords, Block.getStateId(state));
@SubscribeEvent public void onLeftClick(PlayerInteractEvent.LeftClickBlock event) { ItemStack stack = event.getItemStack(); if(!stack.isEmpty() && stack.getItem() == this && canExchange(stack) && ManaItemHandler.requestManaExactForTool(stack, event.getEntityPlayer(), COST, false)) { if(exchange(event.getWorld(), event.getEntityPlayer(), event.getPos(), stack, getBlock(stack).getStateFromMeta(getBlockMeta(stack)))) ManaItemHandler.requestManaExactForTool(stack, event.getEntityPlayer(), COST, true); } }
@Override public IBlockState getTextureBlockState( ItemStack is ) { ItemStack baseItemStack = this.getTextureItem( is ); if( baseItemStack.isEmpty() ) { return Blocks.GLASS.getDefaultState(); } Block block = Block.getBlockFromItem( baseItemStack.getItem() ); if( block == Blocks.AIR ) { return Blocks.GLASS.getDefaultState(); } int metadata = baseItemStack.getItem().getMetadata( baseItemStack ); try { return block.getStateFromMeta( metadata ); } catch( Exception e ) { AELog.warn( "Block %s has broken getStateFromMeta method for meta %d", block.getRegistryName().toString(), baseItemStack.getItemDamage() ); return Blocks.GLASS.getDefaultState(); } }
private void renderPylon(@Nonnull TilePylon pylon, double d0, double d1, double d2, float pticks, boolean renderingItem) { PylonVariant type = renderingItem ? forceVariant : ModBlocks.pylon.getStateFromMeta(pylon.getBlockMetadata()).getValue(BotaniaStateProps.PYLON_VARIANT); IPylonModel model; switch(type) {
Block block = getBlock(stack); int meta = getBlockMeta(stack); List<BlockPos> swap = getBlocksToSwap(world, stack, block.getStateFromMeta(meta), pos, null); if(swap.size() > 0) { ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, true);
@SuppressWarnings("deprecation") @Override @SideOnly(Side.CLIENT) public List<Pair<IBlockState, ItemStack>> mapItemRender(@Nonnull Block block, @Nonnull ItemStack stack, @Nonnull ItemQuadCollector itemQuadCollector) { return Collections .singletonList(Pair.of(block.getStateFromMeta(stack.getMetadata()).withProperty(EnumRenderMode.RENDER, SINGLE_MODEL_INVENTORY), (ItemStack) null)); }
@SuppressWarnings("deprecation") @Override @SideOnly(Side.CLIENT) public List<Pair<IBlockState, ItemStack>> mapItemRender(@Nonnull Block block, @Nonnull ItemStack stack, @Nonnull ItemQuadCollector itemQuadCollector) { return Collections .singletonList(Pair.of(block.getStateFromMeta(stack.getMetadata()).withProperty(EnumRenderMode.RENDER, SINGLE_MODEL_INVENTORY), (ItemStack) null)); }
blockMeta = 0; stateToPlace = ((ItemBlock) stackItem).getBlock().getStateFromMeta(blockMeta);
@Override public void onUpdate() { super.onUpdate(); if(supertile.getWorld().isRemote || redstoneSignal > 0 || !canOperate()) return; int cost = getCost(); if(mana >= cost && ticksExisted % getDelay() == 0) { BlockPos coords = getCoordsToPut(); if(coords != null) { ItemStack stack = getOreToPut(); if(!stack.isEmpty()) { Block block = Block.getBlockFromItem(stack.getItem()); int meta = stack.getItemDamage(); supertile.getWorld().setBlockState(coords, block.getStateFromMeta(meta), 1 | 2); if(ConfigHandler.blockBreakParticles) supertile.getWorld().playEvent(2001, coords, Block.getIdFromBlock(block) + (meta << 12)); supertile.getWorld().playSound(null, supertile.getPos(), ModSounds.orechid, SoundCategory.BLOCKS, 2F, 1F); mana -= cost; sync(); } } } }
tile = TileEntity.create(entity.world, tilecmp); entity.world.setBlockState(pos, block.getStateFromMeta(meta), 1 | 2); entity.world.playEvent(2001, pos, Block.getStateId(block.getStateFromMeta(meta))); if(tile != null) { tile.setPos(pos);
private static void renderBlockAt(Block block, int meta, BlockPos pos) { IBlockState state = block.getStateFromMeta(meta); double renderPosX = Minecraft.getMinecraft().getRenderManager().renderPosX; double renderPosY = Minecraft.getMinecraft().getRenderManager().renderPosY; double renderPosZ = Minecraft.getMinecraft().getRenderManager().renderPosZ; GlStateManager.pushMatrix(); GlStateManager.translate(-renderPosX, -renderPosY, -renderPosZ); GlStateManager.disableDepth(); GlStateManager.pushMatrix(); GlStateManager.enableBlend(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); BlockRendererDispatcher brd = Minecraft.getMinecraft().getBlockRendererDispatcher(); GlStateManager.translate(pos.getX(), pos.getY(), pos.getZ() + 1); GlStateManager.color(1, 1, 1, 1); brd.renderBlockBrightness(state, 1.0F); GlStateManager.color(1F, 1F, 1F, 1F); GlStateManager.enableDepth(); GlStateManager.popMatrix(); GlStateManager.popMatrix(); }
try blockState = block.getStateFromMeta( metadata );