net.minecraft.util.math.BlockPos类的使用及代码示例

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

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

BlockPos介绍

暂无

代码示例

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

/**
   * Returns the multiblock component for the coordinates, adjusted based on the anchor
   */
  private MultiblockComponent getComponent(BlockPos pos) {
    return multiblock.getComponentForLocation(pos.add(new BlockPos(-anchorPos.getX(), -anchorPos.getY(), -anchorPos.getZ())));
  }
}

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

public static void removeBlocksInIteration(EntityPlayer player, ItemStack stack, World world, BlockPos centerPos,
                      Vec3i startDelta, Vec3i endDelta, Predicate<IBlockState> filter,
                      boolean dispose) {
  for (BlockPos iterPos : BlockPos.getAllInBox(centerPos.add(startDelta), centerPos.add(endDelta))) {
    if (iterPos.equals(centerPos)) // skip original block space to avoid crash, vanilla code in the tool class will handle it
      continue;
    removeBlockWithDrops(player, stack, world, iterPos, filter, dispose);
  }
}

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

public static BlockVector3 adapt(BlockPos pos) {
  return BlockVector3.at(pos.getX(), pos.getY(), pos.getZ());
}

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

@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
  super.onBlockAdded(world, pos, state);
  if(!world.isRemote && world.getBlockState(pos.down()).getBlock() == Blocks.IRON_BARS && world.getBlockState(pos.down(2)).getBlock() == Blocks.IRON_BARS) {
    world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
    world.setBlockState(pos.down(), Blocks.AIR.getDefaultState(), 2);
    world.setBlockState(pos.down(2), Blocks.AIR.getDefaultState(), 2);
    EntityBlaze blaze = new EntityBlaze(world);
    blaze.setLocationAndAngles(pos.getX() + 0.5D, pos.getY() - 1.95D, pos.getZ() + 0.5D, 0.0F, 0.0F);
    blaze.deathLootTable = LOOT_TABLE;
    blaze.onInitialSpawn(world.getDifficultyForLocation(pos), null);
    world.spawnEntity(blaze);
    world.notifyNeighborsOfStateChange(pos, Blocks.AIR, false);
    world.notifyNeighborsOfStateChange(pos.down(), Blocks.AIR, false);
    world.notifyNeighborsOfStateChange(pos.down(2), Blocks.AIR, false);
  }
}

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

@Override
public BaseBiome getBiome(BlockVector2 position) {
  checkNotNull(position);
  return new BaseBiome(Biome.getIdForBiome(getWorld().getBiomeForCoordsBody(new BlockPos(position.getBlockX(), 0, position.getBlockZ()))));
}

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

@Override
public void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor )
{
  if( pos.offset( this.getSide().getFacing() ).equals( neighbor ) )
  {
    this.refresh();
  }
}

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

boolean checkAll(BlockPos[] relPositions, Block block) {
  for (BlockPos position : relPositions) {
    if(!checkPlatform(position.getX(), position.getZ(), block))
      return false;
  }
  return true;
}

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

@Override
public boolean shouldSideBeRendered(IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, EnumFacing side) {
  if (world.getBlockState(pos.offset(side)).getBlock() == this) {
    return false;
  }
  return super.shouldSideBeRendered(state, world, pos, side);
}

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

@Override
public ISparkEntity getAttachedSpark() {
  List sparks = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos.up(), pos.up().add(1, 1, 1)), Predicates.instanceOf(ISparkEntity.class));
  if(sparks.size() == 1) {
    Entity e = (Entity) sparks.get(0);
    return (ISparkEntity) e;
  }
  return null;
}

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

public static MultiblockSet makeMultiblockSet() {
  Multiblock mb = new Multiblock();
  for(BlockPos p : PYLON_LOCATIONS)
    mb.addComponent(p.up(), ModBlocks.pylon.getDefaultState().withProperty(BotaniaStateProps.PYLON_VARIANT, PylonVariant.GAIA));
  for(int i = 0; i < 3; i++)
    for(int j = 0; j < 3; j++)
      mb.addComponent(new BeaconComponent(new BlockPos(i - 1, 0, j - 1)));
  mb.addComponent(new BeaconBeamComponent(new BlockPos(0, 1, 0)));
  mb.setRenderOffset(new BlockPos(0, -1, 0));
  return mb.makeSet();
}

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

public List<BlockPos> locatePylons() {
  List<BlockPos> list = new ArrayList();
  int range = 5;
  IBlockState pylonState = ModBlocks.pylon.getDefaultState().withProperty(BotaniaStateProps.PYLON_VARIANT, PylonVariant.NATURA);
  IBlockState poolState = ModBlocks.pool.getDefaultState();
  for(int i = -range; i < range + 1; i++)
    for(int j = -range; j < range + 1; j++)
      for(int k = -range; k < range + 1; k++) {
        BlockPos pos = new BlockPos(i, j, k);
        if(checkPosition(pos, pylonState, false) && checkPosition(pos.down(), poolState, true))
          list.add(pos);
      }
  return list;
}

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

@Override
public boolean canSustainPlant(@Nonnull IBlockState state, @Nonnull IBlockAccess world, BlockPos pos, @Nonnull EnumFacing direction, IPlantable plantable) {
  EnumPlantType type = plantable.getPlantType(world, pos.down());
  return type == EnumPlantType.Plains || type == EnumPlantType.Beach;
}

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

@Override
public boolean canBlockStay(@Nonnull World worldIn, BlockPos pos, IBlockState state)
{
  if (pos.getY() >= 0 && pos.getY() < 256)
  {
    IBlockState iblockstate = worldIn.getBlockState(pos.down());
    return iblockstate.getBlock() == Blocks.MYCELIUM
        || (iblockstate.getBlock() == Blocks.DIRT && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.PODZOL
        || iblockstate.getBlock().canSustainPlant(iblockstate, worldIn, pos.down(), net.minecraft.util.EnumFacing.UP, this));
  }
  else
  {
    return false;
  }
}

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

public List<ItemStack> getFilter() {
  List<ItemStack> filter = new ArrayList<>();
  for(EnumFacing dir : EnumFacing.HORIZONTALS) {
    List<EntityItemFrame> frames = world.getEntitiesWithinAABB(EntityItemFrame.class, new AxisAlignedBB(pos.offset(dir), pos.offset(dir).add(1, 1, 1)));
    for(EntityItemFrame frame : frames) {
      EnumFacing orientation = frame.facingDirection;
      if(orientation == dir)
        filter.add(frame.getDisplayedItem());
    }
  }
  return filter;
}

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

public static boolean canEnchanterExist(World world, BlockPos pos, EnumFacing.Axis axis) {
  for(BlockPos obsidian : OBSIDIAN_LOCATIONS)
    if(world.getBlockState(pos.add(obsidian)).getBlock() != Blocks.OBSIDIAN)
      return false;
  for(BlockPos pylon : PYLON_LOCATIONS.get(axis))
    if(world.getBlockState(pos.add(pylon)).getBlock() != ModBlocks.pylon || !BotaniaAPI.internalHandler.isBotaniaFlower(world, pos.add(pylon).down()))
      return false;
  for(BlockPos flower : FLOWER_LOCATIONS)
    if(!BotaniaAPI.internalHandler.isBotaniaFlower(world, pos.add(flower)))
      return false;
  return true;
}

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

@Override
public boolean equals(Object other) {
  if(!(other instanceof SwapCandidate)) return false;
  SwapCandidate cand = (SwapCandidate) other;
  return coordinates.equals(cand.coordinates) && range == cand.range;
}

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

private AxisAlignedBB getPortalAABB() {
  AxisAlignedBB aabb = new AxisAlignedBB(pos.add(-1, 1, 0), pos.add(2, 4, 1));
  if(world.getBlockState(getPos()).getValue(BotaniaStateProps.ALFPORTAL_STATE) == AlfPortalState.ON_X)
    aabb = new AxisAlignedBB(pos.add(0, 1, -1), pos.add(1, 4, 2));
  return aabb;
}

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

@Override
public boolean acceptBlock(BlockPos pos) {
  if(pos.equals(getPos().up()))
    return false;
  Block block = world.getBlockState(pos).getBlock();
  TileEntity tile = world.getTileEntity(pos);
  return (block instanceof BlockFlower || block instanceof BlockMushroom || block instanceof BlockDoublePlant) && (tile == null || !(tile instanceof ISubTileContainer));
}

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

@Override
public void addCollisionBoxToList(IBlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull AxisAlignedBB par5AxisAlignedBB, @Nonnull List<AxisAlignedBB> stacks, Entity par7Entity, boolean isActualState) {
  PlatformVariant variant = state.getValue(BotaniaStateProps.PLATFORM_VARIANT);
  if(variant == PlatformVariant.INFRANGIBLE || variant == PlatformVariant.ABSTRUSE && par7Entity != null && par7Entity.posY > pos.getY() + 0.9 && (!(par7Entity instanceof EntityPlayer) || !par7Entity.isSneaking()))
    super.addCollisionBoxToList(state, world, pos, par5AxisAlignedBB, stacks, par7Entity, isActualState);
}

相关文章