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

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

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

World.setBlockToAir介绍

暂无

代码示例

代码示例来源:origin: EngineHub/WorldEdit

@Override
public void simulateBlockMine(BlockVector3 position) {
  BlockPos pos = ForgeAdapter.toBlockPos(position);
  IBlockState state = getWorld().getBlockState(pos);
  state.getBlock().dropBlockAsItem(getWorld(), pos, state, 0);
  getWorld().setBlockToAir(pos);
}

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

@Override
public void update() {
  if(!world.isRemote) {
    if(ticks <= 0) {
      world.setBlockToAir(pos);
    } else ticks--;
  }
}

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

@Override
public void harvestBlock(@Nonnull World world, EntityPlayer player, @Nonnull BlockPos pos, @Nonnull IBlockState state, TileEntity te, ItemStack stack) {
  super.harvestBlock(world, player, pos, state, te, stack);
  // Now delete the block and TE
  world.setBlockToAir(pos);
}

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

@Override
public void harvestBlock(@Nonnull World world, EntityPlayer player, @Nonnull BlockPos pos, @Nonnull IBlockState state, TileEntity te, ItemStack stack) {
  super.harvestBlock(world, player, pos, state, te, stack);
  // Now delete the block and TE
  world.setBlockToAir(pos);
}

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

@Override
public void harvestBlock(@Nonnull World world, EntityPlayer player, @Nonnull BlockPos pos, @Nonnull IBlockState state, TileEntity te, ItemStack stack) {
  super.harvestBlock(world, player, pos, state, te, stack);
  // Now delete the block and TE
  world.setBlockToAir(pos);
}

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

@Override
public void harvestBlock(@Nonnull World world, EntityPlayer player, @Nonnull BlockPos pos, @Nonnull IBlockState state, TileEntity te, ItemStack stack) {
  super.harvestBlock(world, player, pos, state, te, stack);
  // Now delete the block and TE
  world.setBlockToAir(pos);
}

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

@Override
public void harvestBlock(World world, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack tool) {
  super.harvestBlock(world, player, pos, state, te, tool);
  world.setBlockToAir(pos);
}

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

@Override
public void fillWithRain( final World w, final BlockPos pos )
{
  if( Platform.isServer() )
  {
    w.setBlockToAir( pos );
  }
}

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

@Override
public void cleanup()
{
  this.getWorld().setBlockToAir( this.pos );
}

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

@Override
public void neighborChanged( IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos )
{
  if( world.isBlockIndirectlyGettingPowered( pos ) > 0 )
  {
    this.startFuse( world, pos, null );
    world.setBlockToAir( pos );
  }
}

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

@Override
public void onEntityWalk( final World w, final BlockPos pos, final Entity entity )
{
  if( entity instanceof EntityArrow && !w.isRemote )
  {
    final EntityArrow entityarrow = (EntityArrow) entity;
    if( entityarrow.isBurning() )
    {
      this.startFuse( w, pos, entityarrow.shootingEntity instanceof EntityLivingBase ? (EntityLivingBase) entityarrow.shootingEntity : null );
      w.setBlockToAir( pos );
    }
  }
}

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

private void spawn()
{
  this.world.setBlockToAir( this.pos );
  final Item i = this.is.getItem();
  final EnumFacing side = EnumFacing.UP;
  final int half = (int) Math.floor( this.size / 2 );
  for( int y = 0; y < this.size; y++ )
  {
    for( int x = -half; x < half; x++ )
    {
      for( int z = -half; z < half; z++ )
      {
        final BlockPos p = this.pos.add( x, y - 1, z );
        i.onItemUse( this.who, this.world, p, EnumHand.MAIN_HAND, side, 0.5f, 0.0f, 0.5f );
      }
    }
  }
}

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

@Override
public void onBlockAdded( final World w, final BlockPos pos, final IBlockState state )
{
  super.onBlockAdded( w, pos, state );
  if( w.isBlockIndirectlyGettingPowered( pos ) > 0 )
  {
    this.startFuse( w, pos, null );
    w.setBlockToAir( pos );
  }
}

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

@Override
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ )
{
  if( heldItem != null && heldItem.getItem() == Items.FLINT_AND_STEEL )
  {
    this.startFuse( w, pos, player );
    w.setBlockToAir( pos );
    heldItem.damageItem( 1, player );
    return true;
  }
  else
  {
    return super.onActivated( w, pos, player, hand, heldItem, side, hitX, hitY, hitZ );
  }
}

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

public void setGeneration(TileEntity flower, int gen) {
  generation = gen;
  if(!ticked) {
    flowerCoords = flower.getPos();
    validCoords = getPos();
    ticked = true;
  } else if(!matchCoords(validCoords, this) || !matchCoords(flowerCoords, flower))
    world.setBlockToAir(pos);
}

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

@Override
public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, BlockPos pos, EnumFacing side) {
  if(player == null || world.isRemote)
    return false;
  if(!player.isSneaking()) {
    playerPositions.put(player.getUniqueID(), new DimWithPos(world.provider.getDimension(), pos));
    world.playSound(null, pos, ModSounds.ding, SoundCategory.BLOCKS, 0.5F, 1F);
  } else {
    spawnAsEntity(world, pos, new ItemStack(this));
    world.setBlockToAir(pos);
    world.playEvent(2001, pos, Block.getStateId(getDefaultState()));
  }
  return true;
}

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

void setBlockForGeneration(BlockPos pos, int gen, int prevGen) {
  World world = supertile.getWorld();
  IBlockState stateAt = world.getBlockState(pos);
  Block blockAt = stateAt.getBlock();
  TileEntity tile = world.getTileEntity(pos);
  if(gen == -2) {
    int val = Math.min(MAX_MANA_GENERATIONS, prevGen) * MANA_PER_GEN;
    mana = Math.min(getMaxMana(), mana + val);
    //world.setBlockToAir(x, y, z);
  } else if(blockAt == ModBlocks.cellBlock) {
    if(gen < 0)
      world.setBlockToAir(pos);
    else ((TileCell) tile).setGeneration(supertile, gen);
  } else if(gen >= 0 && blockAt.isAir(stateAt, supertile.getWorld(), pos)) {
    world.setBlockState(pos, ModBlocks.cellBlock.getDefaultState());
    tile = world.getTileEntity(pos);
    ((TileCell) tile).setGeneration(supertile, gen);
  }
}

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

@Override
public void onBurstCollision(IManaBurst burst, World world, BlockPos pos) {
  if(!burst.isFake() && !world.isRemote) {
    world.playEvent(2001, pos, Block.getStateId(getDefaultState()));
    world.setBlockToAir(pos);
    EntityManaStorm storm = new EntityManaStorm(world);
    storm.setPosition(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
    world.spawnEntity(storm);
  }
}

代码示例来源: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

@Override
public void onUpdate() {
  super.onUpdate();
  if(!supertile.getWorld().isRemote && ticksExisted % 5 == 0) {
    if(mana >= COST) {
      BlockPos coords = getCoordsToPut();
      if(coords != null) {
        supertile.getWorld().setBlockToAir(coords);
        if(ConfigHandler.blockBreakParticles)
          supertile.getWorld().playEvent(2001, coords, Block.getStateId(Blocks.SAND.getDefaultState()));
        EntityItem item = new EntityItem(supertile.getWorld(), coords.getX() + 0.5, coords.getY() + 0.5, coords.getZ() + 0.5, new ItemStack(Items.CLAY_BALL));
        supertile.getWorld().spawnEntity(item);
        mana -= COST;
      }
    }
  }
}

相关文章

微信公众号

最新文章

更多

World类方法