Search in sources :

Example 1 with BeeEntityModelAccessor

use of nomble.beebuddy.client.mixin.accessor.BeeEntityModelAccessor in project beebuddy by queenofthebees.

the class HeadFriendFeatureRenderer method render.

@Override
public void render(MatrixStack matrices, VertexConsumerProvider vcp, int light, T player, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) {
    IFriendlyPlayer friend = (IFriendlyPlayer) (Object) player;
    if (friend.beebuddy$hasHeadFriend()) {
        CompoundTag t = friend.beebuddy$getHeadFriendNbt();
        if (fake == null) {
            fake = new FakeBeeEntity(player.world);
        }
        Identifier tex = null;
        if (t.contains("BeeBuddyNectar")) {
            String type = t.getString("BeeBuddyNectar");
            if (!t.getString("BeeBuddyNectar").equals("default")) {
                String texture = "textures/entity/bee/" + type + "_bee.png";
                tex = new Identifier("beebuddy", texture);
            }
        }
        if (tex == null) {
            tex = new Identifier("textures/entity/bee/bee.png");
        }
        VertexConsumer v = vcp.getBuffer(bee.getLayer(tex));
        ModelPart h = this.getContextModel().getHead();
        matrices.push();
        if (player.isInSneakingPose()) {
            // offsets from BipedEntityModel
            matrices.translate(0F, 0.2625F, 0F);
        }
        matrices.multiply(Vector3f.POSITIVE_Z.getRadialQuaternion(h.roll));
        matrices.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion(h.yaw));
        matrices.multiply(Vector3f.POSITIVE_X.getRadialQuaternion(h.pitch));
        float ageMod = t.getInt("Age") >= 0 ? 2F : 1F;
        float headPos = player.isInSneakingPose() ? -1.4875F : -1.5F;
        matrices.translate(0F, ageMod * headPos - 0.4375, 0F);
        matrices.scale(ageMod, ageMod, ageMod);
        BeeEntityModelAccessor bea = (BeeEntityModelAccessor) (Object) bee;
        bee.setAngles(fake, 0F, 0F, animationProgress, 0F, 0F);
        bea.beebuddy$getBody().pitch = 0F;
        bea.beebuddy$getBody().pivotY = 19F;
        bee.render(matrices, v, light, OverlayTexture.DEFAULT_UV, 1F, 1F, 1F, 1F);
        matrices.pop();
    }
}
Also used : IFriendlyPlayer(nomble.beebuddy.duck.IFriendlyPlayer) Identifier(net.minecraft.util.Identifier) ModelPart(net.minecraft.client.model.ModelPart) BeeEntityModelAccessor(nomble.beebuddy.client.mixin.accessor.BeeEntityModelAccessor) VertexConsumer(net.minecraft.client.render.VertexConsumer) CompoundTag(net.minecraft.nbt.CompoundTag)

Aggregations

ModelPart (net.minecraft.client.model.ModelPart)1 VertexConsumer (net.minecraft.client.render.VertexConsumer)1 CompoundTag (net.minecraft.nbt.CompoundTag)1 Identifier (net.minecraft.util.Identifier)1 BeeEntityModelAccessor (nomble.beebuddy.client.mixin.accessor.BeeEntityModelAccessor)1 IFriendlyPlayer (nomble.beebuddy.duck.IFriendlyPlayer)1