#Trial Spawner Loot Table
1 messages · Page 1 of 1 (latest)
💬 While you wait, take this time to provide more context and details.
🙇 After a while, hit the Summon Helpers button to ping the helper team. They'll be happy to help you
✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve
"functions": [
{
"function": "minecraft:set_count",
"count": {
"type": "minecraft:score",
"target": "this",
"score": "example"
}
}
]
```?
target this, that tracks on the player?
target:this just means the current entity
Yea I thought that would then be the trial spawner
so for example, if it's a loot table on a mob, then this = the mob
in a chest, its whoever opened the chest
for the trial spawner i assume its the player
The trial spawners have an array of players
so would the this then go through all players attached?
there's also: killer, direct_killer and killer_player (if that helps)
thats where I'm confused
I assumed:
This = trial spawner block entity
Killer options = untracked since the player kills seperate entity's
this can't be a block
not a block entity either I'm assuming then?
I guess it's just null
That's what I'm confused by, if this is null, killer options are null, how do I pull the UUID to check the players scoreboard info
so the trial spawner has a nbt tag called registered_players
Yea, that is a array of UUID's of players that have been tracked
Would "this" iterate through those UUID's to provide loot?
Its even more confusing since it seems like the loot table is type: "chest" but also its type: "spawner"?
I guess you could do this:
{ // entry //
"type": "minecraft:item",
"name": "minecraft:iron_nugget",
"functions": [
{
"function": "minecraft:set_nbt",
"tag": "{randumbTag: true}"
}
]
}```
and then:
```hs
execute as @e[type=item, randumbTag=true] run ...
be sure to put that into its own roll
Do you mind explaining what this does?
basically, it spawns an iron nugget with a certain nbt tag which then allows us to check really as much as we want, if loot was generated and then do something (and don't forget kill at the end)
if you put it into tick then you basically allow yourself to run a function
so I spawn an item that allows for a function to change what the item is?
Is there a way to instead add a nbt tag to the spawner block entity with a integer that can then be used?
be used where
well if the block entity has a nbt tag with an integer then couldn't we use a entity_properties condition to check that value?
oh since I want to replace the other loot tables could I modify the weight integer attached to the loot table and use that to select which pool to drop?!
The full problem is I'm trying to get the new trial spawners loot table to actually be interesting. It already can work with multiple players and tracks their UUID but the items suck. I want to take data from the players, specifically their equipment and enchantment level and use that to change the rewards and how many they get.
For example if you only have iron gear, it can spawn 2-4 raw iron. If you have a lvl 3 enchant on your gear it could triple that, but also modify the number of mobs you face.
Also I plan on adding in different effects to the mobs based on the level of armor you have so if you are wearing netherite you could be facing arrows that wither or crazy stuff like that.
I'm struggling to get this information tracked and for the trial spawner to be updated because of this. I've got the numbers being updated on the scoreboard based on gear and enchant levels for doing math but actually impacting the trial spawner itself just seems super unintuitive.
the trail spawner works (like most new feature) almost purely from nbt
that means you can literally just change the table to whtaever you whenever you want
therefore if a player has iron gear change the table to iron nr 1
if he has iron gear with lvl 3 enchant change it to iron nr. 3
how would I go about tracking that and changing it though? is there a way to detect what spawners are around the player? or a way to detect if a UUID is added to the spawner?
Right but I'm not sure how to access that data or interact with it if/when it changes.
I know it has the info on it just not how to use it
... append from (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>]
... append string (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>] [<start>] [<end>]
... append value <value>
Append the source data or direct value data onto the end of the pointed-to list.
... insert <index> from (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>]
... insert <index> string (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>] [<start>] [<end>]
... insert <index> value <value>
Insert the source data or direct value data into the pointed-to list as element <index>, then shift higher elements one position upward.
... merge from (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>]
... merge string (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>] [<start>] [<end>]
... merge value <value>
Merge the source data or direct value data into the pointed-to object.
... prepend from (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>]
... prepend string (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>] [<start>] [<end>]
... prepend value <value>
Prepend the source data or direct value data onto the beginning of the pointed-to list.
... set from (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>]
... set string (block <sourcePos>|entity <source>|storage <source>) [<sourcePath>] [<start>] [<end>]
... set value <value>
Set the tag specified by <targetPath> to the source data or direct value data.
all of these would need a position value to target the specific block wouldn't they? how would I do this in natural world gen?
Solution 1 (fast, tedious):
change all structures that contain trail spawners .nbt file to spawn a tagged marker on the exact block of the spawner and spawn the same spawner if someone places the spawner himself (the second thing should be triggerable due to performance)
Solution 2 (slow, less tedious):
Search through all blocks around the player.
solution 3, /fill replace all the blocks nearby with command blocks which auto run a function
if it works
I'm still really new to this. Would that be an easy thing to learn how to code in to a function?
Also just to be sure cause I'm assuming this is the case cause mojang but have to ask anyways. Theres no way to have it track if a block entity block state changes and then use that to get position values to update this?
well technically yes but it wouldn't be any faster or easier than solution 3
What I mean is more so when minecraft tracks the change sending out a trigger to update since its already doing that instead of having the ticks scanning looking through all the blocks for a change. No triggers or responses that can be waited for and acted upon automatically.
Most code has multiple listeners to it. It seems we only get access to load and tick.
the only things we have which are kinda are advancments and scoreboard objectives
both only apply to players
Thats what I figured. Have to work for 10 hours but is there a place I could read about and learn solution 1? Im struggling to get the spawners to spawn with loot tables i want anyways and that would probably help with that.
the first thing I recommend for solution one is some script or scripting language, it makes your life easier. then you should know how nbt is structured or pick a scripting tool with an nbt library. Then you need to understand how minecraft saves blocks and once you know all that you should be good to go
Knowing a bit of datapack would be advantageous so you know where to look for data in the minecraft files and how to override it accordingly
I've already got what you had suggested previously, built and mostly working. But I'm gonna work to optimize it after I have a basic working version. Last things I need is to get the spawners spawning with the single loot table and to have the number of resources change based on enchant level which only needs predicates built to be finished.
So I do have a general idea for some of the stuff, but its not very deep. Its kinda surface level stuff I know works but I dont know how it's put together and how I could change or interact with it quickly to update it.
well, mcfunction ain't a programming language therefore the answer to your second paragraph is you can't
adaptability is kinda not a thing with datapacks
There is certain ways that are more effective then others though right? Like I could check a players inventory and every single slot every single time to see if a function needs to be run, or I could have it so when a player gets close to what needs to be checked before it runs through the slots.
1 check every tick versus 100 checks every tick to reduce lag is pretty important.
Its more how to do those checks and figure out whats the most optimal that I need to learn and part of that is what data is tracked and how I can have functions check it.
for this example there is conveniently an advancement provided
Oh?
{
"criteria": {
"requirement": {
"trigger": "minecraft:inventory_changed",
"conditions": {
"items": [
{
"items": [
"minecraft:diamond"
],
"enchantments": [
{
"enchantment": "minecraft:unbreaking",
"levels": 3
}
]
}
]
}
}
}
}```
Oh?! So is that a single item or can it be any items in a tag list?
I think almost every advancement, that makes you obtain an item uses' it (e.g. Minecraft)
but you can literally check the way mc does it to find out how it does it's advancements
Its a 1 time thing though right? You cant use that multiple times to update back and forth?
?
Dont advancements trigger the one time to provide the advancement and then stop checking? Or is it just essentially a event listener that triggers everytime an event happens?
the first (or the last) thing you want to do in the function that you specify as a reward is advancement revoke @s <whatever>
So basically they can be used as action listeners to check if certain things happen? Why do people not use these constantly for optimization? I was trying to find something like this a week ago and was told once that it was impossible. Hell I'm pretty sure vanilla tweaks's triggers constantly with its ray tracing when it could be changed to only trigger when a player gets advancement minecraft:item_used_on_block to check if a player has broken a piece of wood making it a LOT more server friendly.
well the thing is they're not faster than tick, anything which can be done in tick is faster there than in a tick advancement. But if your not using the tick advancement it's faster yes
and people do use this a lot
I hadnt seen any resources. But good to know now that it exists