Java Code Examples for net.minecraft.world.World#getActualHeight()

The following examples show how to use net.minecraft.world.World#getActualHeight() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockPortalBase.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Checks if this block can be placed exactly at the given position.
 */
@Override
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
	// can place here if this and the two y-adjacent blocks are replaceable
	// first, make sure it's not too close to the y-boundaries of the world
	if (pos.getY() <= 6 || pos.getY() >= worldIn.getActualHeight() - 7)
	{
		return false;
	}
	for (int i=-1; i<=1; i++)
	{
		if (!worldIn.getBlockState(pos.up(i)).getBlock().isReplaceable(worldIn, pos.up(i)))
		{
			return false;
		}
	}
	return super.canPlaceBlockAt(worldIn, pos);
}
 
Example 2
Source File: CachedGridEntry.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
public CachedGridEntry(World world, int gridX, int gridZ, int primerChunkX, int primerChunkZ) {
    this.gridX = gridX;
    this.gridZ = gridZ;
    long worldSeed = world.getSeed();
    this.gridRandom = new XSTR(31 * 31 * gridX + gridZ * 31 + Long.hashCode(worldSeed));

    int gridSizeX = WorldGeneratorImpl.GRID_SIZE_X * 16;
    int gridSizeZ = WorldGeneratorImpl.GRID_SIZE_Z * 16;
    BlockPos blockPos = new BlockPos(gridX * gridSizeX + gridSizeX / 2, world.getActualHeight(), gridZ * gridSizeZ + gridSizeZ / 2);
    Biome currentBiome = world.getBiomeProvider().getBiome(blockPos);
    this.cachedDepositMap = new ArrayList<>(WorldGenRegistry.INSTANCE.getCachedBiomeVeins(world.provider, currentBiome));

    this.worldSeaLevel = world.getSeaLevel();
    this.masterEntry = searchMasterOrNull(world);
    if (masterEntry == null) {
        Chunk primerChunk = world.getChunkFromChunkCoords(primerChunkX, primerChunkZ);
        BlockPos heightSpot = findOptimalSpot(gridX, gridZ, primerChunkX, primerChunkZ);
        int masterHeight = world.getHeight(heightSpot).getY();
        int masterBottomHeight = world.getTopSolidOrLiquidBlock(heightSpot).getY();
        this.masterEntry = primerChunk.getCapability(GTWorldGenCapability.CAPABILITY, null);
        this.masterEntry = new GTWorldGenCapability();
        this.masterEntry.setMaxHeight(masterHeight, masterBottomHeight);
    }

    triggerVeinsGeneration();
}
 
Example 3
Source File: QuestEnemyEncampment.java    From ToroQuest with GNU General Public License v3.0 6 votes vote down vote up
private BlockPos findSurface(QuestData data, int x, int z, boolean force) {
	World world = data.getPlayer().getEntityWorld();
	BlockPos pos = new BlockPos(x, world.getActualHeight(), z);
	IBlockState blockState;
	while (pos.getY() > 0) {
		blockState = world.getBlockState(pos);
		if (!force && isLiquid(blockState)) {
			return null;
		}
		if (isGroundBlock(blockState)) {
			break;
		}
		pos = pos.down();
	}
	return pos.up();
}
 
Example 4
Source File: WorldGenPlacer.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
private void genMageTower(World world, Random random, int chunkX, int chunkZ) {
	if (!CivilizationsWorldSaveData.get(world).canGenStructure("mage_tower", chunkX, chunkZ)) {
		return;
	}

	BlockPos pos = new BlockPos(chunkX * 16 + random.nextInt(16), world.getActualHeight(), chunkZ * 16 + random.nextInt(16));
	if (new MageTowerGenerator().generate(world, random, pos)) {
		System.out.println("ToroQuest Gen Placer: Mage Tower " + pos);
	}
}
 
Example 5
Source File: WorldGenPlacer.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
private void genBastionsLair(World world, Random random, int chunkX, int chunkZ) {
	if (!CivilizationsWorldSaveData.get(world).canGenStructure("bastions_lair", chunkX, chunkZ)) {
		return;
	}
	BlockPos pos = new BlockPos(chunkX * 16 + random.nextInt(16), world.getActualHeight(), chunkZ * 16 + random.nextInt(16));
	if (new BastionsLairGenerator().generate(world, random, pos)) {
		System.out.println("ToroQuest Gen Placer: Bastion's Lair " + pos);
	}
}
 
Example 6
Source File: WorldGenPlacer.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
private void genMonolith(World world, Random random, int chunkX, int chunkZ) {
	if (!CivilizationsWorldSaveData.get(world).canGenStructure("monolith", chunkX, chunkZ)) {
		return;
	}
	BlockPos pos = new BlockPos(chunkX * 16 + random.nextInt(16), world.getActualHeight(), chunkZ * 16 + random.nextInt(16));
	if (new MonolithGenerator().generate(world, random, pos)) {
		System.out.println("ToroQuest Gen Placer: Monolith " + pos);
	}
}
 
Example 7
Source File: TileEntityTeleportRail.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
public Pair<MCPos, MCPos> getAllowedDestinationRange(World destinationDimension){
    if(destinationDimension == null) return null;

    double moveFactor = getWorld().provider.getMovementFactor() / destinationDimension.provider.getMovementFactor();
    double destX = MathHelper.clamp(getPos().getX() * moveFactor, destinationDimension.getWorldBorder().minX() + 16.0D, destinationDimension.getWorldBorder().maxX() - 16.0D);
    double destZ = MathHelper.clamp(getPos().getZ() * moveFactor, destinationDimension.getWorldBorder().minZ() + 16.0D, destinationDimension.getWorldBorder().maxZ() - 16.0D);
    destX = MathHelper.clamp((int)destX, -29999872, 29999872);
    destZ = MathHelper.clamp((int)destZ, -29999872, 29999872);

    int maxDiff = 8;
    MCPos min = new MCPos(destinationDimension, new BlockPos(destX - maxDiff, 0, destZ - maxDiff));
    MCPos max = new MCPos(destinationDimension, new BlockPos(destX + maxDiff, destinationDimension.getActualHeight(), destZ + maxDiff));
    return new ImmutablePair<MCPos, MCPos>(min, max);
}
 
Example 8
Source File: WorldGenPlacer.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private void genGraveyard(World world, Random random, int chunkX, int chunkZ) {
	BlockPos pos = new BlockPos(chunkX * 16 + random.nextInt(16), world.getActualHeight(), chunkZ * 16 + random.nextInt(16));
	if (new GraveyardGenerator().generate(world, random, pos)) {
		System.out.println("ToroQuest Gen Placer: Graveyard " + pos);
	}
}
 
Example 9
Source File: OilGeneratorFix.java    From NewHorizonsCoreMod with GNU General Public License v3.0 4 votes vote down vote up
public void buildOilStructure( World pWorld, Random pRand, int pSphereX, int pSphereY, int pSphereZ, int pRadius, int pGroundLevel, Block pTargetBlock, boolean pCheckValidLocation )
{
  // Make sure to not exceed the max-build height of minecraft

  EDEPOSIT_SIZE eSize;
  int tSpringHeight = 0;

  if( pRadius >= MainRegistry.CoreConfig.OilFixConfig.OilDepositThresholdLarge )
  {
    tSpringHeight = MainRegistry.CoreConfig.OilFixConfig.OilFountainSizeLarge;
    eSize = EDEPOSIT_SIZE.LARGE;
  }
  else if( pRadius >= MainRegistry.CoreConfig.OilFixConfig.OilDepositThresholdMedium )
  {
    tSpringHeight = MainRegistry.CoreConfig.OilFixConfig.OilFountainSizeSmall;
    eSize = EDEPOSIT_SIZE.MEDIUM;
  }
  else {
      eSize = EDEPOSIT_SIZE.SMALL;
  }

  int pMaxHeight = pGroundLevel + tSpringHeight;
  if( pMaxHeight >= pWorld.getActualHeight() - 1 )
  {
    if( YAMCore.isDebug() ) {
        _mLog.warn("The total height of the calculated OilDeposit would exceed the maximum world-size.");
    }
    return;
  }

  int r2 = pRadius * pRadius;
  for( int bx = -pRadius; bx <= pRadius; bx++ )
  {
    for( int by = -pRadius + 2; by <= pRadius - 2; by++ )
    {
      for( int bz = -pRadius; bz <= pRadius; bz++ )
      {
        int d2 = bx * bx + by * by * 3 + bz * bz;

        if( d2 <= r2 )
        {
          if( !checkBlock( pWorld, bx + pSphereX - 1, by + pSphereY, bz + pSphereZ ) || !pCheckValidLocation )
          {
            if( !checkBlock( pWorld, bx + pSphereX + 1, by + pSphereY, bz + pSphereZ ) || !pCheckValidLocation )
            {
              if( !checkBlock( pWorld, bx + pSphereX, by + pSphereY - 1, bz + pSphereZ ) || !pCheckValidLocation )
              {
                if( !checkBlock( pWorld, bx + pSphereX, by + pSphereY, bz + pSphereZ - 1 ) || !pCheckValidLocation )
                {
                  if( !checkBlock( pWorld, bx + pSphereX, by + pSphereY, bz + pSphereZ + 1 ) || !pCheckValidLocation )
                  {
                    if( !checkBlockAbove( pWorld, bx + pSphereX, by + pSphereY + 1, bz + pSphereZ ) || !pCheckValidLocation )
                    {
                      pWorld.setBlock( bx + pSphereX, by + pSphereY, bz + pSphereZ, pTargetBlock, 0, 2 );
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }

  if( eSize.ordinal() >= EDEPOSIT_SIZE.MEDIUM.ordinal() )
  {
    for( int y = pSphereY + 1; y <= pMaxHeight; y++ )
    {
      pWorld.setBlock( pSphereX, y, pSphereZ, pTargetBlock, 0, 3 );
    }
  }

  if( eSize == EDEPOSIT_SIZE.LARGE )
  {

    for( int y = pSphereY; y <= pMaxHeight - tSpringHeight / 2; y++ )
    {
      pWorld.setBlock( pSphereX + 1, y, pSphereZ, pTargetBlock, 0, 3 );
      pWorld.setBlock( pSphereX - 1, y, pSphereZ, pTargetBlock, 0, 3 );
      pWorld.setBlock( pSphereX, y, pSphereZ + 1, pTargetBlock, 0, 3 );
      pWorld.setBlock( pSphereX, y, pSphereZ - 1, pTargetBlock, 0, 3 );
    }
  }
}