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

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

源代码1 项目: EnderZoo   文件: BlockConfusingCharge.java
public void explode(World world, BlockPos pos, IBlockState state, EntityLivingBase igniter) {
  if (!world.isRemote) {
    if (((Boolean) state.getValue(EXPLODE)).booleanValue()) {
      // EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(worldIn,
      // (double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() +
      // 0.5F), (double)((float)pos.getZ() + 0.5F), igniter);
      // worldIn.spawnEntityInWorld(entitytntprimed);
      // worldIn.playSoundAtEntity(entitytntprimed, "game.tnt.primed", 1.0F,
      // 1.0F);

      EntityPrimedCharge entity = new EntityPrimedCharge(this, world, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, igniter);
      world.spawnEntity(entity);
      world.playSound((EntityPlayer)null, entity.posX, entity.posY, entity.posZ, SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1, 1);
      
      world.updateEntity(entity);
    }
  }
}
 
源代码2 项目: ToroQuest   文件: GraveyardGenerator.java
private boolean levelEnough(BlockPos pos, int rows, int cols) {
	int max = 0, min = 1000;
	int y;
	BlockPos surf;
	for (int x = -2; x <= cols * 2; x++) {
		for (int z = -1; z <= rows * 4 - 2; z++) {
			surf = findSurface(pos.add(x, 0, z));
			if (surf == null) {
				return false;
			}
			y = surf.getY();
			max = Math.max(y, max);
			min = Math.min(y, min);
		}
	}
	return max - min < 5;
}
 
源代码3 项目: BetterChests   文件: TreeHandler.java
@Override
public boolean handleHarvest(IBetterChest chest, IBlockState state, World world, BlockPos pos) {
	MutableBlockPos start = new MutableBlockPos(pos);
	while (canBreak(world, start)) {
		start.move(EnumFacing.UP);
	}
	start.move(EnumFacing.DOWN);

	if (start.getY() >= pos.getY()) {
		BlockPos target = search(world, pos);
		IBlockState targetState = world.getBlockState(target);
		targetState.getBlock().breakBlock(world, pos, state);
		PlantHarvestHelper.breakBlockHandleDrop(world, target, targetState, chest);
		return true;
	}
	return false;
}
 
源代码4 项目: Sakura_mod   文件: BlockMapleLeaveRed.java
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
	Blocks.LEAVES.randomDisplayTick(stateIn, worldIn, pos, rand);
    if (rand.nextInt(40) == 0) {
        int j = rand.nextInt(2) * 2 - 1;
        int k = rand.nextInt(2) * 2 - 1;

        double d0 = pos.getX() + 0.5D + 0.25D * j;
        double d1 = pos.getY() - 0.15D;
        double d2 = pos.getZ() + 0.5D + 0.25D * k;
        double d3 = rand.nextFloat() * j * 0.1D;
        double d4 = ((rand.nextFloat()) * 0.055D) + 0.015D;
        double d5 = rand.nextFloat() * k * 0.1D;

        SakuraMain.proxy.spawnParticle(SakuraParticleType.MAPLERED, d0, d1, d2, d3, -d4, d5);
    }
}
 
源代码5 项目: enderutilities   文件: Effects.java
public static void spawnParticlesAround(World world, EnumParticleTypes type, BlockPos pos, int count, Random rand)
{
    for (int i = 0; i < count; ++i)
    {
        int i1 = rand.nextInt(2) * 2 - 1;
        int j1 = rand.nextInt(2) * 2 - 1;

        double x1 = (double)pos.getX() + 0.5D + 0.25D * (double)i1;
        double y1 = (double)((float)pos.getY() + rand.nextFloat());
        double z1 = (double)pos.getZ() + 0.5D + 0.25D * (double)j1;

        double vx = (double)(rand.nextFloat() * 1.0F * (float)i1);
        double vy = ((double)rand.nextFloat() - 0.5D) * 0.125D;
        double vz = (double)(rand.nextFloat() * 1.0F * (float)j1);

        world.spawnParticle(type, x1, y1, z1, vx, vy, vz);
    }
}
 
源代码6 项目: seppuku   文件: NukerModule.java
private BlockPos getClosestBlockAll() {
    final Minecraft mc = Minecraft.getMinecraft();
    float maxDist = this.distance.getValue();

    BlockPos ret = null;

    for (float x = maxDist; x >= -maxDist; x--) {
        for (float y = maxDist; y >= -maxDist; y--) {
            for (float z = maxDist; z >= -maxDist; z--) {
                final BlockPos pos = new BlockPos(mc.player.posX + x, mc.player.posY + y, mc.player.posZ + z);
                final double dist = mc.player.getDistance(pos.getX(), pos.getY(), pos.getZ());
                if (dist <= maxDist && (mc.world.getBlockState(pos).getBlock() != Blocks.AIR && !(mc.world.getBlockState(pos).getBlock() instanceof BlockLiquid)) && canBreak(pos)) {
                    if (pos.getY() >= mc.player.posY) {
                        maxDist = (float) dist;
                        ret = pos;
                    }
                }
            }
        }
    }

    return ret;
}
 
源代码7 项目: pycode-minecraft   文件: HandItem.java
@Override
public EnumActionResult onItemUse(ItemStack stackIn, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (world.isRemote) {
        return EnumActionResult.PASS;
    }
    if (stackIn.stackSize != 0) {
        float yaw = player.getHorizontalFacing().getHorizontalAngle();
        NBTTagCompound compound = stackIn.getTagCompound();
        HandEntity entity = new HandEntity(world, compound,
                pos.getX() + .5, pos.getY() + 1.0, pos.getZ() + .5, yaw);
        world.spawnEntityInWorld(entity);
        --stackIn.stackSize;
        return EnumActionResult.SUCCESS;
    } else {
        return EnumActionResult.FAIL;
    }
}
 
源代码8 项目: Sakura_mod   文件: WorldGenBigSakura.java
/**
   * Checks a line of blocks in the world from the first coordinate to triplet to the second, returning the distance
   * (in blocks) before a non-air, non-leaf block is encountered and/or the end is encountered.
   */
  int checkBlockLine(BlockPos posOne, BlockPos posTwo)
  {
      BlockPos blockpos = posTwo.add(-posOne.getX(), -posOne.getY(), -posOne.getZ());
      int i = this.getGreatestDistance(blockpos);
      float f = (float)blockpos.getX() / (float)i;
      float f1 = (float)blockpos.getY() / (float)i;
      float f2 = (float)blockpos.getZ() / (float)i;

      if (i == 0)
      {
          return -1;
      }
for (int j = 0; j <= i; ++j)
{
    BlockPos blockpos1 = posOne.add(0.5F + j * f, 0.5F + j * f1, 0.5F + j * f2);

    if (!this.isReplaceable(world, blockpos1))
    {
        return j;
    }
}

return -1;
  }
 
源代码9 项目: CommunityMod   文件: Area.java
public boolean isPointInArea(BlockPos bp) {
	if (bp.getX() >= startX && bp.getX() <= endX && bp.getY() >= startY && bp.getY() <= endY && bp.getZ() >= startZ
			&& bp.getZ() <= endZ) {
		return true;
	} else {
		return false;
	}
}
 
源代码10 项目: TFC2   文件: OreProcessor.java
private BlockPos getMidpoint(BlockPos p0, BlockPos p1)
{
	int x = (p0.getX() + p1.getX()) / 2;
	int y = (p0.getY() + p1.getY()) / 2;
	int z = (p0.getZ() + p1.getZ()) / 2;
	return new BlockPos(x, y, z);
}
 
public MessageBarrelModeUpdate(String modeName, BlockPos pos)
{
	this.x = pos.getX();
	this.y = pos.getY();
	this.z = pos.getZ();
	this.modeName = modeName;
}
 
源代码12 项目: GT-Classic   文件: GTTileMagicEnergyAbsorber.java
@SideOnly(Side.CLIENT)
@Override
public void randomTickDisplay(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
	if (this.isActive && this.portalMode
			&& worldIn.getBlockState(this.pos.offset(EnumFacing.DOWN)).getBlock() == Blocks.END_PORTAL) {
		for (EnumFacing facing : EnumFacing.HORIZONTALS) {
			BlockPos sidePos = pos.offset(facing);
			if (world.getBlockState(sidePos).isFullBlock()) {
				continue;
			}
			for (int k = 3; k > 0; --k) {
				ParticleManager er = Minecraft.getMinecraft().effectRenderer;
				float multPos = (float) (.1 * 2) + 0.9F;
				double x = (double) ((float) sidePos.getX() + 0.05F + rand.nextFloat() * multPos);
				double y = (double) ((float) sidePos.getY() + 0.0F + rand.nextFloat() * 0.5F);
				double z = (double) ((float) sidePos.getZ() + 0.05F + rand.nextFloat() * multPos);
				double[] velocity = new double[] { 0.0D, 7.6D, 0.0D };
				if (k < 4) {
					velocity[2] *= 0.55D;
				}
				float foo = rand.nextFloat() * .25F;
				float[] colour = new float[] { 0.0F, foo, foo };
				er.addEffect(new EntityChargePadAuraFX(this.world, x, y, z, 8, velocity, colour, false));
			}
		}
	}
}
 
源代码13 项目: NOVA-Core   文件: FWItemBlock.java
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
	return IFWItem.super.onItemUse(player.getHeldItem(hand), player, world, pos.getX(), pos.getY(), pos.getZ(), side.ordinal(), hitX, hitY, hitZ);
}
 
源代码14 项目: Sakura_mod   文件: WorldGenMapleTreeGreen.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);
          }
        }
      }
    }
}
 
源代码15 项目: enderutilities   文件: BlockPosEU.java
public BlockPosEU(BlockPos pos, int dim, EnumFacing facing)
{
    this(pos.getX(), pos.getY(), pos.getZ(), dim, facing);
}
 
/**
 * Does not make sure the structure is complete, only gets max bounds!
 * @param world the world
 * @param x coord to evaluate from
 * @param y coord to evaluate from
 * @param z coord to evaluate from
 * @return AxisAlignedBB bounds of structure if valid  otherwise null
 */
@Override
public AxisAlignedBB getRocketPadBounds(World world, BlockPos pos2) {
	EnumFacing direction = RotatableBlock.getFront(world.getBlockState(pos2)).getOpposite();
	int xMin, zMin, xMax, zMax, yMax, yMin;
	int yCurrent = pos2.getY();
	int xCurrent = pos2.getX();
	int zCurrent = pos2.getZ();
	xMax = xMin = xCurrent;
	zMax = zMin = zCurrent;
	int xSize, zSize;

	yMax = ZUtils.getContinuousBlockLength(world, EnumFacing.UP, getPos().add(0,1,0), MAX_SIZE_Y, AdvancedRocketryBlocks.blockStructureTower);

	//Get min and maximum Z/X bounds
	if(direction.getFrontOffsetX() != 0) {
		xSize = ZUtils.getContinuousBlockLength(world, direction, pos2.add(0, yMax, 0), MAX_SIZE, AdvancedRocketryBlocks.blockStructureTower);
		zMin = ZUtils.getContinuousBlockLength(world, EnumFacing.NORTH, pos2.add(0, 0, -1), MAX_SIZE, AdvancedRocketryBlocks.blockStructureTower) + 1;
		zMax = ZUtils.getContinuousBlockLength(world, EnumFacing.SOUTH, pos2.add(0, 0, 1), MAX_SIZE - zMin, AdvancedRocketryBlocks.blockStructureTower);
		zSize = zMin + zMax;

		zMin = zCurrent - zMin +1;
		zMax = zCurrent + zMax;

		if(direction.getFrontOffsetX() > 0) {
			xMax = xCurrent + xSize - 1;
			xMin++;
		}

		if(direction.getFrontOffsetX() < 0) {
			xMin = xCurrent - xSize+1;
			xMax--;
		}
	}
	else {
		zSize = ZUtils.getContinuousBlockLength(world, direction, pos2.add(0, yMax, 0), MAX_SIZE, AdvancedRocketryBlocks.blockStructureTower);
		xMin = ZUtils.getContinuousBlockLength(world, EnumFacing.WEST, pos2.add(-1, 0, 0), MAX_SIZE, AdvancedRocketryBlocks.blockStructureTower) + 1;
		xMax = ZUtils.getContinuousBlockLength(world, EnumFacing.EAST, pos2.add(1, 0, 0), MAX_SIZE - xMin, AdvancedRocketryBlocks.blockStructureTower);
		xSize = xMin + xMax;

		xMin = xCurrent - xMin +1;
		xMax = xCurrent + xMax;


		if(direction.getFrontOffsetZ() > 0) {
			zMax = zCurrent + zSize - 1;
			zMin++;
		}

		if(direction.getFrontOffsetZ() < 0) {
			zMin = zCurrent - zSize+1;
			zMax --;
		}
	}

	//if tower does not meet criteria then reutrn null
	if(yMax < MIN_SIZE_Y || xSize < MIN_SIZE || zSize < MIN_SIZE) {
		return null;
	}

	return new AxisAlignedBB(xMin, yCurrent, zMin, xMax, yCurrent + yMax - 1, zMax);
}
 
源代码17 项目: FastAsyncWorldedit   文件: ForgePlayer.java
@Override
public FaweLocation getLocation() {
    World world = parent.world;
    BlockPos pos = parent.getPosition();
    return new FaweLocation(Fawe.<FaweForge>imp().getWorldName(world), pos.getX(), pos.getY(), pos.getZ());
}
 
源代码18 项目: TFC2   文件: ChunkProviderSurface.java
private boolean isAir(ChunkPrimer chunkprimer, BlockPos pos)
{
	if(pos.getX() < 0 || pos.getX() > 15 || pos.getZ() < 0 || pos.getZ() > 15 || pos.getY() < 0 || pos.getY() > 255)
		return false;
	return chunkprimer.getBlockState(pos.getX(), pos.getY(), pos.getZ()) == Blocks.AIR.getDefaultState();
}
 
源代码19 项目: litematica   文件: PositionUtils.java
public static BlockPos getReverseTransformedBlockPos(BlockPos pos, Mirror mirror, Rotation rotation)
{
    int x = pos.getX();
    int y = pos.getY();
    int z = pos.getZ();
    boolean isRotated = true;
    int tmp = x;

    switch (rotation)
    {
        case CLOCKWISE_90:
            x = z;
            z = -tmp;
            break;
        case COUNTERCLOCKWISE_90:
            x = -z;
            z = tmp;
            break;
        case CLOCKWISE_180:
            x = -x;
            z = -z;
            break;
        default:
            isRotated = false;
    }

    switch (mirror)
    {
        // LEFT_RIGHT is essentially NORTH_SOUTH
        case LEFT_RIGHT:
            z = -z;
            break;
        // FRONT_BACK is essentially EAST_WEST
        case FRONT_BACK:
            x = -x;
            break;
        default:
            if (isRotated == false)
            {
                return pos;
            }
    }

    return new BlockPos(x, y, z);
}
 
源代码20 项目: ForgeHax   文件: Jesus.java
private static boolean isAboveBlock(Entity entity, BlockPos pos) {
  return entity.posY >= pos.getY();
}