Summoning Entity
SummoningEntity is a utility binding that allows you to easily create complex instances of EntityInputs, FakeEntityInputs and EntityOutputs via the EntityInputBuilder and EntityOutputBuilder. The builders offer functionality to add tooltips, offset and spread values, as well as NBT to entities, which is otherwise not possible if you only provide a simple entity input or entity output instance.
Overview
- access in recipes event via:
SummoningEntity - functions:
input(EntityInfo entity)- creates an
EntityInputBuilderwith the specifiedEntityInfo
- creates an
input(Holder<EntityType<?>> entity, Integer count)- creates an
EntityInputBuilderwith the specified entity and the specified count
- creates an
fakeInput(ItemStack displayItem, Integer count, Predicate<Entity> validator)- creates a
FakeEntityInputwith the specified display item, count, and validator - the count defines the amount of entities that have to pass the validator for the input to be valid
- creates a
fakeInput(ItemStack displayItem, Predicate<Entity> validator)- creates a
FakeEntityInputwith the specified display item and validator - by leaving out the count, it acts as a wildcard, meaning any amount of entities passing the validator
- creates a
output(EntityInfo entity)- creates an
EntityOutputBuilderwith the specifiedEntityInfo
- creates an
output(Holder<EntityType<?>> entity, Integer count)- creates an
EntityOutputBuilderwith the specified entity and the specified count
- creates an
SummoningEntity.input("pig")
SummoningEntity.input("5x minecraft:ghast")
SummoningEntity.input("minecraft:fox", 3)
SummoningEntity.fakeInput("minecraft:diamond", 5, e => e.isUnderWater())
SummoningEntity.output("cow")
SummoningEntity.output("3x sheep")
SummoningEntity.output("iron_golem", 2)Entity Input Builder
After obtaining the EntityInputBuilder instance through the binding, you can chain additional functions to it.
- properties:
entity- description: specifies the input entity; defined via the binding function to obtain the builder
- type:
Holder<EntityType<?>> - required: yes
count- description: specifies the count of the input entity; defined via the binding function to obtain the builder
- type:
Integer - required: no
- default:
1
data- description: specifies the data (NBT) of the input entity; only used for rendering
- type:
CompoundTag(JsonObject) - required: no
- default: empty
tooltip- description: specifies additional tooltip lines shown in recipe viewer pages
- type:
List<Component> - required: no
- default: empty list
validator- description: specifies the validator function to check the entity data (NBT)
- type:
Predicate<Entity> - required: no
- default: always
true
- functions:
data(CompoundTag data)- assigns the given NBT data to the
EntityInput
- assigns the given NBT data to the
tooltip(List<Component> tooltip)- assigns the given tooltip lines to the
EntityInput
- assigns the given tooltip lines to the
validator(Predicate<Entity> validator)- assigns the given validator to the
EntityInput
- assigns the given validator to the
What is a validator?
You might ask why a custom validator is required if data is already provided. For inputs, the data property is only used for rendering purposes in recipe viewers. If you give an entity a sword via the data property, it will be displayed on the recipe viewer page, but it won't check whether the entity actually has a sword when being sacrificed.
Why is that?
Because vanilla Minecraft only checks entity data (NBT) for exact matches, there is no way to always cover all desired functionality. If you want to ensure that an entity has at least 10 HP, this wouldn't be possible because Minecraft would check only for the exact value. That's why you have to use a custom validator with your own logic to check whether the respective values are correct.
.entityInputs([
SummoningEntity.input("cat", 3).tooltip("Meow"),
SummoningEntity.input("zombie")
.data({
HandItems: [
{
id: "minecraft:diamond_sword",
Count: 1,
tag: { ench: [{ id: 16, lvl: 1 }] },
},
],
})
.tooltip("Needs any sword")
.validator((e) => e.mainHandItem.id.contains("sword")),
])Entity Output Builder
After obtaining the EntityOutputBuilder instance through the binding, you can chain additional functions to it.
- properties:
entity- description: specifies the output entity; defined via the binding function to obtain the builder
- type:
Holder<EntityType<?>> - required: yes
count- description: specifies the count of the output entity; defined via the binding function to obtain the builder
- type:
Integer - required: no
- default:
1
data- description: specifies the data (NBT) of the output entity
- type:
CompoundTag(JsonObject) - required: no
- default: empty
tooltip- description: specifies additional tooltip lines shown in recipe viewer pages
- type:
List<Component> - required: no
- default: empty list
offset- description: specifies the offset from the altar block where the output entity is spawned
- type:
BlockPos - required: no
- default:
[0, 2, 0]
spread- description: specifies the spread of the output entities; output entities are spawned at different positions within the spread area; a single entity can spawn at a position before a new random position is calculated
- type:
BlockPos - required: no
- default:
[1, 0, 1]
- functions:
data(CompoundTag data)- assigns the given NBT data to the
EntityOutput
- assigns the given NBT data to the
tooltip(List<Component> tooltip)- assigns the given tooltip lines to the
EntityOutput
- assigns the given tooltip lines to the
offset(BlockPos offset)- assigns the given offset to the
EntityOutput
- assigns the given offset to the
spread(BlockPos spread)- assigns the given spread to the
EntityOutput
- assigns the given spread to the
.entityOutputs([
SummoningEntity.output("5x creeper").tooltip("Kaboom"),
SummoningEntity.output("skeleton", 2)
.data({
HandItems: [
{
id: "minecraft:diamond_sword",
Count: 1,
tag: { ench: [{ id: 16, lvl: 1 }] },
},
],
}),
SummoningEntity.output("6x sheep")
.offset([1, 2, 2])
.spread([4, 2, 4])
.data({
Health: 50,
attributes: [{ id: "generic.max_health", base: 50 }],
}),
])