-
Notifications
You must be signed in to change notification settings - Fork 106
Adding Entities
This page explains how to add custom entities to your spells (or elsewhere) using wizardry's built-in classes.
Note that you don't have to use wizardry's built-in classes, but if you do, they will take care of a lot of the inner workings for you, like syncing and saving variables, keeping track of entities' casters, display stuff and so on. In addition, it will allow you to make use of wizardry's generalised spell classes, which can greatly simplify your spell's code. It will also make it easier for you if an update to wizardry changes anything (which is pretty likely).
The relevant classes for summoned creatures can be found in the package electroblob.wizardry.entity.living
. Wizardry's summoned creatures can be split into two categories:
- Creatures that exist in vanilla Minecraft, such as skeletons and blazes. The classes for these entities extend their vanilla counterparts and implement the interface
ISummonedCreature
. Creatures that exist in other mods also fit into this category. - Creatures that don't exist in vanilla Minecraft, like ice wraiths and storm elementals. The classes for these entities extend
EntitySummonedCreature
, which implementsISummonedCreature
itself, so you don't have to.
You can quickly and easily create spells to summon minions by instantiating SpellMinion
. SpellMinion
is generic and takes the entity as a type parameter (it must be a subtype of ISummonedCreature
). This class handles almost everything about a standard summoning spell for you, just fill in the constructor with the appropriate values and chain any setter methods you need onto the end. In addition to the setters common to all spells, SpellMinion
has a boolean setter method flying(...)
which allows you to specify that the given entity can spawn in the air (defaults to false
).
To customise the behaviour, you can extend SpellMinion
and override one or more of the following methods:
-
addMinionExtras(...)
, to do something to the entity just after it spawns (like adding armour, for example) -
createMinion(...)
, to change the actual entity that gets spawned (though it must still be an instance of the specified entity type - like how husks are a kind of zombie) -
spawnMinions(...)
, to change where and how the entities are spawned
Wizardry has two classes used for custom projectiles: EntityMagicProjectile
and EntityMagicArrow
, both of which can be found in the package electroblob.wizardry.entity.projectile
. The key difference between these two classes is that EntityMagicArrow
rotates to face in the direction of travel as it flies (like an arrow), whereas EntityMagicProjectile
doesn't (like a snowball). Other than that, the two classes are fairly similar.
Each of these entity classes has a corresponding generalised spell class, much like SpellMinion
:
-
EntityMagicProjectile
usesSpellProjectile
-
EntityMagicArrow
usesSpellArrow
Again, simply instantiate these and fill in the relevant parameters and wizardry will take care of the rest. Both of these classes have an addProjectileExtras(...)
/addArrowExtras(...)
method that can be overridden to customise the behaviour.
See also EntityBomb
, a special type of EntityMagicProjectile
that implements a (synced) blast modifier set by the spell.
The term construct in wizardry refers to non-living summoned entities, usually large ones that stay in one place. All constructs inherit from EntityMagicConstruct
, found in the package electroblob.wizardry.entity.construct
. This class has all the necessary overrides for vanilla methods, as well as handling despawning and keeping track of the owner entity. Usually, individual constructs will override onUpdate(...)
to perform the majority of their behaviour.
There are two different generalised spell classes for spells that spawn constructs:
-
SpellConstruct
, which spawns the construct based on the caster's position -
SpellConstructRanged
, which spawns the construct where the caster is looking
Both of these classes work in much the same way as the previous ones; instantiate them for simpler spells or extend them for custom behaviour. Both expose two boolean setter methods: floor(...)
, which determines whether the construct must be spawned on the ground, and overlap(...)
, which determines whether constructs spawned by that spell can overlap other ones.
You can even add your own spell casting entities! For more information, take a look at the ISpellCaster
interface and the EntityAICastSpell
class in electroblob.wizardry.entity.living
.
© Electroblob 2021. Details of permissions can be found in the license.
Getting Started
Blocks
Items
Spells
Mobs
Structures
Status Effects
Crafting Recipes
Commands
Ally Designation System
Minion Targeting
Configuration
Loot Functions
Spell Properties
🎯 Troubleshooting
Changelog
Developing Addons
About and Credits
⮡ Curseforge Page
⮡ Minecraft Forum Thread
⮡ Feed the Beast Wiki Page
⮡ Legacy Documentation