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

The following examples show how to use net.minecraft.world.World#getSeed() . 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: TileEntityGnode.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void initialize(World world)
  {
  	// reads from NBT default to 0 if they haven't been set yet.
  	// buildseed = 0 -> very fresh gnode
  	if (this.buildseed == 0)
  	{
  		// buildseed is based on the world's seed and the tile's position
  		long seed1 = world.getSeed();
  		long seed2 = (long)(this.getPos().hashCode());
  		this.buildseed = seed1*seed2;
  		if (this.buildseed == 0)
  		{
  			this.buildseed = 1;
  		}
  	}
  	this.buildrand = new Random(buildseed);
this.blueprint = new LinkedList<BlockPosAndBlock>();
  	this.buildBlueprint();
  }
 
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: WorldTickHandler.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@SubscribeEvent
public void tickEnd(TickEvent.WorldTickEvent event) {
    if (event.side != Side.SERVER) {
        return;
    }

    if (event.phase == TickEvent.Phase.END) {

        World world = event.world;
        int dim = world.provider.getDimension();

        ArrayDeque<ChunkPos> chunks = chunksToGen.get(dim);

        if (chunks != null && !chunks.isEmpty()) {
            ChunkPos c = chunks.pollFirst();
            long worldSeed = world.getSeed();
            Random rand = new Random(worldSeed);
            long xSeed = rand.nextLong() >> 2 + 1L;
            long zSeed = rand.nextLong() >> 2 + 1L;
            rand.setSeed(xSeed * c.x + zSeed * c.z ^ worldSeed);
            OreGenerator.instance.generateWorld(rand, c.x, c.z, world, false);
            chunksToGen.put(dim, chunks);
        } else if (chunks != null) {
            chunksToGen.remove(dim);
        }
    }
}
 
Example 4
Source File: WorldTickHandler.java    From YouTubeModdingTutorial with MIT License 5 votes vote down vote up
@SubscribeEvent
public void tickEnd(TickEvent.WorldTickEvent event) {
    if (event.side != Side.SERVER) {
        return;
    }

    if (event.phase == TickEvent.Phase.END) {

        World world = event.world;
        int dim = world.provider.getDimension();

        ArrayDeque<ChunkPos> chunks = chunksToGen.get(dim);

        if (chunks != null && !chunks.isEmpty()) {
            ChunkPos c = chunks.pollFirst();
            long worldSeed = world.getSeed();
            Random rand = new Random(worldSeed);
            long xSeed = rand.nextLong() >> 2 + 1L;
            long zSeed = rand.nextLong() >> 2 + 1L;
            rand.setSeed(xSeed * c.x + zSeed * c.z ^ worldSeed);
            OreGenerator.instance.generateWorld(rand, c.x, c.z, world, false);
            chunksToGen.put(dim, chunks);
        } else if (chunks != null) {
            chunksToGen.remove(dim);
        }
    }
}
 
Example 5
Source File: ChunkManagerPlanet.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
public ChunkManagerPlanet(World world, String str, List biomes)
{
	this(world.getSeed(), (WorldTypePlanetGen)AdvancedRocketry.planetWorldType, str, DimensionManager.getInstance().getDimensionProperties(world.provider.getDimension()));
	//Note: world MUST BE REGISTERED WITH THE DIMENSION MANAGER
	//This is a mess!
	this.biomes = biomes;
}
 
Example 6
Source File: CreateSpawnHandler.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onCreateSpawn(WorldEvent.CreateSpawnPosition event)
{
	World world = event.getWorld();

	world.findingSpawnPoint = true;
	Random random = new Random(world.getSeed());
	BlockPos blockpos = findTerrainPositionForSpawn(random);
	int i = 0;
	int j = world.provider.getAverageGroundLevel();
	int k = 0;

	if (blockpos != null)
	{
		i = blockpos.getX();
		k = blockpos.getZ();
	}

	int l = 0;

	/*while (!world.provider.canCoordinateBeSpawn(i, k))
	{
		i += random.nextInt(64) - random.nextInt(64);
		k += random.nextInt(64) - random.nextInt(64);
		++l;

		if (l == 1000)
		{
			break;
		}
	}*/

	world.getWorldInfo().setSpawn(new BlockPos(i, j, k));
	world.findingSpawnPoint = false;
	event.setCanceled(true);
}
 
Example 7
Source File: ChunkGeneratorFlatVoid.java    From YUNoMakeGoodMap with Apache License 2.0 5 votes vote down vote up
public ChunkGeneratorFlatVoid(World world)
{
    super(world, world.getSeed(), false, null);
    this.world = world;
    if (this.world.getWorldType() != WorldType.FLAT)
        this.world.setSeaLevel(63); //Fixup sea level as they now calculate it in flat worlds.
}
 
Example 8
Source File: ChunkGeneratorTorikki.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ChunkGeneratorTorikki(World world, long seed) {
	this.world = world;
	rand = new Random(world.getSeed());
	noise = new NoiseGeneratorPerlin(rand, 4);

}
 
Example 9
Source File: WorldTypePlanetGen.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
@Override
public IChunkGenerator getChunkGenerator(World world, String generatorOptions) {
	return new ChunkProviderPlanet(world, world.getSeed(), false, generatorOptions);
}