#Trial Spawner Loot Table

1 messages · Page 1 of 1 (latest)

short igloo
#

I'm trying to figure out how to take info from a players scoreboard and use it to manipulate the loot table rewards in the trial spawner. I can't seem to figure out a way of having the players that are tracked in the Trial Spawner have their score checked

trail prismBOT
#
Someone will come and help soon!

💬 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

keen rain
#

in a loot table most if not all numbers can instead be a score

graceful turtle
#
"functions": [
    {
      "function": "minecraft:set_count",
      "count": {
        "type": "minecraft:score",
        "target": "this",
        "score": "example"
      }
    }
  ]
```?
short igloo
#

target this, that tracks on the player?

keen rain
#

target:this just means the current entity

short igloo
#

Yea I thought that would then be the trial spawner

keen rain
#

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

short igloo
#

The trial spawners have an array of players
so would the this then go through all players attached?

graceful turtle
#

there's also: killer, direct_killer and killer_player (if that helps)

short igloo
#

thats where I'm confused

#

I assumed:
This = trial spawner block entity
Killer options = untracked since the player kills seperate entity's

graceful turtle
#

this can't be a block

short igloo
#

not a block entity either I'm assuming then?

graceful turtle
#

I guess it's just null

short igloo
#

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

keen rain
#

you could maybe use @p

#

idk

graceful turtle
#

so the trial spawner has a nbt tag called registered_players

short igloo
#

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"?

graceful turtle
#

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

short igloo
#

Do you mind explaining what this does?

graceful turtle
#

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

short igloo
#

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?

graceful turtle
#

be used where

short igloo
#

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?!

graceful turtle
#

so this is a problem xy

#

give us the full problem then

short igloo
#

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.

graceful turtle
#

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

short igloo
#

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?

short igloo
#

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

balmy flowerBOT
#
📜 /data

... 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.

short igloo
#

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?

graceful turtle
#

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.

keen rain
#

solution 3, /fill replace all the blocks nearby with command blocks which auto run a function

#

if it works

short igloo
#

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?

graceful turtle
#

well technically yes but it wouldn't be any faster or easier than solution 3

short igloo
#

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.

graceful turtle
#

the only things we have which are kinda are advancments and scoreboard objectives

#

both only apply to players

short igloo
#

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.

graceful turtle
#

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

short igloo
#

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.

graceful turtle
#

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

short igloo
#

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.

graceful turtle
short igloo
#

Oh?

graceful turtle
#
{
  "criteria": {
    "requirement": {
      "trigger": "minecraft:inventory_changed",
      "conditions": {
        "items": [
          {
            "items": [
              "minecraft:diamond"
            ],
            "enchantments": [
              {
                "enchantment": "minecraft:unbreaking",
                "levels": 3
              }
            ]
          }
        ]
      }
    }
  }
}```
short igloo
#

Oh?! So is that a single item or can it be any items in a tag list?

graceful turtle
#

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

short igloo
#

Its a 1 time thing though right? You cant use that multiple times to update back and forth?

graceful turtle
#

?

short igloo
#

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?

graceful turtle
#

the first (or the last) thing you want to do in the function that you specify as a reward is advancement revoke @s <whatever>

short igloo
#

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.

graceful turtle
#

and people do use this a lot

short igloo
#

I hadnt seen any resources. But good to know now that it exists