Java Code Examples for net.minecraft.world.World#isBlockPowered()
The following examples show how to use
net.minecraft.world.World#isBlockPowered() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItemTraverseWoodDoor.java From CommunityMod with GNU Lesser General Public License v2.1 | 6 votes |
public static void placeDoor(World worldIn, BlockPos pos, EnumFacing facing, Block door, boolean isRightHinge) { BlockPos blockpos = pos.offset(facing.rotateY()); BlockPos blockpos1 = pos.offset(facing.rotateYCCW()); int i = (worldIn.getBlockState(blockpos1).isNormalCube() ? 1 : 0) + (worldIn.getBlockState(blockpos1.up()).isNormalCube() ? 1 : 0); int j = (worldIn.getBlockState(blockpos).isNormalCube() ? 1 : 0) + (worldIn.getBlockState(blockpos.up()).isNormalCube() ? 1 : 0); boolean flag = worldIn.getBlockState(blockpos1).getBlock() == door || worldIn.getBlockState(blockpos1.up()).getBlock() == door; boolean flag1 = worldIn.getBlockState(blockpos).getBlock() == door || worldIn.getBlockState(blockpos.up()).getBlock() == door; if ((!flag || flag1) && j <= i) { if (flag1 && !flag || j < i) { isRightHinge = false; } } else { isRightHinge = true; } BlockPos blockpos2 = pos.up(); boolean flag2 = worldIn.isBlockPowered(pos) || worldIn.isBlockPowered(blockpos2); IBlockState iblockstate = door.getDefaultState().withProperty(BlockDoor.FACING, facing).withProperty(BlockDoor.HINGE, isRightHinge ? BlockDoor.EnumHingePosition.RIGHT : BlockDoor.EnumHingePosition.LEFT).withProperty(BlockDoor.POWERED, Boolean.valueOf(flag2)).withProperty(BlockDoor.OPEN, Boolean.valueOf(flag2)); worldIn.setBlockState(pos, iblockstate.withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER), 2); worldIn.setBlockState(blockpos2, iblockstate.withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), 2); worldIn.notifyNeighborsOfStateChange(pos, door, false); worldIn.notifyNeighborsOfStateChange(blockpos2, door, false); }
Example 2
Source File: BlockSoulGlass.java From CommunityMod with GNU Lesser General Public License v2.1 | 6 votes |
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) { boolean powered = worldIn.isBlockPowered(pos) || worldIn.isBlockPowered(pos.up()); if (powered) { if(!state.getValue(POWERED)) { worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn)); worldIn.setBlockState(pos, state.withProperty(POWERED, true)); worldIn.playSound(null, pos, SoundEvents.BLOCK_GLASS_BREAK, SoundCategory.BLOCKS, 1F, 0.25F + worldIn.rand.nextFloat()); } } else { if(state.getValue(POWERED)) { worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn)); worldIn.setBlockState(pos, state.withProperty(POWERED, false)); worldIn.playSound(null, pos, SoundEvents.BLOCK_NOTE_BASEDRUM, SoundCategory.BLOCKS, 1F, 0.25F + worldIn.rand.nextFloat()); } } }
Example 3
Source File: ItemTraverseWoodDoor.java From Traverse-Legacy-1-12-2 with MIT License | 6 votes |
public static void placeDoor(World worldIn, BlockPos pos, EnumFacing facing, Block door, boolean isRightHinge) { BlockPos blockpos = pos.offset(facing.rotateY()); BlockPos blockpos1 = pos.offset(facing.rotateYCCW()); int i = (worldIn.getBlockState(blockpos1).isNormalCube() ? 1 : 0) + (worldIn.getBlockState(blockpos1.up()).isNormalCube() ? 1 : 0); int j = (worldIn.getBlockState(blockpos).isNormalCube() ? 1 : 0) + (worldIn.getBlockState(blockpos.up()).isNormalCube() ? 1 : 0); boolean flag = worldIn.getBlockState(blockpos1).getBlock() == door || worldIn.getBlockState(blockpos1.up()).getBlock() == door; boolean flag1 = worldIn.getBlockState(blockpos).getBlock() == door || worldIn.getBlockState(blockpos.up()).getBlock() == door; if ((!flag || flag1) && j <= i) { if (flag1 && !flag || j < i) { isRightHinge = false; } } else { isRightHinge = true; } BlockPos blockpos2 = pos.up(); boolean flag2 = worldIn.isBlockPowered(pos) || worldIn.isBlockPowered(blockpos2); IBlockState iblockstate = door.getDefaultState().withProperty(BlockDoor.FACING, facing).withProperty(BlockDoor.HINGE, isRightHinge ? BlockDoor.EnumHingePosition.RIGHT : BlockDoor.EnumHingePosition.LEFT).withProperty(BlockDoor.POWERED, Boolean.valueOf(flag2)).withProperty(BlockDoor.OPEN, Boolean.valueOf(flag2)); worldIn.setBlockState(pos, iblockstate.withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER), 2); worldIn.setBlockState(blockpos2, iblockstate.withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), 2); worldIn.notifyNeighborsOfStateChange(pos, door, false); worldIn.notifyNeighborsOfStateChange(blockpos2, door, false); }
Example 4
Source File: BlockFenceGate.java From customstuff4 with GNU General Public License v3.0 | 6 votes |
@Override public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) { if (!worldIn.isRemote && content.opensWithRedstone) { boolean flag = worldIn.isBlockPowered(pos); if (state.getValue(POWERED) != flag) { worldIn.setBlockState(pos, state.withProperty(POWERED, flag).withProperty(OPEN, flag), 2); if (state.getValue(OPEN) != flag) { worldIn.playEvent(null, flag ? 1008 : 1014, pos, 0); } } } }
Example 5
Source File: BlockAirshipEngine.java From Valkyrien-Skies with Apache License 2.0 | 6 votes |
@Override public Vector getBlockForceInShipSpace(World world, BlockPos pos, IBlockState state, PhysicsObject physicsObject, double secondsToApply) { Vector acting = new Vector(0, 0, 0); if (!world.isBlockPowered(pos)) { return acting; } TileEntity tileEntity = world.getTileEntity(pos); if (tileEntity instanceof TileEntityPropellerEngine) { //Just set the Thrust to be the maximum ((TileEntityPropellerEngine) tileEntity) .setThrustMultiplierGoal(this.getEnginePower(world, pos, state, physicsObject)); ((TileEntityPropellerEngine) tileEntity).updateTicksSinceLastRecievedSignal(); ((TileEntityPropellerEngine) tileEntity).setThrustMultiplierGoal(1D); return ((TileEntityPropellerEngine) tileEntity) .getForceOutputUnoriented(secondsToApply, physicsObject); } return acting; }
Example 6
Source File: BlockSoulGlass.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { if(worldIn.isBlockPowered(pos)) { worldIn.scheduleUpdate(new BlockPos(pos), this, this.tickRate(worldIn)); worldIn.setBlockState(pos, state.withProperty(POWERED, true)); } }
Example 7
Source File: BlockFenceGate.java From customstuff4 with GNU General Public License v3.0 | 5 votes |
@Override public IBlockState getStateForPlacement(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, flag) .withProperty(POWERED, flag) .withProperty(IN_WALL, Boolean.FALSE); }
Example 8
Source File: BlockMolecularExciter.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) { if (worldIn.isRemote == false && worldIn.isBlockPowered(pos)) { this.scheduleBlockUpdate(worldIn, pos, state, 1, true); } }
Example 9
Source File: BlockMolecularExciter.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { if (worldIn.isRemote == false && worldIn.isBlockPowered(pos)) { convertBlockToFallingBlockEntity(worldIn, pos.offset(state.getValue(FACING))); } }
Example 10
Source File: BlockPhasing.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) { if (worldIn.isRemote == false) { boolean powered = worldIn.isBlockPowered(pos); if (powered != state.getValue(POWERED)) { worldIn.setBlockState(pos, state.withProperty(POWERED, powered), 2); } } }
Example 11
Source File: TileEntityElevator.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block blockIn) { boolean redstone = worldIn.isBlockPowered(pos); if (redstone != this.redstoneState && redstone) { this.activateByRedstone(worldIn.getRedstonePowerFromNeighbors(pos) < 8); } this.redstoneState = redstone; }