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


Java IBlockState.neighborChanged方法代码示例

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


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

示例1: neighborChanged

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
/**
 * Called when a neighboring block was changed and marks that this state should perform any checks during a neighbor
 * change. Cases may include when redstone power is updated, cactus blocks popping off due to a neighboring solid
 * block, etc.
 */
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos p_189540_5_)
{
    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.neighborChanged(worldIn, blockpos, blockIn, p_189540_5_);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:21,代码来源:BlockPistonExtension.java

示例2: neighborChanged

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
/**
 * Called when a neighboring block was changed and marks that this state should perform any checks during a neighbor
 * change. Cases may include when redstone power is updated, cactus blocks popping off due to a neighboring solid
 * block, etc.
 */
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn)
{
    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.neighborChanged(worldIn, blockpos, blockIn);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:21,代码来源:BlockPistonExtension.java

示例3: func_190524_a

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public void func_190524_a(BlockPos p_190524_1_, final Block p_190524_2_, BlockPos p_190524_3_)
{
    if (!this.isRemote)
    {
        IBlockState iblockstate = this.getBlockState(p_190524_1_);

        try
        {
            iblockstate.neighborChanged(this, p_190524_1_, p_190524_2_, p_190524_3_);
        }
        catch (Throwable throwable)
        {
            CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Exception while updating neighbours");
            CrashReportCategory crashreportcategory = crashreport.makeCategory("Block being updated");
            crashreportcategory.setDetail("Source block type", new ICrashReportDetail<String>()
            {
                public String call() throws Exception
                {
                    try
                    {
                        return String.format("ID #%d (%s // %s)", new Object[] {Integer.valueOf(Block.getIdFromBlock(p_190524_2_)), p_190524_2_.getUnlocalizedName(), p_190524_2_.getClass().getCanonicalName()});
                    }
                    catch (Throwable var2)
                    {
                        return "ID #" + Block.getIdFromBlock(p_190524_2_);
                    }
                }
            });
            CrashReportCategory.addBlockInfo(crashreportcategory, p_190524_1_, iblockstate);
            throw new ReportedException(crashreport);
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:34,代码来源:World.java

示例4: updateComparatorOutputLevel

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public void updateComparatorOutputLevel(BlockPos pos, Block blockIn)
{
    for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
    {
        BlockPos blockpos = pos.offset(enumfacing);

        if (this.isBlockLoaded(blockpos))
        {
            IBlockState iblockstate = this.getBlockState(blockpos);

            if (Blocks.UNPOWERED_COMPARATOR.isSameDiode(iblockstate))
            {
                iblockstate.neighborChanged(this, blockpos, blockIn, pos);
            }
            else if (iblockstate.isNormalCube())
            {
                blockpos = blockpos.offset(enumfacing);
                iblockstate = this.getBlockState(blockpos);

                if (Blocks.UNPOWERED_COMPARATOR.isSameDiode(iblockstate))
                {
                    iblockstate.neighborChanged(this, blockpos, blockIn, pos);
                }
            }
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:28,代码来源:World.java

示例5: onBlockAdded

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
/**
 * Called after the block is set in the Chunk data, but before the Tile Entity is set
 */
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
    if (!worldIn.isRemote)
    {
        state = this.updateDir(worldIn, pos, state, true);

        if (this.isPowered)
        {
            state.neighborChanged(worldIn, pos, this, pos);
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:16,代码来源:BlockRailBase.java

示例6: updateConnectedRails

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
protected void updateConnectedRails(World worldIn, BlockPos pos, IBlockState state, boolean p_185592_4_)
{
    BlockRailBase.Rail blockrailbase$rail = new BlockRailBase.Rail(worldIn, pos, state);

    for (BlockPos blockpos : blockrailbase$rail.getConnectedRails())
    {
        IBlockState iblockstate = worldIn.getBlockState(blockpos);

        if (iblockstate != null)
        {
            iblockstate.neighborChanged(worldIn, blockpos, iblockstate.getBlock(), pos);
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:15,代码来源:BlockRailDetector.java

示例7: updateTick

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    BlockPos blockpos = pos.up();

    if (worldIn.isAirBlock(blockpos))
    {
        int i;

        for (i = 1; worldIn.getBlockState(pos.down(i)).getBlock() == this; ++i)
        {
            ;
        }

        if (i < 3)
        {
            int j = ((Integer)state.getValue(AGE)).intValue();

            if (j == 15)
            {
                worldIn.setBlockState(blockpos, this.getDefaultState());
                IBlockState iblockstate = state.withProperty(AGE, Integer.valueOf(0));
                worldIn.setBlockState(pos, iblockstate, 4);
                iblockstate.neighborChanged(worldIn, blockpos, this, pos);
            }
            else
            {
                worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(j + 1)), 4);
            }
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:32,代码来源:BlockCactus.java

示例8: notifyBlockOfStateChange

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public void notifyBlockOfStateChange(BlockPos pos, final Block blockIn)
{
    if (!this.isRemote)
    {
        IBlockState iblockstate = this.getBlockState(pos);

        try
        {
            iblockstate.neighborChanged(this, pos, blockIn);
        }
        catch (Throwable throwable)
        {
            CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Exception while updating neighbours");
            CrashReportCategory crashreportcategory = crashreport.makeCategory("Block being updated");
            crashreportcategory.setDetail("Source block type", new ICrashReportDetail<String>()
            {
                public String call() throws Exception
                {
                    try
                    {
                        return String.format("ID #%d (%s // %s)", new Object[] {Integer.valueOf(Block.getIdFromBlock(blockIn)), blockIn.getUnlocalizedName(), blockIn.getClass().getCanonicalName()});
                    }
                    catch (Throwable var2)
                    {
                        return "ID #" + Block.getIdFromBlock(blockIn);
                    }
                }
            });
            CrashReportCategory.addBlockInfo(crashreportcategory, pos, iblockstate);
            throw new ReportedException(crashreport);
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:34,代码来源:World.java

示例9: onBlockAdded

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
/**
 * Called after the block is set in the Chunk data, but before the Tile Entity is set
 */
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
    if (!worldIn.isRemote)
    {
        state = this.updateDir(worldIn, pos, state, true);

        if (this.isPowered)
        {
            state.neighborChanged(worldIn, pos, this);
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:16,代码来源:BlockRailBase.java

示例10: updateConnectedRails

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
protected void updateConnectedRails(World worldIn, BlockPos pos, IBlockState state, boolean p_185592_4_)
{
    BlockRailBase.Rail blockrailbase$rail = new BlockRailBase.Rail(worldIn, pos, state);

    for (BlockPos blockpos : blockrailbase$rail.getConnectedRails())
    {
        IBlockState iblockstate = worldIn.getBlockState(blockpos);

        if (iblockstate != null)
        {
            iblockstate.neighborChanged(worldIn, blockpos, iblockstate.getBlock());
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:15,代码来源:BlockRailDetector.java

示例11: updateTick

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    BlockPos blockpos = pos.up();

    if (worldIn.isAirBlock(blockpos))
    {
        int i;

        for (i = 1; worldIn.getBlockState(pos.down(i)).getBlock() == this; ++i)
        {
            ;
        }

        if (i < 3)
        {
            int j = ((Integer)state.getValue(AGE)).intValue();

            if(net.minecraftforge.common.ForgeHooks.onCropsGrowPre(worldIn, blockpos, state, true))
            {
            if (j == 15)
            {
                worldIn.setBlockState(blockpos, this.getDefaultState());
                IBlockState iblockstate = state.withProperty(AGE, Integer.valueOf(0));
                worldIn.setBlockState(pos, iblockstate, 4);
                iblockstate.neighborChanged(worldIn, blockpos, this);
            }
            else
            {
                worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(j + 1)), 4);
            }
            net.minecraftforge.common.ForgeHooks.onCropsGrowPost(worldIn, pos, state, worldIn.getBlockState(pos));
            }
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:36,代码来源:BlockCactus.java

示例12: neighborChanged

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
/**
 * Called when a neighboring block was changed and marks that this state should perform any checks during a neighbor
 * change. Cases may include when redstone power is updated, cactus blocks popping off due to a neighboring solid
 * block, etc.
 */
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos p_189540_5_)
{
    if (state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER)
    {
        BlockPos blockpos = pos.down();
        IBlockState iblockstate = worldIn.getBlockState(blockpos);

        if (iblockstate.getBlock() != this)
        {
            worldIn.setBlockToAir(pos);
        }
        else if (blockIn != this)
        {
            iblockstate.neighborChanged(worldIn, blockpos, blockIn, p_189540_5_);
        }
    }
    else
    {
        boolean flag1 = false;
        BlockPos blockpos1 = pos.up();
        IBlockState iblockstate1 = worldIn.getBlockState(blockpos1);

        if (iblockstate1.getBlock() != this)
        {
            worldIn.setBlockToAir(pos);
            flag1 = true;
        }

        if (!worldIn.getBlockState(pos.down()).isFullyOpaque())
        {
            worldIn.setBlockToAir(pos);
            flag1 = true;

            if (iblockstate1.getBlock() == this)
            {
                worldIn.setBlockToAir(blockpos1);
            }
        }

        if (flag1)
        {
            if (!worldIn.isRemote)
            {
                this.dropBlockAsItem(worldIn, pos, state, 0);
            }
        }
        else
        {
            boolean flag = worldIn.isBlockPowered(pos) || worldIn.isBlockPowered(blockpos1);

            if (blockIn != this && (flag || blockIn.getDefaultState().canProvidePower()) && flag != ((Boolean)iblockstate1.getValue(POWERED)).booleanValue())
            {
                worldIn.setBlockState(blockpos1, iblockstate1.withProperty(POWERED, Boolean.valueOf(flag)), 2);

                if (flag != ((Boolean)state.getValue(OPEN)).booleanValue())
                {
                    worldIn.setBlockState(pos, state.withProperty(OPEN, Boolean.valueOf(flag)), 2);
                    worldIn.markBlockRangeForRenderUpdate(pos, pos);
                    worldIn.playEvent((EntityPlayer)null, flag ? this.getOpenSound() : this.getCloseSound(), pos, 0);
                }
            }
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:70,代码来源:BlockDoor.java

示例13: neighborChanged

import net.minecraft.block.state.IBlockState; //导入方法依赖的package包/类
/**
 * Called when a neighboring block was changed and marks that this state should perform any checks during a neighbor
 * change. Cases may include when redstone power is updated, cactus blocks popping off due to a neighboring solid
 * block, etc.
 */
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn)
{
    if (state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER)
    {
        BlockPos blockpos = pos.down();
        IBlockState iblockstate = worldIn.getBlockState(blockpos);

        if (iblockstate.getBlock() != this)
        {
            worldIn.setBlockToAir(pos);
        }
        else if (blockIn != this)
        {
            iblockstate.neighborChanged(worldIn, blockpos, blockIn);
        }
    }
    else
    {
        boolean flag1 = false;
        BlockPos blockpos1 = pos.up();
        IBlockState iblockstate1 = worldIn.getBlockState(blockpos1);

        if (iblockstate1.getBlock() != this)
        {
            worldIn.setBlockToAir(pos);
            flag1 = true;
        }

        if (!worldIn.getBlockState(pos.down()).isSideSolid(worldIn,  pos.down(), EnumFacing.UP))
        {
            worldIn.setBlockToAir(pos);
            flag1 = true;

            if (iblockstate1.getBlock() == this)
            {
                worldIn.setBlockToAir(blockpos1);
            }
        }

        if (flag1)
        {
            if (!worldIn.isRemote)
            {
                this.dropBlockAsItem(worldIn, pos, state, 0);
            }
        }
        else
        {
            boolean flag = worldIn.isBlockPowered(pos) || worldIn.isBlockPowered(blockpos1);

            if (blockIn != this && (flag || blockIn.getDefaultState().canProvidePower()) && flag != ((Boolean)iblockstate1.getValue(POWERED)).booleanValue())
            {
                worldIn.setBlockState(blockpos1, iblockstate1.withProperty(POWERED, Boolean.valueOf(flag)), 2);

                if (flag != ((Boolean)state.getValue(OPEN)).booleanValue())
                {
                    worldIn.setBlockState(pos, state.withProperty(OPEN, Boolean.valueOf(flag)), 2);
                    worldIn.markBlockRangeForRenderUpdate(pos, pos);
                    worldIn.playEvent((EntityPlayer)null, flag ? this.getOpenSound() : this.getCloseSound(), pos, 0);
                }
            }
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:70,代码来源:BlockDoor.java


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