Started by
akisephila
on
Topic category: Help with Minecraft modding (Java Edition)
I understand that this can be done with the raytracing blocks but not only do the raytracing blocks seem nigh impossible to use (I can't even grab the XYZ of where the player is looking, because the "Look [X/Y/Z] position of [Event/Target Entity]" is a number block and can't be used with logic "AND" blocks), there are also zero tutorials that help me in the slightest, and all other forum topics I have checked on this matter have been useless.
Please help.
Edited by akisephila on Wed, 06/30/2021 - 01:15
You will need to raytrace look position and then check for entities in near range of this position
How do I do that? There aren't any tutorials.
Bump
I suggest you check our tutorials collection playlist on our YouTube channel which contains many examples and tutorials that can help you get started with MCreator: https://www.youtube.com/playlist?list=PLAeL-oIFIEngE6jRgFYeFMfuj8WQsO3Ei
Klemen, you have been of very little help, and evidently did not pay attention. I already said that there aren't any tutorials for what I am looking for help with.
i've been attempting to do this too. tried using a dynamic raytracing procedure i came up with where the distance increases while there's still no entity found, until it either finds an entity and then saves its name or reaches max distance and returns nothing at all, and it kinda works... but it still needs some polishing which I'll be completing very soon, then I'll share it. in the meantime, i can say that familiarizing yourself with how things, or parts of things, work by themselves and how they work with others, is essential to figuring things like these out. so for example, since "look x/y/z position w/ raytrace distance [n]" procedures return a number value, you can find whatever logic condition/check that takes in numbers for its parameters, e.g. "does entity exist at x y z", which i used, and put it in the x/y/z values of the logic condition as arguments. it'll then return either true or false depending on the check, and only then can you use it alongside "AND" block i believe
P.S. it requires a programmer's mindset to fully realize how do stuff like these... otherwise, you might not be able to get anywhere far as to achieve what you've been looking for
alright, here it is (as a procedure template):
https://www.mediafire.com/file/1p11xvo5s8mgm9n/entity-raytrace-search.ptpl/file
if you have any questions, put em here or message me on Discord. or i can make a full tutorial in case the comments i put aren't enough
Thank you so much for the help
@Sajevius
So I'm using your procedure in a player tick update, and it DOES detect my entity, but it doesn't do the action defined in the "if getlocal:entity_found" loop, which despawns the entity being looked at and spawns the hostile variant in its place. A little help?
don't do "is event/target entity subtype of [entity]", that won't work on the detected entity; that only works on the mob executing that procedure (in that case, the player). that's why it doesn't work. maybe do
"IF NOT get nearest entity at x: rd | y: rd | z: rd in sqr cube 1 of type LivingEntity = (null) AND is get nearest entity at x: rd | y: rd | z: rd in sqr cube 1 of type [entity 1] subtype of [entity 1] DO despawn get nearest entity at x: rd | y: rd | z: rd in sqr cube 1 of type [entity 1]; spawn at x: rd | y: rd | z: rd entity [entity 2]" instead
(for quick reference, i represented variable "raytrace_distance" with "rd", so take note of that)
thanks again, ill see if this works!
Turns out it doesn't work. Well, not entirely.
It despawns the entity looked at, and then decides to spawn around 20 instances of the hostile variant.
It also always happens regardless of whether the location looked at is the head or not (despite the fact I set the raytracing distance for the y coordinate to be itself + 2.25 blocks?