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

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

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

World.isBlockPowered介绍

暂无

代码示例

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

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

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

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

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

@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
  if (!world.isRemote) {
    if (((Boolean) state.getValue(POWERED)).booleanValue() && !world.isBlockPowered(pos))
      setState(world, pos, state, false);
    else if (!((Boolean) state.getValue(POWERED)).booleanValue() && world.isBlockPowered(pos))
      setState(world, pos, state, true);
  }
}

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

public boolean isPowered() {
  if (inverted)
    return !getWorld().isBlockPowered(getPos());
  return getWorld().isBlockPowered(getPos());
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@Override
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
  boolean flag = world.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));
}

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

@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
  super.onBlockAdded(world, pos, state);
  if (world.isBlockPowered(pos)) {
    onBlockDestroyedByPlayer(world, pos, state.withProperty(EXPLODE, Boolean.valueOf(true)));
    world.setBlockToAir(pos);
  }
}

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

@Override
public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor) {
  ((TileBlockingPipe)world.getTileEntity(pos)).getAdjacentPipes(world);
  if (world instanceof World) {
    ((TileBlockingPipe)world.getTileEntity(pos)).setRedstoneState(((World)world).isBlockPowered(pos));
  }
}

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

@Override
public void onBlockAdded(World world, BlockPos blockPos, IBlockState blockState) {
  super.onBlockAdded(world, blockPos, blockState);
  if (world.isBlockPowered(blockPos)) {
    this.onBlockDestroyedByPlayer(world, blockPos, blockState.withProperty(PRIMED, true));
    world.setBlockToAir(blockPos);
  }
}

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

@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state)
{
  super.onBlockAdded(world, pos, state);
  TileEntity tile = world.getTileEntity(pos);
  if (tile instanceof TileEntityBasin)
  {
    ((TileEntityBasin) tile).setPowered(world.isBlockPowered(pos));
    ((TileEntityBasin) tile).scheduleFluidConsume();
  }
}

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

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

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

@Override
public void initialUpdate() {
  super.initialUpdate();
  powered = world.isBlockPowered(pos);
  EnumFacing myDir = world.getBlockState(pos).getValue(BlockVacuum.FACING);
  setValidDistributionDirectionsExcluding(myDir, myDir.getOpposite());
}

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

@Override
protected void updateTileEntity() {
  super.updateTileEntity();
  if (!getWorld().isRemote && getEnergyStored() > 0 && getWorld().isBlockPowered(getPos())) {
    addEnergy(Math.min(getEnergyPerTick(), getEnergyStored()));
  }
}

相关文章

World类方法