Entity Holds Item

intermediate

TIP

This tutorial assumes you have a basic understanding of entities, loot tables, and Blockbench.

In this tutorial, you will learn to have an entity spawn with an item in its hand. I'll be using a custom mandalorian_armorer entity and a custom hammer item for the examples.

Model

First of all, you'll need to have a model in Blockbench that has a map called rightArm. Within this map, there needs to be a submap called 'rightItem'. Now set the position of the pivot point of this submap, so it sits in the place you want the entity to hold the item at.

Behavior Pack-side

Now you'll need to add a minecraft:equipment component in the component list for your entity and add a loot table with the desired item.

In our example it will look like this:

BP/entity/mandolorian.json#componentsCopy
"minecraft:equipment": {
    "table": "loot_tables/entities/gear/mandolorian.json"
}
1
2
3

Loot Table

Finally, add the loot table for your entity. It needs to be in loot_tables/entities/<your_loot_table_name>.json in the behavior pack. In our case, it's called mandolorian.json.

WARNING

This isn't the same loot table as what it drops on death. So make sure it has a different name.

To have the entity always spawn with the same item, add the following loot table:

BP/loot_tables/entities/gear/mandolorian.jsonCopy
{
	"pools": [
		{
			"rolls": 1,
			"entries": [
				{
					"type": "item",
					"name": "dd:hammer",
					"weight": 1
				}
			]
		}
	]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14

If everything went well, you'd have something looking like this:

Contributors