Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Extending Existing Minecraft Entities

Daniel Voznyy edited this page Sep 2, 2020 · 1 revision

All custom mobs share a common CustomMob class. However, since protected values and methods commonly need to be accessed or overriden, each mob must manually reimplement each method correctly.

MobBase and the annotation processor

Because this boilerplate code is undesirable, mobzy provides an annotation processor which will copy code from a base entity class (MobBase), which implements CustomMob and extends NMSEntityInsentient.

Simply annotate your new type with @GenerateFromBaseClass and extend the generated class. For example if you wished to extend NMSEntityPig, you would do:

@GenerateFromBase(base = MobBase::class, createFor = [EntityPig::class])
class CustomEntityPig(type: NMSEntityType<*>, world: NMSWorld) : MobzyEntityPig(world, type)

You may also customize the name of the generated class, by default it will simply prefix it with Mobzy.

If any of this code is broken in future versions, just check how it's done within a class like PassiveMob.

Using this new class in your mob config

In the future there will be a way of registering this new class for use by mob configs, by specifying the baseClass property.

For now, three classes exist, registered as: mobzy:passive, mobzy:hostile, mobzy:flying.

Home

Creating Custom Mobs

Non-coder guide to making your own mobs

Code

Addons

Internals

  • TODO

Other stuff

Clone this wiki locally