Search in sources :

Example 1 with Quaternion

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

the class ShriekParticleNX2 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 2 with Quaternion

use of net.minecraft.util.math.Quaternion 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 3 with Quaternion

use of net.minecraft.util.math.Quaternion 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 4 with Quaternion

use of net.minecraft.util.math.Quaternion 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 5 with Quaternion

use of net.minecraft.util.math.Quaternion 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)

Aggregations

Quaternion (net.minecraft.util.math.Quaternion)23 Vec3f (net.minecraft.util.math.Vec3f)13 Vec3d (net.minecraft.util.math.Vec3d)11 VertexConsumerProvider (net.minecraft.client.render.VertexConsumerProvider)5 EntityRenderDispatcher (net.minecraft.client.render.entity.EntityRenderDispatcher)4 MatrixStack (net.minecraft.client.util.math.MatrixStack)4 Color (java.awt.Color)3 VertexConsumer (net.minecraft.client.render.VertexConsumer)3 Vector3f (net.minecraft.client.util.math.Vector3f)2 ItemEntity (net.minecraft.entity.ItemEntity)2 SquidEntity (net.minecraft.entity.passive.SquidEntity)2 Identifier (net.minecraft.util.Identifier)2 Box (net.minecraft.util.math.Box)2 Pair (com.mojang.datafixers.util.Pair)1 EventTarget (dev.hypnotic.event.EventTarget)1 EventRenderItem (dev.hypnotic.event.events.EventRenderItem)1 ArmCustomize (dev.hypnotic.module.render.ArmCustomize)1 CustomFont (dev.hypnotic.module.render.CustomFont)1 OldBlock (dev.hypnotic.module.render.OldBlock)1 QuadColor (dev.hypnotic.utils.render.QuadColor)1