I need help

Started by Dr_Dariano on

Topic category: Help with Minecraft modding (Java Edition)

Joined Apr 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I need help
Tue, 04/09/2024 - 21:40 (edited)

So, I have been trying to create a horror mod for the past month now, and I can't seem to get this one thing to work. My vision is that when the entity chases the player(s), if it is objected by blocks, it will mine the block in front of it to continue chasing the player. It is a Biped entity, so I want it to mine a 2x1 tunnel, so it can continue running, or a 1x1 hole if it is digging down. I have tried everything I could think of, but it doesn't work. Is this even possible to do, and if so, can you please tell me how to do it. Thanks!

By the way, I am using MCreator 2023.4 and the mod is being made for 1.20.1.

Edited by Dr_Dariano on Tue, 04/09/2024 - 21:40
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You essentially need a…
Wed, 04/10/2024 - 04:08

You essentially need a procedure to determine when the entity is blocked, and what block to mine. I haven't done something like this specifically, but I think I've got some general pointers for both problems.

  • There's various ways to detect when an entity is stuck. I did something sort of similar for termites; if their x or z velocity is zero for long enough, they gain a status effect that tells them to change their behavior. (If you wanted to do this more effectively, you would need to both check for lack of movement in either direction, and check that there are solid blocks between the entity and the player, which would require calculating some vectors.) 
  • For most cases though, just detecting if velocity is at or near zero will tell you if it's stuck. You can increment an NBT tag or give the entity increasing duration of a status effect when it isn't moving, and then if the tag/status effect gets high enough, add another NBT tag or status effect that tells it to start breaking blocks.
  • The block breaking part shouldn't be too difficult, you just need to target blocks correctly, and possibly make a tag for which blocks it's allowed to break.
  • To actually target the block, use the 'look at x/y/z' function to make the entity look at the player's positon, then get the block at the entity's x/y/z, plus the x/y/z look angle vectors of the entity. These are vectors that are based on the direction the entity is looking; if it's looking east, the x vector is 1; if it's looking west, the x look angle vector is -1. North or South yields an x vector of zero; and looking southeast yields an x vector of 0.5. This will essentially give you the offset that the desired blocks are at. (You might want to multiply the vectors by something like 1.5, just to make sure it hits the correct blocks.)
  • If you want the entity to break blocks gradually, it's a bit more complicated, but not impossible. I assume though that you want it to break stuff pretty fast. Even still, might wanna give it a brief delay.

Also, good job being descriptive and including your version type, a lot of help requests can be frustratingly vague! Maybe title stuff a bit more descriptively though, otherwise mods aren't super likely to help. =)