Search in sources :

Example 16 with Quaternion

use of net.minecraft.util.math.Quaternion in project isometric-renders by gliscowo.

the class IsometricRenderScreen method drawContent.

@Override
protected void drawContent(MatrixStack matrices) {
    float scale = renderScale * height / 515f;
    RenderSystem.pushMatrix();
    RenderSystem.translatef(115, (float) Math.round(renderHeight * 1f + (height - 515f) / 10f), 1500);
    RenderSystem.scalef(1, 1, -1);
    MatrixStack matrixStack = new MatrixStack();
    matrixStack.translate(0, 0, 1000);
    matrixStack.scale(scale, scale, 1);
    Quaternion flip = Vector3f.POSITIVE_Z.getDegreesQuaternion(180);
    flip.hamiltonProduct(Vector3f.POSITIVE_X.getDegreesQuaternion(-angle));
    Quaternion rotation = Vector3f.POSITIVE_Y.getDegreesQuaternion(RuntimeConfig.rotation);
    matrixStack.multiply(flip);
    matrixStack.multiply(rotation);
    EntityRenderDispatcher entityRenderDispatcher = MinecraftClient.getInstance().getEntityRenderDispatcher();
    entityRenderDispatcher.setRenderShadows(false);
    VertexConsumerProvider.Immediate immediate = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers();
    renderCallback.render(matrixStack, immediate, playAnimations ? ((MinecraftClientAccessor) client).getRenderTickCounter().tickDelta : 0);
    immediate.draw();
    entityRenderDispatcher.setRenderShadows(true);
    RenderSystem.popMatrix();
}
Also used : Quaternion(net.minecraft.util.math.Quaternion) MatrixStack(net.minecraft.client.util.math.MatrixStack) EntityRenderDispatcher(net.minecraft.client.render.entity.EntityRenderDispatcher) VertexConsumerProvider(net.minecraft.client.render.VertexConsumerProvider)

Example 17 with Quaternion

use of net.minecraft.util.math.Quaternion in project MCDungeonsWeapons by chronosacaria.

the class ProjectileEffectHelper method fireChainReactionProjectileFromVictim.

private static void fireChainReactionProjectileFromVictim(World world, LivingEntity attacker, LivingEntity victim, ItemStack projectileStack, float v1, float v2, float centerOffset, PersistentProjectileEntity originalArrow) {
    if (!world.isClient) {
        PersistentProjectileEntity projectile;
        projectile = createChainReactionProjectile(world, attacker, projectileStack, originalArrow);
        projectile.pickupType = PersistentProjectileEntity.PickupPermission.CREATIVE_ONLY;
        Vec3d upVector = victim.getOppositeRotationVector(1.0F);
        Quaternion quaternion = new Quaternion(new Vector3f(upVector), centerOffset, true);
        Vec3d lookVector = victim.getRotationVec(1.0F);
        Vector3f vector3f = new Vector3f(lookVector);
        vector3f.rotate(quaternion);
        projectile.setVelocity((double) vector3f.getX(), (double) vector3f.getY(), (double) vector3f.getZ(), v1, v2);
        world.spawnEntity(projectile);
    }
}
Also used : Quaternion(net.minecraft.util.math.Quaternion) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) Vector3f(net.minecraft.client.util.math.Vector3f) Vec3d(net.minecraft.util.math.Vec3d)

Example 18 with Quaternion

use of net.minecraft.util.math.Quaternion in project BedrockIfy by juancarloscp52.

the class PaperDoll method drawPaperDoll.

/**
 * Draw the player entity in the specified position on screen.
 */
private void drawPaperDoll(MatrixStack matrixStack) {
    client.getProfiler().push("Player");
    ClientPlayerEntity player = client.player;
    if (player == null)
        return;
    matrixStack.push();
    int renderPosY = posY;
    // If the player is elytra flying, the entity must be manually centered depending on the pitch.
    if (player.isFallFlying())
        renderPosY = posY - MathHelper.ceil(size * 2 * toMaxAngleRatio(player.pitch));
    else // If the player is swimming, the entity must also be centered in the Y axis.
    if (player.isSwimming()) {
        renderPosY = posY - size;
    }
    // Position the entity on screen.
    int posX = 30;
    matrixStack.translate(posX + settings.getScreenSafeArea(), renderPosY + settings.getScreenSafeArea(), 0);
    matrixStack.scale((float) size, (float) size, -(float) size);
    Quaternion quaternion = Vector3f.POSITIVE_Z.getDegreesQuaternion(180.0F);
    matrixStack.multiply(quaternion);
    // Store previous entity rotations.
    float bodyYaw = player.bodyYaw;
    float yaw = player.yaw;
    float headYaw = player.headYaw;
    // Set the entity desired rotation for drawing.
    float angle = 145;
    if (!player.isFallFlying()) {
        player.yaw = headYaw - bodyYaw + angle;
        player.headYaw = player.yaw;
    } else {
        player.headYaw = angle;
    }
    player.bodyYaw = angle;
    // Draw the entity.
    EntityRenderDispatcher entityRenderDispatcher = MinecraftClient.getInstance().getEntityRenderDispatcher();
    entityRenderDispatcher.setRenderShadows(false);
    VertexConsumerProvider.Immediate immediate = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers();
    RenderSystem.runAsFancy(() -> entityRenderDispatcher.render(player, 0, 0, 0, 0.0F, 1.0F, matrixStack, immediate, 15728880));
    immediate.draw();
    entityRenderDispatcher.setRenderShadows(true);
    // Restore previous entity rotations.
    player.bodyYaw = bodyYaw;
    player.yaw = yaw;
    player.headYaw = headYaw;
    matrixStack.pop();
    client.getProfiler().pop();
}
Also used : Quaternion(net.minecraft.util.math.Quaternion) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) EntityRenderDispatcher(net.minecraft.client.render.entity.EntityRenderDispatcher) VertexConsumerProvider(net.minecraft.client.render.VertexConsumerProvider)

Example 19 with Quaternion

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

the class ShriekParticle 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(-1, 0, 0, -0.6F);
    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 20 with Quaternion

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

the class ShriekParticle2PosZ 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(-1, 0, 0, 0.6F);
    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)27 Vec3f (net.minecraft.util.math.Vec3f)16 Vec3d (net.minecraft.util.math.Vec3d)13 VertexConsumerProvider (net.minecraft.client.render.VertexConsumerProvider)6 EntityRenderDispatcher (net.minecraft.client.render.entity.EntityRenderDispatcher)5 MatrixStack (net.minecraft.client.util.math.MatrixStack)5 Color (java.awt.Color)3 VertexConsumer (net.minecraft.client.render.VertexConsumer)3 SquidEntity (net.minecraft.entity.passive.SquidEntity)3 PersistentProjectileEntity (net.minecraft.entity.projectile.PersistentProjectileEntity)3 Vector3f (net.minecraft.client.util.math.Vector3f)2 ItemEntity (net.minecraft.entity.ItemEntity)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