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

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

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

World.isAirBlock介绍

暂无

代码示例

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

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

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

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

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

  1. @Override
  2. @SideOnly(Side.CLIENT)
  3. public List<BlockPos> getWireframesToDraw(EntityPlayer player, ItemStack stack) {
  4. if(getLokiRing(player) != stack)
  5. return ImmutableList.of();
  6. RayTraceResult lookPos = Minecraft.getMinecraft().objectMouseOver;
  7. if(lookPos != null && lookPos.getBlockPos() != null && !player.world.isAirBlock(lookPos.getBlockPos()) && lookPos.entityHit == null) {
  8. List<BlockPos> list = getCursorList(stack);
  9. BlockPos origin = getOriginPos(stack);
  10. for (int i = 0; i < list.size(); i++) {
  11. if (origin.getY() != -1) {
  12. list.set(i, list.get(i).add(origin));
  13. } else {
  14. list.set(i, list.get(i).add(lookPos.getBlockPos()));
  15. }
  16. }
  17. return list;
  18. }
  19. return ImmutableList.of();
  20. }

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

  1. @Nonnull
  2. @Override
  3. public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) {
  4. EnumFacing facing = par1IBlockSource.getBlockState().getValue(BlockDispenser.FACING);
  5. BlockPos pos = par1IBlockSource.getBlockPos().offset(facing);
  6. World world = par1IBlockSource.getWorld();
  7. if(world.isAirBlock(pos) && block.canPlaceBlockAt(world, pos)) {
  8. world.setBlockState(pos, block.getDefaultState());
  9. par2ItemStack.shrink(1);
  10. return par2ItemStack;
  11. }
  12. return super.dispenseStack(par1IBlockSource, par2ItemStack);
  13. }

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

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

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

  1. private float rayTraceResistance(Vector3 start, Vector3 end, float prevresistance) {
  2. RayTraceResult mop = world.rayTraceBlocks(start.toVec3D(), end.toVec3D());
  3. if(mop == null)
  4. return prevresistance;
  5. if(mop.typeOfHit == RayTraceResult.Type.BLOCK) {
  6. Block block = world.getBlockState(mop.getBlockPos()).getBlock();
  7. if(world.isAirBlock(mop.getBlockPos()))
  8. return prevresistance;
  9. return prevresistance + block.getExplosionResistance(null) + 0.3F;
  10. } else return prevresistance;
  11. }

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

  1. return;
  2. if(world.isAirBlock(pos))
  3. return;

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

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

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

  1. @Override
  2. public void onUpdate() {
  3. super.onUpdate();
  4. if(supertile.getWorld().isRemote)
  5. return;
  6. if(ticksExisted % 200 == 0)
  7. sync();
  8. if(ticksExisted % 6 == 0 && redstoneSignal == 0) {
  9. int range = getRange();
  10. int x = supertile.getPos().getX() + supertile.getWorld().rand.nextInt(range * 2 + 1) - range;
  11. int z = supertile.getPos().getZ() + supertile.getWorld().rand.nextInt(range * 2 + 1) - range;
  12. for(int i = 4; i > -2; i--) {
  13. int y = supertile.getPos().getY() + i;
  14. BlockPos pos = new BlockPos(x, y, z);
  15. if(supertile.getWorld().isAirBlock(pos))
  16. continue;
  17. if(isPlant(pos) && mana > 5) {
  18. Block block = supertile.getWorld().getBlockState(pos).getBlock();
  19. mana -= 5;
  20. supertile.getWorld().scheduleUpdate(pos, block, 1);
  21. if(ConfigHandler.blockBreakParticles)
  22. supertile.getWorld().playEvent(2005, pos, 6 + supertile.getWorld().rand.nextInt(4));
  23. supertile.getWorld().playSound(null, x, y, z, ModSounds.agricarnation, SoundCategory.BLOCKS, 0.01F, 0.5F + (float) Math.random() * 0.5F);
  24. break;
  25. }
  26. }
  27. }
  28. }

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

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

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

  1. @Nonnull
  2. @Override
  3. protected ItemStack dispenseStack(IBlockSource source, ItemStack stack)
  4. {
  5. World world = source.getWorld();
  6. EnumFacing facing = world.getBlockState(source.getBlockPos()).getValue(BlockDispenser.FACING);
  7. BlockPos blockpos = source.getBlockPos().offset(facing);
  8. Block blockpumpkin = ModBlocks.felPumpkin;
  9. if (world.isAirBlock(blockpos) && world.getBlockState(blockpos.down()).getBlock() == Blocks.IRON_BARS
  10. && world.getBlockState(blockpos.down(2)).getBlock() == Blocks.IRON_BARS) // Botania - Check for iron bars
  11. {
  12. if (!world.isRemote)
  13. {
  14. world.setBlockState(blockpos, blockpumpkin.getDefaultState(), 3);
  15. }
  16. stack.shrink(1);
  17. }
  18. else
  19. {
  20. field_179241_b = false;
  21. }
  22. return stack;
  23. }

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

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

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

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

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

  1. @Nonnull
  2. @Override
  3. public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) {
  4. if(par2ItemStack.getItemDamage() == EnumDyeColor.BROWN.getDyeDamage()) {
  5. Block block = Blocks.COCOA;
  6. EnumFacing facing = par1IBlockSource.getBlockState().getValue(BlockDispenser.FACING);
  7. BlockPos pos = par1IBlockSource.getBlockPos().offset(facing);
  8. World world = par1IBlockSource.getWorld();
  9. BlockPos logPos = pos.offset(facing);
  10. IBlockState logState = world.getBlockState(logPos);
  11. if(logState.getBlock() == Blocks.LOG && logState.getValue(BlockOldLog.VARIANT) == BlockPlanks.EnumType.JUNGLE && world.isAirBlock(pos) && block.canPlaceBlockAt(world, pos)) {
  12. world.setBlockState(pos, block.getDefaultState().withProperty(BlockHorizontal.FACING, facing));
  13. par2ItemStack.shrink(1);
  14. return par2ItemStack;
  15. }
  16. }
  17. return vanillaBehaviour.dispense(par1IBlockSource, par2ItemStack);
  18. }

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

  1. @Override
  2. public void update() {
  3. EnumFacing dir = getOrientation();
  4. BlockPos pos_ = getPos();
  5. int range = getRange();
  6. BlockPos currBinding = getBinding();
  7. setBinding(null);
  8. for(int i = 0; i < range; i++) {
  9. pos_ = pos_.offset(dir);
  10. if(world.isAirBlock(pos_))
  11. continue;
  12. TileEntity tile = world.getTileEntity(pos_);
  13. if(tile instanceof TileRedString)
  14. continue;
  15. if(acceptBlock(pos_)) {
  16. setBinding(pos_);
  17. if(currBinding == null || !currBinding.equals(pos_))
  18. onBound(pos_);
  19. break;
  20. }
  21. }
  22. }

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

  1. @Override
  2. public boolean collideBurst(IManaBurst burst, EntityThrowable entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) {
  3. if(!entity.world.isRemote && !burst.isFake() && pos.getBlockPos() != null) {
  4. int harvestLevel = ConfigHandler.harvestLevelWeight;
  5. BlockPos bPos = pos.getBlockPos();
  6. Block block = entity.world.getBlockState(bPos).getBlock();
  7. IBlockState state = entity.world.getBlockState(bPos);
  8. int neededHarvestLevel = block.getHarvestLevel(state);
  9. 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)) {
  10. state = TECHNICAL_BLOCK_REMAP.getOrDefault(state, state);
  11. EntityFallingBlock falling = new EntityFallingBlock(entity.world, bPos.getX() + 0.5, bPos.getY(), bPos.getZ() + 0.5, state);
  12. falling.fallTime = 1;
  13. entity.world.setBlockToAir(bPos);
  14. ((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)});
  15. entity.world.spawnEntity(falling);
  16. }
  17. }
  18. return dead;
  19. }

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

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

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

  1. @Override
  2. public void onUpdate() {
  3. super.onUpdate();
  4. if(supertile.getWorld().isRemote || redstoneSignal > 0)
  5. return;
  6. if(ticksExisted % 30 == 0 && mana >= COST) {
  7. BlockPos pos = new BlockPos(
  8. supertile.getPos().getX() - RANGE + supertile.getWorld().rand.nextInt(RANGE * 2 + 1),
  9. supertile.getPos().getY() + RANGE,
  10. supertile.getPos().getZ() - RANGE + supertile.getWorld().rand.nextInt(RANGE * 2 + 1)
  11. );
  12. BlockPos up = pos.up();
  13. for(int i = 0; i < RANGE * 2; i++) {
  14. IBlockState stateAbove = supertile.getWorld().getBlockState(up);
  15. Block blockAbove = stateAbove.getBlock();
  16. if((supertile.getWorld().isAirBlock(up) || blockAbove.isReplaceable(supertile.getWorld(), up)) && stateAbove.getMaterial() != Material.WATER && ModBlocks.flower.canPlaceBlockAt(supertile.getWorld(), up)) {
  17. EnumDyeColor color = EnumDyeColor.byMetadata(supertile.getWorld().rand.nextInt(16));
  18. IBlockState state = ModBlocks.flower.getDefaultState().withProperty(BotaniaStateProps.COLOR, color);
  19. if(ConfigHandler.blockBreakParticles)
  20. supertile.getWorld().playEvent(2001, up, Block.getStateId(state));
  21. supertile.getWorld().setBlockState(up, state, 1 | 2);
  22. mana -= COST;
  23. sync();
  24. break;
  25. }
  26. up = pos;
  27. pos = pos.down();
  28. }
  29. }
  30. }

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

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

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

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

相关文章

World类方法