Jump to content

How to locate generated structures (update 1.19.4)


jstastny

Recommended Posts

Hello,

I'm working on updating certain old mod, this time from 1.12.2 to 1.19.4, and I again stumbled upon the same issue. In this mod, I still need the function that gives me coordinates of the nearest generated structure. I again found a method that can do this, but unfortunately, this time the method requires an instance of the class ServerLevel (probably a new name for ServerWorld). In order to get this instance, I again tried reverse-engineering several mods for 1.19.4 and parts of Forge code, but just as in case of 1.15.2, none of the methods I tried worked. Does anyone know how to solve this? Thanks for any response.

Link to comment
Share on other sites

On 3/26/2023 at 5:13 PM, ChampionAsh5357 said:

Well, the method in question for the logic would be via LocateCommand#locateStructure which delegates to ChunkGenerator#findNearestMapStructure. You would of course need the ServerLevel as structures can only exist in the world. So, what context are you executing this in such that you don't have the level?

I have an item that when right-clicked should locate the nearest structure (important is the type of the structure and its coordinates), take the data and if the structure is close enough to the player, create a book that contains the data. So, if I understood the differences between 1.19 and older versions, probably method use(). This method should have arguments Player and World, but I wasn't able to get instance of ServerLevel from neither of those.

Edited by jstastny
Link to comment
Share on other sites

Look at EnderEyeItem.use() which locates the nearest stronghold (StructureTags.EYE_OF_ENDER_LOCATED)

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

4 hours ago, warjort said:

Look at EnderEyeItem.use() which locates the nearest stronghold (StructureTags.EYE_OF_ENDER_LOCATED)

I tried what you suggested and used the method they used with the ender eye and after a bit of tuning, it worked. Honestly, I already tried using exactly this method before, but the game kept crashing because of class cast exception, so I gave up on that. But still, thank you so much!

Regarding the same mod, I have one more question. Is there any way (under the same conditions) to find out boundaries of structures or whether the player is in them?

Link to comment
Share on other sites

The only place in vanilla I know about that checks structure bounds is in NaturalSpawner.isInNetherFortressBounds() for blaze/wither skeleton spawning.

That uses the StructureManager which can be obtained from ServerLever.structureManager()

 

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

4 hours ago, warjort said:

The only place in vanilla I know about that checks structure bounds is in NaturalSpawner.isInNetherFortressBounds() for blaze/wither skeleton spawning.

That uses the StructureManager which can be obtained from ServerLever.structureManager()

 

I tried searching the Forge code, and while I wasn't able to find the code for nether fortresses or spawners, I found a similar code used for spawning cats in swamp huts. I used this code and it worked like charm! Thank you!

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.