Mobs that break blocks and take the block to a chest

Started by FlippinLegend on Sat, 05/23/2020 - 11:10

Topic category: Help with modding (Java Edition)

Last seen on 21:22, 4. Mar 2021
Joined Aug 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Mobs that break blocks and take the block to a chest
Sat, 05/23/2020 - 11:10

I was wondering if it's possible for a flying entity to break only selected blocks and put the blocks they broke into chests. If that's possible. How?

Last seen on 23:27, 4. Apr 2021
Joined May 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
I can how you can do that,…
Tue, 06/09/2020 - 18:41

I can how you can do that, but it is very complex, you kind can spawn flying entity that will fly to a certain high, if there is a chest under it ground level, it will start to verify each block in a determined radius around it, if the block is the block you want it to collect it will destroy it and place in the chest under it ground level, animations like mob flying toward object and down to the chest can be made to I guess. Do you have some math knowledgement about how to use sin and cos? If you do it will make it easier to explain how to do the verification

Last seen on 04:35, 17. Jan 2021
Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Do you have some math…
Tue, 06/09/2020 - 23:21

Do you have some math knowledgement about how to use sin and cos? If you do it will make it easier to explain how to do the verification

We don't need to do the math. There are methods dedicated for these sorts of things. 

Since I believe we are on the same page that this needs to be coded, here goes;

 

CREATE A NEW ENTITY AI CLASS FOR FINDING AND "PICKING UP" ITEMENTITIES.

For finding item entities;

World::getEntitiesWithinAABB

In one of the parameters specify for ItemEntity. If you want to find a specific item, iterate through the results.

 

Now use;

PathNavigator::getPathToEntity

Use this to travel to an ItemEntity. Once nearby remove it.

 

 

CREATE A NEW ENTITY AI CLASS FOR FINDING AND BREAKING BLOCKS.

Since I have no clue what this means or how the blocks get selected;

flying entity to break only selected blocks

Just get the BlockPos for your "selected block" and use;

PathNavigator::getPathToPos

Use this to travel to the block. Also, check the block hardness to make sure it is harvestable. If so, destroy it.

 

That should get you started.