Search in sources :

Example 1 with PlayerEntityRenderer

use of net.minecraft.client.render.entity.PlayerEntityRenderer in project Enchanted-Bionics by Bubblie01.

the class FunnyItem method use.

@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
    if (world.isClient) {
        MinecraftClient client = MinecraftClient.getInstance();
        EntityRenderer<? super AbstractClientPlayerEntity> renderer = client.getEntityRenderDispatcher().getRenderer(client.player);
        PlayerEntityModel<AbstractClientPlayerEntity> playerEntityModel = ((PlayerEntityRenderer) (renderer)).getModel();
        this.playerEntityModel = playerEntityModel;
        (((PlayerLimbInterface) playerEntityModel)).setSpecificVisible(false, EntityModelPartNames.LEFT_ARM);
    }
    return super.use(world, user, hand);
}
Also used : PlayerEntityRenderer(net.minecraft.client.render.entity.PlayerEntityRenderer) MinecraftClient(net.minecraft.client.MinecraftClient) AbstractClientPlayerEntity(net.minecraft.client.network.AbstractClientPlayerEntity)

Example 2 with PlayerEntityRenderer

use of net.minecraft.client.render.entity.PlayerEntityRenderer in project Enchanted-Bionics by Bubblie01.

the class FunnierItem method use.

@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
    if (world.isClient) {
        MinecraftClient client = MinecraftClient.getInstance();
        EntityRenderer<? super AbstractClientPlayerEntity> renderer = client.getEntityRenderDispatcher().getRenderer(client.player);
        PlayerEntityModel<AbstractClientPlayerEntity> playerEntityModel = ((PlayerEntityRenderer) (renderer)).getModel();
        this.playerEntityModel = playerEntityModel;
        (((PlayerLimbInterface) playerEntityModel)).setSpecificVisible(true, EntityModelPartNames.LEFT_ARM);
    }
    return super.use(world, user, hand);
}
Also used : PlayerEntityRenderer(net.minecraft.client.render.entity.PlayerEntityRenderer) MinecraftClient(net.minecraft.client.MinecraftClient) AbstractClientPlayerEntity(net.minecraft.client.network.AbstractClientPlayerEntity)

Example 3 with PlayerEntityRenderer

use of net.minecraft.client.render.entity.PlayerEntityRenderer in project ThonkUtil by LimeAppleBoat.

the class PlayerEntityMixin method initInject.

@Inject(method = "<init>", at = @At("TAIL"))
@SuppressWarnings("unchecked")
public void initInject(EntityRendererFactory.Context ctx, boolean slim, CallbackInfo ci) {
    ((LivingEntityRendererAccessor) (Object) this).callAddFeature(new ItemCapeRenderer((PlayerEntityRenderer) (Object) this, ctx.getModelLoader()));
    ((LivingEntityRendererAccessor) (Object) this).callAddFeature(new ItemElytraRenderer((PlayerEntityRenderer) (Object) this, ctx.getModelLoader()));
    ((LivingEntityRendererAccessor) (Object) this).callAddFeature(new TwoWingedItemElytraRenderer((PlayerEntityRenderer) (Object) this, ctx.getModelLoader()));
}
Also used : PlayerEntityRenderer(net.minecraft.client.render.entity.PlayerEntityRenderer) ItemCapeRenderer(com.jab125.thonkutil.impl.ItemCapeRenderer) ItemElytraRenderer(com.jab125.thonkutil.impl.ItemElytraRenderer) TwoWingedItemElytraRenderer(com.jab125.thonkutil.impl.TwoWingedItemElytraRenderer) TwoWingedItemElytraRenderer(com.jab125.thonkutil.impl.TwoWingedItemElytraRenderer) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 4 with PlayerEntityRenderer

use of net.minecraft.client.render.entity.PlayerEntityRenderer in project beebuddy by queenofthebees.

the class PlayerEntityRendererMixin method addHeadFriendFeature.

@Inject(method = "<init>(Lnet/minecraft/client/render/entity" + "/EntityRenderDispatcher;Z)V", at = @At("TAIL"))
public void addHeadFriendFeature(EntityRenderDispatcher e, boolean b, CallbackInfo cbi) {
    PlayerEntityRenderer us = (PlayerEntityRenderer) (Object) this;
    LivingEntityRendererInvoker inv = (LivingEntityRendererInvoker) (Object) this;
    inv.beebuddy$addFeature(new HeadFriendFeatureRenderer(us));
}
Also used : LivingEntityRendererInvoker(nomble.beebuddy.client.mixin.invoker.LivingEntityRendererInvoker) PlayerEntityRenderer(net.minecraft.client.render.entity.PlayerEntityRenderer) HeadFriendFeatureRenderer(nomble.beebuddy.client.render.entity.feature.HeadFriendFeatureRenderer) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 5 with PlayerEntityRenderer

use of net.minecraft.client.render.entity.PlayerEntityRenderer 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)

Aggregations

PlayerEntityRenderer (net.minecraft.client.render.entity.PlayerEntityRenderer)5 MinecraftClient (net.minecraft.client.MinecraftClient)2 AbstractClientPlayerEntity (net.minecraft.client.network.AbstractClientPlayerEntity)2 Inject (org.spongepowered.asm.mixin.injection.Inject)2 ItemCapeRenderer (com.jab125.thonkutil.impl.ItemCapeRenderer)1 ItemElytraRenderer (com.jab125.thonkutil.impl.ItemElytraRenderer)1 TwoWingedItemElytraRenderer (com.jab125.thonkutil.impl.TwoWingedItemElytraRenderer)1 Color (meteordevelopment.meteorclient.utils.render.color.Color)1 SettingColor (meteordevelopment.meteorclient.utils.render.color.SettingColor)1 EventHandler (meteordevelopment.orbit.EventHandler)1 ModelPart (net.minecraft.client.model.ModelPart)1 PlayerEntityModel (net.minecraft.client.render.entity.model.PlayerEntityModel)1 MatrixStack (net.minecraft.client.util.math.MatrixStack)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 LivingEntityRendererInvoker (nomble.beebuddy.client.mixin.invoker.LivingEntityRendererInvoker)1 HeadFriendFeatureRenderer (nomble.beebuddy.client.render.entity.feature.HeadFriendFeatureRenderer)1