當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。