Search in sources :

Example 1 with ModelPart

use of net.minecraft.client.model.ModelPart 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)

Example 2 with ModelPart

use of net.minecraft.client.model.ModelPart in project Enchanted-Bionics by Bubblie01.

the class PlayerEntityModelMixin method setSpecificVisible.

@Override
public void setSpecificVisible(boolean decider, String name) {
    if (name != null) {
        this.name = name;
        this.decider = decider;
        ModelPart modelPart = rootPart.getChild(name);
        modelPart.visible = decider;
    }
}
Also used : ModelPart(net.minecraft.client.model.ModelPart)

Example 3 with ModelPart

use of net.minecraft.client.model.ModelPart in project Biome-Makeover by Lemonszz.

the class StoneGolemEntityModel method hold.

public static void hold(ModelPart holdingArm, ModelPart otherArm, ModelPart head, boolean rightArmed) {
    ModelPart modelPart = rightArmed ? holdingArm : otherArm;
    ModelPart modelPart2 = rightArmed ? otherArm : holdingArm;
    modelPart.yaw = (rightArmed ? -0.3F : 0.3F) + head.yaw;
    modelPart2.yaw = (rightArmed ? 0.6F : -0.6F) + head.yaw;
    modelPart.pitch = -1.25F + head.pitch + 0.1F;
    modelPart2.pitch = -1.25F + head.pitch;
}
Also used : ModelPart(net.minecraft.client.model.ModelPart)

Example 4 with ModelPart

use of net.minecraft.client.model.ModelPart in project meteor-rejects by AntiCope.

the class SkeletonESP method onRender.

@EventHandler
private void onRender(Render3DEvent event) {
    MatrixStack matrixStack = event.matrices;
    float g = event.tickDelta;
    RenderSystem.setShader(GameRenderer::getPositionColorShader);
    RenderSystem.disableTexture();
    RenderSystem.enableBlend();
    RenderSystem.defaultBlendFunc();
    RenderSystem.disableDepthTest();
    RenderSystem.depthMask(MinecraftClient.isFabulousGraphicsOrBetter());
    RenderSystem.enableCull();
    mc.world.getEntities().forEach(entity -> {
        if (!(entity instanceof PlayerEntity))
            return;
        if (mc.options.getPerspective() == Perspective.FIRST_PERSON && !freecam.isActive() && mc.player == entity)
            return;
        int rotationHoldTicks = Config.get().rotationHoldTicks.get();
        Color skeletonColor = PlayerUtils.getPlayerColor((PlayerEntity) entity, skeletonColorSetting.get());
        if (distance.get())
            skeletonColor = getColorFromDistance(entity);
        PlayerEntity playerEntity = (PlayerEntity) entity;
        Vec3d footPos = getEntityRenderPosition(playerEntity, g);
        PlayerEntityRenderer livingEntityRenderer = (PlayerEntityRenderer) (LivingEntityRenderer<?, ?>) mc.getEntityRenderDispatcher().getRenderer(playerEntity);
        PlayerEntityModel<PlayerEntity> playerEntityModel = (PlayerEntityModel) livingEntityRenderer.getModel();
        float h = MathHelper.lerpAngleDegrees(g, playerEntity.prevBodyYaw, playerEntity.bodyYaw);
        if (mc.player == entity && Rotations.rotationTimer < rotationHoldTicks)
            h = Rotations.serverYaw;
        float j = MathHelper.lerpAngleDegrees(g, playerEntity.prevHeadYaw, playerEntity.headYaw);
        if (mc.player == entity && Rotations.rotationTimer < rotationHoldTicks)
            j = Rotations.serverYaw;
        float q = playerEntity.limbAngle - playerEntity.limbDistance * (1.0F - g);
        float p = MathHelper.lerp(g, playerEntity.lastLimbDistance, playerEntity.limbDistance);
        float o = (float) playerEntity.age + g;
        float k = j - h;
        float m = playerEntity.getPitch(g);
        if (mc.player == entity && Rotations.rotationTimer < rotationHoldTicks)
            m = Rotations.serverPitch;
        playerEntityModel.animateModel(playerEntity, q, p, g);
        playerEntityModel.setAngles(playerEntity, q, p, o, k, m);
        boolean swimming = playerEntity.isInSwimmingPose();
        boolean sneaking = playerEntity.isSneaking();
        boolean flying = playerEntity.isFallFlying();
        ModelPart head = playerEntityModel.head;
        ModelPart leftArm = playerEntityModel.leftArm;
        ModelPart rightArm = playerEntityModel.rightArm;
        ModelPart leftLeg = playerEntityModel.leftLeg;
        ModelPart rightLeg = playerEntityModel.rightLeg;
        matrixStack.translate(footPos.x, footPos.y, footPos.z);
        if (swimming)
            matrixStack.translate(0, 0.35f, 0);
        matrixStack.multiply(new Quaternion(new Vec3f(0, -1, 0), h + 180, true));
        if (swimming || flying)
            matrixStack.multiply(new Quaternion(new Vec3f(-1, 0, 0), 90 + m, true));
        if (swimming)
            matrixStack.translate(0, -0.95f, 0);
        BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
        bufferBuilder.begin(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR);
        Matrix4f matrix4f = matrixStack.peek().getPositionMatrix();
        bufferBuilder.vertex(matrix4f, 0, sneaking ? 0.6f : 0.7f, sneaking ? 0.23f : 0).color(skeletonColor.r, skeletonColor.g, skeletonColor.b, skeletonColor.a).next();
        // spine
        bufferBuilder.vertex(matrix4f, 0, sneaking ? 1.05f : 1.4f, 0).color(skeletonColor.r, skeletonColor.g, skeletonColor.b, skeletonColor.a).next();
        // shoulders
        bufferBuilder.vertex(matrix4f, -0.37f, sneaking ? 1.05f : 1.35f, 0).color(skeletonColor.r, skeletonColor.g, skeletonColor.b, skeletonColor.a).next();
        bufferBuilder.vertex(matrix4f, 0.37f, sneaking ? 1.05f : 1.35f, 0).color(skeletonColor.r, skeletonColor.g, skeletonColor.b, skeletonColor.a).next();
        // pelvis
        bufferBuilder.vertex(matrix4f, -0.15f, sneaking ? 0.6f : 0.7f, sneaking ? 0.23f : 0).color(skeletonColor.r, skeletonColor.g, skeletonColor.b, skeletonColor.a).next();
        bufferBuilder.vertex(matrix4f, 0.15f, sneaking ? 0.6f : 0.7f, sneaking ? 0.23f : 0).color(skeletonColor.r, skeletonColor.g, skeletonColor.b, skeletonColor.a).next();
        // Head
        matrixStack.push();
        matrixStack.translate(0, sneaking ? 1.05f : 1.4f, 0);
        rotate(matrixStack, head);
        matrix4f = matrixStack.peek().getPositionMatrix();
        bufferBuilder.vertex(matrix4f, 0, 0, 0).color(skeletonColor.r, skeletonColor.g, skeletonColor.b, skeletonColor.a).next();
        bufferBuilder.vertex(matrix4f, 0, 0.15f, 0).color(skeletonColor.r, skeletonColor.g, skeletonColor.b, skeletonColor.a).next();
        matrixStack.pop();
        // Right Leg
        matrixStack.push();
        matrixStack.translate(0.15f, sneaking ? 0.6f : 0.7f, sneaking ? 0.23f : 0);
        rotate(matrixStack, rightLeg);
        matrix4f = matrixStack.peek().getPositionMatrix();
        bufferBuilder.vertex(matrix4f, 0, 0, 0).color(skeletonColor.r, skeletonColor.g, skeletonColor.b, skeletonColor.a).next();
        bufferBuilder.vertex(matrix4f, 0, -0.6f, 0).color(skeletonColor.r, skeletonColor.g, skeletonColor.b, skeletonColor.a).next();
        matrixStack.pop();
        // Left Leg
        matrixStack.push();
        matrixStack.translate(-0.15f, sneaking ? 0.6f : 0.7f, sneaking ? 0.23f : 0);
        rotate(matrixStack, leftLeg);
        matrix4f = matrixStack.peek().getPositionMatrix();
        bufferBuilder.vertex(matrix4f, 0, 0, 0).color(skeletonColor.r, skeletonColor.g, skeletonColor.b, skeletonColor.a).next();
        bufferBuilder.vertex(matrix4f, 0, -0.6f, 0).color(skeletonColor.r, skeletonColor.g, skeletonColor.b, skeletonColor.a).next();
        matrixStack.pop();
        // Right Arm
        matrixStack.push();
        matrixStack.translate(0.37f, sneaking ? 1.05f : 1.35f, 0);
        rotate(matrixStack, rightArm);
        matrix4f = matrixStack.peek().getPositionMatrix();
        bufferBuilder.vertex(matrix4f, 0, 0, 0).color(skeletonColor.r, skeletonColor.g, skeletonColor.b, skeletonColor.a).next();
        bufferBuilder.vertex(matrix4f, 0, -0.55f, 0).color(skeletonColor.r, skeletonColor.g, skeletonColor.b, skeletonColor.a).next();
        matrixStack.pop();
        // Left Arm
        matrixStack.push();
        matrixStack.translate(-0.37f, sneaking ? 1.05f : 1.35f, 0);
        rotate(matrixStack, leftArm);
        matrix4f = matrixStack.peek().getPositionMatrix();
        bufferBuilder.vertex(matrix4f, 0, 0, 0).color(skeletonColor.r, skeletonColor.g, skeletonColor.b, skeletonColor.a).next();
        bufferBuilder.vertex(matrix4f, 0, -0.55f, 0).color(skeletonColor.r, skeletonColor.g, skeletonColor.b, skeletonColor.a).next();
        matrixStack.pop();
        bufferBuilder.end();
        BufferRenderer.draw(bufferBuilder);
        if (swimming)
            matrixStack.translate(0, 0.95f, 0);
        if (swimming || flying)
            matrixStack.multiply(new Quaternion(new Vec3f(1, 0, 0), 90 + m, true));
        if (swimming)
            matrixStack.translate(0, -0.35f, 0);
        matrixStack.multiply(new Quaternion(new Vec3f(0, 1, 0), h + 180, true));
        matrixStack.translate(-footPos.x, -footPos.y, -footPos.z);
    });
    RenderSystem.enableTexture();
    RenderSystem.disableCull();
    RenderSystem.disableBlend();
    RenderSystem.enableDepthTest();
    RenderSystem.depthMask(true);
}
Also used : ModelPart(net.minecraft.client.model.ModelPart) PlayerEntityRenderer(net.minecraft.client.render.entity.PlayerEntityRenderer) MatrixStack(net.minecraft.client.util.math.MatrixStack) Color(meteordevelopment.meteorclient.utils.render.color.Color) SettingColor(meteordevelopment.meteorclient.utils.render.color.SettingColor) PlayerEntity(net.minecraft.entity.player.PlayerEntity) PlayerEntityModel(net.minecraft.client.render.entity.model.PlayerEntityModel) EventHandler(meteordevelopment.orbit.EventHandler)

Example 5 with ModelPart

use of net.minecraft.client.model.ModelPart in project Biome-Makeover by Lemonszz.

the class HorseHatFeatureRenderer method render.

@Override
public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, HorseEntity entity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) {
    if (((HorseHat) entity).hasHat()) {
        matrices.scale(1.05F, 1.05F, 1.05F);
        CowboyHatModel<HorseEntity> hatModel = new CowboyHatModel<>();
        ((ModelPart) ((HorseEntityModel) this.getContextModel()).getHeadParts().iterator().next()).rotate(matrices);
        matrices.translate(0F, -0.23F, 0.15);
        matrices.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-25F));
        VertexConsumer vertexConsumer = ItemRenderer.getArmorGlintConsumer(vertexConsumers, hatModel.getLayer(this.getTexture(entity)), true, false);
        hatModel.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, 1F, 1F, 1F, 1F);
    }
}
Also used : HorseEntity(net.minecraft.entity.passive.HorseEntity) ModelPart(net.minecraft.client.model.ModelPart) HorseHat(party.lemons.biomemakeover.util.extensions.HorseHat) VertexConsumer(net.minecraft.client.render.VertexConsumer)

Aggregations

ModelPart (net.minecraft.client.model.ModelPart)7 VertexConsumer (net.minecraft.client.render.VertexConsumer)2 Color (meteordevelopment.meteorclient.utils.render.color.Color)1 SettingColor (meteordevelopment.meteorclient.utils.render.color.SettingColor)1 EventHandler (meteordevelopment.orbit.EventHandler)1 PlayerEntityRenderer (net.minecraft.client.render.entity.PlayerEntityRenderer)1 PlayerEntityModel (net.minecraft.client.render.entity.model.PlayerEntityModel)1 MatrixStack (net.minecraft.client.util.math.MatrixStack)1 HorseEntity (net.minecraft.entity.passive.HorseEntity)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)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 HorseHat (party.lemons.biomemakeover.util.extensions.HorseHat)1