Search in sources :

Example 6 with Vector3f

use of net.minecraft.client.util.math.Vector3f in project canvas by vram-guild.

the class QuadViewImpl method copyNormal.

@Override
public Vector3f copyNormal(int vertexIndex, Vector3f target) {
    if (hasNormal(vertexIndex)) {
        if (target == null) {
            target = new Vector3f();
        }
        final int normal = data[vertexStart() + VANILLA_STRIDE + vertexIndex];
        target.set(NormalHelper.getPackedNormalComponent(normal, 0), NormalHelper.getPackedNormalComponent(normal, 1), NormalHelper.getPackedNormalComponent(normal, 2));
        return target;
    } else {
        return null;
    }
}
Also used : Vector3f(net.minecraft.client.util.math.Vector3f)

Example 7 with Vector3f

use of net.minecraft.client.util.math.Vector3f in project canvas by vram-guild.

the class QuadViewImpl method copyPos.

@Override
public Vector3f copyPos(int vertexIndex, Vector3f target) {
    if (target == null) {
        target = new Vector3f();
    }
    final int index = vertexStart() + vertexIndex * 7;
    target.set(Float.intBitsToFloat(data[index]), Float.intBitsToFloat(data[index + 1]), Float.intBitsToFloat(data[index + 2]));
    return target;
}
Also used : Vector3f(net.minecraft.client.util.math.Vector3f)

Example 8 with Vector3f

use of net.minecraft.client.util.math.Vector3f in project Indium by comp500.

the class AbstractQuadRenderer method bufferQuad.

public static void bufferQuad(VertexConsumer buff, MutableQuadViewImpl quad, Matrix4f matrix, int overlay, Matrix3f normalMatrix, Vector3f normalVec) {
    final boolean useNormals = quad.hasVertexNormals();
    if (useNormals) {
        quad.populateMissingNormals();
    } else {
        final Vector3f faceNormal = quad.faceNormal();
        normalVec.set(faceNormal.getX(), faceNormal.getY(), faceNormal.getZ());
        normalVec.transform(normalMatrix);
    }
    for (int i = 0; i < 4; i++) {
        buff.vertex(matrix, quad.x(i), quad.y(i), quad.z(i));
        final int color = quad.spriteColor(i, 0);
        buff.color(color & 0xFF, (color >> 8) & 0xFF, (color >> 16) & 0xFF, (color >> 24) & 0xFF);
        buff.texture(quad.spriteU(i, 0), quad.spriteV(i, 0));
        buff.overlay(overlay);
        buff.light(quad.lightmap(i));
        if (useNormals) {
            normalVec.set(quad.normalX(i), quad.normalY(i), quad.normalZ(i));
            normalVec.transform(normalMatrix);
        }
        buff.normal(normalVec.getX(), normalVec.getY(), normalVec.getZ());
        buff.next();
    }
}
Also used : Vector3f(net.minecraft.client.util.math.Vector3f)

Example 9 with Vector3f

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

the class ReachAroundPlacement method checkReachAroundAndExecute.

public void checkReachAroundAndExecute(Hand hand, ItemStack itemStack) {
    ClientPlayerEntity player = client.player;
    if (player == null || client.interactionManager == null)
        return;
    int count = itemStack.getCount();
    Vector3f facing = player.getHorizontalFacing().getUnitVector();
    if (canReachAround()) {
        BlockHitResult blockHitResult;
        if (isNonFullBlock()) {
            blockHitResult = new BlockHitResult(player.getPos().add(facing.getX(), facing.getY() - 1, facing.getZ()), Direction.fromVector((int) -facing.getX(), 0, (int) -facing.getZ()), player.getBlockPos().offset(player.getHorizontalFacing()), false);
        } else {
            blockHitResult = new BlockHitResult(player.getPos().add(facing.getX(), facing.getY(), facing.getZ()), Direction.fromVector((int) -facing.getX(), 0, (int) -facing.getZ()), player.getBlockPos().down().offset(player.getHorizontalFacing()), false);
        }
        ActionResult result = client.interactionManager.interactBlock(player, client.world, hand, blockHitResult);
        if (result.isAccepted()) {
            if (result.shouldSwingHand()) {
                player.swingHand(hand);
                if (!itemStack.isEmpty() && (itemStack.getCount() != count || client.interactionManager.hasCreativeInventory())) {
                    client.gameRenderer.firstPersonRenderer.resetEquipProgress(hand);
                }
            }
        }
    }
}
Also used : ActionResult(net.minecraft.util.ActionResult) Vector3f(net.minecraft.client.util.math.Vector3f) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) BlockHitResult(net.minecraft.util.hit.BlockHitResult)

Example 10 with Vector3f

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

the class LightningBugInnerFeatureRenderer method render.

public void render(MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, LightningBugEntity entity, float f, float g, float delta, float j, float k, float l) {
    if (!entity.isInvisible()) {
        this.getContextModel().copyStateTo(this.model);
        this.model.animateModel(entity, f, g, delta);
        this.model.setAngles(entity, f, g, j, k, l);
        VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(RenderLayer.getEntityTranslucent(this.getTexture(entity)));
        Vector3f color = getColor(entity, delta);
        this.model.render(matrixStack, vertexConsumer, i, LivingEntityRenderer.getOverlay(entity, 0.0F), color.getX(), color.getY(), color.getZ(), 1.0F);
    }
}
Also used : Vector3f(net.minecraft.client.util.math.Vector3f) VertexConsumer(net.minecraft.client.render.VertexConsumer)

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