net.minecraft.util.math.BlockPos#getX ( )源码实例Demo

下面列出了net.minecraft.util.math.BlockPos#getX ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: malmo   文件: PositionHelper.java
public static List<BlockPos> getTouchingBlocks(EntityPlayerSP player)
{
	// Determine which blocks we are touching.
	// This code is adapted from Entity, where it is used to fire the Block.onEntityCollidedWithBlock methods.
	BlockPos blockposmin = new BlockPos(player.getEntityBoundingBox().minX - 0.001D, player.getEntityBoundingBox().minY - 0.001D, player.getEntityBoundingBox().minZ - 0.001D);
    BlockPos blockposmax = new BlockPos(player.getEntityBoundingBox().maxX + 0.001D, player.getEntityBoundingBox().maxY + 0.001D, player.getEntityBoundingBox().maxZ + 0.001D);
    List<BlockPos> blocks = new ArrayList<BlockPos>();
    
    if (player.world.isAreaLoaded(blockposmin, blockposmax))
    {
        for (int i = blockposmin.getX(); i <= blockposmax.getX(); ++i)
        {
            for (int j = blockposmin.getY(); j <= blockposmax.getY(); ++j)
            {
                for (int k = blockposmin.getZ(); k <= blockposmax.getZ(); ++k)
                {
                    blocks.add(new BlockPos(i, j, k));
                }
            }
        }
    }
    return blocks;
}
 
源代码2 项目: Galacticraft-Rewoven   文件: CoalGeneratorBlock.java
@Environment(EnvType.CLIENT)
@Override
public void randomDisplayTick(BlockState state, World world, BlockPos blockPos_1, Random rand) {
    if (world.getBlockEntity(blockPos_1) instanceof CoalGeneratorBlockEntity && ((CoalGeneratorBlockEntity) world.getBlockEntity(blockPos_1)).status == CoalGeneratorBlockEntity.CoalGeneratorStatus.ACTIVE || ((CoalGeneratorBlockEntity) world.getBlockEntity(blockPos_1)).status == CoalGeneratorBlockEntity.CoalGeneratorStatus.WARMING) {
        double x = (double) blockPos_1.getX() + 0.5D;
        double y = blockPos_1.getY();
        double z = (double) blockPos_1.getZ() + 0.5D;
        if (rand.nextDouble() < 0.1D) {
            world.playSound(x, y, z, SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false);
        }

        Direction direction_1 = state.get(FACING);
        Direction.Axis direction$Axis_1 = direction_1.getAxis();
        double d = rand.nextDouble() * 0.6D - 0.3D;
        double xo = direction$Axis_1 == Direction.Axis.X ? (double) direction_1.getOffsetX() * 0.52D : d;
        double yo = rand.nextDouble() * 6.0D / 16.0D;
        double zo = direction$Axis_1 == Direction.Axis.Z ? (double) direction_1.getOffsetZ() * 0.52D : d;
        world.addParticle(ParticleTypes.SMOKE, x + xo, y + yo, z + zo, 0.0D, 0.0D, 0.0D);
        world.addParticle(ParticleTypes.FLAME, x + xo, y + yo, z + zo, 0.0D, 0.0D, 0.0D);

    }
}
 
源代码3 项目: Valkyrien-Skies   文件: BlockAirshipEngineLore.java
@Override
public Vector getCustomBlockForcePosition(World world, BlockPos pos, IBlockState state,
    PhysicsObject physicsObject,
    double secondsToApply) {
    TileEntityPropellerEngine engineTile = (TileEntityPropellerEngine) world.getTileEntity(pos);
    if (engineTile != null) {
        VectorImmutable forceOutputNormal = engineTile.getForceOutputNormal(secondsToApply,
            physicsObject);
        // System.out.println(forceOutputNormal.getX() + ":" + forceOutputNormal.getY()
        // + ":" + forceOutputNormal.getZ());
        return new Vector(pos.getX() + .5D - forceOutputNormal.getX() * .75,
            pos.getY() + .5D - forceOutputNormal.getY() * .75,
            pos.getZ() + .5D - forceOutputNormal.getZ() * .75);
    } else {
        return null;
    }
}
 
源代码4 项目: CommunityMod   文件: Area.java
public void expandToFit(BlockPos bp) {
	if (startX == null || bp.getX() < startX) {
		startX = bp.getX();
	}
	if (endX == null || bp.getX() > endX) {
		endX = bp.getX();
	}

	if (startY == null || bp.getY() < startY) {
		startY = bp.getY();
	}
	if (endY == null || bp.getY() > endY) {
		endY = bp.getY();
	}

	if (startZ == null || bp.getZ() < startZ) {
		startZ = bp.getZ();
	}
	if (endZ == null || bp.getZ() > endZ) {
		endZ = bp.getZ();
	}
}
 
源代码5 项目: TofuCraftReload   文件: TofuVillage.java
/**
 * Checks to see if the volume around blockLocation is clear and able to fit blockSize
 */
private boolean isAreaClearAround(BlockPos blockSize, BlockPos blockLocation) {
    if (!this.world.getBlockState(blockLocation.down()).isSideSolid(world, blockLocation, EnumFacing.UP)) {
        return false;
    } else {
        int i = blockLocation.getX() - blockSize.getX() / 2;
        int j = blockLocation.getZ() - blockSize.getZ() / 2;

        for (int k = i; k < i + blockSize.getX(); ++k) {
            for (int l = blockLocation.getY(); l < blockLocation.getY() + blockSize.getY(); ++l) {
                for (int i1 = j; i1 < j + blockSize.getZ(); ++i1) {
                    if (this.world.getBlockState(new BlockPos(k, l, i1)).isNormalCube()) {
                        return false;
                    }
                }
            }
        }

        return true;
    }
}
 
源代码6 项目: TofuCraftReload   文件: WorldGenCrops.java
@Override
public boolean generate(World par1World, Random par2Random, BlockPos pos) {
	int x = pos.getX();
	int y = pos.getY();
	int z = pos.getZ();
	BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos();
	
	
    for (int l = 0; l < 64; ++l)
    {
        int i1 = x + par2Random.nextInt(8) - par2Random.nextInt(8);
        int j1 = y + par2Random.nextInt(4) - par2Random.nextInt(4);
        int k1 = z + par2Random.nextInt(8) - par2Random.nextInt(8);
        mutable.setPos(i1, j1, k1);
        IBlockState state = this.getStateToPlace();
        
        if (par1World.isAirBlock(mutable) && this.plantBlock.canBlockStay(par1World, mutable, state))
        {
            par1World.setBlockState(mutable, state, 2);
        }
    }

    return true;
}
 
源代码7 项目: enderutilities   文件: ItemEnderTool.java
public boolean useHoeArea(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, int rWidth, int rHeight)
{
    boolean northSouth = (((int)MathHelper.floor(player.rotationYaw * 4.0f / 360.0f + 0.5f)) & 1) == 0;
    boolean retValue = false;

    if (northSouth == false)
    {
        int tmp = rWidth;
        rWidth = rHeight;
        rHeight = tmp;
    }

    for (int x = pos.getX() - rWidth; x <= (pos.getX() + rWidth); ++x)
    {
        for (int z = pos.getZ() - rHeight; z <= (pos.getZ() + rHeight); ++z)
        {
            retValue |= this.useHoe(stack, player, world, new BlockPos(x, pos.getY(), z), side);
        }
    }

    return retValue;
}
 
源代码8 项目: TofuCraftReload   文件: BlockSoyMilk.java
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) {
    super.randomDisplayTick(state, world, pos, rand);
    if (world.getBlockState(pos.up()).getMaterial() != Material.WATER && rand.nextInt(3) == 0)
    {
        if (this.getHeatStrength(world, pos) > 0)
        {
            float steamX = pos.getX() + 0.5F;
            float steamY = pos.getY() + 0.9F;
            float steamZ = pos.getZ() + 0.5F;
            float steamRandX = rand.nextFloat() * 0.6F - 0.3F;
            float steamRandZ = rand.nextFloat() * 0.6F - 0.3F;
            double gRand1 = rand.nextGaussian() * 0.01D;
            double gRand2 = rand.nextGaussian() * 0.01D;
            double gRand3 = rand.nextGaussian() * 0.01D;
            world.spawnParticle(EnumParticleTypes.EXPLOSION_NORMAL, (steamX + steamRandX), steamY, (steamZ + steamRandZ), gRand1, gRand2, gRand3);
        }
    }
}
 
源代码9 项目: EnderZoo   文件: EntityUtil.java
public static BlockPos findRandomLandingSurface(EntityLiving entity, int searchRange, int minY, int maxY) {
  BlockPos ep = entity.getPosition();
  World worldObj = entity.getEntityWorld();
  int x = ep.getX() + -searchRange + (worldObj.rand.nextInt(searchRange + 1) * 2);
  int z = ep.getZ() + -searchRange + (worldObj.rand.nextInt(searchRange + 1) * 2);
  return findClearLandingSurface(entity, x, z, minY, maxY);
}
 
源代码10 项目: Production-Line   文件: BlockWaterHyacinth.java
@Override
public void randomTick(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull Random rand) {
    int changedX = rand.nextInt(5) - 3 + pos.getX();
    int changedZ = rand.nextInt(5) - 3 + pos.getZ();
    BlockPos check = new BlockPos(changedX, pos.getY(), changedZ);
    if ((world.isAirBlock(check)) && (this.canSustainBush(world.getBlockState(check.down())))) {
        world.setBlockState(pos, getDefaultState());
    }
}
 
源代码11 项目: Sakura_mod   文件: BlockCampfirePot.java
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
    double d0 = pos.getX() + 0.5D;
    double d2 = pos.getZ() + 0.5D;
    double d4 = rand.nextDouble() * 0.4D - 0.2D;
    if (this.isBurning) {
        worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, pos.getY() + 0.2D, d2 + d4, 0.0D, 0.0D, 0.0D);
        worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, pos.getY() + 0.2D, d2 + d4, 0.0D, 0.0D, 0.0D);

        if (rand.nextDouble() < 0.15D) {
            worldIn.playSound(pos.getX() + 0.5D, pos.getY(), pos.getZ() + 0.5D, SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false);
        }
    }
}
 
源代码12 项目: TFC2   文件: BlockLeaves.java
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand)
{
	if ((worldIn.isRainingAt(pos.up())) && (!worldIn.getBlockState(pos.down()).isFullyOpaque()) && (rand.nextInt(15) == 1))
	{
		double d0 = pos.getX() + rand.nextFloat();
		double d1 = pos.getY() - 0.05D;
		double d2 = pos.getZ() + rand.nextFloat();
		worldIn.spawnParticle(EnumParticleTypes.DRIP_WATER, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]);
	}
}
 
源代码13 项目: litematica   文件: SchematicUtils.java
@Nullable
public static BlockPos getSchematicContainerPositionFromWorldPosition(BlockPos worldPos, ISchematic schematic, String regionName,
        SchematicPlacement schematicPlacement, SubRegionPlacement regionPlacement, ILitematicaBlockStateContainer container)
{
    ISchematicRegion region = schematic.getSchematicRegion(regionName);

    if (region == null)
    {
        return null;
    }

    BlockPos boxMinRel = getReverseTransformedWorldPosition(worldPos, schematic, schematicPlacement, regionPlacement, region.getSize());

    if (boxMinRel == null)
    {
        return null;
    }

    final int startX = boxMinRel.getX();
    final int startY = boxMinRel.getY();
    final int startZ = boxMinRel.getZ();
    Vec3i size = container.getSize();

    /*
    if (startX < 0 || startY < 0 || startZ < 0 || startX >= size.getX() || startY >= size.getY() || startZ >= size.getZ())
    {
        System.out.printf("DEBUG ============= OUT OF BOUNDS - region: %s, startX: %d, startY %s, startZ: %d - size x: %d y: %s z: %d =============\n",
                regionName, startX, startY, startZ, size.getX(), size.getY(), size.getZ());
        return null;
    }

    return boxMinRel;
    */

    return new BlockPos(MathHelper.clamp(startX, 0, size.getX() - 1),
                        MathHelper.clamp(startY, 0, size.getY() - 1),
                        MathHelper.clamp(startZ, 0, size.getZ() - 1));
}
 
源代码14 项目: OpenModsLib   文件: BlockUtils.java
public static AxisAlignedBB singleBlock(BlockPos pos) {
	return new AxisAlignedBB(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1);
}
 
源代码15 项目: Sakura_mod   文件: WorldGenBigSakura.java
public FoliageCoordinates(BlockPos pos, int p_i45635_2_)
{
    super(pos.getX(), pos.getY(), pos.getZ());
    this.branchBase = p_i45635_2_;
}
 
源代码16 项目: the-hallow   文件: CraftingFluidBlock.java
private void spawnCraftingResult(World world, BlockPos pos, ItemStack result) {
	ItemEntity itemEntity = new ItemEntity(world, pos.getX() + .5, pos.getY() + 1, pos.getZ() + .5, result);
	world.spawnEntity(itemEntity);
	// todo: add particles and/or an animation when dropping the recipe result
}
 
源代码17 项目: OpenModsLib   文件: BlockUtils.java
public static AxisAlignedBB expandAround(BlockPos pos, int x, int y, int z) {
	return new AxisAlignedBB(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + x, pos.getY() + y, pos.getZ() + z);
}
 
源代码18 项目: GregTech   文件: NetworkHandler.java
public static TargetPoint blockPoint(World world, BlockPos blockPos) {
    return new TargetPoint(world.provider.getDimension(), blockPos.getX() + 0.5, blockPos.getY() + 0.5, blockPos.getZ() + 0.5, 128.0);
}
 
源代码19 项目: malmo   文件: NearbySmeltCommandsImplementation.java
@Override
public IMessage onMessage(SmeltNearbyMessage message, MessageContext ctx) {
    EntityPlayerMP player = ctx.getServerHandler().playerEntity;
    Vec3d headPos = new Vec3d(player.posX, player.posY + 1.6, player.posZ);

    // Location checking
    boolean closeFurnace = false;
    for (BlockPos furnace : furnaces) {
        Vec3d blockVec = new Vec3d(furnace.getX() + 0.5, furnace.getY() + 0.5, furnace.getZ() + 0.5);

        if (headPos.squareDistanceTo(blockVec) <= 25.0) {
            // Within a reasonable FOV?
            // Lots of trig, let's go
            double fov = Minecraft.getMinecraft().gameSettings.fovSetting;
            double height = Minecraft.getMinecraft().displayHeight;
            double width = Minecraft.getMinecraft().displayWidth;
            Vec3d lookVec = player.getLookVec();
            Vec3d toBlock = blockVec.subtract(headPos);

            // Projection of block onto player look vector - if greater than 0, then in front of us
            double scalarProjection = lookVec.dotProduct(toBlock) / lookVec.lengthVector();
            if (scalarProjection > 0) {
                Vec3d yUnit = new Vec3d(0, 1.0, 0);
                Vec3d lookCross = lookVec.crossProduct(yUnit);
                Vec3d blockProjectedOntoCross = lookCross.scale(lookCross.dotProduct(toBlock) / lookCross.lengthVector());
                Vec3d blockProjectedOntoPlayerPlane = toBlock.subtract(blockProjectedOntoCross);
                double xyDot = lookVec.dotProduct(blockProjectedOntoPlayerPlane);
                double pitchTheta = Math.acos(xyDot / (lookVec.lengthVector() * blockProjectedOntoPlayerPlane.lengthVector()));

                Vec3d playerY = lookCross.crossProduct(lookVec);
                Vec3d blockProjectedOntoPlayerY = playerY.scale(playerY.dotProduct(toBlock) / playerY.lengthVector());
                Vec3d blockProjectedOntoYawPlane = toBlock.subtract(blockProjectedOntoPlayerY);
                double xzDot = lookVec.dotProduct(blockProjectedOntoYawPlane);
                double yawTheta = Math.acos(xzDot / (lookVec.lengthVector() * blockProjectedOntoYawPlane.lengthVector()));

                if (Math.abs(Math.toDegrees(yawTheta)) <= Math.min(1, width / height) * (fov / 2.0) && Math.abs(Math.toDegrees(pitchTheta)) <= Math.min(1, height / width) * (fov / 2.0))
                    closeFurnace = true;
            }
        }
    }

    if (closeFurnace) {
        ItemStack input = CraftingHelper.getSmeltingRecipeForRequestedOutput(message.parameters);
        if (input != null)
            if (CraftingHelper.attemptSmelting(player, input))
                return null;
    }

    return null;
}
 
源代码20 项目: Sakura_mod   文件: WorldGenMapleTree.java
/**
 * Fill the given area with the selected blocks
 */
private void fallenLeaves(World worldIn,BlockPos pos, int xADD, int yADD, int zADD, IBlockState insideBlockState){
	int xx = pos.getX();
    int yy = pos.getY();
    int zz = pos.getZ();
    
    boolean setFlg = false;
    int YEND = 4;
    for (int xx1 = xx - xADD; xx1 <= xx + xADD; xx1++) {
      for (int zz1 = zz - zADD; zz1 <= zz + zADD; zz1++) {
        if (((xx1 != xx - xADD) || (zz1 != zz - zADD)) && ((xx1 != xx + xADD) || (zz1 != zz - zADD)) && ((xx1 != xx - xADD) || (zz1 != zz + zADD)) && ((xx1 != xx + xADD) || (zz1 != zz + zADD)) && (((xx1 >= xx - xADD + 1) && (xx1 <= xx + xADD - 1) && (zz1 >= zz - zADD + 1) && (zz1 <= zz + zADD - 1)) || (worldIn.rand.nextInt(2) != 0)))
        {
          setFlg = false;
          int yy1 = yy + yADD;
          Block cBl = worldIn.getBlockState(new BlockPos(xx1, yy + yADD, zz1)).getBlock();
          
          if ((cBl == Blocks.AIR) || (cBl instanceof BlockLeaves) || (cBl == BlockLoader.CHESTNUTBURR)) {
            for (yy1 = yy + yADD; yy1 >= yy - YEND; yy1--)
            {
              boolean cAir = worldIn.isAirBlock(new BlockPos(xx1, yy1, zz1));
              cBl = worldIn.getBlockState(new BlockPos(xx1, yy1 - 1, zz1)).getBlock();
              if ((cBl == Blocks.AIR) || ((cBl != Blocks.GRASS) && !(cBl instanceof BlockLeaves) && (!worldIn.getBlockState(new BlockPos(xx1, yy1 - 1, zz1)).isOpaqueCube())))
              {
                if (cBl != Blocks.AIR) {
                  break;
                }
              }
              else if (cAir)
              {
                setFlg = true;
                break;
              }
            }
          }
          if (setFlg) {
            setBlockAndNotifyAdequately(worldIn, new BlockPos(xx1, yy1, zz1), insideBlockState);
          }
        }
      }
    }
}