Jump to content

Recommended Posts

Posted (edited)

Is there some event or something I can use to call come code as soon as a chunk finishes loading? I know there is ChunkEvent.Load, but that gives me the chunk before it is loaded, not after.

Edited by deerangle
Posted
  On 9/30/2018 at 12:08 PM, deerangle said:

Is there some event or something I can use to call come code as soon as a chunk finishes loading? I know there is ChunkEvent.Load, but that gives me the chunk before it is loaded, not after.

Expand  

What are you trying to do, not how you want to do it?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

Once ChunkEvent.Load is fired, the chunk is for all intents and purposes loaded - the event is not cancelable and the chunk data is in the chunk provider's loaded chunks map.  The only thing that hasn't yet occurred is population, which is a server-side thing anyway. 

 

You could always schedule your code to run on the next tick via Minecraft#addScheduledTask() (given your mention of map textures, I'm assuming you're doing this client-side).

Posted

Another small problem now is, that when loading the map data, the ChunkEvent.Load event is invoked, which loads the map, which invokes the Event... Therefore, stackoverflowexception. Is there a way I can prevent that?

Posted
  On 10/1/2018 at 12:08 PM, deerangle said:

Another small problem now is, that when loading the map data, the ChunkEvent.Load event is invoked, which loads the map, which invokes the Event... Therefore, stackoverflowexception. Is there a way I can prevent that?

Expand  

The fuck are you doing that causes this?

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

Well, It seems getting the BlockState loads the chunk, which Invokes the event and thus starts a loop. Here is the relevant part of the StackTrace:

 

com.deerangle.render.MinimapEventHandler.loadChunk(MinimapEventHandler.java:40) //calling self again
net.minecraftforge.fml.common.eventhandler.ASMEventHandler_11_MinimapEventHandler_loadChunk_Load.invoke(.dynamic)
net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
net.minecraft.world.chunk.Chunk.onLoad(Chunk.java:920)
net.minecraftforge.common.chunkio.ChunkIOProvider.syncCallback(ChunkIOProvider.java:105)
net.minecraftforge.common.chunkio.ChunkIOExecutor.syncChunkLoad(ChunkIOExecutor.java:94)
net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:130)
net.minecraft.world.gen.ChunkProviderServer.loadChunk(ChunkProviderServer.java:101)
net.minecraft.world.gen.ChunkProviderServer.provideChunk(ChunkProviderServer.java:147)
net.minecraft.world.World.getChunkFromChunkCoords(World.java:361)
net.minecraft.world.World.getChunkFromBlockCoords(World.java:353)
net.minecraft.world.World.getBlockState(World.java:994)
com.deerangle.render.MinimapColors.getOpacity(MinimapColors.java:197)
com.deerangle.render.MinimapColors.getBrightness(MinimapColors.java:190)
com.deerangle.render.MinimapColors.getMapColor(MinimapColors.java:126)
com.deerangle.render.MinimapCacher.getMapPixelColor(MinimapCacher.java:131)
com.deerangle.render.MinimapCacher.loadChunk(MinimapCacher.java:107)
com.deerangle.render.MinimapCacher.cacheChunk(MinimapCacher.java:91)
com.deerangle.render.MinimapEventHandler.loadChunk(MinimapEventHandler.java:40) //initial call when chunk is loaded

 

Posted

I did not ask for a stack trace, as the fact that your code is invoking a chunk load event was already self evident.

 

What I want is your code.

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

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 (edited)
  On 10/1/2018 at 7:47 PM, Draco18s said:

You should use << 4

Expand  

The reason to use bit shifting instead of multiplication/division is that

- Minecraft’s chucks are a power of 2 (16x16) exactly so that you can use bit shifting instead of multiplication/division for performance gains

- Multiplication/division doesn’t always give the same result as bit shifting (-1)

 

Anyway you don’t need to use these functions directly as Minecraft has a ChunkPos class that handles this all for you. new ChunkPos(BlockPos);

 

You should also be using ReflectionHelper and storing a reference to the Field so that you don’t do a Field lookup every time. 

Edited by Cadiboo

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted
  On 10/2/2018 at 7:26 AM, deerangle said:

I fixed these minor things as suggested, but the Error is still not fixed.

Expand  

Has anything changed? Please post your new entire debug log as described in my signature

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted (edited)

Of course nothing changed. I'm now using a bitshift instead of multiply and getting the Field only once using a helper class instead of getting it several times not using the helper class. What difference did you expect?

 

And here the entire debug log:

  Reveal hidden contents

 

Edited by deerangle
Posted

Try scheduling it to run on the next tick? Or make sure your using a ChunkCache?

It appears that your getOpacity is getting a blockstate at a pos which forces a (the) chunk to be (re)loaded.

I see two possible problems:

1) getOpacity forces the current chunk to be reloaded repeatedly somehow

2) Your getting the opacity for a block in a neighbouring chunk causing neighbouring chunks to be loaded indefinitely.

Try printing out the BlockPos that your calling getBlockState for. It will tell you which one of the problems your having (or show a 3rd problem)

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

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.