Java 类net.minecraft.block.state.BlockPistonStructureHelper 实例源码

项目:DecompiledMinecraft    文件:BlockPistonBase.java   
private void checkForMove(World worldIn, BlockPos pos, IBlockState state)
{
    EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
    boolean flag = this.shouldBeExtended(worldIn, pos, enumfacing);

    if (flag && !((Boolean)state.getValue(EXTENDED)).booleanValue())
    {
        if ((new BlockPistonStructureHelper(worldIn, pos, enumfacing, true)).canMove())
        {
            worldIn.addBlockEvent(pos, this, 0, enumfacing.getIndex());
        }
    }
    else if (!flag && ((Boolean)state.getValue(EXTENDED)).booleanValue())
    {
        worldIn.setBlockState(pos, state.withProperty(EXTENDED, Boolean.valueOf(false)), 2);
        worldIn.addBlockEvent(pos, this, 1, enumfacing.getIndex());
    }
}
项目:DecompiledMinecraft    文件:BlockPistonBase.java   
private void checkForMove(World worldIn, BlockPos pos, IBlockState state)
{
    EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
    boolean flag = this.shouldBeExtended(worldIn, pos, enumfacing);

    if (flag && !((Boolean)state.getValue(EXTENDED)).booleanValue())
    {
        if ((new BlockPistonStructureHelper(worldIn, pos, enumfacing, true)).canMove())
        {
            worldIn.addBlockEvent(pos, this, 0, enumfacing.getIndex());
        }
    }
    else if (!flag && ((Boolean)state.getValue(EXTENDED)).booleanValue())
    {
        worldIn.setBlockState(pos, state.withProperty(EXTENDED, Boolean.valueOf(false)), 2);
        worldIn.addBlockEvent(pos, this, 1, enumfacing.getIndex());
    }
}
项目:BaseClient    文件:BlockPistonBase.java   
private void checkForMove(World worldIn, BlockPos pos, IBlockState state)
{
    EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
    boolean flag = this.shouldBeExtended(worldIn, pos, enumfacing);

    if (flag && !((Boolean)state.getValue(EXTENDED)).booleanValue())
    {
        if ((new BlockPistonStructureHelper(worldIn, pos, enumfacing, true)).canMove())
        {
            worldIn.addBlockEvent(pos, this, 0, enumfacing.getIndex());
        }
    }
    else if (!flag && ((Boolean)state.getValue(EXTENDED)).booleanValue())
    {
        worldIn.setBlockState(pos, state.withProperty(EXTENDED, Boolean.valueOf(false)), 2);
        worldIn.addBlockEvent(pos, this, 1, enumfacing.getIndex());
    }
}
项目:BaseClient    文件:BlockPistonBase.java   
private void checkForMove(World worldIn, BlockPos pos, IBlockState state)
{
    EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
    boolean flag = this.shouldBeExtended(worldIn, pos, enumfacing);

    if (flag && !((Boolean)state.getValue(EXTENDED)).booleanValue())
    {
        if ((new BlockPistonStructureHelper(worldIn, pos, enumfacing, true)).canMove())
        {
            worldIn.addBlockEvent(pos, this, 0, enumfacing.getIndex());
        }
    }
    else if (!flag && ((Boolean)state.getValue(EXTENDED)).booleanValue())
    {
        worldIn.setBlockState(pos, state.withProperty(EXTENDED, Boolean.valueOf(false)), 2);
        worldIn.addBlockEvent(pos, this, 1, enumfacing.getIndex());
    }
}
项目:Backmemed    文件:BlockPistonBase.java   
private void checkForMove(World worldIn, BlockPos pos, IBlockState state)
{
    EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
    boolean flag = this.shouldBeExtended(worldIn, pos, enumfacing);

    if (flag && !((Boolean)state.getValue(EXTENDED)).booleanValue())
    {
        if ((new BlockPistonStructureHelper(worldIn, pos, enumfacing, true)).canMove())
        {
            worldIn.addBlockEvent(pos, this, 0, enumfacing.getIndex());
        }
    }
    else if (!flag && ((Boolean)state.getValue(EXTENDED)).booleanValue())
    {
        worldIn.addBlockEvent(pos, this, 1, enumfacing.getIndex());
    }
}
项目:CustomWorldGen    文件:BlockPistonBase.java   
private void checkForMove(World worldIn, BlockPos pos, IBlockState state)
{
    EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
    boolean flag = this.shouldBeExtended(worldIn, pos, enumfacing);

    if (flag && !((Boolean)state.getValue(EXTENDED)).booleanValue())
    {
        if ((new BlockPistonStructureHelper(worldIn, pos, enumfacing, true)).canMove())
        {
            worldIn.addBlockEvent(pos, this, 0, enumfacing.getIndex());
        }
    }
    else if (!flag && ((Boolean)state.getValue(EXTENDED)).booleanValue())
    {
        worldIn.addBlockEvent(pos, this, 1, enumfacing.getIndex());
    }
}
项目:ExpandedRailsMod    文件:BlockPistonBase.java   
private void checkForMove(World worldIn, BlockPos pos, IBlockState state)
{
    EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
    boolean flag = this.shouldBeExtended(worldIn, pos, enumfacing);

    if (flag && !((Boolean)state.getValue(EXTENDED)).booleanValue())
    {
        if ((new BlockPistonStructureHelper(worldIn, pos, enumfacing, true)).canMove())
        {
            worldIn.addBlockEvent(pos, this, 0, enumfacing.getIndex());
        }
    }
    else if (!flag && ((Boolean)state.getValue(EXTENDED)).booleanValue())
    {
        worldIn.addBlockEvent(pos, this, 1, enumfacing.getIndex());
    }
}
项目:DecompiledMinecraft    文件:BlockPistonBase.java   
private boolean doMove(World worldIn, BlockPos pos, EnumFacing direction, boolean extending)
{
    if (!extending)
    {
        worldIn.setBlockToAir(pos.offset(direction));
    }

    BlockPistonStructureHelper blockpistonstructurehelper = new BlockPistonStructureHelper(worldIn, pos, direction, extending);
    List<BlockPos> list = blockpistonstructurehelper.getBlocksToMove();
    List<BlockPos> list1 = blockpistonstructurehelper.getBlocksToDestroy();

    if (!blockpistonstructurehelper.canMove())
    {
        return false;
    }
    else
    {
        int i = list.size() + list1.size();
        Block[] ablock = new Block[i];
        EnumFacing enumfacing = extending ? direction : direction.getOpposite();

        for (int j = list1.size() - 1; j >= 0; --j)
        {
            BlockPos blockpos = (BlockPos)list1.get(j);
            Block block = worldIn.getBlockState(blockpos).getBlock();
            block.dropBlockAsItem(worldIn, blockpos, worldIn.getBlockState(blockpos), 0);
            worldIn.setBlockToAir(blockpos);
            --i;
            ablock[i] = block;
        }

        for (int k = list.size() - 1; k >= 0; --k)
        {
            BlockPos blockpos2 = (BlockPos)list.get(k);
            IBlockState iblockstate = worldIn.getBlockState(blockpos2);
            Block block1 = iblockstate.getBlock();
            block1.getMetaFromState(iblockstate);
            worldIn.setBlockToAir(blockpos2);
            blockpos2 = blockpos2.offset(enumfacing);
            worldIn.setBlockState(blockpos2, Blocks.piston_extension.getDefaultState().withProperty(FACING, direction), 4);
            worldIn.setTileEntity(blockpos2, BlockPistonMoving.newTileEntity(iblockstate, direction, extending, false));
            --i;
            ablock[i] = block1;
        }

        BlockPos blockpos1 = pos.offset(direction);

        if (extending)
        {
            BlockPistonExtension.EnumPistonType blockpistonextension$enumpistontype = this.isSticky ? BlockPistonExtension.EnumPistonType.STICKY : BlockPistonExtension.EnumPistonType.DEFAULT;
            IBlockState iblockstate1 = Blocks.piston_head.getDefaultState().withProperty(BlockPistonExtension.FACING, direction).withProperty(BlockPistonExtension.TYPE, blockpistonextension$enumpistontype);
            IBlockState iblockstate2 = Blocks.piston_extension.getDefaultState().withProperty(BlockPistonMoving.FACING, direction).withProperty(BlockPistonMoving.TYPE, this.isSticky ? BlockPistonExtension.EnumPistonType.STICKY : BlockPistonExtension.EnumPistonType.DEFAULT);
            worldIn.setBlockState(blockpos1, iblockstate2, 4);
            worldIn.setTileEntity(blockpos1, BlockPistonMoving.newTileEntity(iblockstate1, direction, true, false));
        }

        for (int l = list1.size() - 1; l >= 0; --l)
        {
            worldIn.notifyNeighborsOfStateChange((BlockPos)list1.get(l), ablock[i++]);
        }

        for (int i1 = list.size() - 1; i1 >= 0; --i1)
        {
            worldIn.notifyNeighborsOfStateChange((BlockPos)list.get(i1), ablock[i++]);
        }

        if (extending)
        {
            worldIn.notifyNeighborsOfStateChange(blockpos1, Blocks.piston_head);
            worldIn.notifyNeighborsOfStateChange(pos, this);
        }

        return true;
    }
}
项目:DecompiledMinecraft    文件:BlockPistonBase.java   
private boolean doMove(World worldIn, BlockPos pos, EnumFacing direction, boolean extending)
{
    if (!extending)
    {
        worldIn.setBlockToAir(pos.offset(direction));
    }

    BlockPistonStructureHelper blockpistonstructurehelper = new BlockPistonStructureHelper(worldIn, pos, direction, extending);
    List<BlockPos> list = blockpistonstructurehelper.getBlocksToMove();
    List<BlockPos> list1 = blockpistonstructurehelper.getBlocksToDestroy();

    if (!blockpistonstructurehelper.canMove())
    {
        return false;
    }
    else
    {
        int i = list.size() + list1.size();
        Block[] ablock = new Block[i];
        EnumFacing enumfacing = extending ? direction : direction.getOpposite();

        for (int j = list1.size() - 1; j >= 0; --j)
        {
            BlockPos blockpos = (BlockPos)list1.get(j);
            Block block = worldIn.getBlockState(blockpos).getBlock();
            block.dropBlockAsItem(worldIn, blockpos, worldIn.getBlockState(blockpos), 0);
            worldIn.setBlockToAir(blockpos);
            --i;
            ablock[i] = block;
        }

        for (int k = list.size() - 1; k >= 0; --k)
        {
            BlockPos blockpos2 = (BlockPos)list.get(k);
            IBlockState iblockstate = worldIn.getBlockState(blockpos2);
            Block block1 = iblockstate.getBlock();
            block1.getMetaFromState(iblockstate);
            worldIn.setBlockToAir(blockpos2);
            blockpos2 = blockpos2.offset(enumfacing);
            worldIn.setBlockState(blockpos2, Blocks.piston_extension.getDefaultState().withProperty(FACING, direction), 4);
            worldIn.setTileEntity(blockpos2, BlockPistonMoving.newTileEntity(iblockstate, direction, extending, false));
            --i;
            ablock[i] = block1;
        }

        BlockPos blockpos1 = pos.offset(direction);

        if (extending)
        {
            BlockPistonExtension.EnumPistonType blockpistonextension$enumpistontype = this.isSticky ? BlockPistonExtension.EnumPistonType.STICKY : BlockPistonExtension.EnumPistonType.DEFAULT;
            IBlockState iblockstate1 = Blocks.piston_head.getDefaultState().withProperty(BlockPistonExtension.FACING, direction).withProperty(BlockPistonExtension.TYPE, blockpistonextension$enumpistontype);
            IBlockState iblockstate2 = Blocks.piston_extension.getDefaultState().withProperty(BlockPistonMoving.FACING, direction).withProperty(BlockPistonMoving.TYPE, this.isSticky ? BlockPistonExtension.EnumPistonType.STICKY : BlockPistonExtension.EnumPistonType.DEFAULT);
            worldIn.setBlockState(blockpos1, iblockstate2, 4);
            worldIn.setTileEntity(blockpos1, BlockPistonMoving.newTileEntity(iblockstate1, direction, true, false));
        }

        for (int l = list1.size() - 1; l >= 0; --l)
        {
            worldIn.notifyNeighborsOfStateChange((BlockPos)list1.get(l), ablock[i++]);
        }

        for (int i1 = list.size() - 1; i1 >= 0; --i1)
        {
            worldIn.notifyNeighborsOfStateChange((BlockPos)list.get(i1), ablock[i++]);
        }

        if (extending)
        {
            worldIn.notifyNeighborsOfStateChange(blockpos1, Blocks.piston_head);
            worldIn.notifyNeighborsOfStateChange(pos, this);
        }

        return true;
    }
}
项目:BaseClient    文件:BlockPistonBase.java   
private boolean doMove(World worldIn, BlockPos pos, EnumFacing direction, boolean extending)
{
    if (!extending)
    {
        worldIn.setBlockToAir(pos.offset(direction));
    }

    BlockPistonStructureHelper blockpistonstructurehelper = new BlockPistonStructureHelper(worldIn, pos, direction, extending);
    List<BlockPos> list = blockpistonstructurehelper.getBlocksToMove();
    List<BlockPos> list1 = blockpistonstructurehelper.getBlocksToDestroy();

    if (!blockpistonstructurehelper.canMove())
    {
        return false;
    }
    else
    {
        int i = list.size() + list1.size();
        Block[] ablock = new Block[i];
        EnumFacing enumfacing = extending ? direction : direction.getOpposite();

        for (int j = list1.size() - 1; j >= 0; --j)
        {
            BlockPos blockpos = (BlockPos)list1.get(j);
            Block block = worldIn.getBlockState(blockpos).getBlock();
            block.dropBlockAsItem(worldIn, blockpos, worldIn.getBlockState(blockpos), 0);
            worldIn.setBlockToAir(blockpos);
            --i;
            ablock[i] = block;
        }

        for (int k = list.size() - 1; k >= 0; --k)
        {
            BlockPos blockpos2 = (BlockPos)list.get(k);
            IBlockState iblockstate = worldIn.getBlockState(blockpos2);
            Block block1 = iblockstate.getBlock();
            block1.getMetaFromState(iblockstate);
            worldIn.setBlockToAir(blockpos2);
            blockpos2 = blockpos2.offset(enumfacing);
            worldIn.setBlockState(blockpos2, Blocks.piston_extension.getDefaultState().withProperty(FACING, direction), 4);
            worldIn.setTileEntity(blockpos2, BlockPistonMoving.newTileEntity(iblockstate, direction, extending, false));
            --i;
            ablock[i] = block1;
        }

        BlockPos blockpos1 = pos.offset(direction);

        if (extending)
        {
            BlockPistonExtension.EnumPistonType blockpistonextension$enumpistontype = this.isSticky ? BlockPistonExtension.EnumPistonType.STICKY : BlockPistonExtension.EnumPistonType.DEFAULT;
            IBlockState iblockstate1 = Blocks.piston_head.getDefaultState().withProperty(BlockPistonExtension.FACING, direction).withProperty(BlockPistonExtension.TYPE, blockpistonextension$enumpistontype);
            IBlockState iblockstate2 = Blocks.piston_extension.getDefaultState().withProperty(BlockPistonMoving.FACING, direction).withProperty(BlockPistonMoving.TYPE, this.isSticky ? BlockPistonExtension.EnumPistonType.STICKY : BlockPistonExtension.EnumPistonType.DEFAULT);
            worldIn.setBlockState(blockpos1, iblockstate2, 4);
            worldIn.setTileEntity(blockpos1, BlockPistonMoving.newTileEntity(iblockstate1, direction, true, false));
        }

        for (int l = list1.size() - 1; l >= 0; --l)
        {
            worldIn.notifyNeighborsOfStateChange((BlockPos)list1.get(l), ablock[i++]);
        }

        for (int i1 = list.size() - 1; i1 >= 0; --i1)
        {
            worldIn.notifyNeighborsOfStateChange((BlockPos)list.get(i1), ablock[i++]);
        }

        if (extending)
        {
            worldIn.notifyNeighborsOfStateChange(blockpos1, Blocks.piston_head);
            worldIn.notifyNeighborsOfStateChange(pos, this);
        }

        return true;
    }
}
项目:BaseClient    文件:BlockPistonBase.java   
private boolean doMove(World worldIn, BlockPos pos, EnumFacing direction, boolean extending)
{
    if (!extending)
    {
        worldIn.setBlockToAir(pos.offset(direction));
    }

    BlockPistonStructureHelper blockpistonstructurehelper = new BlockPistonStructureHelper(worldIn, pos, direction, extending);
    List<BlockPos> list = blockpistonstructurehelper.getBlocksToMove();
    List<BlockPos> list1 = blockpistonstructurehelper.getBlocksToDestroy();

    if (!blockpistonstructurehelper.canMove())
    {
        return false;
    }
    else
    {
        int i = list.size() + list1.size();
        Block[] ablock = new Block[i];
        EnumFacing enumfacing = extending ? direction : direction.getOpposite();

        for (int j = list1.size() - 1; j >= 0; --j)
        {
            BlockPos blockpos = (BlockPos)list1.get(j);
            Block block = worldIn.getBlockState(blockpos).getBlock();
            block.dropBlockAsItem(worldIn, blockpos, worldIn.getBlockState(blockpos), 0);
            worldIn.setBlockToAir(blockpos);
            --i;
            ablock[i] = block;
        }

        for (int k = list.size() - 1; k >= 0; --k)
        {
            BlockPos blockpos2 = (BlockPos)list.get(k);
            IBlockState iblockstate = worldIn.getBlockState(blockpos2);
            Block block1 = iblockstate.getBlock();
            block1.getMetaFromState(iblockstate);
            worldIn.setBlockToAir(blockpos2);
            blockpos2 = blockpos2.offset(enumfacing);
            worldIn.setBlockState(blockpos2, Blocks.piston_extension.getDefaultState().withProperty(FACING, direction), 4);
            worldIn.setTileEntity(blockpos2, BlockPistonMoving.newTileEntity(iblockstate, direction, extending, false));
            --i;
            ablock[i] = block1;
        }

        BlockPos blockpos1 = pos.offset(direction);

        if (extending)
        {
            BlockPistonExtension.EnumPistonType blockpistonextension$enumpistontype = this.isSticky ? BlockPistonExtension.EnumPistonType.STICKY : BlockPistonExtension.EnumPistonType.DEFAULT;
            IBlockState iblockstate1 = Blocks.piston_head.getDefaultState().withProperty(BlockPistonExtension.FACING, direction).withProperty(BlockPistonExtension.TYPE, blockpistonextension$enumpistontype);
            IBlockState iblockstate2 = Blocks.piston_extension.getDefaultState().withProperty(BlockPistonMoving.FACING, direction).withProperty(BlockPistonMoving.TYPE, this.isSticky ? BlockPistonExtension.EnumPistonType.STICKY : BlockPistonExtension.EnumPistonType.DEFAULT);
            worldIn.setBlockState(blockpos1, iblockstate2, 4);
            worldIn.setTileEntity(blockpos1, BlockPistonMoving.newTileEntity(iblockstate1, direction, true, false));
        }

        for (int l = list1.size() - 1; l >= 0; --l)
        {
            worldIn.notifyNeighborsOfStateChange((BlockPos)list1.get(l), ablock[i++]);
        }

        for (int i1 = list.size() - 1; i1 >= 0; --i1)
        {
            worldIn.notifyNeighborsOfStateChange((BlockPos)list.get(i1), ablock[i++]);
        }

        if (extending)
        {
            worldIn.notifyNeighborsOfStateChange(blockpos1, Blocks.piston_head);
            worldIn.notifyNeighborsOfStateChange(pos, this);
        }

        return true;
    }
}
项目:Backmemed    文件:BlockPistonBase.java   
private boolean doMove(World worldIn, BlockPos pos, EnumFacing direction, boolean extending)
{
    if (!extending)
    {
        worldIn.setBlockToAir(pos.offset(direction));
    }

    BlockPistonStructureHelper blockpistonstructurehelper = new BlockPistonStructureHelper(worldIn, pos, direction, extending);

    if (!blockpistonstructurehelper.canMove())
    {
        return false;
    }
    else
    {
        List<BlockPos> list = blockpistonstructurehelper.getBlocksToMove();
        List<IBlockState> list1 = Lists.<IBlockState>newArrayList();

        for (int i = 0; i < list.size(); ++i)
        {
            BlockPos blockpos = (BlockPos)list.get(i);
            list1.add(worldIn.getBlockState(blockpos).getActualState(worldIn, blockpos));
        }

        List<BlockPos> list2 = blockpistonstructurehelper.getBlocksToDestroy();
        int k = list.size() + list2.size();
        IBlockState[] aiblockstate = new IBlockState[k];
        EnumFacing enumfacing = extending ? direction : direction.getOpposite();

        for (int j = list2.size() - 1; j >= 0; --j)
        {
            BlockPos blockpos1 = (BlockPos)list2.get(j);
            IBlockState iblockstate = worldIn.getBlockState(blockpos1);
            iblockstate.getBlock().dropBlockAsItem(worldIn, blockpos1, iblockstate, 0);
            worldIn.setBlockState(blockpos1, Blocks.AIR.getDefaultState(), 4);
            --k;
            aiblockstate[k] = iblockstate;
        }

        for (int l = list.size() - 1; l >= 0; --l)
        {
            BlockPos blockpos3 = (BlockPos)list.get(l);
            IBlockState iblockstate2 = worldIn.getBlockState(blockpos3);
            worldIn.setBlockState(blockpos3, Blocks.AIR.getDefaultState(), 2);
            blockpos3 = blockpos3.offset(enumfacing);
            worldIn.setBlockState(blockpos3, Blocks.PISTON_EXTENSION.getDefaultState().withProperty(FACING, direction), 4);
            worldIn.setTileEntity(blockpos3, BlockPistonMoving.createTilePiston((IBlockState)list1.get(l), direction, extending, false));
            --k;
            aiblockstate[k] = iblockstate2;
        }

        BlockPos blockpos2 = pos.offset(direction);

        if (extending)
        {
            BlockPistonExtension.EnumPistonType blockpistonextension$enumpistontype = this.isSticky ? BlockPistonExtension.EnumPistonType.STICKY : BlockPistonExtension.EnumPistonType.DEFAULT;
            IBlockState iblockstate3 = Blocks.PISTON_HEAD.getDefaultState().withProperty(BlockPistonExtension.FACING, direction).withProperty(BlockPistonExtension.TYPE, blockpistonextension$enumpistontype);
            IBlockState iblockstate1 = Blocks.PISTON_EXTENSION.getDefaultState().withProperty(BlockPistonMoving.FACING, direction).withProperty(BlockPistonMoving.TYPE, this.isSticky ? BlockPistonExtension.EnumPistonType.STICKY : BlockPistonExtension.EnumPistonType.DEFAULT);
            worldIn.setBlockState(blockpos2, iblockstate1, 4);
            worldIn.setTileEntity(blockpos2, BlockPistonMoving.createTilePiston(iblockstate3, direction, true, true));
        }

        for (int i1 = list2.size() - 1; i1 >= 0; --i1)
        {
            worldIn.notifyNeighborsOfStateChange((BlockPos)list2.get(i1), aiblockstate[k++].getBlock(), false);
        }

        for (int j1 = list.size() - 1; j1 >= 0; --j1)
        {
            worldIn.notifyNeighborsOfStateChange((BlockPos)list.get(j1), aiblockstate[k++].getBlock(), false);
        }

        if (extending)
        {
            worldIn.notifyNeighborsOfStateChange(blockpos2, Blocks.PISTON_HEAD, false);
        }

        return true;
    }
}