net.minecraft.world.World.isBlockPowered()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(138)

本文整理了Java中net.minecraft.world.World.isBlockPowered()方法的一些代码示例,展示了World.isBlockPowered()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。World.isBlockPowered()方法的具体详情如下:
包路径:net.minecraft.world.World
类名称:World
方法名:isBlockPowered

World.isBlockPowered介绍

暂无

代码示例

代码示例来源:origin: Vazkii/Botania

  1. @Override
  2. public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
  3. if(!worldIn.isRemote && state.getValue(BotaniaStateProps.LUMINIZER_VARIANT) == LuminizerVariant.TOGGLE) {
  4. if(state.getValue(BotaniaStateProps.POWERED) && !worldIn.isBlockPowered(pos))
  5. worldIn.setBlockState(pos, state.withProperty(BotaniaStateProps.POWERED, false));
  6. else if(!state.getValue(BotaniaStateProps.POWERED) && worldIn.isBlockPowered(pos))
  7. worldIn.setBlockState(pos, state.withProperty(BotaniaStateProps.POWERED, true));
  8. }
  9. }

代码示例来源:origin: SleepyTrousers/EnderIO

  1. @Override
  2. public boolean isBlockPowered(@Nonnull BlockPos pos) {
  3. return wrapped.isBlockPowered(pos);
  4. }

代码示例来源:origin: vadis365/TheErebus

  1. @Override
  2. public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
  3. if (!world.isRemote) {
  4. if (((Boolean) state.getValue(POWERED)).booleanValue() && !world.isBlockPowered(pos))
  5. setState(world, pos, state, false);
  6. else if (!((Boolean) state.getValue(POWERED)).booleanValue() && world.isBlockPowered(pos))
  7. setState(world, pos, state, true);
  8. }
  9. }

代码示例来源:origin: WayofTime/BloodMagic

  1. public boolean isPowered() {
  2. if (inverted)
  3. return !getWorld().isBlockPowered(getPos());
  4. return getWorld().isBlockPowered(getPos());
  5. }

代码示例来源:origin: vadis365/TheErebus

  1. @Override
  2. public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos fromPos) {
  3. TileEntityExtenderThingy tile = Utils.getTileEntity(world, pos, TileEntityExtenderThingy.class);
  4. tile.setExtending(world.isBlockPowered(pos));
  5. }

代码示例来源:origin: Esteemed-Innovation/Esteemed-Innovation

  1. @Override
  2. public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighbor, BlockPos fromPos) {
  3. TileEntity tileEntity = world.getTileEntity(pos);
  4. if (tileEntity != null && tileEntity instanceof TileEntityFan) {
  5. boolean poweredByRedstone = world.isBlockPowered(pos);
  6. TileEntityFan fan = (TileEntityFan) tileEntity;
  7. fan.updateRedstoneState(poweredByRedstone);
  8. }
  9. }

代码示例来源:origin: Esteemed-Innovation/Esteemed-Innovation

  1. @Override
  2. public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos fromPos) {
  3. TileEntity tileEntity = world.getTileEntity(pos);
  4. if (tileEntity != null && tileEntity instanceof TileEntityVacuum) {
  5. TileEntityVacuum tileentityvacuum = (TileEntityVacuum) tileEntity;
  6. boolean isPowered = world.isBlockPowered(pos);
  7. tileentityvacuum.updateRedstoneState(isPowered);
  8. }
  9. }

代码示例来源:origin: Vazkii/Quark

  1. @Override
  2. public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
  3. boolean flag = !worldIn.isBlockPowered(pos);
  4. if(flag != state.getValue(ENABLED))
  5. worldIn.setBlockState(pos, state.withProperty(ENABLED, Boolean.valueOf(flag)), 2 | 4);
  6. }

代码示例来源:origin: Vazkii/Quark

  1. @Override
  2. public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
  3. boolean flag = !worldIn.isBlockPowered(pos);
  4. if(flag != state.getValue(ENABLED))
  5. worldIn.setBlockState(pos, state.withProperty(ENABLED, Boolean.valueOf(flag)), 2 | 4);
  6. }

代码示例来源:origin: vadis365/TheErebus

  1. @Override
  2. public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
  3. if (!world.isRemote) {
  4. if (state.getValue(TYPE) == EnumType.RED_LAMP_OFF && !world.isBlockPowered(pos))
  5. world.scheduleBlockUpdate(pos, this, 0, 4);
  6. else if (state.getValue(TYPE) == EnumType.RED_LAMP_ON && world.isBlockPowered(pos))
  7. world.setBlockState(pos, state.withProperty(TYPE, EnumType.RED_LAMP_OFF), 2);
  8. }
  9. }

代码示例来源:origin: vadis365/TheErebus

  1. @Override
  2. public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos fromPos) {
  3. if (!world.isRemote) {
  4. boolean flag = world.isBlockPowered(pos);
  5. if (((Boolean) state.getValue(POWERED)).booleanValue() != flag) {
  6. world.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(flag)).withProperty(OPEN, Boolean.valueOf(flag)), 2);
  7. if (((Boolean) state.getValue(OPEN)).booleanValue() != flag)
  8. world.playEvent((EntityPlayer) null, flag ? 1008 : 1014, pos, 0);
  9. }
  10. }
  11. }

代码示例来源:origin: CyclopsMC/IntegratedDynamics

  1. /**
  2. * @return If the machine is able to work in its current state.
  3. * This for example takes into account the available energy.
  4. */
  5. public boolean canWork() {
  6. int rate = getEnergyConsumptionRate();
  7. return drainEnergy(rate, true) == rate && !world.isBlockPowered(getPos());
  8. }

代码示例来源:origin: vadis365/TheErebus

  1. @Override
  2. public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
  3. boolean flag = world.isBlockPowered(pos);
  4. return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing()).withProperty(OPEN, Boolean.valueOf(flag)).withProperty(POWERED, Boolean.valueOf(flag)) .withProperty(IN_WALL, Boolean.valueOf(false));
  5. }

代码示例来源:origin: vadis365/TheErebus

  1. @Override
  2. public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
  3. super.onBlockAdded(world, pos, state);
  4. if (world.isBlockPowered(pos)) {
  5. onBlockDestroyedByPlayer(world, pos, state.withProperty(EXPLODE, Boolean.valueOf(true)));
  6. world.setBlockToAir(pos);
  7. }
  8. }

代码示例来源:origin: SonOfTheStars/Logistics-Pipes-2

  1. @Override
  2. public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor) {
  3. ((TileBlockingPipe)world.getTileEntity(pos)).getAdjacentPipes(world);
  4. if (world instanceof World) {
  5. ((TileBlockingPipe)world.getTileEntity(pos)).setRedstoneState(((World)world).isBlockPowered(pos));
  6. }
  7. }

代码示例来源:origin: CyclopsMC/EvilCraft

  1. @Override
  2. public void onBlockAdded(World world, BlockPos blockPos, IBlockState blockState) {
  3. super.onBlockAdded(world, blockPos, blockState);
  4. if (world.isBlockPowered(blockPos)) {
  5. this.onBlockDestroyedByPlayer(world, blockPos, blockState.withProperty(PRIMED, true));
  6. world.setBlockToAir(blockPos);
  7. }
  8. }

代码示例来源:origin: squeek502/VeganOption

  1. @Override
  2. public void onBlockAdded(World world, BlockPos pos, IBlockState state)
  3. {
  4. super.onBlockAdded(world, pos, state);
  5. TileEntity tile = world.getTileEntity(pos);
  6. if (tile instanceof TileEntityBasin)
  7. {
  8. ((TileEntityBasin) tile).setPowered(world.isBlockPowered(pos));
  9. ((TileEntityBasin) tile).scheduleFluidConsume();
  10. }
  11. }

代码示例来源:origin: Esteemed-Innovation/Esteemed-Innovation

  1. @Override
  2. public void initialUpdate() {
  3. super.initialUpdate();
  4. powered = world.isBlockPowered(pos);
  5. setDistributionDirections(new EnumFacing[] { world.getBlockState(pos).getValue(BlockFan.FACING).getOpposite() });
  6. }

代码示例来源:origin: Esteemed-Innovation/Esteemed-Innovation

  1. @Override
  2. public void initialUpdate() {
  3. super.initialUpdate();
  4. powered = world.isBlockPowered(pos);
  5. EnumFacing myDir = world.getBlockState(pos).getValue(BlockVacuum.FACING);
  6. setValidDistributionDirectionsExcluding(myDir, myDir.getOpposite());
  7. }

代码示例来源:origin: CyclopsMC/IntegratedDynamics

  1. @Override
  2. protected void updateTileEntity() {
  3. super.updateTileEntity();
  4. if (!getWorld().isRemote && getEnergyStored() > 0 && getWorld().isBlockPowered(getPos())) {
  5. addEnergy(Math.min(getEnergyPerTick(), getEnergyStored()));
  6. }
  7. }

相关文章

World类方法