Jump to content

Recommended Posts

Posted

I'm not sure what's causing the problem, but sometimes it skips out on chunks.

 

My mod is supposed to generate new structures and ores after the Ender Dragon is killed. When I return to the overworld, only some chunks have the new ores.

 

Chunk Load Event:

@SubscribeEvent
public void chunkLoad(ChunkDataEvent.Load event) {
	if(!event.world.isRemote) {
		World world = event.world;
		Chunk chunk = event.getChunk();
		NBTTagCompound nbt = event.getData();
		if(!nbt.hasKey(ReferenceRF.ID)) {
			nbt.setTag(ReferenceRF.ID, new NBTTagCompound());
		}
		nbt = event.getData().getCompoundTag(ReferenceRF.ID);
		if(!nbt.getBoolean("postDragon") && ServerProxyRF.getWorldProperty(world.getWorldInfo().getWorldName(), "hasDefeatedEnderDragon", false).getBoolean(false)) {
			nbt.setBoolean("postDragon", true);
			ServerWorldTickHandlerRF.chunksToGenerate.add(chunk);
		}
	}
}

 

Here's my World Tick Handler:

public class ServerWorldTickHandlerRF {
public static ArrayList<Chunk> chunksToGenerate = new ArrayList<Chunk>();

@SubscribeEvent
public void onWorldTick(TickEvent.WorldTickEvent event) {
	if(!event.world.isRemote)
		for(int i = 0; i < chunksToGenerate.size(); i++) {
			Chunk chunk = chunksToGenerate.get(i);
			for(int j = 0; j < 8; j++) {
				int x = (chunk.xPosition * 16) + event.world.rand.nextInt(16);
				int y = 128;
				int z = (chunk.zPosition * 16) + event.world.rand.nextInt(16);
				event.world.setBlock(x, y, z, Blocks.diamond_block);
				System.err.println("Generating at X: " + x + "|Y: " + y + "|Z: " + z);
			}
			chunksToGenerate.remove(i);
			System.err.println("LOADING");
		}
}
}

Kain

Posted

Hi

 

Just my guess: perhaps it doesn't need to reload all the chunks if you have moved to the ender and back to the overworld.

 

What happens if you save the game after killing the dragon, shut down the game, then restart and reload it?

 

-TGG

Posted

I tried that, the only other thing I noticed was that if I selected the world, it would return to the world selection menu. After a couple of seconds, it spawns me in the world. During that time, it said it was generating the stuff, but when I spawned nothing was there.

Kain

Posted

Hi

 

That's curious.  I don't see anything obviously wrong.  Perhaps the onWorldTick is being invoked too soon after the ChunkLoad.  I'd suggest you add some more logging to your world load event, to figure out whether the problem is in your ChunkLoad or onWorldTick.

 

-TGG

 

Posted

Update: I found an event (ChunkWatchEvent.Watch) that gets called when a chunk is loaded, but I can't get the NBT of the chunk or even tell if I've gone through it yet.

Kain

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.