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've been working on modifying some of the world generation in one of my mods so that certain resources are added to worlds that were created before installing the mod. I'm using ChunkDataEvent to save NBT tags containing the version of the mod, as well as to check to see if that tag is there or not when the chunk is loaded. If the tag is there, I don't spawn the resources, if it isn't, I do. The problem is that the tag seems to disappear after the world has been loaded, and so only the first time each chunk is loaded after the world is loaded does it prevent spawning more resources. My code is shown below.

 

public class WorldGenerationUpdater
{

private static boolean[][] hasHadSpawn = new boolean[1024][1024]; //For testing only

@ForgeSubscribe
public void Load(ChunkDataEvent event)
{
	NBTTagCompound data = event.getData();
	Chunk chunk = event.getChunk();

	if(! data.hasKey("emasher_gas_info"))
	{

		EmasherGas.gasVentGenerator.generate(new Random(System.nanoTime()), chunk.xPosition, chunk.zPosition, chunk.worldObj, null, null);

		if(hasHadSpawn[chunk.xPosition + 512][chunk.zPosition + 512]) //For testing only
		{
			System.err.println("[GasCraft]Error: Chunk @" + chunk.xPosition + ", " + chunk.zPosition +  "has already had shale gas spawn");
		}
		else
		{
			System.out.println("Adding Shale Gas @" + chunk.xPosition + ", " + chunk.zPosition);
		}

		hasHadSpawn[chunk.xPosition + 512][chunk.zPosition + 512] = true; //For testing only

	}
	else
	{
		System.out.println("Chunk @" + chunk.xPosition + ", " + chunk.zPosition +  "already has shale gas, Not spawning more");
	}
}

@ForgeSubscribe
public void Save(ChunkDataEvent event)
{
	NBTTagCompound data = event.getData();
	Chunk chunk = event.getChunk();

	NBTTagCompound tag = new NBTTagCompound();

	tag.setString("GasCraft_Version", EmasherGas.version);

	data.setCompoundTag("emasher_gas_info", tag);

	//System.out.println("Saving chunk@" + chunk.xPosition + ", " + chunk.zPosition);
}

}

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.