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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • When trying to load Craft to Exile 2, game crashes and this error message pops up:   https://api.mclo.gs/1/raw/B2oYte0
    • FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':processResources'. > Could not copy file 'C:\Users\jedil\Downloads\forge-1.20-46.0.14-mdk\src\main\resources\META-INF\mods.toml' to 'C:\Users\jedil\Downloads\forge-1.20-46.0.14-mdk\build\resources\main\META-INF\mods.toml'.    > Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed:      SimpleTemplateScript1.groovy: 1: Unexpected input: '(' @ line 1, column 10.         out.print("""# This is an example mods.toml file. It contains the data relating to the loading mods.                  ^   This is my mods.toml script: # This is an example mods.toml file. It contains the data relating to the loading mods. # There are several mandatory fields (#mandatory), and many more that are optional (#optional). # The overall format is standard TOML format, v0.5.0. # Note that there are a couple of TOML lists in this file. # Find more information on toml format here: https://github.com/toml-lang/toml # The name of the mod loader type to load - for regular FML @Mod mods it should be javafml modLoader="javafml" #mandatory # A version range to match for said mod loader - for regular FML @Mod it will be the forge version loaderVersion="${46.0.14}" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. # The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties. # Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here. license="${All Rights Reserved}" # A URL to refer people to when problems occur with this mod #issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional # A list of mods - how many allowed here is determined by the individual mod loader [[mods]] #mandatory # The modid of the mod modId="${MCRefined}" #mandatory # The version number of the mod version="${1.0.0}" #mandatory # A display name for the mod displayName="${Minecraft Refined}" #mandatory # A URL to query for updates for this mod. See the JSON update specification https://docs.minecraftforge.net/en/latest/misc/updatechecker/ #updateJSONURL="https://change.me.example.invalid/updates.json" #optional # A URL for the "homepage" for this mod, displayed in the mod UI #displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional # A file name (in the root of the mod JAR) containing a logo for display #logoFile="examplemod.png" #optional # A text field displayed in the mod UI #credits="" #optional # A text field displayed in the mod UI authors="${me}" #optional # Display Test controls the display for your mod in the server connection screen # MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod. # IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod. # IGNORE_ALL_VERSION means that your mod will not cause a red X if it's present on the client or the server. This is a special case and should only be used if your mod has no server component. # NONE means that no display test is set on your mod. You need to do this yourself, see IExtensionPoint.DisplayTest for more information. You can define any scheme you wish with this value. # IMPORTANT NOTE: this is NOT an instruction as to which environments (CLIENT or DEDICATED SERVER) your mod loads on. Your mod should load (and maybe do nothing!) whereever it finds itself. #displayTest="MATCH_VERSION" # MATCH_VERSION is the default if nothing is specified (#optional) # The description text for the mod (multi line!) (#mandatory) description='''${Minecraft, but it's, like, better.}''' # A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional. I tried using --scan or --stacktrace, those were no help. I also tried Ctrl+Alt+S, the template I used did not appear. HELP
    • They were intended to be used on tutorial posts so that people could easily find tutorials based on their skill level, but instead the tags were abused for unrelated things that made the original intent useless... for example, people often posted crash reports with the "beginner" tag, so instead of finding tutorials for beginners, you got crash reports showing up in searches.
    • The crash says: Exception caught when registering wandering trader java.lang.NullPointerException: Cannot invoke "net.minecraft.world.entity.Entity.m_9236_()" because "entity" is null at com.telepathicgrunt.repurposedstructures.misc.maptrades.StructureSpecificMaps$TreasureMapForEmeralds.m_213663_(StructureSpecificMaps.java:53) ~[repurposed_structures-7.1.15+1.20.1-forge.jar%23708!/:?] at jeresources.collection.TradeList.addMerchantRecipe(TradeList.java:58) ~[JustEnoughResources-1.20.1-1.4.0.247.jar%23630!/:1.4.0.247] JustEnoughResources is mentioned, too Does it work without one of these mods?
    • I have been trying to place a jigsaw structure for about a week now and cant get it to work. I have the template pool etc set up and working it does randomly generate now I just want to place it in the world using a coded trigger. I cant seem to find any useful information on the internet and am completely stuck I think I need to use : JigsawPlacement.generateJigsaw() But I cant get the Holder<StructureTemplatePool>
  • Topics

×
×
  • Create New...

Important Information

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