This test mod adds a new component type called Vita. Two entities can hold it: Vita Zombies and Players. Players do not naturally have vita, vita zombies are the only source. Hitting a vita holder with a vita stick will transfer some of it to the stick. Subsequently right-clicking the stick will transfer the collected vita to the player. Vita sticks also display the player's current (synchronized) vita in their tooltip.
When shift-right-clicking a non-empty vita stick, a sliver of vita will be released in the world, and a title will be displayed to every player within it. There is a small chance that the released vita slips into the global fabric, making it available in every world.
A vita condenser is a special block interacting with ambient vita. When placed, it will slowly transfer vita from the world to the chunk it is placed in. Right clicking a vita condenser displays the amount of vita available in the chunk.
org.ladysnake.componenttest
: root packagecontent
: implementation of the content in the test modvita
: component classesVita
: the interface defining the vita componentBaseVita
: base implementationAmbientVita
: abstract synchronized extension ofBaseVita
with custom behaviourLevelVita
: global implementation ofAmbientVita
WorldVita
: world-aware implementation ofAmbientVita
SyncedVita
: synchronized implementation ofBaseVita
EntityVita
: entity-specific extension ofBaseVita
with custom behaviourPlayerVita
: player-specific, synchronized extension ofEntityVita
with custom respawn behaviour
CardinalComponentsTest
: mod initializationTestComponents
: component registrationVitalityCondenser
: a custom block re-implementingBlockProvider
, interacting with chunk and ambient vitaVitalityStickItem
: a custom item that attaches aBaseVita
instance to its item stacksVitalityZombieEntity
: a custom entity that attaches anEntityVita
instance to itself
tests
: unit test suite using Minecraft's gametest API
Most Vita implementations exist to exhibit custom logic and synchronization behaviour. Synchronization is not actually needed in most cases, the mod's function being here contrived to test synchronization facilities. This means that a standard mod could very well have one or two component implementations for all providers.
All component registration is done in TestComponents
, using some variant of ComponentFactoryRegistry
.
Most use a regular lambda or constructor reference, although the zombie vita uses a method reference to a VitalityZombieEntity
instance method instead.
Adding custom items and entities is never required to use components. The ones in this test mod are merely examples of what a typical mod could do.