Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I want to know how to retrieve the spawn location before generating a structure. Any thoughts? i was using the WorldInfo.getSpawnX() and getSpawnZ()

I like collars. XP

  • Author

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

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.