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


Java Blocks.piston方法代码示例

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


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

示例1: onBlockHarvested

import net.minecraft.init.Blocks; //导入方法依赖的package包/类
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
{
    if (player.capabilities.isCreativeMode)
    {
        EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);

        if (enumfacing != null)
        {
            BlockPos blockpos = pos.offset(enumfacing.getOpposite());
            Block block = worldIn.getBlockState(blockpos).getBlock();

            if (block == Blocks.piston || block == Blocks.sticky_piston)
            {
                worldIn.setBlockToAir(blockpos);
            }
        }
    }

    super.onBlockHarvested(worldIn, pos, state, player);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:21,代码来源:BlockPistonExtension.java

示例2: onNeighborBlockChange

import net.minecraft.init.Blocks; //导入方法依赖的package包/类
/**
 * Called when a neighboring block changes.
 */
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
    EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
    BlockPos blockpos = pos.offset(enumfacing.getOpposite());
    IBlockState iblockstate = worldIn.getBlockState(blockpos);

    if (iblockstate.getBlock() != Blocks.piston && iblockstate.getBlock() != Blocks.sticky_piston)
    {
        worldIn.setBlockToAir(pos);
    }
    else
    {
        iblockstate.getBlock().onNeighborBlockChange(worldIn, blockpos, iblockstate, neighborBlock);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:19,代码来源:BlockPistonExtension.java

示例3: setBlockBoundsBasedOnState

import net.minecraft.init.Blocks; //导入方法依赖的package包/类
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
{
    TileEntityPiston tileentitypiston = this.getTileEntity(worldIn, pos);

    if (tileentitypiston != null)
    {
        IBlockState iblockstate = tileentitypiston.getPistonState();
        Block block = iblockstate.getBlock();

        if (block == this || block.getMaterial() == Material.air)
        {
            return;
        }

        float f = tileentitypiston.getProgress(0.0F);

        if (tileentitypiston.isExtending())
        {
            f = 1.0F - f;
        }

        block.setBlockBoundsBasedOnState(worldIn, pos);

        if (block == Blocks.piston || block == Blocks.sticky_piston)
        {
            f = 0.0F;
        }

        EnumFacing enumfacing = tileentitypiston.getFacing();
        this.minX = block.getBlockBoundsMinX() - (double)((float)enumfacing.getFrontOffsetX() * f);
        this.minY = block.getBlockBoundsMinY() - (double)((float)enumfacing.getFrontOffsetY() * f);
        this.minZ = block.getBlockBoundsMinZ() - (double)((float)enumfacing.getFrontOffsetZ() * f);
        this.maxX = block.getBlockBoundsMaxX() - (double)((float)enumfacing.getFrontOffsetX() * f);
        this.maxY = block.getBlockBoundsMaxY() - (double)((float)enumfacing.getFrontOffsetY() * f);
        this.maxZ = block.getBlockBoundsMaxZ() - (double)((float)enumfacing.getFrontOffsetZ() * f);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:38,代码来源:BlockPistonMoving.java

示例4: breakBlock

import net.minecraft.init.Blocks; //导入方法依赖的package包/类
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    super.breakBlock(worldIn, pos, state);
    EnumFacing enumfacing = ((EnumFacing)state.getValue(FACING)).getOpposite();
    pos = pos.offset(enumfacing);
    IBlockState iblockstate = worldIn.getBlockState(pos);

    if ((iblockstate.getBlock() == Blocks.piston || iblockstate.getBlock() == Blocks.sticky_piston) && ((Boolean)iblockstate.getValue(BlockPistonBase.EXTENDED)).booleanValue())
    {
        iblockstate.getBlock().dropBlockAsItem(worldIn, pos, iblockstate, 0);
        worldIn.setBlockToAir(pos);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:14,代码来源:BlockPistonExtension.java

示例5: breakWeapon

import net.minecraft.init.Blocks; //导入方法依赖的package包/类
private void breakWeapon(World world, ItemStack stack, Entity entity)
{
	if (!(entity instanceof EntityPlayer)) // For QuiverMobs/Arms Assistants
	{
		this.setCooldown(stack, 40);
		return;
	}
	
	EntityPlayer player = (EntityPlayer) entity;
	
	player.renderBrokenItemStack(stack);
	player.destroyCurrentEquippedItem();	// Breaking
	stack.stackSize = 0;
	
	EntityItem piston = new EntityItem(world, player.posX, player.posY + 1.0F, player.posZ, new ItemStack(Blocks.piston));
	piston.delayBeforeCanPickup = 10;
	
	if (player.captureDrops) { player.capturedDrops.add(piston); }
	else { world.spawnEntityInWorld(piston); }
	
	EntityItem hook = new EntityItem(world, player.posX, player.posY + 1.0F, player.posZ, new ItemStack(Blocks.tripwire_hook));
	hook.delayBeforeCanPickup = 10;
	
	if (player.captureDrops) { player.capturedDrops.add(hook); }
	else { world.spawnEntityInWorld(hook); }
	
	world.playSoundAtEntity(player, "random.break", 1.0F, 1.5F);
}
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:29,代码来源:Seedling.java

示例6: canPush

import net.minecraft.init.Blocks; //导入方法依赖的package包/类
public static boolean canPush(Block blockIn, World worldIn, BlockPos pos, EnumFacing direction, boolean allowDestroy)
{
    if (blockIn == Blocks.obsidian)
    {
        return false;
    }
    else if (!worldIn.getWorldBorder().contains(pos))
    {
        return false;
    }
    else if (pos.getY() >= 0 && (direction != EnumFacing.DOWN || pos.getY() != 0))
    {
        if (pos.getY() <= worldIn.getHeight() - 1 && (direction != EnumFacing.UP || pos.getY() != worldIn.getHeight() - 1))
        {
            if (blockIn != Blocks.piston && blockIn != Blocks.sticky_piston)
            {
                if (blockIn.getBlockHardness(worldIn, pos) == -1.0F)
                {
                    return false;
                }

                if (blockIn.getMobilityFlag() == 2)
                {
                    return false;
                }

                if (blockIn.getMobilityFlag() == 1)
                {
                    if (!allowDestroy)
                    {
                        return false;
                    }

                    return true;
                }
            }
            else if (((Boolean)worldIn.getBlockState(pos).getValue(EXTENDED)).booleanValue())
            {
                return false;
            }

            return !(blockIn instanceof ITileEntityProvider);
        }
        else
        {
            return false;
        }
    }
    else
    {
        return false;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:54,代码来源:BlockPistonBase.java


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