本文整理了Java中net.minecraft.block.Block.getBlockFromItem()
方法的一些代码示例,展示了Block.getBlockFromItem()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.getBlockFromItem()
方法的具体详情如下:
包路径:net.minecraft.block.Block
类名称:Block
方法名:getBlockFromItem
暂无
代码示例来源:origin: Vazkii/Botania
@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);
}
};
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
@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;
}
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
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 );
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
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 );
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
final Block block = Block.getBlockFromItem( item );
final boolean isBlock = block != Blocks.AIR && !block.equals( Blocks.AIR );
final Class<? extends ItemStack> stackClass = input.getClass();
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
final Block block = Block.getBlockFromItem( input );
final boolean isBlock = block != Blocks.AIR && !block.equals( Blocks.AIR );
final Class<? extends Item> itemClass = input.getClass();
代码示例来源:origin: Vazkii/Botania
@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;
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
@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() );
}
}
代码示例来源:origin: Vazkii/Botania
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);
代码示例来源:origin: Vazkii/Botania
return;
Block block = Block.getBlockFromItem(blockToPlace.getItem());
int meta = blockToPlace.getItemDamage();
IBlockState state = block.getStateFromMeta(meta);
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
@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();
}
}
代码示例来源:origin: SleepyTrousers/EnderIO
/**
* 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);
}
}
}
代码示例来源:origin: SleepyTrousers/EnderIO
@Override
public boolean doApply(@Nonnull ItemStack input) {
return Block.getBlockFromItem(input.getItem()) instanceof IPaintable;
}
};
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
if( Block.getBlockFromItem( result.getItem() ) == blockID && result.getItem().getDamage( result ) == blockID
.getMetaFromState( state ) )
代码示例来源:origin: Vazkii/Botania
@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();
}
}
}
}
代码示例来源:origin: Vazkii/Botania
if(block instanceof BlockShulkerBox && Block.getBlockFromItem(stack_.getItem()) instanceof BlockShulkerBox)
continue;
if(world.rand.nextFloat() <= chance)
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
final Block block = Block.getBlockFromItem( itemStack.getItem() );
if( block == Blocks.AIR || itemStack.hasTagCompound() )
代码示例来源:origin: SleepyTrousers/EnderIO
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;
}
}
代码示例来源:origin: ForestryMC/ForestryMC
@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());
}
代码示例来源:origin: SleepyTrousers/EnderIO
@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);
}
内容来源于网络,如有侵权,请联系作者删除!