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

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

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

World.setBlockToAir介绍

暂无

代码示例

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

  1. @Override
  2. public void simulateBlockMine(BlockVector3 position) {
  3. BlockPos pos = ForgeAdapter.toBlockPos(position);
  4. IBlockState state = getWorld().getBlockState(pos);
  5. state.getBlock().dropBlockAsItem(getWorld(), pos, state, 0);
  6. getWorld().setBlockToAir(pos);
  7. }

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

  1. @Override
  2. public void update() {
  3. if(!world.isRemote) {
  4. if(ticks <= 0) {
  5. world.setBlockToAir(pos);
  6. } else ticks--;
  7. }
  8. }

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

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

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

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

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

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

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

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

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

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

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

  1. @Override
  2. public void fillWithRain( final World w, final BlockPos pos )
  3. {
  4. if( Platform.isServer() )
  5. {
  6. w.setBlockToAir( pos );
  7. }
  8. }

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

  1. @Override
  2. public void cleanup()
  3. {
  4. this.getWorld().setBlockToAir( this.pos );
  5. }

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

  1. @Override
  2. public void neighborChanged( IBlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos )
  3. {
  4. if( world.isBlockIndirectlyGettingPowered( pos ) > 0 )
  5. {
  6. this.startFuse( world, pos, null );
  7. world.setBlockToAir( pos );
  8. }
  9. }

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

  1. @Override
  2. public void onEntityWalk( final World w, final BlockPos pos, final Entity entity )
  3. {
  4. if( entity instanceof EntityArrow && !w.isRemote )
  5. {
  6. final EntityArrow entityarrow = (EntityArrow) entity;
  7. if( entityarrow.isBurning() )
  8. {
  9. this.startFuse( w, pos, entityarrow.shootingEntity instanceof EntityLivingBase ? (EntityLivingBase) entityarrow.shootingEntity : null );
  10. w.setBlockToAir( pos );
  11. }
  12. }
  13. }

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

  1. private void spawn()
  2. {
  3. this.world.setBlockToAir( this.pos );
  4. final Item i = this.is.getItem();
  5. final EnumFacing side = EnumFacing.UP;
  6. final int half = (int) Math.floor( this.size / 2 );
  7. for( int y = 0; y < this.size; y++ )
  8. {
  9. for( int x = -half; x < half; x++ )
  10. {
  11. for( int z = -half; z < half; z++ )
  12. {
  13. final BlockPos p = this.pos.add( x, y - 1, z );
  14. i.onItemUse( this.who, this.world, p, EnumHand.MAIN_HAND, side, 0.5f, 0.0f, 0.5f );
  15. }
  16. }
  17. }
  18. }

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

  1. @Override
  2. public void onBlockAdded( final World w, final BlockPos pos, final IBlockState state )
  3. {
  4. super.onBlockAdded( w, pos, state );
  5. if( w.isBlockIndirectlyGettingPowered( pos ) > 0 )
  6. {
  7. this.startFuse( w, pos, null );
  8. w.setBlockToAir( pos );
  9. }
  10. }

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

  1. @Override
  2. 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 )
  3. {
  4. if( heldItem != null && heldItem.getItem() == Items.FLINT_AND_STEEL )
  5. {
  6. this.startFuse( w, pos, player );
  7. w.setBlockToAir( pos );
  8. heldItem.damageItem( 1, player );
  9. return true;
  10. }
  11. else
  12. {
  13. return super.onActivated( w, pos, player, hand, heldItem, side, hitX, hitY, hitZ );
  14. }
  15. }

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

  1. public void setGeneration(TileEntity flower, int gen) {
  2. generation = gen;
  3. if(!ticked) {
  4. flowerCoords = flower.getPos();
  5. validCoords = getPos();
  6. ticked = true;
  7. } else if(!matchCoords(validCoords, this) || !matchCoords(flowerCoords, flower))
  8. world.setBlockToAir(pos);
  9. }

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

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

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

  1. void setBlockForGeneration(BlockPos pos, int gen, int prevGen) {
  2. World world = supertile.getWorld();
  3. IBlockState stateAt = world.getBlockState(pos);
  4. Block blockAt = stateAt.getBlock();
  5. TileEntity tile = world.getTileEntity(pos);
  6. if(gen == -2) {
  7. int val = Math.min(MAX_MANA_GENERATIONS, prevGen) * MANA_PER_GEN;
  8. mana = Math.min(getMaxMana(), mana + val);
  9. //world.setBlockToAir(x, y, z);
  10. } else if(blockAt == ModBlocks.cellBlock) {
  11. if(gen < 0)
  12. world.setBlockToAir(pos);
  13. else ((TileCell) tile).setGeneration(supertile, gen);
  14. } else if(gen >= 0 && blockAt.isAir(stateAt, supertile.getWorld(), pos)) {
  15. world.setBlockState(pos, ModBlocks.cellBlock.getDefaultState());
  16. tile = world.getTileEntity(pos);
  17. ((TileCell) tile).setGeneration(supertile, gen);
  18. }
  19. }

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

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

代码示例来源: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. @Override
  2. public void onUpdate() {
  3. super.onUpdate();
  4. if(!supertile.getWorld().isRemote && ticksExisted % 5 == 0) {
  5. if(mana >= COST) {
  6. BlockPos coords = getCoordsToPut();
  7. if(coords != null) {
  8. supertile.getWorld().setBlockToAir(coords);
  9. if(ConfigHandler.blockBreakParticles)
  10. supertile.getWorld().playEvent(2001, coords, Block.getStateId(Blocks.SAND.getDefaultState()));
  11. EntityItem item = new EntityItem(supertile.getWorld(), coords.getX() + 0.5, coords.getY() + 0.5, coords.getZ() + 0.5, new ItemStack(Items.CLAY_BALL));
  12. supertile.getWorld().spawnEntity(item);
  13. mana -= COST;
  14. }
  15. }
  16. }
  17. }

相关文章

World类方法