Jump to content

Recommended Posts

Posted (edited)
11 minutes ago, diesieben07 said:

What is a "cubed mc style radius"?

radius is normally in circle style this is radius in mc style radius of 1. circle style has 4 points cube style has more then that depending on the radius

xxx
xyx
xxx

 

I am mostly confused on how to get chunks without creating them if it's null. I think I found the equation of getting radius in chunks though from this post. How does one get chunks and expect null if not loaded already so it doesn't become recursion and lag everything. I don't want to populate or generate it if it doesn't exist

 

Edited by jredfox
Posted (edited)
1 hour ago, diesieben07 said:

What is a "cubed mc style radius"?

Would this make recursion I am trying to avoid it when trying to get chunk radius otherwise it would lag very bad seconds per chunk 

 

	/**
	 * Get chunks from center radius intention is to ignores chunks that haven't been populated yet?
	 */
	public static ArrayList<Chunk> getRadiusChunks(World w, int chunkPosX, int chunkPosZ,int radius) {
		ArrayList<Chunk> chunks = new ArrayList();
		  for (int x = chunkPosX - radius; x <= chunkPosX + radius; x++) {
	            for (int z = chunkPosZ - radius; z <= chunkPosZ + radius; z++) {
	            	if(w.isChunkGeneratedAt(x, z))
	            		chunks.add(w.getChunkFromChunkCoords(x, z));
	            }
		  }
		return chunks;
	}

 

Edited by jredfox
Posted (edited)

isn't solved I got this warning

[17:32:12] [Server thread/WARN] [FML]: Dungeon Tweeks loaded a new chunk (-14, 6  Dimension: -1) during chunk population, causing cascading worldgen lag. Please report this to the mod's issue tracker. This log can be disabled in the Forge config.

 

 

Also I noticed that this might not work with negitive chunks is this correct? What should I do instead math.abs then what?

Edited by jredfox
Posted

If you are in a chunk that has just been populated, you can only (for sure) request the three chunks that are X+ and Z+ of the current one

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
11 hours ago, Draco18s said:

If you are in a chunk that has just been populated, you can only (for sure) request the three chunks that are X+ and Z+ of the current one

I don't want an ify of only scan these chunks I want a radius that will get any loaded chunks already and maybe also ones that doe exists (on disk) but, are dormant

Posted
2 minutes ago, diesieben07 said:

There is no black and white "generated" and "not generated". Chunks may have rough generation (terrain, etc.) being done but they are not populated (trees, other plants, structures, etc.) yet. Requesting those latter chunks will cause them to be populated.

 

Do you want those chunks or not?

I actually saw loaded chunks in one of the classes so there is a way to determine that part. And I might have seen stuff with does exists on disk. I just need to know when chunks are written to disk one they are unloaded? So if it's not written to disk and if it's not loaded I should ignore that chunk.

 

So vanilla keeps track of loaded chunks I might have to do some manual reflection method to determine if it exists on the disk if if not loaded or not on disk return null maybe then the messege would go away. Or would forge still be spamming that console if I loaded a chunk that was already to the disk.

 

If I load a chunk is it forever loaded or does an entity/tile entity need to keep loading it? If so I am not worried about loading unloaded chunks that have been populated and exist on disk but, not loaded into memory

Posted (edited)
7 minutes ago, diesieben07 said:

I am having a real hard time following what you are trying to say.

Why are you trying to check for loaded chunks? Also please clarify what you mean by "loaded". Loaded into RAM? 

because when scanning for an already scanned chunk from my mod such as the blaze spawner going to an already loaded chunk scan radius of 1 to newer chunk and bam find the blaze spawner that is why I am scanning in the radius. yes loaded into ram

 

My code specified only if chunk wasn't loaded to add it to the arraylist  what is wrong with vanilla that simply doing that loads the chunk anyways?

Edited by jredfox
Posted
1 minute ago, diesieben07 said:

I asked why you are checking for loaded chunks. Not why you are scanning.

 

isChunkGeneratedAt should not cause a chunkload. Use the debugger to find out why (or if) it does.

doesn't happen one only the default chunk was added the current chunk.

 

if(w.isChunkGeneratedAt(x, z));

doesn't seem to be causing it the code causing it has to be

chunks.add(w.getChunkFromChunkCoords(x, z));

 

Posted
1 minute ago, diesieben07 said:

Wat?

 

Well, yes, requesting the chunk will load it...

Well if I only can loaded chunks and scan for only generated will it cause any issues with the spawners or does it need those extra chunks?

Posted (edited)
4 minutes ago, diesieben07 said:

Your sentences make no sense, sorry.

  public boolean isChunkGeneratedAt(int x, int z)
    {
        return this.isChunkLoaded(x, z, false) ? true : this.chunkProvider.isChunkGeneratedAt(x, z);
    }

it's checking for both the is generated and is loaded. Forge is saying o no the chunks are loading before we expect them to.

 

I was saying if I use reflection to call world.isChunkLoaded(x,z,false); instead of simply world.isChunkGeneratedAt(x,z) will it cause issues with the spawner I am scanning for not to show up sometimes?

Edited by jredfox
Posted
Just now, diesieben07 said:

Checking if the chunk is generated yet does not check if it is populated (i.e. chunks which are generated but not populated will be accepted as "ok" by your method). But accessing it will cause it to get populated.

 

You must follow Draco's advice.

Actually I could simply create my own method I found some codessss
https://bukkit.org/threads/how-do-you-determine-if-a-chunk-has-been-loaded-and-populated.216667/

 

Chunk c = w.getChunkProvider().getLoadedChunk(x, z);
 if(c.isPopulated())

 

There is also forge fetch dormant chunk then I could check if it is populated already which should return true else do nothing

Posted
8 minutes ago, diesieben07 said:

This will be equivalent to what Draco suggested. Only way too complicated.

maybe equivalent but, mine will also grab the chunks he considers rarely happens so.

Posted (edited)
1 hour ago, diesieben07 said:

This will be equivalent to what Draco suggested. Only way too complicated.

Got it working had to check both loaded and populated chunks. If loaded is null check dormant populated chunks

Edited by jredfox
Posted

Question would calling this ever cause an index out of bounds exception if the chunk is not loaded?

Chunk c = w.getChunkProvider().getLoadedChunk(x, z);

 

Posted (edited)
2 minutes ago, diesieben07 said:

No.

One last quest will using cause any breakage since I don't call chunk.load or populate? I only use it when the loaded chunk is null
 

long pos = ChunkPos.asLong(x, z);
c = net.minecraftforge.common.ForgeChunkManager.fetchDormantChunk(pos, w);

 

Edited by jredfox
Posted (edited)
2 minutes ago, diesieben07 said:

The fact that you ask this shows you should not call it... Why are you randomly calling methods that you do not understand?

 

fetchDormantChunk is an internal method used by Forge to cache Chunk data in RAM to make chunks that rapidly load and unload less taxing. You do not need to call it, it is called from patches to vanilla code already.

Ok how do I get an unloaded chunk without loading it into memory via the world? Then once I determine if it's populated then I should load it into the world temporary then at end of the method unload so it sync's?

Edited by jredfox
Posted (edited)
8 minutes ago, diesieben07 said:

You cannot.

Well if I comment out the lines about getting using the method you don't like it turns into a blaze spawener again. So what's the issue it loads it into ram how do I unload it because I physically need to scan this or maybe I should be using player tick on server side?


So what should I be unloading or should I let the game do that really confused right now because, if I don't use that method then it doesn't do it's job with the wither skele spawners

https://github.com/jredfox/dungeontweeks

 

public static Chunk getLoadedOrPopulatedChunk(World w, int x, int z)
	{
		Chunk c = w.getChunkProvider().getLoadedChunk(x, z);
		if(c == null)
			c = getPopulatedChunk(w,x,z,true);
		return c;
	}
public static Chunk getPopulatedChunk(World w, int x, int z,boolean dormant) {
		Chunk c = null;
		if(!dormant)
			w.getChunkProvider().getLoadedChunk(x, z);
		if(c == null)
		{
			 long pos = ChunkPos.asLong(x, z);
	         c = net.minecraftforge.common.ForgeChunkManager.fetchDormantChunk(pos, w);
	         if(c == null)
	        	 return null;
		}
    	if(c.isPopulated())
    		return c;
    	else
    		return null;
	}

 

Edited by jredfox
Posted
2 minutes ago, diesieben07 said:

I guess actually you will ultimately have to call it, but you can't do it that simple.

You would need to copy what ChunkProviderServer::loadChunk does in some way (and leave out the chunk population), but this is getting quite dangerous, as you might end up with chunks in the world which are not populated and the game will "forget" to populate them until they unload and reload again.

 

Overall this "loading of chunks but not populating them" is not a good idea.

What about this it's seems simple and clean with it unloading the chunk from the world or whatever as soon as I fetch it then it will re-load it when necessary if tile entities are read and update properly because if it's dormant it will do it if it's not it won't

public static Chunk getPopulatedChunk(World w, int x, int z,boolean dormant) {
		Chunk c = null;
		if(!dormant)
			w.getChunkProvider().getLoadedChunk(x, z);
		if(c == null)
		{
			 long pos = ChunkPos.asLong(x, z);
	         c = net.minecraftforge.common.ForgeChunkManager.fetchDormantChunk(pos, w);
	         if(c == null)
	        	 return null;
	         c.onUnload();//if dormant chunk isn't null unload after fetching
		}
    	if(c.isPopulated())
    		return c;
    	else
    		return null;
	}

 

Posted
2 minutes ago, diesieben07 said:
  • Chunk::onUnload does not unload the chunk.
  • You should really change the name of that "dormant" parameter.
  • Your method will not work for chunks which are generated, but are not loaded into memory at the moment.

Then What should I be calling? Everything that the provider server is calling?

Posted (edited)
19 minutes ago, diesieben07 said:
  • Chunk::onUnload does not unload the chunk.
  • You should really change the name of that "dormant" parameter.
  • Your method will not work for chunks which are generated, but are not loaded into memory at the moment.

Edit: I don't think I need dormant chunks do I? Because, by placing blocks into unloaded chunks it would load them right? Well if that's true then it was just something I did that was my fault which I did fix but, I want to be 100% in case your speed with a mod velocity goes like 80 blocks a second and unloads chunks before the next one can load causing issues.

 

But if that's the case that above is going to cause Issues I should still work on getting dormant chunks how should I accomplish this?

Edited by jredfox
Posted (edited)
2 hours ago, diesieben07 said:

25jnbn.jpg

 

Sorry, mate, you just keep spewing out words. It is completely unclear to me what the hell you are talking about and what you are trying to do.

well I thought it meant chunks written to disk but, not loaded into memory made some sense.

 

I am looking for unloaded chunks how do I get unloaded chunks then only if it's not in the process of loading? But, am I already fine or does it need more work I currently now only use loaded chunks radius

 

so what is dormant chunks and when do they get stored to a cache not to be used should I also be grabbing them or nah?

Edited by jredfox
Posted
31 minutes ago, diesieben07 said:

I already explained this above. Dormant chunks are chunks that have been kept in RAM by Forge after they are unloaded in case they are loaded again quickly.

 

What is "it"? Who is loading? I thought you were saying unloaded chunks...

Loaded chunks = already grab them
Dormant chunks = ok don't need them

Unloaded chunks = how does one get them if and only if they are populated, if forge freaks out about generally loading a chunk on populate then I will forget it

 

Hope that's clear just that one last question here thanks. Yes my spawners are working I did something really stupid when converting the event back to the old one

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.