Jump to content

World Generation based off of spawn location?


gravitythief

Recommended Posts

Now i have another problem: here is my code

 

Main mod class

package net.mrblockplacer.mike;

import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;

@Mod (modid = "genmod", name = "genmod", version = "0.0.1" )

@NetworkMod (clientSideRequired = true, serverSideRequired = false)
public class Genmod {

public static generation worldGen = new generation();

@Init
public void myLoadMethod(FMLInitializationEvent event)
{
GameRegistry.registerWorldGenerator(worldGen);
    }



}

 

World Generator class

package net.mrblockplacer.mike;

import java.util.List;
import java.util.Random;

import net.minecraft.src.Block;
import net.minecraft.src.Chunk;
import net.minecraft.src.ChunkPosition;
import net.minecraft.src.EnumCreatureType;
import net.minecraft.src.IChunkProvider;
import net.minecraft.src.IProgressUpdate;
import net.minecraft.src.World;
import net.minecraft.src.WorldInfo;
import cpw.mods.fml.common.IWorldGenerator;

public class generation implements IWorldGenerator {



@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
	int spawnX = (world.getSpawnPoint().posX);
	int spawnZ = (world.getSpawnPoint().posZ);
	float spawnXdec = (float) spawnX;
	float spawnZdec = (float) spawnZ;
	spawnXdec = spawnXdec / 16;
	spawnZdec = spawnZdec / 16;
	int spawnchunkX = (int) spawnXdec;
	int spawnchunkZ = (int) spawnZdec;
	if (chunkX == spawnchunkX && chunkZ == spawnchunkZ) {

		for (int i = 0; i < 16; i++) {

			for (int j = 0; j < 16; j++) {
				world.setBlock(chunkX + i, 100, chunkZ + j, Block.planks.blockID);
			}

			for (int j = 0; j < 7; j++) {
				world.setBlock(chunkX + i, 100 + j, chunkZ, Block.planks.blockID);
				world.setBlock(chunkX + i, 100 + j, chunkZ + 15, Block.planks.blockID);
				world.setBlock(chunkX, 100 + j, chunkZ + i, Block.planks.blockID);
				world.setBlock(chunkX + 15, 100 + j, chunkZ + i, Block.planks.blockID);
			}
		System.out.println("spawning");
		}


		world.setBlockAndMetadata(chunkX + 8, 101, chunkZ + 8, Block.pistonBase.blockID, 2);
		System.out.println("spawned at:" + (chunkX *16) + ", " + (chunkZ * 16));

	}
}

}

 

the structure is supposed to spawn over my head, and then the generator is supposed output the spawn location to the console, but for some strange reason, it won't spawn, but the message is still outputted to the console with the coords it was supposed to spawn at. Any tips?

I like collars. XP

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.