Feat/modelengine support - #315
Open
mattwithabat wants to merge 2 commits into
Open
Conversation
- introduce ModelProvider abstraction with BetterModel and ModelEngine implementations - resolve unprefixed model names via BetterModel first, then ModelEngine; support bm:/me: prefixes - ModelEngine models are attached to a Dummy base entity that follows the (invisible) NPC - route ModelEngine hitbox clicks to FancyNpcs interactions, keep native clicks as fallback - make BetterModel optional and add ModelEngine as optional dependency Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…e model The invisible flag was only set in the deferred model-creation task, one tick after FancyNpcs had already sent the entity metadata - so the player NPC stayed visible next to the model until the next metadata refresh. Set the flag before the attribute application cycle sends metadata, and restore visibility if model creation fails. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📋 Description
This PR adds ModelEngine support to the
fancynpcs-modeladdon, alongside the existingBetterModel support. Until now the addon was hard-wired to BetterModel and listed it as a
required dependency, so servers running ModelEngine (the most widely used custom-model plugin
in the ecosystem) could not use custom models on FancyNpcs NPCs at all.
Rather than bolting a second integration onto the existing code, the BetterModel-specific logic
is extracted behind a small
ModelProviderabstraction. Both plugins are now optionaldependencies and either (or both) can be installed. All existing behaviour, commands and config
are preserved — an existing setup keeps working unchanged after updating.
The ModelEngine integration needs a different strategy than BetterModel: FancyNpcs NPCs are
packet-based and don't exist in the world, so ModelEngine cannot track them like a normal entity.
Instead, a ModelEngine
Dummybase entity carrying the model is created at the NPC's location,the NPC entity itself is made invisible, and the dummy is kept in sync with the NPC's location
via a ModelEngine tick task.
No related issue is open that I'm aware of — happy to link one if there is.
✅ Checklist
Fixes #issue_numberorCloses #issue_number— no related issue foundmainbranch — branched off2da46d9🔍 Changes
ModelProviderinterface (Javadoc'd) abstracting model listing, attach/detach,animations and interaction handling from a concrete model plugin
ModelProviderRegistry, which detects installed model plugins at enable time andresolves model names to a provider
CustomModelAttributeintoBetterModelProvider— behaviour unchangedModelEngineProvider+ModelEngineInteractListenerimplementing the ModelEngineintegration (dummy base entity, invisible NPC, location sync, scale, hitbox clicks)
NpcEntityAccessutility holding the shared NPC → Bukkit entity reflection lookupModelEngine; names may be prefixed to force a provider (
bm:/bettermodel:,me:/meg:/modelengine:)/npc custom_model,/npc play_animationand theplay_animation_once/play_animation_loopactions to dispatch through the active providerpaper-plugin.yml:BetterModelis now optional,ModelEngineadded as optional;the plugin disables itself with a clear message if neither is installed
custom_model.appliedmessage to also name the provider that was usedcom.ticxo.modelengine:ModelEngine:R4.1.1as a non-transitivecompileOnlydependency plus the
mvn.lumine.iorepositoryrefresh, by setting the invisible flag before the attribute cycle sends entity metadata
README.md, aCHANGELOG.mdentry, and bumpedVERSIONto1.2.0🧪 How to Test
Setup: Paper or Folia 26.2 with FancyNpcs 2.11.0 and this addon build. Test once with
ModelEngine R4.1.1 installed, and once with BetterModel 3.2.0, to confirm neither path regressed.
(
/npc create test) and apply a model:/npc custom_model test <model>. The model shouldappear and the player NPC should become invisible immediately — no visible Steve alongside
the model, and none for players who join afterwards.
play_animation_loop) and run/npc play_animation test <animation> --loop— tab-completion should list the model'sanimations, and the animation should play/loop.
/npc moveHere testand/npc teleport— the model should follow the NPC's new location./npc scale test 2and re-apply the model; the model and its hitbox should scale./npc custom_model test @none— the model disappears and the normalplayer NPC becomes visible again. Then
/npc remove testwith a model applied and confirm noorphan model is left in the world. Reload/restart the server and confirm models are restored
from the saved attribute without duplicates.
unchanged.
bm:<model>andme:<model>each force the intendedprovider, and that switching an NPC from one provider to the other leaves nothing behind.
log message instead of throwing.