Package com.goodbird.npcgecko.api
Class GeckoAPI
- java.lang.Object
-
- com.goodbird.npcgecko.api.AbstractGeckoAPI
-
- com.goodbird.npcgecko.api.GeckoAPI
-
public class GeckoAPI extends AbstractGeckoAPI
Implementation ofAbstractGeckoAPIthat provides the concrete GeckoLib integration. This class is loaded reflectively when GeckoLib is present and should not be referenced directly. UseAbstractGeckoAPI.Instance()to obtain the API.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IGeckoColorcolorOfRGB(int r, int g, int b)Create a color from RGB components.IGeckoColorcolorOfRGBA(int r, int g, int b, int a)Create a color from RGBA components.IGeckoAnimationBuildercreateAnimationBuilder()Create a new animation builder for constructing animation sequences.IGeckoAnimationBuildercreateAnimBuilder()Create a new animation builder for constructing animation sequences.IGeckoAnimatablegetAnimatable(IBlockScripted scriptedBlock)Get the gecko model configuration interface for a scripted block.IGeckoAnimatablegetAnimatable(ICustomNpc<noppes.npcs.entity.EntityNPCInterface> npc)Get the gecko model configuration interface for an NPC.IGeckoAnimationgetAnimation(String animationFile, String animationName)Get animation metadata from a loaded animation file.String[]getAnimationFileList()Get a list of all loaded animation file resource locations.String[]getAnimationList(String animationFile)Get a list of all animation names defined in an animation file.String[]getDisplayFileList()Get a list of all loaded display file names from item_displays/ resource folders.IGeckoItemModelgetItemGecko(IItemCustomizable item)Get the gecko model interface for a customizable item.static AbstractGeckoAPIInstance()voidsetAnimationFile(IBlockScripted scriptedBlock, String animation)Set the animation file resource location for a scripted block.voidsetAnimationFile(ICustomNpc<noppes.npcs.entity.EntityNPCInterface> npc, String animation)Set the animation file resource location for an NPC.voidsetIdleAnimation(IBlockScripted scriptedBlock, String animation)Set the idle animation name for a scripted block.voidsetIdleAnimation(ICustomNpc<noppes.npcs.entity.EntityNPCInterface> npc, String animation)Set the idle animation name for an NPC.voidsetModel(IBlockScripted scriptedBlock, String model)Set the GeckoLib geo model resource location for a scripted block.voidsetModel(ICustomNpc<noppes.npcs.entity.EntityNPCInterface> npc, String model)Set the GeckoLib geo model resource location for an NPC.voidsetTexture(IBlockScripted scriptedBlock, String texture)Set the texture resource location for a scripted block.voidsetTexture(ICustomNpc<noppes.npcs.entity.EntityNPCInterface> npc, String texture)Set the texture resource location for an NPC.voidsyncAnimForAll(IBlockScripted scriptedBlock, IGeckoAnimationBuilder builder)Sync a queued animation sequence to all connected players for a scripted block.voidsyncAnimForAll(ICustomNpc<noppes.npcs.entity.EntityNPCInterface> npc, IGeckoAnimationBuilder builder)Sync a queued animation sequence to all connected players for an NPC.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.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.-
Methods inherited from class com.goodbird.npcgecko.api.AbstractGeckoAPI
IsAvailable
-
-
-
-
Method Detail
-
Instance
public static AbstractGeckoAPI Instance()
-
createAnimBuilder
public IGeckoAnimationBuilder createAnimBuilder()
Description copied from class:AbstractGeckoAPICreate a new animation builder for constructing animation sequences. Alias forAbstractGeckoAPI.createAnimationBuilder().- Specified by:
createAnimBuilderin classAbstractGeckoAPI- Returns:
- a new animation builder instance
-
createAnimationBuilder
public IGeckoAnimationBuilder createAnimationBuilder()
Description copied from class:AbstractGeckoAPICreate 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);- Specified by:
createAnimationBuilderin classAbstractGeckoAPI- Returns:
- a new animation builder instance
-
getAnimatable
public IGeckoAnimatable getAnimatable(ICustomNpc<noppes.npcs.entity.EntityNPCInterface> npc)
Description copied from class:AbstractGeckoAPIGet the gecko model configuration interface for an NPC. The returned object allows reading and writing model, texture, animation file, and animation state settings.- Specified by:
getAnimatablein classAbstractGeckoAPI- Parameters:
npc- the NPC to configure- Returns:
- the animatable interface for this NPC
- See Also:
IGeckoAnimatable
-
getAnimatable
public IGeckoAnimatable getAnimatable(IBlockScripted scriptedBlock)
Description copied from class:AbstractGeckoAPIGet the gecko model configuration interface for a scripted block. The returned object allows reading and writing model, texture, animation file, and animation state settings.- Specified by:
getAnimatablein classAbstractGeckoAPI- Parameters:
scriptedBlock- the scripted block to configure- Returns:
- the animatable interface for this block
- See Also:
IGeckoAnimatable
-
getAnimationList
public String[] getAnimationList(String animationFile)
Description copied from class:AbstractGeckoAPIGet a list of all animation names defined in an animation file.- Specified by:
getAnimationListin classAbstractGeckoAPI- 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 String[] getAnimationFileList()
Description copied from class:AbstractGeckoAPIGet a list of all loaded animation file resource locations.- Specified by:
getAnimationFileListin classAbstractGeckoAPI- Returns:
- array of animation file resource location strings
-
getAnimation
public IGeckoAnimation getAnimation(String animationFile, String animationName)
Description copied from class:AbstractGeckoAPIGet animation metadata from a loaded animation file.- Specified by:
getAnimationin classAbstractGeckoAPI- 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 IGeckoColor colorOfRGB(int r, int g, int b)
Description copied from class:AbstractGeckoAPICreate a color from RGB components.- Specified by:
colorOfRGBin classAbstractGeckoAPI- 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 IGeckoColor colorOfRGBA(int r, int g, int b, int a)
Description copied from class:AbstractGeckoAPICreate a color from RGBA components.- Specified by:
colorOfRGBAin classAbstractGeckoAPI- 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 void setModel(ICustomNpc<noppes.npcs.entity.EntityNPCInterface> npc, String model)
Description copied from class:AbstractGeckoAPISet the GeckoLib geo model resource location for an NPC.- Specified by:
setModelin classAbstractGeckoAPI- Parameters:
npc- the target NPCmodel- the model resource location (e.g. "geckolib3:geo/npc.geo.json")
-
setTexture
public void setTexture(ICustomNpc<noppes.npcs.entity.EntityNPCInterface> npc, String texture)
Description copied from class:AbstractGeckoAPISet the texture resource location for an NPC.- Specified by:
setTexturein classAbstractGeckoAPI- Parameters:
npc- the target NPCtexture- the texture resource location (e.g. "geckolib3:textures/model/npc.png")
-
setAnimationFile
public void setAnimationFile(ICustomNpc<noppes.npcs.entity.EntityNPCInterface> npc, String animation)
Description copied from class:AbstractGeckoAPISet the animation file resource location for an NPC.- Specified by:
setAnimationFilein classAbstractGeckoAPI- Parameters:
npc- the target NPCanimation- the animation file resource location (e.g. "geckolib3:animations/npc.animation.json")
-
setIdleAnimation
public void setIdleAnimation(ICustomNpc<noppes.npcs.entity.EntityNPCInterface> npc, String animation)
Description copied from class:AbstractGeckoAPISet the idle animation name for an NPC. The animation must exist in the currently assigned animation file.- Specified by:
setIdleAnimationin classAbstractGeckoAPI- Parameters:
npc- the target NPCanimation- the animation name (e.g. "animation.npc.idle")
-
syncAnimForPlayer
public void syncAnimForPlayer(ICustomNpc<noppes.npcs.entity.EntityNPCInterface> npc, IGeckoAnimationBuilder builder, IPlayer<net.minecraft.entity.player.EntityPlayerMP> player)
Description copied from class:AbstractGeckoAPISync a queued animation sequence to a specific player for an NPC. Only the specified player will see the animation.- Specified by:
syncAnimForPlayerin classAbstractGeckoAPI- 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 void syncAnimForAll(ICustomNpc<noppes.npcs.entity.EntityNPCInterface> npc, IGeckoAnimationBuilder builder)
Description copied from class:AbstractGeckoAPISync a queued animation sequence to all connected players for an NPC.- Specified by:
syncAnimForAllin classAbstractGeckoAPI- Parameters:
npc- the NPC to play the animation onbuilder- the animation builder containing the queued animation sequence
-
setModel
public void setModel(IBlockScripted scriptedBlock, String model)
Description copied from class:AbstractGeckoAPISet the GeckoLib geo model resource location for a scripted block.- Specified by:
setModelin classAbstractGeckoAPI- Parameters:
scriptedBlock- the target scripted blockmodel- the model resource location (e.g. "geckolib3:geo/block.geo.json")
-
setTexture
public void setTexture(IBlockScripted scriptedBlock, String texture)
Description copied from class:AbstractGeckoAPISet the texture resource location for a scripted block.- Specified by:
setTexturein classAbstractGeckoAPI- Parameters:
scriptedBlock- the target scripted blocktexture- the texture resource location (e.g. "geckolib3:textures/model/block.png")
-
setAnimationFile
public void setAnimationFile(IBlockScripted scriptedBlock, String animation)
Description copied from class:AbstractGeckoAPISet the animation file resource location for a scripted block.- Specified by:
setAnimationFilein classAbstractGeckoAPI- Parameters:
scriptedBlock- the target scripted blockanimation- the animation file resource location (e.g. "geckolib3:animations/block.animation.json")
-
setIdleAnimation
public void setIdleAnimation(IBlockScripted scriptedBlock, String animation)
Description copied from class:AbstractGeckoAPISet the idle animation name for a scripted block. The animation must exist in the currently assigned animation file.- Specified by:
setIdleAnimationin classAbstractGeckoAPI- Parameters:
scriptedBlock- the target scripted blockanimation- the animation name (e.g. "animation.block.idle")
-
syncAnimForPlayer
public void syncAnimForPlayer(IBlockScripted scriptedBlock, IGeckoAnimationBuilder builder, IPlayer<net.minecraft.entity.player.EntityPlayerMP> player)
Description copied from class:AbstractGeckoAPISync a queued animation sequence to a specific player for a scripted block. Only the specified player will see the animation.- Specified by:
syncAnimForPlayerin classAbstractGeckoAPI- 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 void syncAnimForAll(IBlockScripted scriptedBlock, IGeckoAnimationBuilder builder)
Description copied from class:AbstractGeckoAPISync a queued animation sequence to all connected players for a scripted block.- Specified by:
syncAnimForAllin classAbstractGeckoAPI- Parameters:
scriptedBlock- the scripted block to play the animation onbuilder- the animation builder containing the queued animation sequence
-
getItemGecko
public IGeckoItemModel getItemGecko(IItemCustomizable item)
Description copied from class:AbstractGeckoAPIGet 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");- Specified by:
getItemGeckoin classAbstractGeckoAPI- Parameters:
item- the customizable item (IItemCustom or IItemLinked)- Returns:
- the gecko model interface for this item
- See Also:
IGeckoItemModel
-
getDisplayFileList
public String[] getDisplayFileList()
Description copied from class:AbstractGeckoAPIGet 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).- Specified by:
getDisplayFileListin classAbstractGeckoAPI- Returns:
- array of display file names (e.g. "sword.json", "tool.json")
-
-