#New to making datapacks how do I make this into a chance based effect
1 messages · Page 1 of 1 (latest)
Also Im probably not very efficient at this since I just learned how to do this yesterday but Im working with what I got
on hit effects could be triggered with advancements or enchantments
As for how to implement a chance predicate, do you know how to make a predicate?
@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
Well, do you know how to make an advancement?
I do not
Alright, well I recommend going to Misode to help
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.
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
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
Ok
Which @ do I use for predicate
it stopped working and I forgot which it goes with
need to know what code you got
None?
Any?
I don't understand the question
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
@ 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
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
Are you revoking the advancement in the reward function?
You need to do that in order for it to be achievable again
I haven't done the advancement thing yet Im trying to get it to work consistently before changing its activation conditions
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
how do I do the chat bubble thing where everything is in a gray box
Do you have an example?
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
...
what's a tensura
I am not going to be able to help you if I can't follow your train of thought
a mod?
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
is 'grey bubble' a text display?
Yeah
You have way too many @e selectors here to be detecting anything useful
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
yeah but it's likely not optimised or even logical
I know I just started doing all this yesterday
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
And that's fine
I don't know how to do things effectively I just find out ways to do them and go with tha
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
what kind of ability do you want to activate and what does it check
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
Ok, none of this does that right now
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
so what would the command look like for that then? and why was what I did working at all?
as only changes who is running the rest of the command, but keeps running it at the current position
We established it wasnt
It was though
More likely it was working inconsistently based on where you and the various other entities happened to be
when I used the ability predator it was giving me the desired skill from the correct mob
Then idk what you even wanted
Im trying to get it to happen consistently
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
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
Yeah
does the mist cloud happen to have an owner (origin)?
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
Let's get something working consistently at all first before we dive into details like that
(I however am awake)
I don't know what origin means here but it has to and can only be used by a player if that helps
it is a modded ability so let's leave the origin thing for later
I can't be sure how it's implemented there
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
what's your current advancement?
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
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
so the first clause should be 'as every mist'
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?
you just duplicated the mist check which is not only redundant but also duplicates the whole command quadratically
I only did what I managed to get to work
I don't know how to make it work in any other way
first clause you got right
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
yeah so the next part is moving the execution position to the mist
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
that should work yeah?
Yeah it still functions
now check for the mob
is it the same @e[type=mob]?
Yeah Im asking if that's how I do it
then the part you checked for the mob previously should work here
Like what was in my original code?
yes
so execute at @e[type=tensura:predator_mist] if entity @e[type=tensura:shizu] as @p run tensura edit @p ability grant tensura:degenerate?
try it now
Yeah it works
you forgot the distance
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
okay
Is it possible to attach a message to that?
because currently it just silently gives you the ability
the 2nd @p you should change to @s
@s stands for self
since you already selected a player
okay
well now it works, I could go off distance for the trigger but would it be better to make hitting them the trigger?
who needs to hit whom?
Player hitting Shizu with predator
Maybe I just leave it a distance trigger then
you could check if the shizu mob has been hit recently
but it doesn't specify how it got hit
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
hmm it's for multiplayer huh
it might grant the ability to the wrong player if they stand closer than you
do you know about tick freeze?
Like the command that stops everything? Basically jojo style time stop?
Huh?
So just stop everything from moving so I can cast predator?
I need to know what the mist is made out of so...
Its an entity
yes, and I need to know its entity data
I don't know how to find that
so freezing makes it easier to look at it
Is there tick freeze in 1.19.2?
I don't really understand the mist entity, I initially thought it was a particle until I was browsing the mod files
~1 second
do you know about the /data command
Sort of
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
like before, just an @e[type=...]
Well I tried to summon the entity as well
Apparently the entity predator_mist itself is invisible and the black particles it summons only appear when used by a player
and then use /data in time before it goes away
The response I get is "Only one entity is allowed, but the provided selector allows more than one"
seems like 1.19.2 doesn't have the command I wanted but uh
add a limit=1 inside brackets
Where in them exactly?
after the type or before it, might work both ways but I'd put it after
I don't think I understand
[type=something, limit=1]
Now I don't understand because it said no entity found
because there's currently none
I got it
you have to cast it and paste the command quickly
I haven't tried
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
this stuff would've been easier on a later version
This mod is only in 1.19.2
can you scroll and post screenshots for the output?
so it does have an owner right at the beginning
is that helpful?
okay
so there's this thing called execute on that lets you access an entity's owner, or rider, or vehicle
so do I replace execute with execute on?
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
so @e[type=tensura:predator_mist comes before on owner?
yes
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
yes, that part enough is not complete
for the skill not the hi
does the say hi work
what do you have right now for the hi?
execute at @e[type=tensura:predator_mist] on owner if entity @e[type=tensura:shizu, distance=..4] as @p run say hi
oh okay
for now, the skill command is not complete
so for now do I disregard shizu and distance and just specify mist and owner to say hi?
yes
execute as @e[type=tensura:predator_mist] on owner run say hi
while it's not dead of course
Maybe Im doing this wrong but nothing happens
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
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?
text displays?
maybe
text displays don't exist until 1.19.4
shucks
so your only options are tellraw and say
what is this predicate
"condition": "minecraft:random_chance",
"chance": 0.9
}```
chance is gonna be changed but that's probably not important
you want it to run once per mist so after
yes
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?
no, you use if predicate gluttony:degenerate_obtained
okay
they don't go in brackets
I didn't know that, it worked so I thought it was right
it worked because you're testing on single player
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?
yes
whats the difference between tellraw and say?
tellraw is more customisable, with colour and styles
is it also serverwide?
both of them can be
but aren't by default?
tellraw can also be personal
say is global, tellraw you have to specify who
is it possible then to add a personal tellraw to the end of that code to also put in chat that they obtained degenerate?
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
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?
no
just give it a name that you won't fumble
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?
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
I assume triggering only the first time would have to do with unless or if or smth
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
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
Predicates only return true or false, so yes a random scoreboard would be the way to go for something like that
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?
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
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
Yep