[Legacy] GeckoLib Fabric

[Legacy] GeckoLib Fabric

3M Downloads

Rendering virtual item in hand not tracking animation

lab3 opened this issue ยท 1 comments

commented

I have items rendering in hands just fine but I have a custom layer that is attempting to render a custom texture when casting a spell which shows up fine. The issue is the location where the texture is being rendered is not tracking the hand position like the items do during an animation. It just stays on the side of the mob where the default bone position is for that hand.

I have a feeling i'm missing something basic here but I have been beating my head against a while for a while on this one. Any insight would be appreciated.

Here is the code for the layer. I have a feeling the problem is right after the "//Lance position" comment

@OnlyIn(Dist.CLIENT)
public class GeoChargeSpellLayer extends GeoLayerRenderer<AbstractSpellCastingMob> {
    public GeoChargeSpellLayer(IGeoRenderer entityRenderer) {
        super(entityRenderer);
    }

    @Override
    public void render(PoseStack poseStack, MultiBufferSource bufferSource, int packedLightIn, AbstractSpellCastingMob entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
        var syncedSpellData = ClientMagicData.getSyncedSpellData(entity);
        var spell = syncedSpellData.getCastingSpellType();
        if (spell == SpellType.LIGHTNING_LANCE_SPELL) {
            var model = this.getRenderer().getGeoModelProvider().getModel(this.getEntityModel().getModelResource(entity));

            Optional<GeoBone> bone = model.getBone(DefaultBipedBoneIdents.RIGHT_HAND_BONE_IDENT);
            if (bone.isPresent()) {
                poseStack.pushPose();

                //Lance position
                RenderUtils.prepMatrixForBone(poseStack, bone.get());
                RenderUtils.translateAndRotateMatrixForBone(poseStack, bone.get());
                LightningLanceRenderer.renderModel(poseStack, bufferSource, entity.tickCount);

                poseStack.popPose();
            }
        }
    }
}

Here is a screenshot to illustrate what I'm talking about.

lance

commented

Join the discord for dev help if needed