當前位置: 首頁>>代碼示例>>Java>>正文


Java World.isBlockPowered方法代碼示例

本文整理匯總了Java中net.minecraft.world.World.isBlockPowered方法的典型用法代碼示例。如果您正苦於以下問題:Java World.isBlockPowered方法的具體用法?Java World.isBlockPowered怎麽用?Java World.isBlockPowered使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.world.World的用法示例。


在下文中一共展示了World.isBlockPowered方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: neighborChanged

import net.minecraft.world.World; //導入方法依賴的package包/類
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos)
{
    if(!worldIn.isRemote)
    {
        boolean flag = worldIn.isBlockPowered(pos);
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if(tileentity instanceof TileEntityInstrumentPlayer)
        {
            TileEntityInstrumentPlayer player = (TileEntityInstrumentPlayer)tileentity;

            if(player.previousRedstoneState != flag)
            {
                player.changeRedstoneState(flag);
                player.previousRedstoneState = flag;
            }
        }
    }
}
 
開發者ID:iChun,項目名稱:Clef,代碼行數:21,代碼來源:BlockInstrumentPlayer.java

示例2: onNeighborChangedInternal

import net.minecraft.world.World; //導入方法依賴的package包/類
protected void onNeighborChangedInternal(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
    boolean flag = ((Boolean)state.getValue(POWERED)).booleanValue();
    boolean flag1 = worldIn.isBlockPowered(pos) || this.func_176566_a(worldIn, pos, state, true, 0) || this.func_176566_a(worldIn, pos, state, false, 0);

    if (flag1 != flag)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(flag1)), 3);
        worldIn.notifyNeighborsOfStateChange(pos.down(), this);

        if (((BlockRailBase.EnumRailDirection)state.getValue(SHAPE)).isAscending())
        {
            worldIn.notifyNeighborsOfStateChange(pos.up(), this);
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:17,代碼來源:BlockRailPowered.java

示例3: neighborChanged

import net.minecraft.world.World; //導入方法依賴的package包/類
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {

	if (!world.isRemote) {
		TileEntity tile = world.getTileEntity(pos);

		if (tile == null)
			return;

		if (tile instanceof TileDisplacer) {

			if (world.isBlockPowered(pos)) {
				if (!state.getValue(POWERED)) {
					state = state.withProperty(POWERED, true);
				}
			} else {
				if (state.getValue(POWERED)) {
					state = state.withProperty(POWERED, false);
				}
			}

			world.setBlockState(pos, state);
		}
	}
}
 
開發者ID:oMilkyy,項目名稱:SimpleTubes,代碼行數:26,代碼來源:BlockDisplacer.java

示例4: neighborChanged

import net.minecraft.world.World; //導入方法依賴的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 (!worldIn.isRemote)
    {
        boolean flag = worldIn.isBlockPowered(pos);

        if (flag || blockIn.getDefaultState().canProvidePower())
        {
            boolean flag1 = ((Boolean)state.getValue(OPEN)).booleanValue();

            if (flag1 != flag)
            {
                worldIn.setBlockState(pos, state.withProperty(OPEN, Boolean.valueOf(flag)), 2);
                this.playSound((EntityPlayer)null, worldIn, pos, flag);
            }
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:24,代碼來源:BlockTrapDoor.java

示例5: neighborChanged

import net.minecraft.world.World; //導入方法依賴的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 (!worldIn.isRemote)
    {
        boolean flag = worldIn.isBlockPowered(pos);

        if (flag || blockIn.getDefaultState().canProvidePower())
        {
            boolean flag1 = ((Boolean)state.getValue(OPEN)).booleanValue();

            if (flag1 != flag)
            {
                worldIn.setBlockState(pos, state.withProperty(OPEN, Boolean.valueOf(flag)), 2);
                this.playSound((EntityPlayer)null, worldIn, pos, flag);
            }
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:24,代碼來源:BlockTrapDoor.java

示例6: onNeighborBlockChange

import net.minecraft.world.World; //導入方法依賴的package包/類
/**
 * Called when a neighboring block changes.
 */
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
    boolean flag = worldIn.isBlockPowered(pos) || worldIn.isBlockPowered(pos.up());
    boolean flag1 = ((Boolean)state.getValue(TRIGGERED)).booleanValue();

    if (flag && !flag1)
    {
        worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
        worldIn.setBlockState(pos, state.withProperty(TRIGGERED, Boolean.valueOf(true)), 4);
    }
    else if (!flag && flag1)
    {
        worldIn.setBlockState(pos, state.withProperty(TRIGGERED, Boolean.valueOf(false)), 4);
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:19,代碼來源:BlockDispenser.java

示例7: neighborChanged

import net.minecraft.world.World; //導入方法依賴的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 (!worldIn.isRemote)
    {
        boolean flag = worldIn.isBlockPowered(pos);

        if (((Boolean)state.getValue(POWERED)).booleanValue() != flag)
        {
            worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(flag)).withProperty(OPEN, Boolean.valueOf(flag)), 2);

            if (((Boolean)state.getValue(OPEN)).booleanValue() != flag)
            {
                worldIn.playEvent((EntityPlayer)null, flag ? 1008 : 1014, pos, 0);
            }
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:23,代碼來源:BlockFenceGate.java

示例8: onBlockPlaced

import net.minecraft.world.World; //導入方法依賴的package包/類
/**
 * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
 * IBlockstate
 */
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
    IBlockState iblockstate = this.getDefaultState();

    if (facing.getAxis().isHorizontal())
    {
        iblockstate = iblockstate.withProperty(FACING, facing).withProperty(OPEN, Boolean.valueOf(false));
        iblockstate = iblockstate.withProperty(HALF, hitY > 0.5F ? BlockTrapDoor.DoorHalf.TOP : BlockTrapDoor.DoorHalf.BOTTOM);
    }
    else
    {
        iblockstate = iblockstate.withProperty(FACING, placer.getHorizontalFacing().getOpposite()).withProperty(OPEN, Boolean.valueOf(false));
        iblockstate = iblockstate.withProperty(HALF, facing == EnumFacing.UP ? BlockTrapDoor.DoorHalf.BOTTOM : BlockTrapDoor.DoorHalf.TOP);
    }

    if (worldIn.isBlockPowered(pos))
    {
        iblockstate = iblockstate.withProperty(OPEN, Boolean.valueOf(true));
    }

    return iblockstate;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:27,代碼來源:BlockTrapDoor.java

示例9: neighborChanged

import net.minecraft.world.World; //導入方法依賴的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 (!worldIn.isRemote)
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityCommandBlock)
        {
            TileEntityCommandBlock tileentitycommandblock = (TileEntityCommandBlock)tileentity;
            boolean flag = worldIn.isBlockPowered(pos);
            boolean flag1 = tileentitycommandblock.isPowered();
            boolean flag2 = tileentitycommandblock.isAuto();

            if (flag && !flag1)
            {
                tileentitycommandblock.setPowered(true);

                if (tileentitycommandblock.getMode() != TileEntityCommandBlock.Mode.SEQUENCE && !flag2)
                {
                    boolean flag3 = !tileentitycommandblock.isConditional() || this.isNextToSuccessfulCommandBlock(worldIn, pos, state);
                    tileentitycommandblock.setConditionMet(flag3);
                    worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));

                    if (flag3)
                    {
                        this.propagateUpdate(worldIn, pos);
                    }
                }
            }
            else if (!flag && flag1)
            {
                tileentitycommandblock.setPowered(false);
            }
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:42,代碼來源:BlockCommandBlock.java

示例10: onNeighborBlockChange

import net.minecraft.world.World; //導入方法依賴的package包/類
/**
 * Called when a neighboring block changes.
 */
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
    if (!worldIn.isRemote)
    {
        if (this.isOn && !worldIn.isBlockPowered(pos))
        {
            worldIn.scheduleUpdate(pos, this, 4);
        }
        else if (!this.isOn && worldIn.isBlockPowered(pos))
        {
            worldIn.setBlockState(pos, Blocks.lit_redstone_lamp.getDefaultState(), 2);
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:18,代碼來源:BlockRedstoneLight.java

示例11: updateTick

import net.minecraft.world.World; //導入方法依賴的package包/類
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (!worldIn.isRemote)
    {
        if (this.isOn && !worldIn.isBlockPowered(pos))
        {
            worldIn.setBlockState(pos, Blocks.REDSTONE_LAMP.getDefaultState(), 2);
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:11,代碼來源:BlockRedstoneLight.java

示例12: onBlockAdded

import net.minecraft.world.World; //導入方法依賴的package包/類
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
    super.onBlockAdded(worldIn, pos, state);

    if (worldIn.isBlockPowered(pos))
    {
        this.onBlockDestroyedByPlayer(worldIn, pos, state.withProperty(EXPLODE, Boolean.valueOf(true)));
        worldIn.setBlockToAir(pos);
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:11,代碼來源:BlockTNT.java

示例13: updateTick

import net.minecraft.world.World; //導入方法依賴的package包/類
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (!worldIn.isRemote)
    {
        if (this.isOn && !worldIn.isBlockPowered(pos))
        {
            worldIn.setBlockState(pos, Blocks.redstone_lamp.getDefaultState(), 2);
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:11,代碼來源:BlockRedstoneLight.java

示例14: onBlockAdded

import net.minecraft.world.World; //導入方法依賴的package包/類
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
    if (!worldIn.isRemote)
    {
        if (this.isOn && !worldIn.isBlockPowered(pos))
        {
            worldIn.setBlockState(pos, Blocks.redstone_lamp.getDefaultState(), 2);
        }
        else if (!this.isOn && worldIn.isBlockPowered(pos))
        {
            worldIn.setBlockState(pos, Blocks.lit_redstone_lamp.getDefaultState(), 2);
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:15,代碼來源:BlockRedstoneLight.java

示例15: onBlockPlaced

import net.minecraft.world.World; //導入方法依賴的package包/類
/**
 * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
 * IBlockstate
 */
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
    boolean flag = worldIn.isBlockPowered(pos);
    return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing()).withProperty(OPEN, Boolean.valueOf(flag)).withProperty(POWERED, Boolean.valueOf(flag)).withProperty(IN_WALL, Boolean.valueOf(false));
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:10,代碼來源:BlockFenceGate.java


注:本文中的net.minecraft.world.World.isBlockPowered方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。