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