#how to change a potion

1 messages · Page 1 of 1 (latest)

halcyon acorn
#

Hey all, new to datapacks, and was wondering if there was a way to change the potion from pufferfish->waterbottle=mundane potion, to pufferfish->waterbottle=custom potion?

balmy inletBOT
#

<@&1201956957406109788>

Someone will come and help soon!

💬 While you wait, take this time to provide more context and details.

🙇 If nobody has answered you by <t:1722614307:t>, feel free to use the Summon Helpers button to ping our helper team.

✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve

wooden mirage
#

No, unfortunately brewing recipes are hardcoded

#

You would have to make the potion some other way

halcyon acorn
#

interesting OK, is there a way to detect mundane potions in a brewing stand, than replace it with my custom potion?

wooden mirage
#

Maybe

#

Ok, it looks like you can detect which items are in a brewing stand, the real problem is detecting the brewing stand

halcyon acorn
#

well what if instead of just brewing stand it just checks all inventorys being acessed

wooden mirage
#

How do you mean?

halcyon acorn
#

like if a player is in a chest or barrel or any storage gui, it checks the slots for the mundane potion, then replaces it with the custom potion

wooden mirage
#

Oh I see, no that's not really the issue

#

You just can't really detect which inventories a player has open, since that's client-side

#

But I think you can detect a player opening a brewing stand

#

So you'd need to detect that, summon a marker at the brewing stand, and check the block at that marker

halcyon acorn
#

so would that only affect when the brewing stand is first opened, or throughout the entire time its open

wooden mirage
#

The whole time

#

You would basically set a marker there so you know that the brewing stand is there

#

although I'm not sure how/if you can detect the player closing it again

halcyon acorn
#

hmm

#

well i guess thats not too bad

wooden mirage
#

The only downside really is that it would continue checking brewing stands once the player has closed them

halcyon acorn
#

well thats fine actually

#

cause then a player may start brewing

#

then leave the gui while its brewing, then break the stand

#

actualyl wait a second, how would the marker know its the first time acessing the brewing stand,

#

or would it just create another one every time its acessed

wooden mirage
#

You would have to check if there's already a marker there

halcyon acorn
#

ok i seem to get what your saying, sorry still very new to datapacks

wooden mirage
#

that's all good

halcyon acorn
#

when placing the first marker, id have to use an advancement that rewards a function for detecting when the brewing stand is acessed right?

wooden mirage
#

Yep

halcyon acorn
#

Hey, if your still here, I'm trying to make the advancement, but i'm not sure of the syntax to confirm that its a brewing stand

wooden mirage
#

You don't want a location trigger, that just detects a player's location

#

You need default_block_use, which detects the player right-clicking on a block

halcyon acorn
#

ohhh that makes more sense

wooden mirage
#

Like this should work, I think:

{
  "criteria": {
    "open_brewing_stand": {
      "trigger": "minecraft:default_block_use",
      "conditions": {
        "location": [
          {
            "condition": "minecraft:location_check",
            "predicate": {
              "block": {
                "blocks": "minecraft:brewing_stand"
              }
            }
          }
        ]
      }
    }
  },
  "rewards": {
    "function": "puff:open_brewing_stand"
  }
}
halcyon acorn
#

ok so the location should be in the condition, but it

wooden mirage
#

Yep

halcyon acorn
#

ok perfect, now the open brewing stand function is working

wooden mirage
#

Cool

halcyon acorn
#

but my command to replace the potion is not

wooden mirage
#

Right, I think I know why

halcyon acorn
#

oh?

#

i put the puff_potion.json under puff/tags

wooden mirage
#

Well there's a couple of reasons actually

#

You can't create custom item IDs

halcyon acorn
#

oh ok, so could I just generate a command with the potion, and put it next to set value?

wooden mirage
#

What do you mean by that?

halcyon acorn
#

like using mcstacker, i can create a potion with my desired affects

#

that gives it in a /give format, but i just get rid of that first /give @a where ever, and put it next to set value above

wooden mirage
#

Almost

#

The syntax will be slightly different

halcyon acorn
#

ok

#

do you know where a documentation is

wooden mirage
#

The Minecraft wiki has information about all sorts, including commands and datapack stuff

#

There's no official documentation unfortunately

halcyon acorn
#

OK, i see

#

im looking at the modify command

halcyon acorn
#

looking into it further, its not even detecting when theres a mondane potion in the stand, im not getting the tellraw output

wooden mirage
#

Yes, there are more problems too

#

First of all, the reward function isn't run at the position of the brewing stand, but at the position of the player. You need to run a raycast to find the brewing stand block

somber yachtBOT
#

Raycast

    >>> # Raycasting Guide

Raycasting is when we shoot a line from the player's eyes in the direction they are looking. We use this to get what the player is looking at, and do something to it, such as spawning an explosion.

Raycasting is very simple. All we need do is run a recursive function. This function will run at the player's eyes, check if there is a block at ~ ~ ~, and if there is not, then move 0.1 blocks forward and run itself again. This creates a loop, which will eventually hit a block.

start_raycast function:

# Set the distance limit on the raycast. (10 x limit in blocks, so 1000 would be 100 blocks)
scoreboard players set .limit <any objective> 1000

# Start the raycast
execute at @s anchored eyes positioned ^ ^ ^.1 run function <namespace>:raycast

raycast function:

# Remove one from the limit
scoreboard players remove .limit <objective> 1

# Optional - place a particle, to make the raycast leave a trail
particle minecraft:dust 1 0 0 1 ~ ~ ~

# If the raycast has hit a block, do something
execute unless block ~ ~ ~ #<namespace>:pass_through run setblock ~ ~ ~ diamond_block

# If the raycast hasn't hit a block, continue, but only if the limit is 1 or more (1..)
execute if block ~ ~ ~ #<namespace>:pass_through positioned ^ ^ ^0.1 if score .limit <objective> matches 1.. run function <namespace>:raycast```

namespace/tags/block/**pass_through**.json:```
{
    "replace": false,
    "values": [
        "minecraft:air",
        "minecraft:cave_air",
        "minecraft:void_air"
    ]
}

This should be it! Make sure you add all the functions, and fill in all the blanks (indicated by <this>). Then, you can run the start_raycast function as a player, and it should work.

halcyon acorn
#

most likely dumb question, but what does it mean by objective

wooden mirage
#

You need to create a scoreboard objective

#

And use that

halcyon acorn
#

whenever I run the raycast, the tellraw in start_raycast works, but the tellraw in raycast itself does not

silk grotto
#

try replacing ^ ^ ^.1 by ^ ^ ^0.1 in the start_raycast function

#

I don't think that omitting the 0 is a possibility in datapacks

halcyon acorn
#

just tried, raycast still isnt running

silk grotto
#

oh yeah you need to put a # before your block tags in the raycast function, rn it thinks that puff:pass_through is a block id but because it doesn't exist it throws an error

#

the hashtag tells it that it's a tag

halcyon acorn
#

well then why isnt the tellraw running?

silk grotto
#

in the raycast function?

halcyon acorn
#

yea

silk grotto
#

after or before adding the hashtag?

halcyon acorn
#

both

#

i think somethings causing the raycast function to not start at all

#

so i think the error is somewhere in the start_raycast

#

I think i just fixed it

silk grotto
#

by doing what?

halcyon acorn
#

i changed the coords in start raycast back to 0,5

#

or just to

silk grotto
#

that doesn't make sense

halcyon acorn
#

maybe something didnt save before and that caused it to save?

silk grotto
#

ig

#

does it still work if you change the 0.5 to 0.1 like it was before?

halcyon acorn
#

let me try

#

yea

silk grotto
#

yeah so it was a saving issue

halcyon acorn
#

for this function, the tellraw at the bottom is running but none of the above are working, i cant tell if its a marker issue, or general command issue

wooden mirage
#

Yeah, you're currently checking the marker's nbt data. You need to check the nbt of the block at the position of the marker

halcyon acorn
#

still isnt doing the tellraw for some reason

#

Ok i found the problem, its still creating marker at the player

#

whenever this command runs, it still sets the ~ ~ ~ to the players position and not the raycasts?

#

i tried by tp'ing a mob instead of creating a marker and it just tp's to the player

wooden mirage
#

It looks like puff:pass_through isn't defined, there's an error in vscode

halcyon acorn
#

oh would it be tag now in 1.21?

silk grotto
#

no

#

but you need to add .json at the end of the file

halcyon acorn
#

🤦‍♂️

#

im foolish

#

still this command is not running

silk grotto
#

items don't use NBT since 1.20.5
now they use components: https://minecraft.wiki/w/Data_component_format

Minecraft Wiki

Data components, or simply components, are structured data used to define and store various properties. They are used on items, where they are referred as item components or item stack components, and block entities, partially replacing NBT format.
Data components are used in various places, including the player's inventory, container block enti...

halcyon acorn
#

oh let me read this, thanks

halcyon acorn
#

I believe im inputting this correctly, though evidently im not

wooden mirage
#

Blocks still have NBT

#

So it's still if block ~ ~ ~ brewing_stand{Items:[{...}]}

halcyon acorn
#

so inside the items container i would put the nbt or components of the mundane potion?

#

its saying slot 0 is not a valid term despite what the wiki says above unless im missing something

silk grotto
#

it's not very well formated on this particular instance on the wiki, but slots are always of the byte type and thus need a b at the end of the value: Slot:0b

halcyon acorn
#

would that be in its own brackets?

silk grotto
#

no

halcyon acorn
silk grotto
#

yes normally it's that
maybe the syntax highlighter is broken

#

or maybe that brewing stand are indeed the only block in the game that have non-byte slots value but that wouldn't make any sense because the slot nbt is stored in the item, not the block

halcyon acorn
#

well with this the datapack doesnt work at all

silk grotto
#

like it doesn't even load?

halcyon acorn
#

well it loads, and plays load message, but interacting with brewing stands no longer works

#

and if i comment the line out it works again so

silk grotto
#

oh you put a colon instead of a comma after Slot:0b

halcyon acorn
#

then that makes potion have an error

#

actually i think that makes sense

#

doesnt work with the potion portion in front

silk grotto
#

it needs to be components:{"minecraft:potion_contents":{potion:"mundane"}} where components contains all the components that the item has,
"minecraft:potion_contents" is the component that handles potions (needs to be in-between quotation marks in this case because of the colon in the name, without the quotes it would consider as minecraft as the key and potion_contents as the value,
and potion:"mundane" is the id of the potion

halcyon acorn
#

ok so this is in the slot:1b,

silk grotto
#

with your command it checks if it is in the slot 0b

halcyon acorn
#

gosh, I am so confused by this componenet stuff

silk grotto
#

slots aren't related to components tho

halcyon acorn
#

so, for this command after I type slot:0b, then would i type componenets

#

arent they above componenets

silk grotto
#

the order doesn't matter

halcyon acorn
#

oh i get you

silk grotto
#

could be {components:{...}, Slot:0b} as well as {Slot:0b, components:{...}}

halcyon acorn
#

ok I see

#

aaand now my potion ID is not working

#

ok i got it

#

perfect it works

#

thanks a ton

halcyon acorn
#

whenever this command runs it replaces the 3rd slot of the brewing stand, but the potion it replaces is put in the first slot, and when multiple potions are in the stand ,they all get replaced and put in the first slot deleting 2

#

in the set value section do i need to specify a slot? I had thought that when I modified the block the data with slot was continued

wooden mirage
#

You probably do need a slot there, yeah

#

Otherwise the data gets lost

#

data modify ... set ... overwrites the entire compound, so any slot data gets removed unless you specify it

halcyon acorn
#

could i just put Slot:0b, next to the ID in the custom potion?

wooden mirage
#

Yep

#

... set value {id:"...",count:1b,Slot:0b,components:{...}}

#

Or any order you like

#

Although I'm pretty sure count has to be count:1 now, not 1b

halcyon acorn
#

oh yea,

#

I have come to realize that the entire thing ive been basing this on hasnt been correct

#

on the wiki

#

it says pufferfish make a mundane potion

#

but in the actual game, it doesnt actually work

wooden mirage
#

Really?

#

That's strange

#

The wiki normally has correct info

halcyon acorn
#

well

#

i guess i could also check to see if pufferfish is in the top slot

wooden mirage
#

According to the wiki, there are quite a few items which can be used to make a mundane potion

halcyon acorn
#

yeah, but now that i think about it this is a bit better to check if a pufferish is in the top slot, then delete it, cause then you cant trick it by using anything to make a mundane potion

halcyon acorn
#

so ive got it working where it onyl does it with a pufferfish, and deletes it after, however it only does the replace when I open up the GUI, so if i place all the correct materials in teh brewing stand, it only does the replace if I back out and go back in,

#

and my tick function looks like this

#

this is the remove_marker

halcyon acorn
#

Oh i see I justed needed to get rid of the open brewing stand requirement

wooden mirage
#

You don't want to tick as the players who have the advancement

#

You want to detect the advancement being given with a reward function, revoke it, then summon a marker once at the brewing stand, and check the block at the marker every tick

halcyon acorn
#

I see you posted this today, but I actually did change it to that yesterday

wooden mirage
#

Right. Are you still having the problem above, where it only replaces it on initial open?

halcyon acorn
#

no I fixed it

#

i had just removed the advancements check

#

and it checks every tick

wooden mirage
#

Oh ok cool

balmy inletBOT
# halcyon acorn no I fixed it
🎗️ Is your question resolved?

If your question is resolved, that's great to hear! Make sure to run /resolve or click the Resolve Question button. Otherwise, feel free to continue asking for help! :D