GeckoJS is a powerful bridge between GeckoLib and KubeJS, allowing you to create high-quality animated items, armor, blocks, and entities using simple JavaScript scripts. This project is a remake of the original GeckoJS mod, modernized for Minecraft 1.21.1 and NeoForge.
To use GeckoJS, you need the following mods installed:
- NeoForge (1.21.1)
- KubeJS (latest version for 1.21.1)
- GeckoLib (4.6.6 or higher)
GeckoJS relies on standard GeckoLib .geo.json models and .animation.json animations. By default, it looks for these files in your KubeJS assets folder.
When using .defaultGeoModel(), the following paths are assumed (replace item_id with your item's name):
| Type | Model Path (assets/kubejs/geo/) |
Texture Path (assets/kubejs/textures/) |
Animation Path (assets/kubejs/animations/) |
|---|---|---|---|
| Items | item/item_id.geo.json |
item/item_id.png |
item/item_id.animation.json |
| Armor | armor/item_id.geo.json |
armor/item_id.png |
armor/item_id.animation.json |
| Blocks | block/item_id.geo.json |
block/item_id.png |
block/item_id.animation.json |
Register your objects in a Startup Script (kubejs/startup_scripts/).
animatable(Items or Blocks)anim_sword,anim_pickaxe,anim_axe,anim_shovel,anim_hoeanim_shieldanim_helmet,anim_chestplate,anim_leggings,anim_boots
StartupEvents.registry('item', event => {
event.create('cool_sword', 'anim_sword')
.tier('diamond')
.defaultGeoModel()
.addController(controller => {
controller.addAnimation(state => {
if (state.isMoving()) {
return state.setAndContinue(RawAnimation.begin().thenLoop("walk"))
}
return state.setAndContinue(RawAnimation.begin().thenLoop("idle"))
})
})
})Armor registration is similar to items but includes helpers for bone visibility, allowing you to hide specific parts of the player model or your custom model dynamically.
event.create('fancy_helmet', 'anim_helmet')
.material('iron')
.defaultGeoModel()
.armorItemUseGeoModel() // Makes the item icon use the 3D model
.boneVisibility((renderer, slot) => {
// Hide a specific bone on the armor model
renderer.hideBone("extra_antenna")
})renderer.hideBone("boneName")renderer.showBone("boneName")renderer.setBoneVisible(renderer.getBone("boneName"), boolean)renderer.getHeadBone(),renderer.getChestBone(),renderer.getLeftArmBone(), etc.
Blocks registered with the animatable type will automatically have an associated Block Entity that handles GeckoLib animations.
StartupEvents.registry('block', event => {
event.create('animated_pillar', 'animatable')
.defaultGeoModel()
.addController(controller => {
controller.addAnimation(state => {
return state.setAndContinue(RawAnimation.begin().thenLoop("spin"))
})
})
})You can add multiple controllers to a single object. Each controller manages its own animation state.
.addController(name, controller => { ... }).addController(controller => { ... })(uses default name)
The following GeckoLib classes are exposed to JavaScript:
RawAnimationPlayStateAnimationControllerAnimationStateGeoItemGeoBoneEasingTypeDataTicketsEquipmentSlot
RawAnimation.begin().thenPlay("anim"): Plays once.RawAnimation.begin().thenLoop("anim"): Loops indefinitely.RawAnimation.begin().thenWait(20).thenPlay("anim"): Waits for 20 ticks before playing.
If you are a developer looking to build GeckoJS from source:
- Clone the repository.
- Ensure you have Java 21 installed.
- Run the following command in the terminal:
./gradlew build
- The compiled JAR will be in
build/libs/.