#Getting list of structures

74 messages · Page 1 of 1 (latest)

toxic goblet
#

Is there any way to get all the structure ids? kinda like how /kubejs dump_registries does it

I'm trying to a compat config for a mod. this config script simply adds a structure tag to modded structures

trail coralBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

strong yew
#

Ik it might not be quite what you're looking for but the /locate command gives you the id of structures pretty easy.

toxic goblet
#

yeah but are there any way to get them as a list directly instead of from Minecraft's console?

valid quest
valid quest
#

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

toxic goblet
#

works, thanks (sorry i only got the chance to check now lol)

toxic goblet
valid quest
#

But I think you can put the code in ServerEvents.loaded and store the result for later use.

toxic goblet
#

alright, gonna try

#

but i have a feeling that it might not for my script

valid quest
#

what's your end goal?

toxic goblet
#

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

#

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

quartz basinBOT
#

Paste version of compat-dungeon_difficulty-tagger.js from @toxic goblet

valid quest
#

I'm reading

toxic goblet
#

take your time

valid quest
#

So you want to use tag to mark different difficulties for different structures, and put the result into config json files?

toxic goblet
#

yea

valid quest
#

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?

toxic goblet
#

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

valid quest
#

And the mod respects tag in-game?

toxic goblet
#

what do you mean by that

valid quest
#

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

toxic goblet
#

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

valid quest
#

Is the structures-manifest the json file the mod reads?

toxic goblet
#

no, their own config file (difficulty.json)

valid quest
#

I don't see JsonIO read/write that path in the above codehmmm

toxic goblet
#

yeah cause i want it to be left untouched 😭

valid quest
#

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?

toxic goblet
#

it supports tag based structure searching, yes

valid quest
#

ok, i think i get it

toxic goblet
valid quest
#

btw, you can do an auto reload upon server loaded if you need it

toxic goblet
#

you can auto reload?

valid quest
#

server.runCommand(reload)

toxic goblet
#

oh

#

do i just shove this to a ServerEvents.loaded event, right?

#

but aren't events able to run in parallel

valid quest
#

What do you mean parallel?

toxic goblet
#

uhhh

#

it doesn't block the code after it

#
ServerEvents.loaded(...)

//... some code outside/after the event block
valid quest
#

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

toxic goblet
#

right

#

still can't get the command to load on server start, unless there's something i did wrong

toxic goblet
#

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

valid quest
#

Yeah. I think separating them would be better.

toxic goblet
#

how do you make sure the other script load first (the generator)? if it's possible

quartz basinBOT
#

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!')
valid quest
#

The priority header can specify the loading order

toxic goblet
#

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?

valid quest
#

mod Id I think

toxic goblet
#

is the default priority value 1?