Package com.goodbird.npcgecko.api
Interface IGeckoItemModel
-
public interface IGeckoItemModelInterface for accessing and modifying GeckoLib 3D model configuration on items. Provides control over model, texture, animation files, display transforms, and display JSON settings for Scripted and Linked items.Changes made through this interface are automatically persisted to the ItemStack's NBT and synced to clients via container mechanics.
Obtain an instance via
AbstractGeckoAPI.getItemGecko(noppes.npcs.api.item.IItemCustomizable).Usage example:
var itemGecko = gecko.getItemGecko(event.item); itemGecko.setModel("geckolib3:geo/sword.geo.json"); itemGecko.setTexture("geckolib3:textures/model/sword.png"); itemGecko.setAnimationFile("geckolib3:animations/sword.animation.json"); var anim = itemGecko.getItemAnimation(); anim.setIdleAnimation("animation.sword.idle"); anim.setSwingAnimation("animation.sword.swing"); anim.setAttackAnimation("animation.sword.attack");
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclear()Remove the gecko model from this item, reverting it to normal 2D rendering.StringgetAnimationFile()Get the animation file resource location.StringgetDisplayJSON()Get the display JSON filename currently assigned to this item.IItemAnimationgetItemAnimation()Get the item animation configuration interface.StringgetModel()Get the geo model resource location.StringgetTexture()Get the texture resource location.intgetTransitionLengthTicks()Get the transition duration between animations in ticks.booleanhasModel()Check if this item currently has a gecko model assigned.voidsetAnimationFile(String animationFile)Set the animation file resource location.voidsetDisplay(String context, float tx, float ty, float tz, float rx, float ry, float rz, float sx, float sy, float sz)Set the display transform for a specific render context.voidsetDisplayJSON(String displayFile)Set the display JSON file for controlling how the 3D model is positioned, rotated, and scaled in each render context (first person, third person, inventory, and ground).voidsetModel(String model)Set the GeckoLib geo model resource location.voidsetTexture(String texture)Set the texture resource location used when rendering this item's 3D model.voidsetTransitionLengthTicks(int ticks)Set the transition duration between animations in ticks.
-
-
-
Method Detail
-
hasModel
boolean hasModel()
Check if this item currently has a gecko model assigned.- Returns:
- true if the item has a GeckoLib 3D model
-
getModel
String getModel()
Get the geo model resource location.- Returns:
- the model resource location string, or an empty string if no model is set
-
setModel
void setModel(String model)
Set the GeckoLib geo model resource location. The model file should be a Blockbench geo JSON exported for GeckoLib.- Parameters:
model- the model resource location (e.g. "geckolib3:geo/sword.geo.json")
-
getTexture
String getTexture()
Get the texture resource location.- Returns:
- the texture resource location string, or an empty string if no texture is set
-
setTexture
void setTexture(String texture)
Set the texture resource location used when rendering this item's 3D model.- Parameters:
texture- the texture resource location (e.g. "geckolib3:textures/model/sword.png")
-
getAnimationFile
String getAnimationFile()
Get the animation file resource location.- Returns:
- the animation file resource location string, or an empty string if none is set
-
setAnimationFile
void setAnimationFile(String animationFile)
Set the animation file resource location. The file should be a Blockbench animation JSON exported for GeckoLib.- Parameters:
animationFile- the animation file resource location (e.g. "geckolib3:animations/sword.animation.json")
-
getItemAnimation
IItemAnimation getItemAnimation()
Get the item animation configuration interface. Provides access to getters and setters for all animation types (idle, swing, attack, use).- Returns:
- the item animation interface
- See Also:
IItemAnimation
-
getTransitionLengthTicks
int getTransitionLengthTicks()
Get the transition duration between animations in ticks.- Returns:
- the transition length in ticks (default: 10)
-
setTransitionLengthTicks
void setTransitionLengthTicks(int ticks)
Set the transition duration between animations in ticks. Controls how smoothly one animation blends into the next.- Parameters:
ticks- the transition length in ticks (20 ticks = 1 second)
-
getDisplayJSON
String getDisplayJSON()
Get the display JSON filename currently assigned to this item.- Returns:
- the display JSON filename (e.g. "sword.json"), or an empty string if none is set
-
setDisplayJSON
void setDisplayJSON(String displayFile)
Set the display JSON file for controlling how the 3D model is positioned, rotated, and scaled in each render context (first person, third person, inventory, and ground).Display files are loaded from
assets/{domain}/item_displays/resource folders. UseAbstractGeckoAPI.getDisplayFileList()to list available files.- Parameters:
displayFile- the display JSON filename (e.g. "sword.json")- See Also:
AbstractGeckoAPI.getDisplayFileList()
-
setDisplay
void setDisplay(String context, float tx, float ty, float tz, float rx, float ry, float rz, float sx, float sy, float sz)
Set the display transform for a specific render context. This overrides any display JSON settings for the specified context and controls how the 3D model is positioned, rotated, and scaled.Valid context values:
"first_person"- held item in first-person view"third_person"- held item in third-person view"inventory"- item icon in inventory GUI"ground"- dropped item entity on the ground
- Parameters:
context- the render context nametx- translation X offsetty- translation Y offsettz- translation Z offsetrx- rotation X in degreesry- rotation Y in degreesrz- rotation Z in degreessx- scale X multipliersy- scale Y multipliersz- scale Z multiplier- Throws:
IllegalArgumentException- if the context name is not recognized
-
clear
void clear()
Remove the gecko model from this item, reverting it to normal 2D rendering. Clears all model, texture, animation, and display settings.
-
-