AI Task help

Started by hey23 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jul 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
AI Task help

So... theres an AI task for mobs, that makes them destroy blocks but it doesen't drop them. How do I detect when a block is broken BY an entity AND which block was broken so that I can drop it by doing Spawn Dropped Item?

Joined Jul 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Still found no fix... sorry…
Mon, 07/22/2024 - 12:07

Still found no fix... sorry for bumping

You should make custom…
Tue, 07/23/2024 - 14:30

You should make custom action for this using entity tick trigger or adding custom code to AI condition "should continue executing" and check for position and drop accordingly there

Joined Jul 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This is how I did it, even…
Tue, 07/23/2024 - 18:03

This is how I did it, even though I'm not sure it's the best solution:
I found out that the trigger Entity about to grief world fires when the mob decides to destroy a block and it keeps firing every 2 ticks until the mob sees a block type it has been set to destroy. With this information, I made 4 procedures which work together to drop the block which the mob destroys.

The first one is triggered by the global trigger and then checks if the entity is the custom entity you created. In my case it's a placeholder G. It then takes a timestamp of the current world time, which will be compared in another procedure later, and if the other procedure hasn't started yet for this specific entity, it starts it and makes sure more don't get called using a flag tag.
First procedure

The second procedure waits until the entity stops sending grief calls which would mean it has located a block it would like to destroy. I used a number dependency so that the first time the procedure is called, it can be 1 tick ahead of the grief event and every following call stays 1 tick ahead. The most significant part of this procedure is the check if the timestamp is the same as the current time minus 1 tick. Since the timestamp is updated on every grief call and this procedure is 1 tick ahead of it, it means that if this check returns false, the grief calls have stopped and the entity has seen a desired block. It calls itself to continue waiting.

Second procedure

The third procedure waits until the entity is standing on top of its desired block so that it can destroy it. After that it passes the coordinates of where the block that will be destroyed is to the final procedure.

Third procedure

The fourth procedure drops the block as an item as soon as it's destroyed.

Fourth procedure