Search in sources :

Example 6 with Vec3f

use of net.minecraft.util.math.Vec3f in project wildmod by Osmiooo.

the class MangroveBoatEntityRenderer method render.

public void render(MangroveBoatEntity boatEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) {
    matrixStack.push();
    matrixStack.translate(0.0D, 0.375D, 0.0D);
    matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(180.0F - f));
    float h = (float) boatEntity.getDamageWobbleTicks() - g;
    float j = boatEntity.getDamageWobbleStrength() - g;
    if (j < 0.0F) {
        j = 0.0F;
    }
    if (h > 0.0F) {
        matrixStack.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(MathHelper.sin(h) * h * j / 10.0F * (float) boatEntity.getDamageWobbleSide()));
    }
    float k = boatEntity.interpolateBubbleWobble(g);
    if (!MathHelper.approximatelyEquals(k, 0.0F)) {
        matrixStack.multiply(new Quaternion(new Vec3f(1.0F, 0.0F, 1.0F), boatEntity.interpolateBubbleWobble(g), true));
    }
    Identifier texture = this.texture;
    MangroveBoatEntityModel model = this.model;
    Identifier identifier = texture;
    MangroveBoatEntityModel boatEntityModel = model;
    matrixStack.scale(-1.0F, -1.0F, 1.0F);
    matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(90.0F));
    boatEntityModel.setAngles(boatEntity, g, 0.0F, -0.1F, 0.0F, 0.0F);
    VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(boatEntityModel.getLayer(identifier));
    boatEntityModel.render(matrixStack, vertexConsumer, i, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F);
    if (!boatEntity.isSubmergedInWater()) {
        VertexConsumer vertexConsumer2 = vertexConsumerProvider.getBuffer(RenderLayer.getWaterMask());
        boatEntityModel.getWaterPatch().render(matrixStack, vertexConsumer2, i, OverlayTexture.DEFAULT_UV);
    }
    matrixStack.pop();
    super.render(boatEntity, f, g, matrixStack, vertexConsumerProvider, i);
}
Also used : Identifier(net.minecraft.util.Identifier) Quaternion(net.minecraft.util.math.Quaternion) VertexConsumer(net.minecraft.client.render.VertexConsumer) Vec3f(net.minecraft.util.math.Vec3f)

Example 7 with Vec3f

use of net.minecraft.util.math.Vec3f in project wildmod by Osmiooo.

the class ChestBoatEntityRenderer method render.

public void render(ChestBoatEntity boatEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) {
    matrixStack.push();
    matrixStack.translate(0.0D, 0.375D, 0.0D);
    matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(180.0F - f));
    float h = (float) boatEntity.getDamageWobbleTicks() - g;
    float j = boatEntity.getDamageWobbleStrength() - g;
    if (j < 0.0F) {
        j = 0.0F;
    }
    if (h > 0.0F) {
        matrixStack.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(MathHelper.sin(h) * h * j / 10.0F * (float) boatEntity.getDamageWobbleSide()));
    }
    float k = boatEntity.interpolateBubbleWobble(g);
    if (!MathHelper.approximatelyEquals(k, 0.0F)) {
        matrixStack.multiply(new Quaternion(new Vec3f(1.0F, 0.0F, 1.0F), boatEntity.interpolateBubbleWobble(g), true));
    }
    Pair<Identifier, ChestBoatEntityModel> pair = (Pair) this.texturesAndModels.get(boatEntity.getBoatType());
    Identifier identifier = (Identifier) pair.getFirst();
    ChestBoatEntityModel boatEntityModel = (ChestBoatEntityModel) pair.getSecond();
    matrixStack.scale(-1.0F, -1.0F, 1.0F);
    matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(90.0F));
    boatEntityModel.setAngles(boatEntity, g, 0.0F, -0.1F, 0.0F, 0.0F);
    VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(boatEntityModel.getLayer(identifier));
    boatEntityModel.render(matrixStack, vertexConsumer, i, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F);
    if (!boatEntity.isSubmergedInWater()) {
        VertexConsumer vertexConsumer2 = vertexConsumerProvider.getBuffer(RenderLayer.getWaterMask());
        boatEntityModel.getWaterPatch().render(matrixStack, vertexConsumer2, i, OverlayTexture.DEFAULT_UV);
    }
    matrixStack.pop();
    super.render(boatEntity, f, g, matrixStack, vertexConsumerProvider, i);
}
Also used : Identifier(net.minecraft.util.Identifier) Quaternion(net.minecraft.util.math.Quaternion) VertexConsumer(net.minecraft.client.render.VertexConsumer) Vec3f(net.minecraft.util.math.Vec3f) Pair(com.mojang.datafixers.util.Pair)

Example 8 with Vec3f

use of net.minecraft.util.math.Vec3f in project wildmod by Osmiooo.

the class ShriekParticleNX method buildGeometry.

@Override
public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float f) {
    Vec3d vec3d = camera.getPos();
    float g = (float) (MathHelper.lerp((double) f, this.prevPosX, this.x) - vec3d.getX());
    float h = (float) (MathHelper.lerp((double) f, this.prevPosY, this.y) - vec3d.getY());
    float i = (float) (MathHelper.lerp((double) f, this.prevPosZ, this.z) - vec3d.getZ());
    Quaternion quaternion;
    quaternion = new Quaternion(-0.2F, -0.8F, 0.8F, 0.2F);
    Vec3f j = new Vec3f(0.0F, -1.0F, -1.0F);
    j.rotate(quaternion);
    Vec3f[] vec3fs = new Vec3f[] { new Vec3f(-1.0F, -1.0F, 0.0F), new Vec3f(-1.0F, 1.0F, 0.0F), new Vec3f(1.0F, 1.0F, 0.0F), new Vec3f(1.0F, -1.0F, 0.0F) };
    float k = this.getSize(f);
    for (int l = 0; l < 4; ++l) {
        Vec3f vec3f = vec3fs[l];
        vec3f.rotate(quaternion);
        vec3f.scale((float) (((this.age) / (9.8)) / 7));
        vec3f.add(g, h, i);
        this.setAlpha((float) (this.age - this.maxAge) * 6);
    }
    float l = this.getMinU();
    float vec3f = this.getMaxU();
    float m = this.getMinV();
    float n = this.getMaxV();
    int o = this.getBrightness(f);
    vertexConsumer.vertex((double) vec3fs[0].getX(), (double) vec3fs[0].getY(), (double) vec3fs[0].getZ()).texture(vec3f, n).color(this.red, this.green, this.blue, this.alpha).light(o).next();
    vertexConsumer.vertex((double) vec3fs[1].getX(), (double) vec3fs[1].getY(), (double) vec3fs[1].getZ()).texture(vec3f, m).color(this.red, this.green, this.blue, this.alpha).light(o).next();
    vertexConsumer.vertex((double) vec3fs[2].getX(), (double) vec3fs[2].getY(), (double) vec3fs[2].getZ()).texture(l, m).color(this.red, this.green, this.blue, this.alpha).light(o).next();
    vertexConsumer.vertex((double) vec3fs[3].getX(), (double) vec3fs[3].getY(), (double) vec3fs[3].getZ()).texture(l, n).color(this.red, this.green, this.blue, this.alpha).light(o).next();
}
Also used : Quaternion(net.minecraft.util.math.Quaternion) Vec3f(net.minecraft.util.math.Vec3f) Vec3d(net.minecraft.util.math.Vec3d)

Example 9 with Vec3f

use of net.minecraft.util.math.Vec3f in project wildmod by Osmiooo.

the class ShriekParticleX2 method buildGeometry.

@Override
public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float f) {
    Vec3d vec3d = camera.getPos();
    float g = (float) (MathHelper.lerp((double) f, this.prevPosX, this.x) - vec3d.getX());
    float h = (float) (MathHelper.lerp((double) f, this.prevPosY, this.y) - vec3d.getY());
    float i = (float) (MathHelper.lerp((double) f, this.prevPosZ, this.z) - vec3d.getZ());
    Quaternion quaternion;
    quaternion = new Quaternion(0.2F, -0.8F, -0.8F, 0.2F);
    Vec3f j = new Vec3f(-1.0F, -1.0F, 0.0F);
    j.rotate(quaternion);
    Vec3f[] vec3fs = new Vec3f[] { new Vec3f(-1.0F, -1.0F, 0.0F), new Vec3f(-1.0F, 1.0F, 0.0F), new Vec3f(1.0F, 1.0F, 0.0F), new Vec3f(1.0F, -1.0F, 0.0F) };
    float k = this.getSize(f);
    for (int l = 0; l < 4; ++l) {
        Vec3f vec3f = vec3fs[l];
        vec3f.rotate(quaternion);
        vec3f.scale((float) (((this.age) / (9.8)) / 7));
        vec3f.add(g, h, i);
        this.setAlpha((float) (this.age - this.maxAge) * 6);
    }
    float l = this.getMinU();
    float vec3f = this.getMaxU();
    float m = this.getMinV();
    float n = this.getMaxV();
    int o = this.getBrightness(f);
    vertexConsumer.vertex((double) vec3fs[0].getX(), (double) vec3fs[0].getY(), (double) vec3fs[0].getZ()).texture(vec3f, n).color(this.red, this.green, this.blue, this.alpha).light(o).next();
    vertexConsumer.vertex((double) vec3fs[1].getX(), (double) vec3fs[1].getY(), (double) vec3fs[1].getZ()).texture(vec3f, m).color(this.red, this.green, this.blue, this.alpha).light(o).next();
    vertexConsumer.vertex((double) vec3fs[2].getX(), (double) vec3fs[2].getY(), (double) vec3fs[2].getZ()).texture(l, m).color(this.red, this.green, this.blue, this.alpha).light(o).next();
    vertexConsumer.vertex((double) vec3fs[3].getX(), (double) vec3fs[3].getY(), (double) vec3fs[3].getZ()).texture(l, n).color(this.red, this.green, this.blue, this.alpha).light(o).next();
}
Also used : Quaternion(net.minecraft.util.math.Quaternion) Vec3f(net.minecraft.util.math.Vec3f) Vec3d(net.minecraft.util.math.Vec3d)

Example 10 with Vec3f

use of net.minecraft.util.math.Vec3f in project Hypnotic-Client by Hypnotic-Development.

the class RenderUtils method drawEntityBox.

public static void drawEntityBox(MatrixStack matrixstack, Entity entity, double x, double y, double z, Color color) {
    setup3DRender(true);
    matrixstack.translate(x, y, z);
    matrixstack.multiply(new Quaternion(new Vec3f(0, -1, 0), 0, true));
    matrixstack.translate(-x, -y, -z);
    Box bb = new Box(x - entity.getWidth() + 0.25, y, z - entity.getWidth() + 0.25, x + entity.getWidth() - 0.25, y + entity.getHeight() + 0.1, z + entity.getWidth() - 0.25);
    if (entity instanceof ItemEntity)
        bb = new Box(x - 0.15, y + 0.1f, z - 0.15, x + 0.15, y + 0.5, z + 0.15);
    drawFilledBox(matrixstack, bb, new Color(color.getRed(), color.getGreen(), color.getBlue(), 130), true);
    RenderSystem.lineWidth(1.5f);
    drawOutlineBox(matrixstack, bb, color, true);
    end3DRender();
    matrixstack.translate(x, y, z);
    matrixstack.multiply(new Quaternion(new Vec3f(0, 1, 0), 0, true));
    matrixstack.translate(-x, -y, -z);
}
Also used : ItemEntity(net.minecraft.entity.ItemEntity) Quaternion(net.minecraft.util.math.Quaternion) Color(java.awt.Color) Box(net.minecraft.util.math.Box) Vec3f(net.minecraft.util.math.Vec3f)

Aggregations

Vec3f (net.minecraft.util.math.Vec3f)28 Quaternion (net.minecraft.util.math.Quaternion)16 Vec3d (net.minecraft.util.math.Vec3d)10 Matrix4f (net.minecraft.util.math.Matrix4f)5 Matrix3f (net.minecraft.util.math.Matrix3f)4 MatrixStack (net.minecraft.client.util.math.MatrixStack)3 Identifier (net.minecraft.util.Identifier)3 Color (java.awt.Color)2 Camera (net.minecraft.client.render.Camera)2 VertexConsumer (net.minecraft.client.render.VertexConsumer)2 ClientWorld (net.minecraft.client.world.ClientWorld)2 ItemEntity (net.minecraft.entity.ItemEntity)2 PersistentProjectileEntity (net.minecraft.entity.projectile.PersistentProjectileEntity)2 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 Pair (com.mojang.datafixers.util.Pair)1 CustomFont (dev.hypnotic.module.render.CustomFont)1 MonoColorSkybox (io.github.amerebagatelle.fabricskyboxes.skyboxes.MonoColorSkybox)1 AnimatedSquareTexturedSkybox (io.github.amerebagatelle.fabricskyboxes.skyboxes.textured.AnimatedSquareTexturedSkybox)1 SquareTexturedSkybox (io.github.amerebagatelle.fabricskyboxes.skyboxes.textured.SquareTexturedSkybox)1