Search in sources :

Example 1 with NewBobberEntity

use of com.minecolonies.coremod.entity.NewBobberEntity in project minecolonies by Minecolonies.

the class RenderFishHook method render.

@Override
public void render(final Entity entityIn, final float entityYaw, final float partialTicks, @NotNull final MatrixStack matrixStackIn, @NotNull final IRenderTypeBuffer bufferIn, final int packedLightIn) {
    NewBobberEntity bobber = (NewBobberEntity) entityIn.getEntity();
    if (bobber != null && bobber.getAngler() != null) {
        final EntityCitizen citizen = bobber.getAngler();
        matrixStackIn.pushPose();
        matrixStackIn.pushPose();
        matrixStackIn.scale(0.5F, 0.5F, 0.5F);
        matrixStackIn.mulPose(this.entityRenderDispatcher.cameraOrientation());
        matrixStackIn.mulPose(Vector3f.YP.rotationDegrees(180.0F));
        final MatrixStack.Entry matrixstack$entry = matrixStackIn.last();
        final Matrix4f matrix4f = matrixstack$entry.pose();
        final Matrix3f matrix3f = matrixstack$entry.normal();
        final IVertexBuilder ivertexbuilder = bufferIn.getBuffer(RENDER_TYPE);
        vertex(ivertexbuilder, matrix4f, matrix3f, packedLightIn, 0.0F, 0, 0, 1);
        vertex(ivertexbuilder, matrix4f, matrix3f, packedLightIn, 1.0F, 0, 1, 1);
        vertex(ivertexbuilder, matrix4f, matrix3f, packedLightIn, 1.0F, 1, 1, 0);
        vertex(ivertexbuilder, matrix4f, matrix3f, packedLightIn, 0.0F, 1, 0, 0);
        matrixStackIn.popPose();
        int i = citizen.getMainArm() == HandSide.RIGHT ? 1 : -1;
        final ItemStack itemstack = citizen.getMainHandItem();
        if (!(itemstack.getItem() instanceof net.minecraft.item.FishingRodItem)) {
            i = -i;
        }
        final float f2 = MathHelper.lerp(partialTicks, citizen.yBodyRotO, citizen.yBodyRot) * ((float) Math.PI / 180F);
        final double d0 = MathHelper.sin(f2);
        final double d1 = MathHelper.cos(f2);
        final double d2 = (double) i * 0.35D;
        double d4 = MathHelper.lerp(partialTicks, citizen.xo, citizen.getX()) - d1 * d2 - d0 * 0.8D;
        double d5 = citizen.yo + (double) citizen.getEyeHeight() + (citizen.getY() - citizen.yo) * (double) partialTicks - 0.45D;
        double d6 = MathHelper.lerp(partialTicks, citizen.zo, citizen.getZ()) - d0 * d2 + d1 * 0.8D;
        float f3 = citizen.isCrouching() ? -0.1875F : 0.0F;
        double d9 = MathHelper.lerp(partialTicks, entityIn.xo, entityIn.getX());
        double d10 = MathHelper.lerp(partialTicks, entityIn.yo, entityIn.getY()) + 0.25D;
        double d8 = MathHelper.lerp(partialTicks, entityIn.zo, entityIn.getZ());
        float f4 = (float) (d4 - d9);
        float f5 = (float) (d5 - d10) + f3;
        float f6 = (float) (d6 - d8);
        final IVertexBuilder ivertexbuilder1 = bufferIn.getBuffer(RenderType.lines());
        final Matrix4f matrix4f1 = matrixStackIn.last().pose();
        for (int k = 0; k < 16; ++k) {
            stringVertex(f4, f5, f6, ivertexbuilder1, matrix4f1, fraction(k, 16));
            stringVertex(f4, f5, f6, ivertexbuilder1, matrix4f1, fraction(k + 1, 16));
        }
        matrixStackIn.popPose();
        super.render(entityIn, entityYaw, partialTicks, matrixStackIn, bufferIn, packedLightIn);
    }
}
Also used : MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) IVertexBuilder(com.mojang.blaze3d.vertex.IVertexBuilder) Matrix4f(net.minecraft.util.math.vector.Matrix4f) NewBobberEntity(com.minecolonies.coremod.entity.NewBobberEntity) Matrix3f(net.minecraft.util.math.vector.Matrix3f) EntityCitizen(com.minecolonies.coremod.entity.citizen.EntityCitizen) ItemStack(net.minecraft.item.ItemStack)

Example 2 with NewBobberEntity

use of com.minecolonies.coremod.entity.NewBobberEntity in project minecolonies by ldtteam.

the class RenderFishHook method render.

@Override
public void render(final Entity entityIn, final float entityYaw, final float partialTicks, @NotNull final MatrixStack matrixStackIn, @NotNull final IRenderTypeBuffer bufferIn, final int packedLightIn) {
    NewBobberEntity bobber = (NewBobberEntity) entityIn.getEntity();
    if (bobber != null && bobber.getAngler() != null) {
        final EntityCitizen citizen = bobber.getAngler();
        matrixStackIn.pushPose();
        matrixStackIn.pushPose();
        matrixStackIn.scale(0.5F, 0.5F, 0.5F);
        matrixStackIn.mulPose(this.entityRenderDispatcher.cameraOrientation());
        matrixStackIn.mulPose(Vector3f.YP.rotationDegrees(180.0F));
        final MatrixStack.Entry matrixstack$entry = matrixStackIn.last();
        final Matrix4f matrix4f = matrixstack$entry.pose();
        final Matrix3f matrix3f = matrixstack$entry.normal();
        final IVertexBuilder ivertexbuilder = bufferIn.getBuffer(RENDER_TYPE);
        vertex(ivertexbuilder, matrix4f, matrix3f, packedLightIn, 0.0F, 0, 0, 1);
        vertex(ivertexbuilder, matrix4f, matrix3f, packedLightIn, 1.0F, 0, 1, 1);
        vertex(ivertexbuilder, matrix4f, matrix3f, packedLightIn, 1.0F, 1, 1, 0);
        vertex(ivertexbuilder, matrix4f, matrix3f, packedLightIn, 0.0F, 1, 0, 0);
        matrixStackIn.popPose();
        int i = citizen.getMainArm() == HandSide.RIGHT ? 1 : -1;
        final ItemStack itemstack = citizen.getMainHandItem();
        if (!(itemstack.getItem() instanceof net.minecraft.item.FishingRodItem)) {
            i = -i;
        }
        final float f2 = MathHelper.lerp(partialTicks, citizen.yBodyRotO, citizen.yBodyRot) * ((float) Math.PI / 180F);
        final double d0 = MathHelper.sin(f2);
        final double d1 = MathHelper.cos(f2);
        final double d2 = (double) i * 0.35D;
        double d4 = MathHelper.lerp(partialTicks, citizen.xo, citizen.getX()) - d1 * d2 - d0 * 0.8D;
        double d5 = citizen.yo + (double) citizen.getEyeHeight() + (citizen.getY() - citizen.yo) * (double) partialTicks - 0.45D;
        double d6 = MathHelper.lerp(partialTicks, citizen.zo, citizen.getZ()) - d0 * d2 + d1 * 0.8D;
        float f3 = citizen.isCrouching() ? -0.1875F : 0.0F;
        double d9 = MathHelper.lerp(partialTicks, entityIn.xo, entityIn.getX());
        double d10 = MathHelper.lerp(partialTicks, entityIn.yo, entityIn.getY()) + 0.25D;
        double d8 = MathHelper.lerp(partialTicks, entityIn.zo, entityIn.getZ());
        float f4 = (float) (d4 - d9);
        float f5 = (float) (d5 - d10) + f3;
        float f6 = (float) (d6 - d8);
        final IVertexBuilder ivertexbuilder1 = bufferIn.getBuffer(RenderType.lines());
        final Matrix4f matrix4f1 = matrixStackIn.last().pose();
        for (int k = 0; k < 16; ++k) {
            stringVertex(f4, f5, f6, ivertexbuilder1, matrix4f1, fraction(k, 16));
            stringVertex(f4, f5, f6, ivertexbuilder1, matrix4f1, fraction(k + 1, 16));
        }
        matrixStackIn.popPose();
        super.render(entityIn, entityYaw, partialTicks, matrixStackIn, bufferIn, packedLightIn);
    }
}
Also used : MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) IVertexBuilder(com.mojang.blaze3d.vertex.IVertexBuilder) Matrix4f(net.minecraft.util.math.vector.Matrix4f) NewBobberEntity(com.minecolonies.coremod.entity.NewBobberEntity) Matrix3f(net.minecraft.util.math.vector.Matrix3f) EntityCitizen(com.minecolonies.coremod.entity.citizen.EntityCitizen) ItemStack(net.minecraft.item.ItemStack)

Aggregations

NewBobberEntity (com.minecolonies.coremod.entity.NewBobberEntity)2 EntityCitizen (com.minecolonies.coremod.entity.citizen.EntityCitizen)2 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)2 IVertexBuilder (com.mojang.blaze3d.vertex.IVertexBuilder)2 ItemStack (net.minecraft.item.ItemStack)2 Matrix3f (net.minecraft.util.math.vector.Matrix3f)2 Matrix4f (net.minecraft.util.math.vector.Matrix4f)2