GlowstoneMC / Glowstone

A fast, customizable and compatible open source server for Minecraft: Java Edition
https://glowstone.net
Other
1.9k stars 273 forks source link

[WIP] Annotations to replace constant entity properties #821

Closed aramperes closed 6 years ago

aramperes commented 6 years ago

The goal of this PR is to replace constant entity properties (for example, isUndead and isArthropod) with annotations (@EntityProperties) instead of allowing these methods to be overriden.

I also added a Sounds annotation for hurt/death/ambient sounds instead of overriding the getters. The getters are not final for the moment because I only implemented it for certain entities.

I'm thinking of adding other properties like the bounding box dimensions (setSize()). Other technical annotations like entity metadata are planned but not part of the scope of this PR.

Example (click to expand) For example, `GlowZombie.java`: ```java public class GlowZombie extends GlowMonster implements Zombie { /* ... */ @Override protected Sound getHurtSound() { return Sound.ENTITY_ZOMBIE_HURT; } @Override protected Sound getDeathSound() { return Sound.ENTITY_ZOMBIE_DEATH; } @Override protected Sound getAmbientSound() { return Sound.ENTITY_ZOMBIE_AMBIENT; } @Override public boolean isUndead() { return true; } } ``` Becomes: ```java @EntityProperties(undead = true) @Sounds(hurt = Sound.ENTITY_ZOMBIE_HURT, death = Sound.ENTITY_ZOMBIE_DEATH, ambient = Sound.ENTITY_ZOMBIE_AMBIENT) public class GlowZombie extends GlowMonster implements Zombie { /* ... */ } ```
aramperes commented 6 years ago

Closing this because other developers expressed their preference for a Builder pattern over Annotations. I'll keep the branch up for reference.