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

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

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

World.isAirBlock介绍

暂无

代码示例

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

@Override
public boolean canGrow(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, boolean fuckifiknow) {
  return world.isAirBlock(pos.up());
}

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

for(int k = 2; k >= -2; k--) {
  BlockPos pos_ = pos.add(i + 1, k + 1, j + 1);
  if(world.isAirBlock(pos_) && (!world.provider.isNether() || pos_.getY() < 255) && ModBlocks.flower.canPlaceBlockAt(world, pos_))
    validCoords.add(pos_);

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

@Override
@SideOnly(Side.CLIENT)
public List<BlockPos> getWireframesToDraw(EntityPlayer player, ItemStack stack) {
  if(getLokiRing(player) != stack)
    return ImmutableList.of();
  RayTraceResult lookPos = Minecraft.getMinecraft().objectMouseOver;
  if(lookPos != null && lookPos.getBlockPos() != null && !player.world.isAirBlock(lookPos.getBlockPos()) && lookPos.entityHit == null) {
    List<BlockPos> list = getCursorList(stack);
    BlockPos origin = getOriginPos(stack);
    for (int i = 0; i < list.size(); i++) {
      if (origin.getY() != -1) {
        list.set(i, list.get(i).add(origin));
      } else {
        list.set(i, list.get(i).add(lookPos.getBlockPos()));
      }
    }
    return list;
  }
  return ImmutableList.of();
}

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

@Nonnull
@Override
public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) {
  EnumFacing facing = par1IBlockSource.getBlockState().getValue(BlockDispenser.FACING);
  BlockPos pos = par1IBlockSource.getBlockPos().offset(facing);
  World world = par1IBlockSource.getWorld();
  if(world.isAirBlock(pos) && block.canPlaceBlockAt(world, pos)) {
    world.setBlockState(pos, block.getDefaultState());
    par2ItemStack.shrink(1);
    return par2ItemStack;
  }
  return super.dispenseStack(par1IBlockSource, par2ItemStack);
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

if( this.world.isAirBlock( wc.getPos() ) )

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

private float rayTraceResistance(Vector3 start, Vector3 end, float prevresistance) {
  RayTraceResult mop = world.rayTraceBlocks(start.toVec3D(), end.toVec3D());
  if(mop == null)
    return prevresistance;
  if(mop.typeOfHit == RayTraceResult.Type.BLOCK) {
    Block block = world.getBlockState(mop.getBlockPos()).getBlock();
    if(world.isAirBlock(mop.getBlockPos()))
      return prevresistance;
    return prevresistance + block.getExplosionResistance(null) + 0.3F;
  } else return prevresistance;
}

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

return;
if(world.isAirBlock(pos))
  return;

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

if(!player.world.isAirBlock(bPos)) {
  List<BlockPos> coordsList = getBlocksToSwap(player.world, stack, block.getStateFromMeta(meta), bPos, targetBlock == null ? null : targetBlock.getStateFromMeta(targetMeta));
  for(BlockPos coords : coordsList)

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

@Override
public void onUpdate() {
  super.onUpdate();
  if(supertile.getWorld().isRemote)
    return;
  if(ticksExisted % 200 == 0)
    sync();
  if(ticksExisted % 6 == 0 && redstoneSignal == 0) {
    int range = getRange();
    int x = supertile.getPos().getX() + supertile.getWorld().rand.nextInt(range * 2 + 1) - range;
    int z = supertile.getPos().getZ() + supertile.getWorld().rand.nextInt(range * 2 + 1) - range;
    for(int i = 4; i > -2; i--) {
      int y = supertile.getPos().getY() + i;
      BlockPos pos = new BlockPos(x, y, z);
      if(supertile.getWorld().isAirBlock(pos))
        continue;
      if(isPlant(pos) && mana > 5) {
        Block block = supertile.getWorld().getBlockState(pos).getBlock();
        mana -= 5;
        supertile.getWorld().scheduleUpdate(pos, block, 1);
        if(ConfigHandler.blockBreakParticles)
          supertile.getWorld().playEvent(2005, pos, 6 + supertile.getWorld().rand.nextInt(4));
        supertile.getWorld().playSound(null, x, y, z, ModSounds.agricarnation, SoundCategory.BLOCKS, 0.01F, 0.5F + (float) Math.random() * 0.5F);
        break;
      }
    }
  }
}

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

int z1 = z + event.getRand().nextInt(dist * 2) - dist;
    BlockPos pos2 = new BlockPos(x1, y1, z1);
    if(event.getWorld().isAirBlock(pos2) && (!event.getWorld().provider.isNether() || y1 < 127) && ModBlocks.flower.canPlaceBlockAt(event.getWorld(), pos2)) {
      event.getWorld().setBlockState(pos2, ModBlocks.flower.getDefaultState().withProperty(BotaniaStateProps.COLOR, color), 2);
      if(event.getRand().nextDouble() < ConfigHandler.flowerTallChance && ((BlockModFlower) ModBlocks.flower).canGrow(event.getWorld(), pos2, event.getWorld().getBlockState(pos2), false))
BlockPos pos3 = new BlockPos(x, y, z);
EnumDyeColor color = EnumDyeColor.byMetadata(event.getRand().nextInt(16));
if(event.getWorld().isAirBlock(pos3) && ModBlocks.mushroom.canPlaceBlockAt(event.getWorld(), pos3))
  event.getWorld().setBlockState(pos3, ModBlocks.mushroom.getDefaultState().withProperty(BotaniaStateProps.COLOR, color), 2);

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

@Nonnull
@Override
protected ItemStack dispenseStack(IBlockSource source, ItemStack stack)
{
  World world = source.getWorld();
  EnumFacing facing = world.getBlockState(source.getBlockPos()).getValue(BlockDispenser.FACING);
  BlockPos blockpos = source.getBlockPos().offset(facing);
  Block blockpumpkin = ModBlocks.felPumpkin;
  if (world.isAirBlock(blockpos) && world.getBlockState(blockpos.down()).getBlock() == Blocks.IRON_BARS
      && world.getBlockState(blockpos.down(2)).getBlock() == Blocks.IRON_BARS) // Botania - Check for iron bars
  {
    if (!world.isRemote)
    {
      world.setBlockState(blockpos, blockpumpkin.getDefaultState(), 3);
    }
    stack.shrink(1);
  }
  else
  {
    field_179241_b = false;
  }
  return stack;
}

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

BlockPos coords = supertile.getPos().add(acoords);
World world = supertile.getWorld();
if(!world.isAirBlock(coords)) {
  world.profiler.startSection("findRecipe");
  RecipePureDaisy recipe = findRecipe(coords);

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

BlockPos pos = s.blockPos;
World world = server.getWorld(worldId);
if(world.isAirBlock(pos.offset(dir)))
  world.setBlockState(pos.offset(dir), ModBlocks.pistonRelay.getDefaultState());
else if(!world.isRemote) {
  if(world.isAirBlock(pos2.offset(dir)) || destMat.isReplaceable()) {
    world.setBlockState(pos2, Blocks.AIR.getDefaultState());
    world.setBlockState(pos2.offset(dir), srcState, 1 | 2);

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

@Nonnull
@Override
public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) {
  if(par2ItemStack.getItemDamage() == EnumDyeColor.BROWN.getDyeDamage()) {
    Block block = Blocks.COCOA;
    EnumFacing facing = par1IBlockSource.getBlockState().getValue(BlockDispenser.FACING);
    BlockPos pos = par1IBlockSource.getBlockPos().offset(facing);
    World world = par1IBlockSource.getWorld();
    BlockPos logPos = pos.offset(facing);
    IBlockState logState = world.getBlockState(logPos);
    if(logState.getBlock() == Blocks.LOG && logState.getValue(BlockOldLog.VARIANT) == BlockPlanks.EnumType.JUNGLE && world.isAirBlock(pos) && block.canPlaceBlockAt(world, pos)) {
      world.setBlockState(pos, block.getDefaultState().withProperty(BlockHorizontal.FACING, facing));
      par2ItemStack.shrink(1);
      return par2ItemStack;
    }
  }
  return vanillaBehaviour.dispense(par1IBlockSource, par2ItemStack);
}

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

@Override
public void update() {
  EnumFacing dir = getOrientation();
  BlockPos pos_ = getPos();
  int range = getRange();
  BlockPos currBinding = getBinding();
  setBinding(null);
  for(int i = 0; i < range; i++) {
    pos_ = pos_.offset(dir);
    if(world.isAirBlock(pos_))
      continue;
    TileEntity tile = world.getTileEntity(pos_);
    if(tile instanceof TileRedString)
      continue;
    if(acceptBlock(pos_)) {
      setBinding(pos_);
      if(currBinding == null || !currBinding.equals(pos_))
        onBound(pos_);
      break;
    }
  }
}

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

@Override
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) {
  if(!entity.world.isRemote && !burst.isFake() && pos.getBlockPos() != null) {
    int harvestLevel = ConfigHandler.harvestLevelWeight;
    BlockPos bPos = pos.getBlockPos();
    Block block = entity.world.getBlockState(bPos).getBlock();
    IBlockState state = entity.world.getBlockState(bPos);
    int neededHarvestLevel = block.getHarvestLevel(state);
    if(entity.world.isAirBlock(bPos.down()) && state.getBlockHardness(entity.world, bPos) != -1 && neededHarvestLevel <= harvestLevel && entity.world.getTileEntity(bPos) == null && block.canSilkHarvest(entity.world, bPos, state, null)) {
      state = TECHNICAL_BLOCK_REMAP.getOrDefault(state, state);
      EntityFallingBlock falling = new EntityFallingBlock(entity.world, bPos.getX() + 0.5, bPos.getY(), bPos.getZ() + 0.5, state);
      falling.fallTime = 1;
      entity.world.setBlockToAir(bPos);
      ((WorldServer) entity.world).spawnParticle(EnumParticleTypes.FALLING_DUST, bPos.getX() + 0.5, bPos.getY() + 0.5, bPos.getZ() + 0.5, 10, 0.45, 0.45, 0.45, 5, new int[] {Block.getStateId(state)});
      entity.world.spawnEntity(falling);
    }
  }
  return dead;
}

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

|| !world.isAirBlock(pos) && world.getBlockState(pos).getBlock() != place)
break;
for(int j = -2; j < 1; j++) {
  placePos.setPos(pos.getX() + i, pos.getY(), pos.getZ() + j);
  if(world.isAirBlock(placePos)
      || world.getBlockState(placePos).getBlock() == place) {
    world.setBlockState(placePos, place.getDefaultState(), 2);

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

@Override
public void onUpdate() {
  super.onUpdate();
  if(supertile.getWorld().isRemote || redstoneSignal > 0)
    return;
  if(ticksExisted % 30 == 0 && mana >= COST) {
    BlockPos pos = new BlockPos(
        supertile.getPos().getX() - RANGE + supertile.getWorld().rand.nextInt(RANGE * 2 + 1),
        supertile.getPos().getY() + RANGE,
        supertile.getPos().getZ() - RANGE + supertile.getWorld().rand.nextInt(RANGE * 2 + 1)
        );
    BlockPos up = pos.up();
    for(int i = 0; i < RANGE * 2; i++) {
      IBlockState stateAbove = supertile.getWorld().getBlockState(up);
      Block blockAbove = stateAbove.getBlock();
      if((supertile.getWorld().isAirBlock(up) || blockAbove.isReplaceable(supertile.getWorld(), up)) && stateAbove.getMaterial() != Material.WATER && ModBlocks.flower.canPlaceBlockAt(supertile.getWorld(), up)) {
        EnumDyeColor color = EnumDyeColor.byMetadata(supertile.getWorld().rand.nextInt(16));
        IBlockState state = ModBlocks.flower.getDefaultState().withProperty(BotaniaStateProps.COLOR, color);
        if(ConfigHandler.blockBreakParticles)
          supertile.getWorld().playEvent(2001, up, Block.getStateId(state));
        supertile.getWorld().setBlockState(up, state, 1 | 2);
        mana -= COST;
        sync();
        break;
      }
      up = pos;
      pos = pos.down();
    }
  }
}

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

@Override
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) {
  BlockPos coords = burst.getBurstSourceBlockPos();
  if(!entity.world.isRemote && pos.getBlockPos() != null && !coords.equals(pos.getBlockPos()) && !burst.isFake() && !isManaBlock) {
    BlockPos pos_ = pos.getBlockPos().offset(pos.sideHit.getOpposite());
    if(entity.world.isAirBlock(pos_) || entity.world.getBlockState(pos_).getBlock().isReplaceable(entity.world, pos_)) {
      IBlockState state = entity.world.getBlockState(pos.getBlockPos());
      TileEntity tile = entity.world.getTileEntity(pos.getBlockPos());
      if(state.getPushReaction() == EnumPushReaction.NORMAL && state.getBlock() != Blocks.OBSIDIAN && state.getBlockHardness(entity.world, pos_) >= 0 && tile == null) {
        entity.world.destroyBlock(pos.getBlockPos(), false);
        entity.world.setBlockState(pos_, state, 1 | 2);
      }
    }
  }
  return dead;
}

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

BlockPos pos = new BlockPos(x, y, z);
if(entity.world.isAirBlock(pos)) {
  Block block = Blocks.AIR;
  if (lens.hasTagCompound()) {

相关文章

微信公众号

最新文章

更多

World类方法