#how to change a potion
1 messages · Page 1 of 1 (latest)
<@&1201956957406109788>
💬 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
No, unfortunately brewing recipes are hardcoded
You would have to make the potion some other way
interesting OK, is there a way to detect mundane potions in a brewing stand, than replace it with my custom potion?
Maybe
Ok, it looks like you can detect which items are in a brewing stand, the real problem is detecting the brewing stand
well what if instead of just brewing stand it just checks all inventorys being acessed
How do you mean?
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
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
so would that only affect when the brewing stand is first opened, or throughout the entire time its open
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
The only downside really is that it would continue checking brewing stands once the player has closed them
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
You would have to check if there's already a marker there
ok i seem to get what your saying, sorry still very new to datapacks
that's all good
when placing the first marker, id have to use an advancement that rewards a function for detecting when the brewing stand is acessed right?
Yep
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
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
ohhh that makes more sense
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"
}
}
ok so the location should be in the condition, but it
Yep
ok perfect, now the open brewing stand function is working
Cool
but my command to replace the potion is not
Right, I think I know why
oh ok, so could I just generate a command with the potion, and put it next to set value?
What do you mean by that?
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
The Minecraft wiki has information about all sorts, including commands and datapack stuff
There's no official documentation unfortunately
looking into it further, its not even detecting when theres a mondane potion in the stand, im not getting the tellraw output
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
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.
most likely dumb question, but what does it mean by objective
whenever I run the raycast, the tellraw in start_raycast works, but the tellraw in raycast itself does not
try replacing ^ ^ ^.1 by ^ ^ ^0.1 in the start_raycast function
I don't think that omitting the 0 is a possibility in datapacks
just tried, raycast still isnt running
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
well then why isnt the tellraw running?
in the raycast function?
yea
after or before adding the hashtag?
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
by doing what?
that doesn't make sense
maybe something didnt save before and that caused it to save?
yeah so it was a saving issue
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
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
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
It looks like puff:pass_through isn't defined, there's an error in vscode
items don't use NBT since 1.20.5
now they use components: https://minecraft.wiki/w/Data_component_format
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...
oh let me read this, thanks
I believe im inputting this correctly, though evidently im not
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
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
would that be in its own brackets?
no
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
well with this the datapack doesnt work at all
like it doesn't even load?
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
oh you put a colon instead of a comma after Slot:0b
then that makes potion have an error
actually i think that makes sense
doesnt work with the potion portion in front
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
ok so this is in the slot:1b,
with your command it checks if it is in the slot 0b
gosh, I am so confused by this componenet stuff
slots aren't related to components tho
so, for this command after I type slot:0b, then would i type componenets
arent they above componenets
the order doesn't matter
oh i get you
could be {components:{...}, Slot:0b} as well as {Slot:0b, components:{...}}
ok I see
aaand now my potion ID is not working
ok i got it
perfect it works
thanks a ton
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
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
could i just put Slot:0b, next to the ID in the custom potion?
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
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
According to the wiki, there are quite a few items which can be used to make a mundane potion
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
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
Oh i see I justed needed to get rid of the open brewing stand requirement
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
I see you posted this today, but I actually did change it to that yesterday
Right. Are you still having the problem above, where it only replaces it on initial open?
no I fixed it
i had just removed the advancements check
and it checks every tick
Oh ok cool
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