net.minecraft.block.Block.isReplaceable()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(228)

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

Block.isReplaceable介绍

暂无

代码示例

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

private boolean canReplace( World w, IBlockState state, Block block, BlockPos pos )
{
  return block.isReplaceable( w, pos ) && !( block instanceof IFluidBlock ) && !( block instanceof BlockLiquid ) && !state.getMaterial().isLiquid();
}

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

private boolean placeBlock(ItemStack itemstack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float xOffset, float yOffset, float zOffset) {
  IBlockState iblockstate = world.getBlockState(pos);
  Block block = iblockstate.getBlock();
  if(!block.isReplaceable(world, pos)) {
    pos = pos.offset(side);
  }
  if(itemstack.isEmpty()) {
    return false;
  } else if(!player.canPlayerEdit(pos, side, itemstack)) {
    return false;
  } else if(world.mayPlace(Blocks.MOB_SPAWNER, pos, false, side, null)) {
    int meta = this.getMetadata(itemstack.getMetadata());
    IBlockState iblockstate1 = Blocks.MOB_SPAWNER.getStateForPlacement(world, pos, side, xOffset, yOffset, zOffset, meta, player);
    if (placeBlockAt(itemstack, player, world, pos, side, xOffset, yOffset, zOffset, iblockstate1)) {
      world.playSound(null, pos, Blocks.MOB_SPAWNER.getSoundType().getPlaceSound(), SoundCategory.BLOCKS, (Blocks.MOB_SPAWNER.getSoundType().getVolume() + 1.0F) / 2.0F, Blocks.MOB_SPAWNER.getSoundType().getPitch() * 0.8F);
      player.renderBrokenItemStack(itemstack);
      itemstack.shrink(1);
      for(int i = 0; i < 100; i++)
        Botania.proxy.sparkleFX(pos.getX() + Math.random(), pos.getY() + Math.random(), pos.getZ() + Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), 0.45F + 0.2F * (float) Math.random(), 6);
    }
    return true;
  } else {
    return false;
  }
}

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

if( blk.isReplaceable( w.getWorld(), new BlockPos( i, j, k ) ) )
    if( !xf.isReplaceable( w.getWorld(), new BlockPos( i, j - 1, k ) ) )

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

BlockPos pos_ = pos.offset(dir);
Block block_ = world.getBlockState(pos_).getBlock();
if(block_.isAir(world.getBlockState(pos_), world, pos_) || block_.isReplaceable(world, pos_) || block_ instanceof BlockFlower && !(block_ instanceof ISpecialFlower) || block_ == Blocks.DOUBLE_PLANT) {
  airBlocks.add(pos_);

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

IBlockState state = player.world.getBlockState(pos);
Block block = state.getBlock();
if(block.isReplaceable(player.world, pos))
  pos = pos.down();
      Block block1 = state1.getBlock();
      if(player.world.getWorldBorder().contains(newPos)
          && (block1.isAir(state1, player.world, newPos) || block1.isReplaceable(player.world, newPos)))
        coords.add(newPos);

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

@Override
public void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor )
{
  if( pos.offset( this.getSide().getFacing() ).equals( neighbor ) )
  {
    final TileEntity te = this.getHost().getTile();
    final AEPartLocation side = this.getSide();
    final BlockPos tePos = te.getPos().offset( side.getFacing() );
    this.blocked = !w.getBlockState( tePos ).getBlock().isReplaceable( w, tePos );
  }
}

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

@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
  // Copy of ItemBlock.onItemUse
  IBlockState iblockstate = world.getBlockState(pos);
  Block block = iblockstate.getBlock();
  if (!block.isReplaceable(world, pos))
  {
    pos = pos.offset(facing);
  }
  ItemStack stack = player.getHeldItem(hand);
  if (!stack.isEmpty() && player.canPlayerEdit(pos, facing, stack) && world.mayPlace(ModBlocks.buriedPetals, pos, false, facing, null))
  {
    int i = this.getMetadata(stack.getMetadata());
    IBlockState iblockstate1 = ModBlocks.buriedPetals.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, i, player);
    if (placeBlockAt(stack, player, world, pos, facing, hitX, hitY, hitZ, iblockstate1))
    {
      SoundType soundtype = ModBlocks.buriedPetals.getSoundType();
      world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
      stack.shrink(1);
    }
    return EnumActionResult.SUCCESS;
  }
  else
  {
    return EnumActionResult.FAIL;
  }
}

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

return EnumActionResult.FAIL;
} else {
  if (worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos)) {
    facing = EnumFacing.UP;
    pos = pos.down();
  boolean flag = block.isReplaceable(worldIn, pos);

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

if( whatsThere.isReplaceable( w, hitPos ) && w.isAirBlock( hitPos ) )

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

@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);
    Block blockAt = entity.world.getBlockState(pos.getBlockPos()).getBlock();
    Block blockAt_ = entity.world.getBlockState(pos_).getBlock();
    if(blockAt == ModBlocks.manaFlame)
      entity.world.setBlockState(pos.getBlockPos(), Blocks.AIR.getDefaultState());
    else if(blockAt_.isAir(entity.world.getBlockState(pos_), entity.world, pos_) || blockAt_.isReplaceable(entity.world, pos_)) {
      entity.world.setBlockState(pos_, ModBlocks.manaFlame.getDefaultState());
      TileEntity tile = entity.world.getTileEntity(pos_);
      if(tile instanceof TileManaFlame)
        ((TileManaFlame) tile).setColor(burst.getColor());
    }
  }
  return dead;
}

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

if(filter == supertile.getWorld().getBlockState(pos_)
    && (blockAbove.isAir(stateAbove, supertile.getWorld(), up)
        || blockAbove.isReplaceable(supertile.getWorld(), up)))
  validPositions.add(up);

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

protected boolean canMakeSnow(@Nonnull World world, final @Nonnull BlockPos neighborPos, final @Nonnull IBlockState neighborState) {
 final BlockPos belowNeighborPos = neighborPos.down();
 final Block neighborBlock = neighborState.getBlock();
 return neighborBlock != Blocks.SNOW_LAYER && !(neighborBlock instanceof IFluidBlock) && !(neighborBlock instanceof BlockLiquid)
   && neighborBlock.isReplaceable(world, neighborPos) && world.getBlockState(belowNeighborPos).isSideSolid(world, belowNeighborPos, EnumFacing.UP);
}

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

private boolean isValidPlantingSpot(@Nonnull World world, @Nonnull BlockPos pos) {
 for (int x = -1; x <= 1; x++) {
  for (int y = 0; y <= 1; y++) {
   for (int z = -1; z <= 1; z++) {
    if (!world.getBlockState(pos.add(x, y, z)).getBlock().isReplaceable(world, pos.add(x, y, z))) {
     return false;
    }
   }
  }
 }
 return true;
}

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

if( blkID != null && !blkID.isReplaceable( world, pos ) )
  if( blkID == null || blkID.isReplaceable( world, te_pos ) || host != null )

代码示例来源:origin: Alex-the-666/Ice_and_Fire

public boolean canPlaceBlockAt(World worldIn, BlockPos pos) {
  IBlockState soil = worldIn.getBlockState(pos.down());
  if (this == ModBlocks.fire_lily) {
    return worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos) && (soil.getMaterial() == Material.SAND || soil.getBlock() == Blocks.NETHERRACK);
  } else {
    return worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos) && (soil.getMaterial() == Material.PACKED_ICE || soil.getMaterial() == Material.ICE);
  }
}

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

if( w.getBlockState( tePos ).getBlock().isReplaceable( w, tePos ) )
this.blocked = !w.getBlockState( tePos ).getBlock().isReplaceable( w, tePos );

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

IBlockState state = world.getBlockState(pos_);
Block block = state.getBlock();
if(!block.isAir(state, world, pos_) && !block.isReplaceable(world, pos_) && !(block instanceof BlockFalling) && (!(block instanceof ILaputaImmobile) || ((ILaputaImmobile) block).canMove(world, pos_)) && state.getBlockHardness(world, pos_) != -1) {
  TileEntity tile = world.getTileEntity(pos_);

代码示例来源:origin: ForestryMC/ForestryMC

public static boolean canPlaceTree(IBlockState blockState, World world, BlockPos pos) {
  BlockPos downPos = pos.down();
  Block block = world.getBlockState(downPos).getBlock();
  return !(block.isReplaceable(world, downPos) &&
    blockState.getMaterial().isLiquid()) &&
    !block.isLeaves(blockState, world, downPos) &&
    !block.isWood(world, downPos);
}

相关文章

Block类方法