#New to making datapacks how do I make this into a chance based effect

1 messages · Page 1 of 1 (latest)

delicate saffron
#

I couldn't figure out how to make it trigger on hit so I settled with a proximity based trigger but Im not sure how to implement a predicate into it to make the outcome into a chance of occuring

#

Also Im probably not very efficient at this since I just learned how to do this yesterday but Im working with what I got

oak cave
#

on hit effects could be triggered with advancements or enchantments

prisma sluice
#

As for how to implement a chance predicate, do you know how to make a predicate?

#

@delicate saffron

delicate saffron
#

Yeah I already figured out how to attach the predicate, I however still don't know how to make the hit effect work or how to make it work on advancement

prisma sluice
#

Well, do you know how to make an advancement?

delicate saffron
#

I do not

prisma sluice
#

Alright, well I recommend going to Misode to help

opal lakeBOT
#
Misode
About

misode.github.io is the most popular site for JSON datapack generators. This site has generators for commonly used files such as advancements, recipes, and more, as well as datapack changelogs, debug inspectors, and more.

prisma sluice
#

If I'm understanding your goal, you'll be making a player_hurt_entity advancement trigger

#

That will let you detect which entity the player hurt, with what weapon, and you can also use a chance predicate

delicate saffron
#

Yeah at the moment I just have it so that a particle which is actually an entity is within 3 blocks triggers the predicate and if the predicate succeeds runs the command to give additional abilities

prisma sluice
#

Ok

delicate saffron
#

Which @ do I use for predicate

#

it stopped working and I forgot which it goes with

oak cave
#

need to know what code you got

prisma sluice
#

Any?

#

I don't understand the question

delicate saffron
#

I was using an @ command to make it launch the predicate, I only know it wasn't @a because it wasn't a player launching the command

#

I think I figured it out but idk

prisma sluice
#

@ isn't a command, it's used in target selectors

#

You can check a predicate as a target selector argument, and it can be used for any target selector

delicate saffron
#

Im assuming its due to probable bad execution of the code since I don't entirely know what Im doing but the effect works, if I hit the correct mob with the correct skill it gives me the skill assigned to said mob, but after assigning more skills to be given from mobs it just ceases to work after predicate is added since it stopped working

prisma sluice
#

Are you revoking the advancement in the reward function?

#

You need to do that in order for it to be achievable again

delicate saffron
#

I haven't done the advancement thing yet Im trying to get it to work consistently before changing its activation conditions

prisma sluice
#

I see

#

Then you're gonna need to show your work if you want assistance

#

Cause I think we're running into an issue of language where you're describing things by what you call them, but not in a vocabulary that we share

delicate saffron
#

how do I do the chat bubble thing where everything is in a gray box

prisma sluice
#

Do you have an example?

delicate saffron
#

one sec

#

I got it

#

so this is probably very sloppy since I don't really know what Im doing but I had it like
execute as @e[predicate=gluttony:degenerate_obtained] as @e[type=tensura:predator_mist] if entity @e[type=tensura:shizu,distance=..4] as @p run tensura edit @p ability grant tensura:degenerate

prisma sluice
#

What

#

How is that an example of the grey chat bubble thing?

delicate saffron
#

I found out how to do it

#

or atleast I think

prisma sluice
#

...

oak cave
#

what's a tensura

prisma sluice
#

I am not going to be able to help you if I can't follow your train of thought

oak cave
#

a mod?

delicate saffron
#

its a mod

#

the bubble's not important I just wanted to make things neater

prisma sluice
#

You ask how to do X, I ask for an example of X so I can answer, you give me Y, now I don't know what you want

oak cave
#

is 'grey bubble' a text display?

delicate saffron
#

Yeah

prisma sluice
delicate saffron
#

I just did what worked

#

I had an entity spawning from the skill and if the entity spawned close enough to the target entity it triggered and gave me a skill with a 90% chance of failing

oak cave
#

yeah but it's likely not optimised or even logical

delicate saffron
#

I know I just started doing all this yesterday

prisma sluice
#

You're running a command as every entity that has that predicate, a command as every entity that is predator mist, another command as every other entity that is shizu and is within 4 blocks of the executing position (which currently is neither of those preceding entities), another command as the closest player to that executing position, a modded command

prisma sluice
delicate saffron
#

I don't know how to do things effectively I just find out ways to do them and go with tha

prisma sluice
#

But that's why we need examples so we can explain what's going on

#

What do you actually want to be detecting here?

#

Explain in plain language

oak cave
#

what kind of ability do you want to activate and what does it check

delicate saffron
#

I want the predator ability, which just spawns a mist, to when in proximity (or ideally when damaging) the mob Shizu to trigger a command giving a skill

prisma sluice
#

Ok, none of this does that right now

delicate saffron
#

I had it working for several different mobs

#

until it stopped working

prisma sluice
#

You want to execute as and at each predator mist, if entity @e[type=tensura:shizu,distance=..4], the tensura skill command

#

The at is important because it changes where the rest of the command gets run from, which is important for the distance check. And then for the shizu, you don't need to execute as it, you can just check if it exists at all

delicate saffron
#

so what would the command look like for that then? and why was what I did working at all?

prisma sluice
#

as only changes who is running the rest of the command, but keeps running it at the current position

delicate saffron
#

It was though

prisma sluice
#

More likely it was working inconsistently based on where you and the various other entities happened to be

delicate saffron
#

when I used the ability predator it was giving me the desired skill from the correct mob

prisma sluice
#

Then idk what you even wanted

delicate saffron
#

Im trying to get it to happen consistently

prisma sluice
#

This will help do that

#

And I'm not going to write the command for you. I explained how it should look generally, so try to write it based on that, paste your result here, and we'll dissect it from there so you can learn

oak cave
#

I probably need a diagram

#

I still don't understand how this ability works

delicate saffron
#

like the ability predator?

#

the predator_mist?

prisma sluice
# oak cave I still don't understand how this ability works

The ability summons a predator mist entity. They want to detect when the ability is used to kill a Shizu, so they are just detecting if a Shizu is nearby a Predator Mist, and if so, grant the nearest player (presumably the one who used the ability) a new tensura skill

#

And once they have that they can add an if predicate ... before the run to make it only happen on a random chance

delicate saffron
#

Yeah

oak cave
#

does the mist cloud happen to have an owner (origin)?

prisma sluice
#

I am however going to sleep, so if no one helps you troubleshoot the command you write based on this instruction...
#1308260757074608223 message

Then we'll pick up in the morning

prisma sluice
oak cave
#

(I however am awake)

delicate saffron
#

I don't know what origin means here but it has to and can only be used by a player if that helps

oak cave
#

it is a modded ability so let's leave the origin thing for later

#

I can't be sure how it's implemented there

delicate saffron
#

Im not sure, I only know what I've managed to scrape together to work

#

I don't understand the as and at for the entity predator_mist

oak cave
#

what's your current advancement?

delicate saffron
#

I don't have one for that yet, Im trying to get the ability to activate consistently, also Im not sure how to make the advancement trigger on a player using the skill

oak cave
#

if not advancement, then when does this function run?

#

or is this a tick function?

delicate saffron
#

its a tick function that I have constantly running but it only triggers if the entity predator_mist and the mob Shizu are near eachother

#

becuase I currently don't know how to make it a hit effect, and I can't get the effect to trigger consistently enough to even tell if it works as a hit effect

oak cave
#

so the first clause should be 'as every mist'

delicate saffron
#

so like I currently have execute as @e[type=tensura:predator_mist] if entity @e[type=tensura:predator_mist] as @p run tensura edit @p ability grant tensura:degenerate typed out, and everytime I use predator it runs the command to give me degenerate

#

wouldn't I have to specify the mod?

oak cave
#

you just duplicated the mist check which is not only redundant but also duplicates the whole command quadratically

delicate saffron
#

I only did what I managed to get to work

#

I don't know how to make it work in any other way

oak cave
#

first clause you got right

delicate saffron
#

ah

#

so execute as @e[type=tensura:predator_mist] as @p run tensura edit @p ability grant tensura:degenerate

#

Which still works so that I understand

oak cave
#

yeah so the next part is moving the execution position to the mist

delicate saffron
#

which means what?

#

execute at?

#

so execute at @e[type=tensura:predator_mist] as @p run tensura edit @p ability grant tensura:degenerate?

#

I just started this stuff so if it works I have no idea that I did it wrong, which is probably what led to the halt in the process working at all

oak cave
#

that should work yeah?

delicate saffron
#

Yeah it still functions

oak cave
#

now check for the mob

delicate saffron
#

is it the same @e[type=mob]?

oak cave
#

inbetween the mist and @p

#

you want to check if the mob exists

delicate saffron
#

Yeah Im asking if that's how I do it

oak cave
#

then the part you checked for the mob previously should work here

delicate saffron
#

Like what was in my original code?

oak cave
#

yes

delicate saffron
#

so execute at @e[type=tensura:predator_mist] if entity @e[type=tensura:shizu] as @p run tensura edit @p ability grant tensura:degenerate?

oak cave
#

try it now

delicate saffron
#

Yeah it works

oak cave
#

you forgot the distance

delicate saffron
#

well that just works if Shizu exists

#

but distance works too

oak cave
#

not 'but'

#

checking existence and distance should be in the same place

delicate saffron
#

No I was saying distance works tooo

#

execute at @e[type=tensura:predator_mist] if entity @e[type=tensura:shizu, distance=..4] as @p run tensura edit @p ability grant tensura:degenerate

#

that's what I have atm

oak cave
#

okay

delicate saffron
#

Is it possible to attach a message to that?

#

because currently it just silently gives you the ability

oak cave
#

the 2nd @p you should change to @s

#

@s stands for self

#

since you already selected a player

delicate saffron
#

okay

#

well now it works, I could go off distance for the trigger but would it be better to make hitting them the trigger?

oak cave
#

who needs to hit whom?

delicate saffron
#

Player hitting Shizu with predator

oak cave
#

exactly when the skill triggers?

#

this might be a little bit more difficult

delicate saffron
#

Maybe I just leave it a distance trigger then

oak cave
#

you could check if the shizu mob has been hit recently

#

but it doesn't specify how it got hit

delicate saffron
#

Where as currently it has to be predator near shizu, and only players can have predator so more specific but it could be cheesed

#

Though the datapack is intended for my friend group so thats not a huge issue

oak cave
#

hmm it's for multiplayer huh

#

it might grant the ability to the wrong player if they stand closer than you

delicate saffron
#

True

#

So how would I make it give it only to the correct player?

oak cave
#

do you know about tick freeze?

delicate saffron
#

Like the command that stops everything? Basically jojo style time stop?

oak cave
#

yes

#

freeze, and then cast the spell

delicate saffron
#

Huh?

oak cave
#

type /tick freeze in chat (not in functions)

#

and then cast predator

delicate saffron
#

So just stop everything from moving so I can cast predator?

oak cave
#

I need to know what the mist is made out of so...

delicate saffron
#

Its an entity

oak cave
#

yes, and I need to know its entity data

delicate saffron
#

I don't know how to find that

oak cave
#

so freezing makes it easier to look at it

delicate saffron
#

Is there tick freeze in 1.19.2?

oak cave
#

hmm, i don't know

#

if there's not we'll find another way

delicate saffron
#

I don't really understand the mist entity, I initially thought it was a particle until I was browsing the mod files

oak cave
#

how long does it last?

#

until it dies

delicate saffron
#

~1 second

oak cave
#

do you know about the /data command

delicate saffron
#

Sort of

oak cave
#

you can get the nbt data of some entity by using /data get entity

#

and then a selector

#

you want to get the data of a mist

#

or rather, I want you to

#

so we can dissect it

delicate saffron
#

So how do I specify the mist?

#

For the command in world

oak cave
#

like before, just an @e[type=...]

delicate saffron
#

Well I tried to summon the entity as well

oak cave
#

no I want you to cast it

#

summoning loses important context

delicate saffron
#

Apparently the entity predator_mist itself is invisible and the black particles it summons only appear when used by a player

oak cave
delicate saffron
#

The response I get is "Only one entity is allowed, but the provided selector allows more than one"

oak cave
#

seems like 1.19.2 doesn't have the command I wanted but uh

delicate saffron
#

Where in them exactly?

oak cave
#

after the type or before it, might work both ways but I'd put it after

delicate saffron
#

I don't think I understand

oak cave
#

[type=something, limit=1]

delicate saffron
#

Now I don't understand because it said no entity found

oak cave
#

because there's currently none

delicate saffron
#

I got it

oak cave
#

you have to cast it and paste the command quickly

delicate saffron
#

I wasn't fast enough initially

#

Is it possible to copy the result?

oak cave
#

I haven't tried

delicate saffron
#

I have the data result but there's a lot of stuff

#

Oh wait some of it is because of me one sec

#

Still a lot but now there's no items involved in it

oak cave
#

this stuff would've been easier on a later version

delicate saffron
#

This mod is only in 1.19.2

oak cave
#

can you scroll and post screenshots for the output?

delicate saffron
oak cave
#

so it does have an owner right at the beginning

delicate saffron
#

is that helpful?

oak cave
#

the owner is you

#

we don't want it to grant an ability to the wrong person

delicate saffron
#

okay

oak cave
#

so there's this thing called execute on that lets you access an entity's owner, or rider, or vehicle

delicate saffron
#

so do I replace execute with execute on?

oak cave
#

first you select the mist, and then add on owner next to it

#

and try running something like say hi

#

if it comes out as you then it works

delicate saffron
#

so @e[type=tensura:predator_mist comes before on owner?

oak cave
#

yes

delicate saffron
#

Im almost certain this is wrong but

#

execute at @e[type=tensura:predator_mist] on owner if entity @e[type=tensura:shizu, distance=..4] as @p run tensura edit @s ability grant tensura:degenerate

oak cave
#

yes, that part enough is not complete

delicate saffron
#

for the skill not the hi

oak cave
#

does the say hi work

delicate saffron
#

imma change it for say hi too

#

uhhh

#

No

oak cave
#

what do you have right now for the hi?

delicate saffron
#

execute at @e[type=tensura:predator_mist] on owner if entity @e[type=tensura:shizu, distance=..4] as @p run say hi

oak cave
#

no no

#

make a new command for the say hi

delicate saffron
#

oh okay

oak cave
#

for now, the skill command is not complete

delicate saffron
#

so for now do I disregard shizu and distance and just specify mist and owner to say hi?

oak cave
#

yes

#

execute as @e[type=tensura:predator_mist] on owner run say hi

#

while it's not dead of course

delicate saffron
#

Maybe Im doing this wrong but nothing happens

oak cave
#

does it work without the owner part?

#

if the mist cloud does say hi, then owner doesn't work and I have no more ideas

delicate saffron
#

uh sort of

#

yeah

#

mist cloud said hi

#

well

#

I'll just have it distance related

#

it should be mostly fine

#

I might have another question but Im gonna see if I can do it myself first

#

oh wait

#

can I attach a message to the normal command?

#

so like when run tensura edit @s ability grant tensura:degenerate happens it notifies the user that they got degenerate instead of degenerate silently appearing in their list?

oak cave
#

text displays?

delicate saffron
#

maybe

oak cave
#

text displays don't exist until 1.19.4

delicate saffron
#

shucks

oak cave
#

so your only options are tellraw and say

delicate saffron
#

okay

#

also where would I put the predicate now?

#

would it be before the mist?

oak cave
#

what is this predicate

delicate saffron
#
    "condition": "minecraft:random_chance",
    "chance": 0.9
}```
#

chance is gonna be changed but that's probably not important

oak cave
#

you want it to run once per mist so after

delicate saffron
#

okay so after mist before shizu then/

#

*?

oak cave
#

yes

delicate saffron
#

how do I add the predicate, do I use as or at

#

or is it like @a or smth

#

execute at @e[type=tensura:predator_mist] as @a[predicate=gluttony:degenerate_obtained] if entity @e[type=tensura:shizu, distance=..4] as @p run tensura edit @s ability grant tensura:degenerate is that right?

oak cave
#

no, you use if predicate gluttony:degenerate_obtained

delicate saffron
#

okay

oak cave
#

they don't go in brackets

delicate saffron
#

I didn't know that, it worked so I thought it was right

oak cave
#

it worked because you're testing on single player

delicate saffron
#

execute at @e[type=tensura:predator_mist] if predicate gluttony:degenerate_obtained if entity @e[type=tensura:shizu, distance=..4] as @p run tensura edit @s ability grant tensura:degenerate

#

like that?

oak cave
#

yes

delicate saffron
#

whats the difference between tellraw and say?

oak cave
#

tellraw is more customisable, with colour and styles

delicate saffron
#

is it also serverwide?

oak cave
#

both of them can be

delicate saffron
#

but aren't by default?

oak cave
#

tellraw can also be personal

oak cave
delicate saffron
#

is it possible then to add a personal tellraw to the end of that code to also put in chat that they obtained degenerate?

oak cave
#

yes, so instead of running the tensura command you run a new function

#

that contains the tensura command and the tellraw

#

run function somewhere:something

delicate saffron
#

okay I'll try that and probably fail

#

does it matter what i name the function?

#

like it doesnt have to be like the load.mcfunction right?

oak cave
#

just give it a name that you won't fumble

delicate saffron
#

evidentally I didn't do the function right

#

wait maybe im just dumb

#

okay nevermind I don't know

#

so execute at @e[type=tensura:predator_mist] if predicate gluttony:degenerate_obtained if entity @e[type=tensura:shizu, distance=..4] run function gluttony:message.mcfunction

#

is that correct?

oak cave
#

without the .mcfunction

#

also add the as @p back here

delicate saffron
#

Alr

#

can I limit it to just saying it once? and only when degenerate is obtained?

#

I assume the repeat is there being several of the entities with one use

delicate saffron
#

I assume triggering only the first time would have to do with unless or if or smth

oak cave
#

I don't know

#

can you check if you already have the skill?

delicate saffron
#

I can add a tag to myself when I get it

#

otherwise Im not sure how to check if I have it, I know it shows up in the /data for my player

prisma sluice
#

You can check for tags in target selector arguments

#

@s[tag=foo.bar]

delicate saffron
#

Is it possible to set a predicate where instead of the chance being something happens or doesnt, it has several potential outcomes? or is it simpler to make that run through an rng dummy where score = outcome

prisma sluice
#

Predicates only return true or false, so yes a random scoreboard would be the way to go for something like that

delicate saffron
#

So I currently have execute if predicate name:rng as @e[type=Villager] as @s run tag @e[type=Villager] add tagname

#

Which Im hoping makes it so on a % chance gives a villager a tag, but it's set as tick function to apply to any villagers, but I have no idea how to make it only run once, so it just keeps running until all villagers have the tag, how would I limit that?

prisma sluice
#

Change this to just run as all villagers that do not have some arbitrary tag (such as checked), and have it run a function. Have that function give the checked tag as well as check the rng predicate to give the tag you actually care about

delicate saffron
#

So have a function that checks if they have the tag, and then if they don't it runs a function to give them a tag

prisma sluice
#

Yep