Carpet

Carpet

2M Downloads

[Suggestion] Detect professional blocK

Lolor63 opened this issue · 28 comments

commented

Add a way to detect the professional bloc of the villager,
By the track command and a new item, like the system to detect bed but for professional block, with a radius they can detect or not =)

commented

i thought bloc as in the profession carrier, like white robes for cartographer and librarian. It's just cos both bloc and block are english words. This couls actually be pretty useful

commented

Yes you're right, i will try on scarpet, i have to do some researsh to do that but well, i tell you if i succeed..
For the bloc or block, i don't what is good, it's like a compost blocK for a farmer villager, sorry i'm not an english man =)

commented

dont worry, and I'm making the app myself rn. It's not trivial

commented

ill give you what I have, if u wanna do it, and I gotta go rn:

brain=e~'nbt':'Brain';
mem=brain:'memories';
pos=mem:'"minecraft:job_site"':'"pos"';

pos is rn a string. You just gotta take out the commas and stuff, and then thats about it
@Lolor63

commented

btw, bloc and block are completely different. EU is a trade bloc, composter is a farming block

commented

You can do that easily with scarpet.

commented

Never mind, I did it myself:
Gnembon, this may be useful, so I'll add (at some point) to the scarpet repo!

__on_player_uses_item(player, item_tuple, hand)->(
    if(item_tuple:0=='blaze_rod',
        entity=query(player,'trace',20,'entities')||null;
        if(type(entity)=='entity'&&entity~'type'=='villager',
            brain= entity~'nbt':'Brain';
            mem=brain:'memories';
            pos=mem:'"minecraft:job_site"':'"pos"'||null;
            if(!pos,return());
            l(x,y,z)=nbt(pos):'[]';
            particle_line('happy_villager',pos(entity),pos(player));
            particle_line('happy_villager',pos(entity),l(x+0.5,y+0.5,z+0.5),0.1);
        )
    )
)
commented

and do tell me when you got the app please, I wanna see it.
And then close this issue

commented

For the particle line you can use particle_line(particle type, pos1, pos2)

commented

yes, that's great. I would remove that return() cause you don't want to have exception thrown and caught every time a player uses an item.

commented

done!

commented

no worries man, you'll get there too!

commented

Actually, @Lolor63 try it now, with the exta line at the bottom to see exactly which villager you're pointing at

And I had made a mistake, so use it now

commented

that last edit is so that I don't entity trace avry time I use item, only if clicking with blaze rod

commented

Hi @Ghoulboy78, woa that's perfect, I tried without success since someone day, thank you for your job!

commented

Nothing more, i've tried his eventtest script, work properly,
I just found a gnembon script for villager but don't work for me

commented

i'm on a 20w19a server, something change maybe? Or it's just me =/

commented

do you have discord?

commented

yes @Lolor63_, i'll be avaible tonight, have to go to work now =)

commented

r u on any technical server? cos then it's easier to find you
if not just, like, join scicraft and then I'll dm you

commented

i've join scicraft

commented

I've just try, but I don't know how to active this script 😕

commented

so you open a command block
then you type /script run __on_player_uses_item(player, item_tuple, hand)->(if(item_tuple:0=='blaze_rod',entity=query(player,'trace',20,'entities')||null;if(type(entity)=='entity'&&entity~'type'=='villager',brain=entity~'nbt':'Brain';mem=brain:'memories';pos=mem:'"minecraft:job_site"':'"pos"'||null;if(!pos,return());l(x,y,z)=nbt(pos):'[]';particle_line('happy_villager',pos(entity),pos(player));particle_line('happy_villager',pos(entity),l(x+0.5,y+0.5,z+0.5),0.1))))

and then activate once, then break command block.
It should work, @Lolor63

commented

yes i do that but after i have to right clic a pnj with a blaze rode right?

commented

whats pnj? you have to click from a distance, or it fails, and u open villager gui. If you click jobless villager, nothing happens. If you click villager with job, it makes particle line to the workstation

commented

It's what i do, but nothing happens, i thing i do something wrong...

commented

what i thought. Put it into a .sc file- If you don't know what that is. go to https://www.youtube.com/watch?v=XQprFbtVAV8
gnembon explains here

commented

for the .sc file copy the first code i posted, up above #268 (comment)