Search in sources :

Example 11 with Vector3f

use of net.minecraft.client.util.math.Vector3f in project Biome-Makeover by Lemonszz.

the class LightningBugInnerFeatureRenderer method getColor.

public Vector3f getColor(LightningBugEntity entity, float delta) {
    BlockPos pos = entity.getBlockPos();
    int redHash = pos.hashCode();
    int greenHash = (pos.getX() + pos.getY() * 31) * 31 + pos.getZ();
    int blueHash = (pos.getZ() + pos.getX() * 31) * 31 + pos.getY();
    float drawRed = 1F, drawGreen = 1F, drawBlue = 1F;
    float rTarget = (redHash % 255) / 255F;
    float bTarget = (greenHash % 255) / 255F;
    float gTarget = (blueHash % 255) / 255F;
    if (entity.prevRed == -1) {
        drawRed = rTarget;
        drawGreen = gTarget;
        drawBlue = bTarget;
    } else {
        drawRed = MathUtils.approachValue(entity.prevRed, rTarget, 0.025F * delta);
        drawGreen = MathUtils.approachValue(entity.prevGreen, gTarget, 0.025F * delta);
        drawBlue = MathUtils.approachValue(entity.prevBlue, bTarget, 0.025F * delta);
    }
    entity.prevRed = drawRed;
    entity.prevGreen = drawGreen;
    entity.prevBlue = drawBlue;
    return new Vector3f(drawRed, drawGreen, drawBlue);
}
Also used : Vector3f(net.minecraft.client.util.math.Vector3f) BlockPos(net.minecraft.util.math.BlockPos)

Example 12 with Vector3f

use of net.minecraft.client.util.math.Vector3f in project Biome-Makeover by Lemonszz.

the class DecayedItemFeatureRenderer method renderShield.

private void renderShield(LivingEntity entity, ItemStack stack, ModelTransformation.Mode transformationMode, Arm arm, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) {
    if (!stack.isEmpty()) {
        matrices.push();
        this.getContextModel().setArmAngle(arm, matrices);
        matrices.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(-90.0F));
        matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(180.0F));
        boolean isLeft = arm == Arm.LEFT;
        matrices.translate(2F * (isLeft ? 1F : -1F) / 16.0F, 0.3D, -0.625D);
        Vector3f dirY = isLeft ? Vector3f.NEGATIVE_Y : Vector3f.POSITIVE_Y;
        Vector3f dirZ = isLeft ? Vector3f.POSITIVE_Z : Vector3f.NEGATIVE_Z;
        Vector3f dirX = Vector3f.NEGATIVE_X;
        matrices.multiply(dirY.getDegreesQuaternion(60));
        matrices.multiply(dirZ.getDegreesQuaternion(0));
        matrices.multiply(dirX.getDegreesQuaternion(25));
        MinecraftClient.getInstance().getHeldItemRenderer().renderItem(entity, stack, transformationMode, isLeft, matrices, vertexConsumers, light);
        matrices.pop();
    }
}
Also used : Vector3f(net.minecraft.client.util.math.Vector3f)

Example 13 with Vector3f

use of net.minecraft.client.util.math.Vector3f in project LittleMaidModelLoader-Fabric by SistrScarlet.

the class SmoothModelPart method renderSmoothCuboids.

private void renderSmoothCuboids(MatrixStack.Entry defaultEntry, MatrixStack.Entry childEntry, VertexConsumer vertexConsumer, int light, int overlay, float red, float green, float blue, float alpha) {
    Matrix4f defaultPosMat = defaultEntry.getModel();
    Matrix3f defaultNormal = defaultEntry.getNormal();
    Matrix4f childPosMat = childEntry.getModel();
    Matrix3f childNormal = childEntry.getNormal();
    ObjectList<Cuboid> cuboids = ((ModelPartAccessor) this).getCuboids();
    for (Cuboid cuboid : cuboids) {
        Quad[] quads = ((CuboidAccessor) cuboid).getQuads();
        // ここで値取ってこれと一致する頂点をーの方がいいかもね
        int indexQ = 0;
        for (Quad quad : quads) {
            Direction quadDirection = getQuadDirection(indexQ++);
            Vector3f defaultNormalVec = quad.direction.copy();
            defaultNormalVec.transform(defaultNormal);
            Vector3f smoothNormalVec = quad.direction.copy();
            smoothNormalVec.transform(childNormal);
            int indexV = 0;
            for (Vertex vertex : quad.vertices) {
                Vector4f posVec = new Vector4f(vertex.pos.getX() / 16.0F, vertex.pos.getY() / 16.0F, vertex.pos.getZ() / 16.0F, 1.0F);
                if (shouldRotate(indexV++, quadDirection, direction)) {
                    posVec.transform(childPosMat);
                    vertexConsumer.vertex(posVec.getX(), posVec.getY(), posVec.getZ(), red, green, blue, alpha, vertex.u, vertex.v, overlay, light, smoothNormalVec.getX(), smoothNormalVec.getY(), smoothNormalVec.getZ());
                } else {
                    posVec.transform(defaultPosMat);
                    vertexConsumer.vertex(posVec.getX(), posVec.getY(), posVec.getZ(), red, green, blue, alpha, vertex.u, vertex.v, overlay, light, defaultNormalVec.getX(), defaultNormalVec.getY(), defaultNormalVec.getZ());
                }
            }
        }
    }
}
Also used : ModelPartAccessor(net.sistr.littlemaidmodelloader.client.util.ModelPartAccessor) Direction(net.minecraft.util.math.Direction) Matrix4f(net.minecraft.util.math.Matrix4f) Vector4f(net.minecraft.client.util.math.Vector4f) Matrix3f(net.minecraft.util.math.Matrix3f) Vector3f(net.minecraft.client.util.math.Vector3f) CuboidAccessor(net.sistr.littlemaidmodelloader.client.util.CuboidAccessor)

Example 14 with Vector3f

use of net.minecraft.client.util.math.Vector3f in project LittleMaidModelLoader-Fabric by SistrScarlet.

the class ModelRenderer method doRender.

private void doRender(MatrixStack.Entry matrixEntryIn, VertexConsumer bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
    Matrix4f matrix4f = matrixEntryIn.getModel();
    Matrix3f matrix3f = matrixEntryIn.getNormal();
    for (ModelBoxBase modelBoxBase : this.cubeList) {
        for (ModelBoxBase.TexturedQuad quad : modelBoxBase.quadList) {
            // 互換性のためにnormalを@Nullableにしているため、ここで計算する
            if (quad.normal == null) {
                Vector3f n1 = quad.vertexPositions[0].position.copy();
                Vector3f n2 = quad.vertexPositions[2].position.copy();
                n1.subtract(quad.vertexPositions[1].position);
                n2.subtract(quad.vertexPositions[1].position);
                n2.cross(n1);
                n2.normalize();
                quad.normal = n2;
            }
            Vector3f normal = quad.normal.copy();
            normal.transform(matrix3f);
            float normalX = normal.getX();
            float normalY = normal.getY();
            float normalZ = normal.getZ();
            for (int i = 0; i < 4; ++i) {
                ModelBoxBase.PositionTextureVertex vertex = quad.vertexPositions[i];
                float f3 = vertex.position.getX() / 16.0F;
                float f4 = vertex.position.getY() / 16.0F;
                float f5 = vertex.position.getZ() / 16.0F;
                Vector4f vector4f = new Vector4f(f3, f4, f5, 1.0F);
                vector4f.transform(matrix4f);
                bufferIn.vertex(vector4f.getX(), vector4f.getY(), vector4f.getZ(), red, green, blue, alpha, vertex.textureU, vertex.textureV, packedOverlayIn, packedLightIn, normalX, normalY, normalZ);
            }
        }
    }
}
Also used : Matrix4f(net.minecraft.util.math.Matrix4f) Vector4f(net.minecraft.client.util.math.Vector4f) Matrix3f(net.minecraft.util.math.Matrix3f) Vector3f(net.minecraft.client.util.math.Vector3f)

Example 15 with Vector3f

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

Aggregations

Vector3f (net.minecraft.client.util.math.Vector3f)23 Direction (net.minecraft.util.math.Direction)4 BlockState (net.minecraft.block.BlockState)3 ChunkOcclusionDataBuilder (net.minecraft.client.render.chunk.ChunkOcclusionDataBuilder)3 Vector4f (net.minecraft.client.util.math.Vector4f)3 BlockPos (net.minecraft.util.math.BlockPos)3 Matrix3f (net.minecraft.util.math.Matrix3f)3 Matrix4f (net.minecraft.util.math.Matrix4f)3 ChunkMeshBuilder (me.jellysquid.mods.sodium.client.render.mesh.ChunkMeshBuilder)2 Block (net.minecraft.block.Block)2 BlockEntity (net.minecraft.block.entity.BlockEntity)2 BufferBuilder (net.minecraft.client.render.BufferBuilder)2 RenderLayer (net.minecraft.client.render.RenderLayer)2 VertexConsumer (net.minecraft.client.render.VertexConsumer)2 FluidState (net.minecraft.fluid.FluidState)2 Quaternion (net.minecraft.util.math.Quaternion)2 CuboidAccessor (net.sistr.littlemaidmodelloader.client.util.CuboidAccessor)2 ModelPartAccessor (net.sistr.littlemaidmodelloader.client.util.ModelPartAccessor)2 Lists (com.google.common.collect.Lists)1 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)1