Jump to content

Recommended Posts

Posted

I'm trying to create a simple chunk loader to load just the chunk the block is located in. I read about Forge's ticket system, however I'm not sure I understand it. This is what I have so far:

public class TileLoader extends TileEntity {
private ForgeChunkManager.Ticket ticket;

@Override
public void validate() {
	super.validate();
	if (!worldObj.isRemote && ticket == null) {
		ticket = ForgeChunkManager.requestTicket(LoaderTest.instance, this.worldObj, ForgeChunkManager.Type.NORMAL);
		ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(this.xCoord / 16, this.yCoord / 16));
	}
}

@Override
public void invalidate() {
	super.invalidate();
	ForgeChunkManager.releaseTicket(ticket);
}
}

With this code, many more tickets are created than needed and it doesn't seem to even load the chunk it is.

What have I done wrong?

Posted

Thanks for your suggestion. If I'm reading Buildcraft's code correctly, the ticket is created and used in the TileEntity update method with an initialized boolean to make sure that it only happens once. I tried using this method rather than the validate function, however it did not been to change the results. Many more tickets are created than needed and the chunk doesn't seem to be loaded.

Any other suggestions?

Posted

What is it about player entities that keeps chunks loaded around them? Could you imitate that? Or, create a special entity (or tile entity) that tricks the vanilla system into keeping its chunk loaded... sort of like a phantom player with observation radius 1.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

I mean I'd rather go through forge's system for it. I'm pretty sure the vanilla player entity loads chunks in a completely separate way. There's no need to "trick" the system when forge has a system built just for this. I just can't figure out how to use forge's system.

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.