Package com.goodbird.npcgecko.api
Class AbstractGeckoAPI
- java.lang.Object
-
- com.goodbird.npcgecko.api.AbstractGeckoAPI
-
- Direct Known Subclasses:
GeckoAPI
public abstract class AbstractGeckoAPI extends Object
Main entry point for the GeckoLib Addon API. Provides methods for controlling GeckoLib 3D models, animations, textures, and display settings on CustomNPC+ entities, scripted blocks, and items.Access the API singleton via
AbstractGeckoAPI.Instance(). Check availability first withAbstractGeckoAPI.IsAvailable().Script usage example:
var gecko = Java.type("com.goodbird.npcgecko.api.AbstractGeckoAPI").Instance(); if (gecko != null) { gecko.setModel(npc, "geckolib3:geo/custom_npc.geo.json"); gecko.setTexture(npc, "geckolib3:textures/model/custom_npc.png"); }- See Also:
IGeckoAnimatable,IGeckoItemModel,IGeckoAnimationBuilder
-
-
Constructor Summary
Constructors Constructor Description AbstractGeckoAPI()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract IGeckoColorcolorOfRGB(int r, int g, int b)Create a color from RGB components.abstract IGeckoColorcolorOfRGBA(int r, int g, int b, int a)Create a color from RGBA components.abstract IGeckoAnimationBuildercreateAnimationBuilder()Create a new animation builder for constructing animation sequences.abstract IGeckoAnimationBuildercreateAnimBuilder()Create a new animation builder for constructing animation sequences.abstract IGeckoAnimatablegetAnimatable(IBlockScripted scriptedBlock)Get the gecko model configuration interface for a scripted block.abstract IGeckoAnimatablegetAnimatable(ICustomNpc<noppes.npcs.entity.EntityNPCInterface> npc)Get the gecko model configuration interface for an NPC.abstract IGeckoAnimationgetAnimation(String animationFile, String animationName)Get animation metadata from a loaded animation file.abstract String[]getAnimationFileList()Get a list of all loaded animation file resource locations.abstract String[]getAnimationList(String animationFile)Get a list of all animation names defined in an animation file.abstract String[]getDisplayFileList()Get a list of all loaded display file names from item_displays/ resource folders.abstract IGeckoItemModelgetItemGecko(IItemCustomizable item)Get the gecko model interface for a customizable item.static AbstractGeckoAPIInstance()Get the API singleton instance.static booleanIsAvailable()Check whether the GeckoLib mod is loaded and the API is available.abstract voidsetAnimationFile(IBlockScripted scriptedBlock, String animation)Set the animation file resource location for a scripted block.abstract voidsetAnimationFile(ICustomNpc<noppes.npcs.entity.EntityNPCInterface> npc, String animation)Set the animation file resource location for an NPC.abstract voidsetIdleAnimation(IBlockScripted scriptedBlock, String animation)Set the idle animation name for a scripted block.abstract voidsetIdleAnimation(ICustomNpc<noppes.npcs.entity.EntityNPCInterface> npc, String animation)Set the idle animation name for an NPC.abstract voidsetModel(IBlockScripted scriptedBlock, String model)Set the GeckoLib geo model resource location for a scripted block.abstract voidsetModel(ICustomNpc<noppes.npcs.entity.EntityNPCInterface> npc, String model)Set the GeckoLib geo model resource location for an NPC.abstract voidsetTexture(IBlockScripted scriptedBlock, String texture)Set the texture resource location for a scripted block.abstract voidsetTexture(ICustomNpc<noppes.npcs.entity.EntityNPCInterface> npc, String texture)Set the texture resource location for an NPC.abstract voidsyncAnimForAll(IBlockScripted scriptedBlock, IGeckoAnimationBuilder builder)Sync a queued animation sequence to all connected players for a scripted block.abstract voidsyncAnimForAll(ICustomNpc<noppes.npcs.entity.EntityNPCInterface> npc, IGeckoAnimationBuilder builder)Sync a queued animation sequence to all connected players for an NPC.abstract voidsyncAnimForPlayer(IBlockScripted scriptedBlock, IGeckoAnimationBuilder builder, IPlayer<net.minecraft.entity.player.EntityPlayerMP> player)Sync a queued animation sequence to a specific player for a scripted block.abstract voidsyncAnimForPlayer(ICustomNpc<noppes.npcs.entity.EntityNPCInterface> npc, IGeckoAnimationBuilder builder, IPlayer<net.minecraft.entity.player.EntityPlayerMP> player)Sync a queued animation sequence to a specific player for an NPC.
-
-
-
Method Detail
-
IsAvailable
public static boolean IsAvailable()
Check whether the GeckoLib mod is loaded and the API is available.- Returns:
- true if GeckoLib is loaded
-
Instance
public static AbstractGeckoAPI Instance()
Get the API singleton instance. Returns null if GeckoLib is not loaded.- Returns:
- the API instance, or null if GeckoLib is unavailable
-
createAnimBuilder
public abstract IGeckoAnimationBuilder createAnimBuilder()
Create a new animation builder for constructing animation sequences. Alias forcreateAnimationBuilder().- Returns:
- a new animation builder instance
-
createAnimationBuilder
public abstract IGeckoAnimationBuilder createAnimationBuilder()
Create a new animation builder for constructing animation sequences.Usage example:
var builder = gecko.createAnimationBuilder(); builder.playOnce("animation.model.attack").loop("animation.model.idle"); gecko.syncAnimForAll(npc, builder);- Returns:
- a new animation builder instance
-
getAnimatable
public abstract IGeckoAnimatable getAnimatable(ICustomNpc<noppes.npcs.entity.EntityNPCInterface> npc)
Get the gecko model configuration interface for an NPC. The returned object allows reading and writing model, texture, animation file, and animation state settings.- Parameters:
npc- the NPC to configure- Returns:
- the animatable interface for this NPC
- See Also:
IGeckoAnimatable
-
getAnimatable
public abstract IGeckoAnimatable getAnimatable(IBlockScripted scriptedBlock)
Get the gecko model configuration interface for a scripted block. The returned object allows reading and writing model, texture, animation file, and animation state settings.- Parameters:
scriptedBlock- the scripted block to configure- Returns:
- the animatable interface for this block
- See Also:
IGeckoAnimatable
-
getAnimationList
public abstract String[] getAnimationList(String animationFile)
Get a list of all animation names defined in an animation file.- Parameters:
animationFile- the animation file resource location (e.g. "geckolib3:animations/model.animation.json")- Returns:
- array of animation names, or an empty array if the file was not found
-
getAnimationFileList
public abstract String[] getAnimationFileList()
Get a list of all loaded animation file resource locations.- Returns:
- array of animation file resource location strings
-
getAnimation
public abstract IGeckoAnimation getAnimation(String animationFile, String animationName)
Get animation metadata from a loaded animation file.- Parameters:
animationFile- the animation file resource locationanimationName- the animation name within the file- Returns:
- the animation metadata, or null if not found
- See Also:
IGeckoAnimation
-
colorOfRGB
public abstract IGeckoColor colorOfRGB(int r, int g, int b)
Create a color from RGB components.- Parameters:
r- red component (0-255)g- green component (0-255)b- blue component (0-255)- Returns:
- a new color instance
- See Also:
IGeckoColor
-
colorOfRGBA
public abstract IGeckoColor colorOfRGBA(int r, int g, int b, int a)
Create a color from RGBA components.- Parameters:
r- red component (0-255)g- green component (0-255)b- blue component (0-255)a- alpha component (0-255, where 255 is fully opaque)- Returns:
- a new color instance
- See Also:
IGeckoColor
-
setModel
public abstract void setModel(ICustomNpc<noppes.npcs.entity.EntityNPCInterface> npc, String model)
Set the GeckoLib geo model resource location for an NPC.- Parameters:
npc- the target NPCmodel- the model resource location (e.g. "geckolib3:geo/npc.geo.json")
-
setTexture
public abstract void setTexture(ICustomNpc<noppes.npcs.entity.EntityNPCInterface> npc, String texture)
Set the texture resource location for an NPC.- Parameters:
npc- the target NPCtexture- the texture resource location (e.g. "geckolib3:textures/model/npc.png")
-
setAnimationFile
public abstract void setAnimationFile(ICustomNpc<noppes.npcs.entity.EntityNPCInterface> npc, String animation)
Set the animation file resource location for an NPC.- Parameters:
npc- the target NPCanimation- the animation file resource location (e.g. "geckolib3:animations/npc.animation.json")
-
setIdleAnimation
public abstract void setIdleAnimation(ICustomNpc<noppes.npcs.entity.EntityNPCInterface> npc, String animation)
Set the idle animation name for an NPC. The animation must exist in the currently assigned animation file.- Parameters:
npc- the target NPCanimation- the animation name (e.g. "animation.npc.idle")
-
syncAnimForPlayer
public abstract void syncAnimForPlayer(ICustomNpc<noppes.npcs.entity.EntityNPCInterface> npc, IGeckoAnimationBuilder builder, IPlayer<net.minecraft.entity.player.EntityPlayerMP> player)
Sync a queued animation sequence to a specific player for an NPC. Only the specified player will see the animation.- Parameters:
npc- the NPC to play the animation onbuilder- the animation builder containing the queued animation sequenceplayer- the player to send the animation to
-
syncAnimForAll
public abstract void syncAnimForAll(ICustomNpc<noppes.npcs.entity.EntityNPCInterface> npc, IGeckoAnimationBuilder builder)
Sync a queued animation sequence to all connected players for an NPC.- Parameters:
npc- the NPC to play the animation onbuilder- the animation builder containing the queued animation sequence
-
setModel
public abstract void setModel(IBlockScripted scriptedBlock, String model)
Set the GeckoLib geo model resource location for a scripted block.- Parameters:
scriptedBlock- the target scripted blockmodel- the model resource location (e.g. "geckolib3:geo/block.geo.json")
-
setTexture
public abstract void setTexture(IBlockScripted scriptedBlock, String texture)
Set the texture resource location for a scripted block.- Parameters:
scriptedBlock- the target scripted blocktexture- the texture resource location (e.g. "geckolib3:textures/model/block.png")
-
setAnimationFile
public abstract void setAnimationFile(IBlockScripted scriptedBlock, String animation)
Set the animation file resource location for a scripted block.- Parameters:
scriptedBlock- the target scripted blockanimation- the animation file resource location (e.g. "geckolib3:animations/block.animation.json")
-
setIdleAnimation
public abstract void setIdleAnimation(IBlockScripted scriptedBlock, String animation)
Set the idle animation name for a scripted block. The animation must exist in the currently assigned animation file.- Parameters:
scriptedBlock- the target scripted blockanimation- the animation name (e.g. "animation.block.idle")
-
syncAnimForPlayer
public abstract void syncAnimForPlayer(IBlockScripted scriptedBlock, IGeckoAnimationBuilder builder, IPlayer<net.minecraft.entity.player.EntityPlayerMP> player)
Sync a queued animation sequence to a specific player for a scripted block. Only the specified player will see the animation.- Parameters:
scriptedBlock- the scripted block to play the animation onbuilder- the animation builder containing the queued animation sequenceplayer- the player to send the animation to
-
syncAnimForAll
public abstract void syncAnimForAll(IBlockScripted scriptedBlock, IGeckoAnimationBuilder builder)
Sync a queued animation sequence to all connected players for a scripted block.- Parameters:
scriptedBlock- the scripted block to play the animation onbuilder- the animation builder containing the queued animation sequence
-
getItemGecko
public abstract IGeckoItemModel getItemGecko(IItemCustomizable item)
Get the gecko model interface for a customizable item. Works with both Scripted Items and Linked Items. The returned object allows reading and writing model, texture, animation, and display transform settings.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.setAttackAnimation("animation.sword.attack");- Parameters:
item- the customizable item (IItemCustom or IItemLinked)- Returns:
- the gecko model interface for this item
- Throws:
IllegalArgumentException- if the item is not a Scripted or Linked item- See Also:
IGeckoItemModel
-
getDisplayFileList
public abstract String[] getDisplayFileList()
Get a list of all loaded display file names from item_displays/ resource folders. Display files control how 3D item models are positioned, rotated, and scaled in each render context (first person, third person, inventory, ground).- Returns:
- array of display file names (e.g. "sword.json", "tool.json")
-
-