#Getting list of structures
74 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
Ik it might not be quite what you're looking for but the /locate command gives you the id of structures pretty easy.
yeah but are there any way to get them as a list directly instead of from Minecraft's console?
const structureTypes = Utils.getRegistryIds("minecraft:worldgen/structure_type")
console.log(structureTypes)
Oh wait, not that one
const $Registries = Java.loadClass("net.minecraft.core.registries.Registries")
const structureIds = Utils.server.registryAccess().lookupOrThrow($Registries.STRUCTURE).listElementIds().map(resourceKey => resourceKey.location()).toList()
console.log(structureIds)
Should be this one
works, thanks (sorry i only got the chance to check now lol)
Ticket closed!
wait i should put this under server_script right? it doesn't run upon world creation until /reload is fired, unless this is intentional. got thrown an error saying something regarding RegistryAccess()
Thing is the structure registry needs a level or a server to access. It's not like potions, attributes and mob effects, which are accessible directly with Utils.getRegistry.
But I think you can put the code in ServerEvents.loaded and store the result for later use.
what's your end goal?
I have a modpack installed that increases difficulty (it's more like increasing mob health and armor points) for specific regions like biomes, structures or dimensions
https://modrinth.com/mod/dungeon-difficulty this to be exact
from the config you can add structures either by literal matching, tags, or regex. by default it uses tags
hence why i decide to go with that route of using tags, and the have the this script's config files separated by mod
smth like this
script so long i can't post it bruh hold on
here
Paste version of compat-dungeon_difficulty-tagger.js from @toxic goblet
I'm reading
take your time
So you want to use tag to mark different difficulties for different structures, and put the result into config json files?
yea
Oh wait, I kinda read it oppositely. It seems more likely read the difficulties from json files and assign difficulty tag to structures based on the json files
Are you trying to do json -> tag or tag -> json?
it's a bit both
tag and ids -> json for new structures (in case i added more mods that adds more structures)
json -> tag for loading the tags to those listed structures
And the mod respects tag in-game?
what do you mean by that
I mean, does the mod do its things based on the tag of a structure has? 'Cause their project main page says sth about confuguring it with json files
oh, yeah
but ima be honest, traversing hundreds of structure in the config for a specific one is kinda a hassle
and the mod can crash the game if there's some typo in the config
so yeah i'd rather add tags than modifying the config that comes with it when making other modded structures compat lol
Is the structures-manifest the json file the mod reads?
no, their own config file (difficulty.json)
I don't see JsonIO read/write that path in the above code
yeah cause i want it to be left untouched 😭
So eh, although the mod has its config json, it also reads tags of structures? Or you just generate a json file and copy paste it to the path manually to prevent unwanted result?
it supports tag based structure searching, yes
ok, i think i get it
this bit of code adds those tags to structures listed here #1391396895108239480 message, which they themselves just holds its structures and difficulty level for each
btw, you can do an auto reload upon server loaded if you need it
you can auto reload?
server.runCommand(reload)
oh
do i just shove this to a ServerEvents.loaded event, right?
but aren't events able to run in parallel
What do you mean parallel?
uhhh
it doesn't block the code after it
ServerEvents.loaded(...)
//... some code outside/after the event block
Things in a scope happens from above to below. However, things inside event callback are not in the same scope with things outside
So that you can put BlockEvents.placed above ServerEvents.tags and things still work fine
right
still can't get the command to load on server start, unless there's something i did wrong
gonna wrap it under try..catch block cause it was only meant to generate new files for missing configs of modded structures
now i think about it, should i separate these two logics? one for generating missing config for (future) structures and one loading (tagging) them
Yeah. I think separating them would be better.
how do you make sure the other script load first (the generator)? if it's possible
In 1.19.2 and all versions above you can use various headers at the top of a script to change its load conditions.
For example:
//ignored: true
console.log("I am never printed")
//packmode: default
console.log('I will only print when packmode in kubejs/config/common.properties is set to default')
//requires: minecraft
//requires: create
console.log('I will only print when mods with ids of minecraft AND create are loaded')
You can stack these too, like so
//priority: 10
//packmode: hard
//requires: create
//requires: tconstruct
console.log('I am complicated!')
The priority header can specify the loading order
what's the default?
nvm
how does the require field work? does it wait for ids of certain mods (or classes im gonna assume) are loaded?
mod Id I think
is the default priority value 1?