-
-
Notifications
You must be signed in to change notification settings - Fork 128
Geckolib Armor (Geckolib3)
When making your armor model in Blockbench, ensure you have selected the Armor
model type in the Geckolib Model Settings
panel in the File
menu.
This is critical to ensure that Blockbench generates the correct project template and output files for you when finished.
Creating a GeckoLib armor requires the following steps:
- Creating your Blockbench Model
- Creating your Geo Model
- Creating your item display json
- Creating your Item class
- Creating and registering your renderer
Steps #1 and #2 will not be covered on this page, instead visit their respective links for info. This page will focus on steps #3, #4, and #5
Forge
Armor item classes are created the exact same way normal animatable item classes are. Because of this, you'll want to look at the Geckolib Items page for instructions on creating the class.
The only difference to normal items is that we should extend GeoArmorItem
instead. This handles the rendering callback for you.
If for some reason you're unable to extend GeoArmorItem, you will need to re-implement the functionality that GeoArmorItem
contains.
public class ExampleArmorItem extends GeoArmorItem implements IAnimatable {
protected static final AnimationBuilder IDLE_ANIM = new AnimationBuilder().addAnimation("misc.idle", true);
private final AnimationFactory factory = GeckoLibUtil.createFactory(this);
public ExampleArmorItem(ArmorMaterial armorMaterial, EquipmentSlot slot, Properties properties) {
super(armorMaterial, slot, properties);
}
private <T extends ExampleArmorItem> PlayState idleAnimController(final AnimationEvent<T> event) {
event.getController().setAnimation(IDLE_ANIM);
return PlayState.CONTINUE;
}
@Override
public void registerControllers(AnimationData data) {
data.addAnimationController(new AnimationController(this, "Idle Controller", 0, this::idleAnimController));
}
@Override
public AnimationFactory getFactory() {
return this.factory;
}
}
Fabric
Armor item classes are created the exact same way normal animatable item classes are. Because of this, you'll want to look at the Geckolib Items page for instructions on creating the class.
public class ExampleArmorItem extends ArmorItem implements IAnimatable {
protected static final AnimationBuilder IDLE_ANIM = new AnimationBuilder().addAnimation("misc.idle", true);
private final AnimationFactory factory = GeckoLibUtil.createFactory(this);
public ExampleArmorItem(ArmorMaterial armorMaterial, EquipmentSlot slot, Properties properties) {
super(armorMaterial, slot, properties);
}
private <T extends ExampleArmorItem> PlayState idleAnimController(final AnimationEvent<T> event) {
event.getController().setAnimation(IDLE_ANIM);
return PlayState.CONTINUE;
}
@Override
public void registerControllers(AnimationData data) {
data.addAnimationController(new AnimationController(this, "Idle Controller", 0, this::idleAnimController));
}
@Override
public AnimationFactory getFactory() {
return this.factory;
}
}
GeoArmorRenderers are probably the most involved renderer type for GeckoLib3. Unlike most normal renderers, we have to do some additional manual work in the constructor to make sure everything works properly.
By default, Geckolib armors operate on a humanoid model basis. This means that the expected format for an armour roughly resembles a humanoid in that it has two arms, two legs, two feet, a torso, and a head. We need to tell the renderer which of our 'bones' align with the humanoid representation of them, so that it can match them up for rendering.
We do this by assigning the name of the bone (found in our geo.json, or as the name of the bone group in Blockbench) to each respective part of the renderer. See below for example usage of this, with generic placeholder bone names.
public class ExampleArmorRenderer extends GeoArmorRenderer<ExampleArmorItem> {
public ExampleArmorRenderer() {
super(new ExampleArmorModel());
// These values are what each bone name is in blockbench. So if your head bone group is named "bone545",
// you would do to do this.headBone = "bone545";
// The default values are the ones that come with the default armor template in the GeckoLib Blockbench plugin.
this.headBone = "helmet";
this.bodyBone = "chestplate";
this.rightArmBone = "rightArm";
this.leftArmBone = "leftArm";
this.rightLegBone = "rightLeg";
this.leftLegBone = "leftLeg";
this.rightBootBone = "rightBoot";
this.leftBootBone = "leftBoot";
}
}
Forge
To register your Geckolib armor renderer, we need to call GeoArmorRenderer#registerArmorRenderer
during FMLClientSetupEvent
in your mod.
To that, we pass the class of the armor item, and a supplier for the renderer.
@SubscribeEvent
public static void clientSetup(final FMLClientSetupEvent event) {
GeoArmorRenderer.registerArmorRenderer(ExampleArmorItem.class, ExampleArmorRenderer::new);
}
Fabric
To register your Geckolib armor renderer, we need to call GeoArmorRenderer#registerArmorRenderer
inside onInitializeClient
in your mod.
To that, we pass the an instance of the renderer for the armor, as well as the item instances for each relevant armor piece.
@Override
public void onInitializeClient() {
GeoArmorRenderer.registerArmorRenderer(new PotatoArmorRenderer(),
MyItems.EXAMPLE_ARMOR_HELMET, MyItems.EXAMPLE_ARMOR_CHESTPLATE, MyItems.EXAMPLE_ARMOR_LEGGINGS, MyItems.EXAMPLE_ARMOR_BOOTS);
}
Geckolib 3
Geckolib 4
- Installation
- Getting Started
- Upgrading from GeckoLib 3.1.x to 4.0
- Updating to GeckoLib 4.5
- Basic
- Advanced
- Miscellaneous
Package repository hosting is graciously provided by Cloudsmith.
Cloudsmith is the only fully hosted, cloud-native, universal package management solution that enables your organization to create, store and share packages in any format, to any place, with total confidence.