Skip to main content

Misc

Smaller API pieces that do not fit the other pages.

Description system​

Items and blocks can show an extended description in their tooltip while FactionApi's "item description" key binding is held; otherwise a "hold … for info" hint is shown.

PieceWhereWhat it does
IDescriptionProviderAPI, on an Item or the Block of a BlockItemObject[] getDescriptionParameters() – arguments for the translatable description text.
IBlockWithDescriptionAPI, on a BlockappendHoverText(stack, context, display, flag, tooltips) – the block adds its own tooltip lines.
factionapi:shift_descriptionitem component (ShiftDescription)Shows the description. With neither field set, the translation key tooltip.<item namespace>.<item path> (Identifier#toLanguageKey("tooltip")) is used and filled from the IDescriptionProvider if there is one. Fields: component or formatableString (a translation key).
factionapi:block_descriptionitem component (BlockDescription, unit)Marks a BlockItem whose block implements IBlockWithDescription; the block's appendHoverText is used.

ShiftDescription and BlockDescription live in de.teamlapen.faction.common.util (module FactionApi, not the API module). Items are configured with the injected Item.Properties methods (see interface injection): factions$withShiftDescription(), factions$withShiftDescription(Component), factions$withShiftDescription(ShiftDescription), factions$withShiftDescriptionWithId(String) – or set the component directly. Block items set .component(FactionDataComponents.BLOCK_DESCRIPTION, BlockDescription.INSTANCE). Skills and actions use SkillProperties#withDescription() for their description text.

Customization​

  • ICustomizationHolder – int getEntityTextureType(); ICustomizationHolder.NONE returns 0. For entities that choose a texture variant.
  • ICustomizationOption<T> – Identifier id() and StreamCodec<? super RegistryFriendlyByteBuf, T> codec() describe one customizable value. MinionAppearance implements it.

Disguise​

IDisguise (returned by IFactionPlayer#getDisguise()) lets a faction player appear as another faction: actualFaction(), getViewedFaction(viewerFaction) (what a viewer of the given faction sees), getViewedFaction(viewer, ignoreDisguise), disguiseAs(faction) (nullable), unDisguise(), isDisguised(). IDisguise.None is the no-op implementation. IFactionPredicate uses it unless ignoreDisguise() is set.

Neutral player​

INeutralPlayer is the IFactionPlayer of players without faction (attachment FactionAttachments.NEUTRAL_PLAYER): faction Factions.NEUTRAL, level 0, max level 0, can always leave, never disguised.

Faction food​

IFactionFoodBehavior (factionapi:food_behaviour) is a functional interface apply(level, entity, stack, consumable, foodProperties) that defines what eating does. The item component factionapi:faction_food (FactionFoodList) holds a defaultFood and a list of entries { faction: <faction tag>, foodProperties, behaviour }. When an entity eats the item, all entries whose faction tag matches the entity's faction apply their behaviour with their own food properties; if none matches the default food is applied with the built-in factionapi:default behaviour (plays the eat/burp sounds and adds nutrition and saturation to players). Items are set up with the injected Item.Properties#factions$factionFood(list[, consumable]).

Sync API (de.teamlapen.sync.api)​

Interfaces for attachments that are saved and synced to clients.

TypePurpose
ISyncablesync(), serializeFullUpdate(ValueOutput), serializeUpdate(ValueOutput) (defaults to full), deserializeUpdate(ValueInput). Deserializers must not assume all data is present.
IAttachmentSyncValueIOSerializable + ISyncable + IEntity + MutableDataComponentHolder with getType() (its AttachmentType). Base of FactionApi's player attachments.
MutableDataComponentMapA DataComponentMap with set / remove (type or supplier) and set(Supplier<DataComponentType<Unit>>, boolean) for flag components. IMinionData extends it.

Attachments​

FactionAttachments (API) holds lookup holders; the implementation registers the types.

Key (factionapi:)Holder in APIType
faction_player_handlerFACTION_PLAYER_HANDLERIFactionPlayerHandler
neutral_playerNEUTRAL_PLAYERINeutralPlayer
task_managerTASK_MANAGERITaskManager
refinement_handlerREFINEMENT_HANDLERIRefinementHandler
lord_playerLORD_PLAYERILordPlayer
damage_handler– (Keys.DAMAGE_HANDLER only)implementation LevelDamage
minion_data– (Keys.MINION_DATA only)implementation EntitySyncHolder<MinionEntity, MinionData>

Data component keys​

FactionDataComponents (API) exposes lookup holders and the Keys ids. Faction, skill and minion task components are definition components of registry entries (set through FactionProperties, SkillProperties, MinionTaskProperties); the minion data keys are persisted per minion. The rows without an API holder (all minion data keys, shift_description, block_description, faction_food) are only registered by the implementation (de.teamlapen.faction.common.core.FactionDataComponents); the API exposes their ids in FactionDataComponents.Keys.

Faction (on IFaction)

Key (factionapi:)ConstantValue type
faction_colorFACTION_COLORInteger
chat_colorCHAT_COLORTextColor
faction_name_singularFACTION_NAME_SINGULARComponent
faction_name_pluralFACTION_NAME_PLURALComponent
max_levelMAX_LEVELInteger
max_lord_levelMAX_LORD_LEVELInteger
player_capabilityPLAYER_CAPABILITYHolder<AttachmentType<?>>
refinementsREFINEMENTSRefinementItems
lord_titlesLORD_TITLESLordTitles
task_masterTASK_MASTERHolder<EntityType<?>>
village_bad_omenVILLAGE_BAD_OMENHolder<MobEffect>
village_totemVILLAGE_TOTEMTotemPair
village_guardsVILLAGE_GUARDSTagKey<EntityType<?>>
village_bannerVILLAGE_BANNERVillageBanner

Skill (on ISkill)

Key (factionapi:)ConstantValue type
skill_nameSKILL_NAMEComponent
skill_costSKILL_COSTInteger
skill_descriptionSKILL_DESCRIPTIONComponent
skill_actionSKILL_ACTIONHolder<? extends IAction<?>>
skill_actionsSKILL_ACTIONSList<Holder<? extends IAction<?>>>
skill_factionsSKILL_FACTIONSTagKey<IFaction<?>>
skill_tree_requirementSKILL_TREE_REQUIREMENTSkillTreeRequirement
skill_enable_consumableSKILL_ENABLE_CONSUMABLEHolder<FactionPlayerConsumer>
skill_deactivate_consumableSKILL_DISABLE_CONSUMABLEHolder<FactionPlayerConsumer>

Minion task (on IMinionTask)

Key (factionapi:)ConstantValue type
minion_task_nameMINION_TASK_NAMEComponent
minion_task_factionsMINION_TASK_FACTIONSTagKey<IFaction<?>>
minion_task_skill_requirementMINION_TASK_SKILL_REQUIREMENTHolder<? extends ISkill<?>>
minion_task_global_commandMINION_TASK_GLOBAL_COMMANDUnit
minion_task_categoryMINION_TASK_CATEGORYHolder<IMinionTaskCategory>
minion_task_category_defaultMINION_TASK_CATEGORY_DEFAULTUnit

Minion data (on IMinionData, persistent)

Key (factionapi:)ConstantValue type
minion_levelMINION_LEVELInteger
minion_nameMINION_NAMEString
minion_use_lord_skinMINION_USE_LORD_SKINBoolean
minion_use_minion_skinMINION_USE_MINION_SKINBoolean
minion_has_increased_statsMINION_HAS_INCREASED_STATSUnit
minion_skinMINION_SKINInteger
minion_health_levelMINION_HEALTH_LEVELInteger
minion_inventory_levelMINION_INVENTORY_LEVELInteger
minion_speed_levelMINION_SPEED_LEVELInteger
minion_attack_damage_levelMINION_ATTACK_DAMAGE_LEVELInteger
minion_resources_levelMINION_RESOURCES_LEVELInteger
minion_inventory_sizeMINION_INVENTORY_SLOTSInteger

Item

Key (factionapi:)ConstantValue type
refinement_setREFINEMENT_SETIEffectiveRefinementSet
is_faction_bannerIS_FACTION_BANNERUnit
faction_restrictionFACTION_RESTRICTIONIFactionRestriction
faction_slayerFACTION_SLAYERIFactionSlayer
shift_descriptionSHIFT_DESCRIPTIONShiftDescription
block_descriptionBLOCK_DESCRIPTIONBlockDescription
faction_foodFACTION_FOODFactionFoodList

Interface injection and access transformers​

The FactionApi module publishes META-INF/interfaceinjection.json and META-INF/accesstransformer.cfg (see projects/faction/build.gradle: neoForge { interfaceInjectionData { … publish … } accessTransformers { … publish … } }). Mods that depend on it inherit them through ModDevGradle.

Injected interfaces (interfaceinjection.json):

Target classInjected interface
net.minecraft.world.item.Item$PropertiesIItemPropertiesFactionsMock → methods factions$restrictFaction, factions$description, factions$descriptionWithout, factions$withShiftDescription…, factions$factionFood, factions$addAttributes
net.minecraft.world.effect.MobEffectInstanceIEffectInstanceWithSourceFactionsMock (factions$getHiddenEffect, factions$getProperties, factions$hasProperty, …)
StatsScreen, ImageWidget$Sprite, ImageWidget$Texture, BossHealthOverlayclient-only helper mocks

The …FactionsMock classes only exist so the dev environment compiles against the methods; the real implementation is provided by mixins. They are @Deprecated and throw if called directly, so treat the factions$… methods as part of the development-time surface and use them through the injected types only (the declaring interfaces such as IItemProperties are in de.teamlapen.faction.misc.extensions, not in the API module).

The access transformer makes some vanilla client members public (StatsScreen sprites, BossHealthOverlay.OVERLAY_BACKGROUND_SPRITES, ImageWidget$Sprite/Texture, AdvancementTabType, a Tooltip constructor, ObjectiveCriteria#registerCustom, TooltipRenderUtil sprite getters, AbstractSelectionList#repositionEntries, SectionStorage members, LootContextParamSets.REGISTRY). See the file for the exact lines.

Utilities​

  • FIdentifier – mod(path) (factionapi:<path>), modString(path), loc(namespace, path), common(path) (c:), mc(path) (minecraft:). REFERENCE.MOD_ID is "factionapi".
  • SafeCast.cast(Object) – unchecked cast to the inferred type (<T> T); only use when you are sure of the type.
  • @FloatRange(from, to) – TYPE_USE annotation (class retention) documenting the allowed range of a float value; informational only.
  • ModStreamCodecs – helper stream codecs (table(...), pair(...)) used by the API records.