Jump to content

[Solved] [1.15.2] Structure Generation


Ugdhar

Recommended Posts

So, I built a little house and saved it with a structure block, and I've been trying to get it to spawn in the world as a structure.

I used the igloo as something to follow, and searched around on here and on google, and managed to get something that seems like it should be right, there's no errors, seems like my structure is registered properly, when I type /locate it shows as an option, but it always says "Could not find that structure nearby", and I never see it anywhere no matter how far I travel.

Obviously I'm doing something wrong, and I honestly do not completely understand the system(s) being used to generate the structure, I just tried to dissect the igloo as much as I could and dumb it down to a simple house thing.

If there are any explanations on how the structure/template system works out there, I'd love links :)

If you'd like to take a look, here's the github link: https://github.com/Ugdhar/structest

***edit: I'm going to leave this public github repo as long as it exists/is free, for anyone else that needs an example or has issues. It's pretty basic, and I'm sure there's a million ways it can be configured/improved, but it works on a basic level, so is a good start. :)

Thanks!

Edited by Ugdhar
Link to comment
Share on other sites

11 hours ago, ChampionAsh5357 said:

you have to add the structure to the structure map using Biome#addStructure.

Awesome, thank you, I was definitely missing that. Looking back it looks like that's done within the vanilla biome constructors, but I figured FMLCommonSetup would be a good place for it.

This definitely made a difference, as now my /locate command returns some coordinates for me.

Problem now however is when I go to said coordinates, there is no structure to be found, dig down to 0 or fly up to 255, and I find nothing in the area.

Setting some breakpoints and debugging is showing me the place method is returning false, and stepping into it I get here in the place method within the Structure class:

for(Long olong : worldIn.getChunk(i, j).getStructureReferences(this.getStructureName())) {

but evidently this returns nothing, so the code in that for block is never run.

I tried stepping into it, but it hits so many places I have no idea what it's really even supposed to be doing exactly, and I can't see where anything is missing, my structure name and stuff seems to come up when I inspect variables.

I've updated my repo with the changes if you (or anyone!) feel inclined to check it out.

 

Thanks again Ash for the addStructure, can't believe I missed that lol.

Link to comment
Share on other sites

A good thing to look at is the log since it does check if there is an error while parsing a blockstate in a certain space. Based on a quick glance, you seem to have a random structure block with no metadata in your nbt making it completely pointless. I didn't see anything wrong with the code itself, but I also have very limited knowledge on nbt loading of structure pieces. I still need to create some tests of my own.

Link to comment
Share on other sites

1 hour ago, diesieben07 said:

You will need to use DeferredWorkQueue as well, as the biome data structures are not thread safe.

You must not have checked out my github repo:

	public void commonSetup(FMLCommonSetupEvent args) {
		DeferredWorkQueue.runLater(() -> {
			Iterator<Biome> biomes = ForgeRegistries.BIOMES.iterator();
			biomes.forEachRemaining((biome) -> {
				biome.addStructure(BRICK_HOUSE.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG));
				biome.addFeature(GenerationStage.Decoration.SURFACE_STRUCTURES, BRICK_HOUSE.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG).withPlacement(Placement.NOPE.configure(IPlacementConfig.NO_PLACEMENT_CONFIG)));
			});
		});
	}

 

Link to comment
Share on other sites

6 hours ago, ChampionAsh5357 said:

A good thing to look at is the log since it does check if there is an error while parsing a blockstate in a certain space.

I combed through the debug.log, and I don't get any errors or anything, it all looks fine. https://gist.github.com/Ugdhar/be8b7180b72989bbe7934d69cbf2b92d

 

6 hours ago, ChampionAsh5357 said:

Based on a quick glance, you seem to have a random structure block with no metadata in your nbt making it completely pointless.

Ah yes, I was playing with structure blocks (first time) and it said something about corners, so I was messing with that, but ended up only using the one block I think, but likely forgot to remove the other one. I'll fix that and update, and see if it helps. OMG if that's EVEN what is making this all not work. . .lol. I appreciate the help, thanks for taking time to glance at my stuff!

 

11 minutes ago, diesieben07 said:

You are correct :D

I read your posts and try to keep in mind the advice you give people on how to do things :) I feel like I remember things like DeferredWorkQueue and doing things in appropriate registry events/DeferredRegister most of the time, thanks in part to reading your replies to others!

Link to comment
Share on other sites

8 hours ago, ChampionAsh5357 said:

Based on a quick glance, you seem to have a random structure block with no metadata in your nbt making it completely pointless.

Removed the extraneous structure block, but it doesn't seem to have helped at all.

I implemented the place method in my structure class, just taking it from the parent instead of calling super so I could break down some of what it was doing, and as far as I can tell, it seems to never make it to actually generating pieces due to this returning an empty set:

LongSet structRefs = chnk.getStructureReferences(this.getStructureName());

Unfortunately I can't figure out why, or where the value(s) are supposed to come from, aside from it being related to chunk position somehow.

 

Hopefully there's enough info here that someone that knows can tell me where I went wrong/what to research, or someone with a bit more experience/knowledge with the internals could figure it out if they were bored :)

Edited by Ugdhar
Link to comment
Share on other sites

I had a similar problem the last few days and I solved it by overriding func_225558_a_ in my structure class. For some reason the original function always returned false because generatorIn.hasStructure(biomeIn, this); always returned false although I added my structure to the biome. When using biomeIn.hasStructure(this) it returns the correct value. This doesn't really make sense because hasStructure from the ChunkGenerator basically just calls hasStructure from the Biome.

Link to comment
Share on other sites

2 hours ago, Boy132 said:

I had a similar problem the last few days and I solved it by overriding func_225558_a_ in my structure class. For some reason the original function always returned false because generatorIn.hasStructure(biomeIn, this); always returned false although I added my structure to the biome. When using biomeIn.hasStructure(this) it returns the correct value. This doesn't really make sense because hasStructure from the ChunkGenerator basically just calls hasStructure from the Biome.

Thanks for taking the time to reply! I overrode func_225558_a_ in my structure, and also expanded it out a bit for debugging purposes/setting breakpoints. It seems to fire off true for everything every time the chunk positions match, so unfortunately I don't think this is my problem. I know it's something I'm missing, I just don't know what!!!

 

I've updated my github repo with these changes if you feel like checking it out. Thanks again!

Link to comment
Share on other sites

23 minutes ago, Boy132 said:

I think I found the issue: you set the templates x and z to 0.

Just tested it with my code and it also didn't work when x and z are 0. So you should try this instead:


this.templatePosition = new BlockPos(p_i49313_3_.getX(), 90, p_i49313_3_.getZ());

 

Awesome, thank you! I also had to change that Y 90 to a 0, and there was another place I had 90 (not sure why, I think it was copied from the igloo?) for Y instead of 0, but now my stuff spawns pretty much as i expected!

 

Do you happen to know much about structures, for instance what ScatteredStructure is vs Structure, or how the Placement configuration works? I've tinkered with it some but honestly have no clue what I'm doing, just tinkering, guessing, and stabbing in the dark lol.

 

I'll leave the repository there, remove some of the stuff I was testing, and hopefully if someone else has issues they'll get some help from it.

Link to comment
Share on other sites

23 minutes ago, Ugdhar said:

Do you happen to know much about structures, for instance what ScatteredStructure is vs Structure, or how the Placement configuration works? I've tinkered with it some but honestly have no clue what I'm doing, just tinkering, guessing, and stabbing in the dark lol.

I think a Structure can spawn in every chunk and ScatteredStructure's are... scattered :D. Look at ScatteredStructure#getStartPositionForPosition for more details.

 

Most of the vanilla structures (or actually all?) don't use any placement config so you have to manually check the config somewhere. I havn't done this either so I don't really know how and when to do this.

 

Edited by Boy132
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.