Bewitchment (Legacy)

Bewitchment (Legacy)

8M Downloads

Creation of "base classes" is not recommended

Jummit opened this issue ยท 0 comments

commented

Point four of forges "Code Style Guide" says

Do not abuse inheritance for code-reuse.
This often manifests in classes like ItemBase, BaseItem or ItemExampleMod.
Using this pattern prevents you from extending other essential classes,
such as ItemFood and in that case requires code duplication.
Prefer composition or utility methods instead to reuse code.

Using base classes can lead to major problems later on. I tackled this problem with a RegistryHelper.register method, which I call in the constructor of a block/item:
RegistryHelper.register(this, "myid")

Also, number three:

Using an interface (usually called IHasModel) on your Item and/or Block classes
to denote that they are capable of registering a model is an anti-pattern and not necessary.
All items require a model to be registered for them and usually no type-specific information
from the item is needed, only the registry name,
which is accessible for all items by default.