@Nonnull @Override public IBakedModel handleItemState(@Nonnull IBakedModel model, ItemStack stack, World world, EntityLivingBase entity) { // Items always have GRASS island IFloatingFlower.IslandType islandType = IFloatingFlower.IslandType.GRASS; String identifier; if(Block.getBlockFromItem(stack.getItem()) == ModBlocks.floatingSpecialFlower) { // Magic flower identifier = ItemBlockSpecialFlower.getType(stack); } else { // Mundane flower identifier = MUNDANE_PREFIX + stack.getItemDamage(); } return FloatingFlowerModel.this.getModel(islandType, identifier); } };
@Override public int getMaxInstalled( final Upgrades upgrades ) { int max = 0; for( final ItemStack is : upgrades.getSupported().keySet() ) { final Item encodedItem = is.getItem(); if( encodedItem instanceof ItemBlock && Block.getBlockFromItem( encodedItem ) == this.block ) { max = upgrades.getSupported().get( is ); break; } } return max; } }
public static InWorldToolOperationResult getBlockOperationResult( final ItemStack[] items ) { final List<ItemStack> temp = new ArrayList<>(); IBlockState b = null; for( final ItemStack l : items ) { if( b == null ) { final Block bl = Block.getBlockFromItem( l.getItem() ); if( bl != null && !( bl instanceof BlockAir ) ) { b = bl.getDefaultState(); continue; } } temp.add( l ); } return new InWorldToolOperationResult( b, temp ); }
private double getMaxEnergyCapacity() { final Block blockID = Block.getBlockFromItem( this ); final IBlockDefinition energyCell = Api.INSTANCE.definitions().blocks().energyCell(); return energyCell.maybeBlock().map( block -> { if( blockID == block ) { return 200000; } else { return 8 * 200000; } } ).orElse( 0 ); }
final Block block = Block.getBlockFromItem( item ); final boolean isBlock = block != Blocks.AIR && !block.equals( Blocks.AIR ); final Class<? extends ItemStack> stackClass = input.getClass();
final Block block = Block.getBlockFromItem( input ); final boolean isBlock = block != Blocks.AIR && !block.equals( Blocks.AIR ); final Class<? extends Item> itemClass = input.getClass();
@Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { TileEntity tile = world.getTileEntity(pos); if(world.isRemote) return true; ItemStack currentStack = player.getHeldItem(hand); if(!currentStack.isEmpty() && Block.getBlockFromItem(currentStack.getItem()) != null && tile instanceof TileCamo) { TileCamo camo = (TileCamo) tile; IBlockState changeState = Block.getBlockFromItem(currentStack.getItem()).getStateForPlacement(world, pos, side, hitX, hitY, hitZ, currentStack.getItemDamage(), player); if(isValidBlock(changeState) && !(changeState.getBlock() instanceof BlockCamo) && changeState.getMaterial() != Material.AIR) { camo.camoState = changeState; world.notifyBlockUpdate(pos, state, state, 8); return true; } } return false; }
@Override public void process( final IMCMessage m ) { final ItemStack is = m.getItemStackValue(); if( !is.isEmpty() ) { final Block blk = Block.getBlockFromItem( is.getItem() ); if( blk != Blocks.AIR ) { AEApi.instance().registries().movable().blacklistBlock( blk ); return; } } AELog.info( "Bad Block blacklisted by " + m.getSender() ); } }
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);
return; Block block = Block.getBlockFromItem(blockToPlace.getItem()); int meta = blockToPlace.getItemDamage(); IBlockState state = block.getStateFromMeta(meta);
@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(); } }
/** * Registers items that can be painted but are not items for blocks implement IPaintable themselves. Used for items that do not have a block , e.g. Dark Steel * Helmets and Facades. */ public static void registerPaintable(Item... items) { for (Item item : items) { if (!(Block.getBlockFromItem(item) instanceof IPaintable)) { PaintUtil.paintables.add(item); } } }
@Override public boolean doApply(@Nonnull ItemStack input) { return Block.getBlockFromItem(input.getItem()) instanceof IPaintable; } };
if( Block.getBlockFromItem( result.getItem() ) == blockID && result.getItem().getDamage( result ) == blockID .getMetaFromState( state ) )
@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(); } } } }
if(block instanceof BlockShulkerBox && Block.getBlockFromItem(stack_.getItem()) instanceof BlockShulkerBox) continue; if(world.rand.nextFloat() <= chance)
final Block block = Block.getBlockFromItem( itemStack.getItem() ); if( block == Blocks.AIR || itemStack.hasTagCompound() )
protected boolean plant(@Nonnull IFarmer farm, @Nonnull World world, @Nonnull BlockPos bc, @Nonnull ItemStack sapling) { if (canPlant(world, bc, sapling) && farm.checkAction(FarmingAction.PLANT, FarmingTool.HOE)) { world.setBlockToAir(bc); final Item item = sapling.getItem(); final IBlockState state = Block.getBlockFromItem(item).getStateFromMeta(item.getMetadata(sapling.getMetadata())); world.setBlockState(bc, state, 1 | 2); farm.registerAction(FarmingAction.PLANT, FarmingTool.HOE, state, bc); return true; } else { return false; } }
@Override protected ModelDefaultLeaves.Key getInventoryKey(ItemStack stack) { Block block = Block.getBlockFromItem(stack.getItem()); Preconditions.checkArgument(block instanceof BlockDefaultLeaves, "ItemStack must be for default leaves."); BlockDefaultLeaves bBlock = (BlockDefaultLeaves) block; return new Key(bBlock.getTreeType(stack.getMetadata()), Proxies.render.fancyGraphicsEnabled()); }
@Override protected @Nonnull ItemStack mkItemStack(@Nonnull ItemStack target, @Nonnull Block targetBlock) { NNIterator<FusedQuartzType> iterator = NNList.of(FusedQuartzType.class).iterator(); while (iterator.hasNext()) { FusedQuartzType type = iterator.next(); if (type.getBlock() == Block.getBlockFromItem(target.getItem())) { return new ItemStack(targetBlock, 1, FusedQuartzType.getMetaFromType(type)); } } return new ItemStack(targetBlock, 1, 0); }