Search in sources :

Example 1 with ModelQuadOrientation

use of me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadOrientation in project meteor-client by MeteorDevelopment.

the class SodiumBlockRendererMixin method whRenderQuad.

// https://github.com/CaffeineMC/sodium-fabric/blob/8b3015efe85be9336a150ff7c26085ea3d2d43d0/src/main/java/me/jellysquid/mods/sodium/client/render/pipeline/BlockRenderer.java#L119
// Copied from Sodium, for now, can't think of a better way, because of the nature of the locals, and for loop.
// Mixin seems to freak out when I try to do this the "right" way - Wala (sobbing)
private void whRenderQuad(BlockRenderView world, BlockState state, BlockPos pos, BlockPos origin, ModelVertexSink vertices, IndexBufferBuilder indices, Vec3d blockOffset, ColorSampler<BlockState> colorSampler, BakedQuad bakedQuad, QuadLightData light, ChunkModelBuilder model, int alpha) {
    ModelQuadView src = (ModelQuadView) bakedQuad;
    ModelQuadOrientation orientation = ModelQuadOrientation.orientByBrightness(light.br);
    int[] colors = null;
    if (bakedQuad.hasColor()) {
        colors = this.colorBlender.getColors(world, pos, src, colorSampler, state);
    }
    int vertexStart = vertices.getVertexCount();
    for (int i = 0; i < 4; i++) {
        int j = orientation.getVertexIndex(i);
        float x = src.getX(j) + (float) blockOffset.getX();
        float y = src.getY(j) + (float) blockOffset.getY();
        float z = src.getZ(j) + (float) blockOffset.getZ();
        int color = ColorABGR.mul(colors != null ? colors[j] : 0xFFFFFFFF, light.br[j]);
        int blue = ColorABGR.unpackBlue(color);
        int green = ColorABGR.unpackGreen(color);
        int red = ColorABGR.unpackRed(color);
        color = ColorABGR.pack(red, green, blue, alpha);
        float u = src.getTexU(j);
        float v = src.getTexV(j);
        int lm = light.lm[j];
        vertices.writeVertex(origin, x, y, z, color, u, v, lm, model.getChunkId());
    }
    indices.add(vertexStart, ModelQuadWinding.CLOCKWISE);
    Sprite sprite = src.getSprite();
    if (sprite != null) {
        model.addSprite(sprite);
    }
}
Also used : ModelQuadView(me.jellysquid.mods.sodium.client.model.quad.ModelQuadView) Sprite(net.minecraft.client.texture.Sprite) ModelQuadOrientation(me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadOrientation)

Example 2 with ModelQuadOrientation

use of me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadOrientation in project Client by MatHax.

the class BlockRendererMixin method whRenderQuad.

// https://github.com/CaffeineMC/sodium-fabric/blob/8b3015efe85be9336a150ff7c26085ea3d2d43d0/src/main/java/me/jellysquid/mods/sodium/client/render/pipeline/BlockRenderer.java#L119
// Copied from Sodium, for now, can't think of a better way, because of the nature of the locals, and for loop.
// Mixin seems to freak out when I try to do this the "right" way - Wala (sobbing)
private void whRenderQuad(BlockRenderView world, BlockState state, BlockPos pos, BlockPos origin, ModelVertexSink vertices, IndexBufferBuilder indices, Vec3d blockOffset, ColorSampler<BlockState> colorSampler, BakedQuad bakedQuad, QuadLightData light, ChunkModelBuilder model, int alpha) {
    ModelQuadView src = (ModelQuadView) bakedQuad;
    ModelQuadOrientation orientation = ModelQuadOrientation.orientByBrightness(light.br);
    int[] colors = null;
    if (bakedQuad.hasColor())
        colors = this.colorBlender.getColors(world, pos, src, colorSampler, state);
    int vertexStart = vertices.getVertexCount();
    for (int i = 0; i < 4; i++) {
        int j = orientation.getVertexIndex(i);
        float x = src.getX(j) + (float) blockOffset.getX();
        float y = src.getY(j) + (float) blockOffset.getY();
        float z = src.getZ(j) + (float) blockOffset.getZ();
        int color = ColorABGR.mul(colors != null ? colors[j] : 0xFFFFFFFF, light.br[j]);
        int blue = ColorABGR.unpackBlue(color);
        int green = ColorABGR.unpackGreen(color);
        int red = ColorABGR.unpackRed(color);
        color = ColorABGR.pack(red, green, blue, alpha);
        float u = src.getTexU(j);
        float v = src.getTexV(j);
        int lm = light.lm[j];
        vertices.writeVertex(origin, x, y, z, color, u, v, lm, model.getChunkId());
    }
    indices.add(vertexStart, ModelQuadWinding.CLOCKWISE);
    Sprite sprite = src.getSprite();
    if (sprite != null)
        model.addSprite(sprite);
}
Also used : ModelQuadView(me.jellysquid.mods.sodium.client.model.quad.ModelQuadView) Sprite(net.minecraft.client.texture.Sprite) ModelQuadOrientation(me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadOrientation)

Aggregations

ModelQuadView (me.jellysquid.mods.sodium.client.model.quad.ModelQuadView)2 ModelQuadOrientation (me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadOrientation)2 Sprite (net.minecraft.client.texture.Sprite)2