Search in sources :

Example 6 with IVertexBuilder

use of com.mojang.blaze3d.vertex.IVertexBuilder in project BluePower by Qmunity.

the class RenderEngine method render.

@Override
public void render(TileEngine engine, float f, MatrixStack matrixStack, IRenderTypeBuffer iRenderTypeBuffer, int i, int i1) {
    World world = engine.getLevel();
    BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRenderer();
    BlockPos pos = engine.getBlockPos();
    BlockState state = BPBlocks.engine.defaultBlockState().setValue(BlockEngine.FACING, engine.getOrientation());
    Direction facing = engine.getOrientation();
    matrixStack.pushPose();
    float rotationX = 90.0F;
    float rotation = 0.0F;
    if (facing == Direction.NORTH) {
        matrixStack.translate(0, 1, 0);
        rotation = 0F;
    } else if (facing == Direction.SOUTH) {
        matrixStack.translate(1, 1, 1);
        rotation = 180F;
    } else if (facing == Direction.EAST) {
        matrixStack.translate(1, 1, 0);
        rotation = 90F;
    } else if (facing == Direction.WEST) {
        matrixStack.translate(0, 1, 1);
        rotation = -90F;
    } else if (facing == Direction.UP) {
        matrixStack.translate(0, 1, 1);
        rotationX = 180F;
    } else if (facing == Direction.DOWN) {
        rotationX = 0F;
    }
    matrixStack.mulPose(Vector3f.XP.rotationDegrees(rotationX));
    matrixStack.mulPose(Vector3f.ZP.rotationDegrees(rotation));
    matrixStack.pushPose();
    float f2 = 0;
    if (engine.isActive) {
        f += engine.pumpTick;
        if (engine.pumpSpeed > 0) {
            f /= engine.pumpSpeed;
        }
        f2 = ((float) (.5 - .5 * Math.cos(3.1415926535897931D * (double) f)) / 4);
    }
    matrixStack.translate(0, f2, 0);
    IBakedModel glider = dispatcher.getBlockModel(state.setValue(BlockEngine.GLIDER, true));
    // Render the glider
    IVertexBuilder builder = iRenderTypeBuffer.getBuffer(RenderType.cutout());
    dispatcher.getModelRenderer().renderModel(world, glider, state.setValue(BlockEngine.GLIDER, true), pos, matrixStack, builder, false, new Random(), 0, 0, EmptyModelData.INSTANCE);
    matrixStack.popPose();
    matrixStack.pushPose();
    matrixStack.translate(0.5, 0, 0.5);
    long angle = engine.isActive ? (System.currentTimeMillis() / 10) % 360 : 0;
    matrixStack.mulPose(Vector3f.YP.rotationDegrees(angle));
    matrixStack.translate(-0.5, 0, -0.5);
    IBakedModel gear = dispatcher.getBlockModel(state.setValue(BlockEngine.GEAR, true));
    // Render the rotating cog
    dispatcher.getModelRenderer().renderModel(world, gear, state.setValue(BlockEngine.GEAR, true), pos, matrixStack, iRenderTypeBuffer.getBuffer(RenderType.cutout()), false, new Random(), 0, 0, EmptyModelData.INSTANCE);
    matrixStack.popPose();
    matrixStack.popPose();
}
Also used : BlockState(net.minecraft.block.BlockState) Random(java.util.Random) BlockPos(net.minecraft.util.math.BlockPos) IBakedModel(net.minecraft.client.renderer.model.IBakedModel) World(net.minecraft.world.World) Direction(net.minecraft.util.Direction) IVertexBuilder(com.mojang.blaze3d.vertex.IVertexBuilder)

Example 7 with IVertexBuilder

use of com.mojang.blaze3d.vertex.IVertexBuilder in project Overloaded by CJ-MC-Mods.

the class RenderMultiToolAssist method renderBlockModel.

private static void renderBlockModel(RenderWorldLastEvent event, BlockPos toRenderAt, @Nonnull IBakedModel model, @Nonnull BlockState state) {
    ActiveRenderInfo camera = Minecraft.getInstance().gameRenderer.getMainCamera();
    final double x = camera.getPosition().x();
    final double y = camera.getPosition().y();
    final double z = camera.getPosition().z();
    event.getMatrixStack().pushPose();
    event.getMatrixStack().translate(toRenderAt.getX() - x, toRenderAt.getY() - y, toRenderAt.getZ() - z);
    IVertexBuilder buffer = Minecraft.getInstance().renderBuffers().bufferSource().getBuffer(GhostRenderType.getInstance());
    Minecraft.getInstance().getBlockRenderer().getModelRenderer().tesselateBlock(Minecraft.getInstance().level, model, state, toRenderAt, event.getMatrixStack(), buffer, false, Minecraft.getInstance().level.random, 0, 0);
    event.getMatrixStack().popPose();
    Minecraft.getInstance().renderBuffers().bufferSource().endBatch(GhostRenderType.getInstance());
}
Also used : ActiveRenderInfo(net.minecraft.client.renderer.ActiveRenderInfo) IVertexBuilder(com.mojang.blaze3d.vertex.IVertexBuilder)

Example 8 with IVertexBuilder

use of com.mojang.blaze3d.vertex.IVertexBuilder in project NetherEx by LogicTechCorp.

the class RenderEventHandler method renderThirdPersonBlueFire.

private static void renderThirdPersonBlueFire(MatrixStack matrixStack, IRenderTypeBuffer buffer, Entity entity) {
    TextureAtlasSprite blueFireLayerOSprite = BLUE_FIRE_LAYER_O.getSprite();
    TextureAtlasSprite blueFireLayer1Sprite = BLUE_FIRE_LAYER_1.getSprite();
    matrixStack.push();
    float f = entity.getWidth() * 1.4F;
    matrixStack.scale(f, f, f);
    float f1 = 0.5F;
    float f3 = entity.getHeight() / f;
    float f4 = 0.0F;
    matrixStack.rotate(Vector3f.YP.rotationDegrees(-MINECRAFT.getRenderManager().info.getYaw()));
    matrixStack.translate(0.0D, 0.0D, (-0.3F + (float) ((int) f3) * 0.02F));
    float f5 = 0.0F;
    int i = 0;
    IVertexBuilder builder = buffer.getBuffer(Atlases.getCutoutBlockType());
    for (MatrixStack.Entry matrixEntry = matrixStack.getLast(); f3 > 0.0F; i++) {
        TextureAtlasSprite sprite = i % 2 == 0 ? blueFireLayerOSprite : blueFireLayer1Sprite;
        float minU = sprite.getMinU();
        float minV = sprite.getMinV();
        float maxU = sprite.getMaxU();
        float maxV = sprite.getMaxV();
        if (i / 2 % 2 == 0) {
            float f10 = maxU;
            maxU = minU;
            minU = f10;
        }
        fireVertex(matrixEntry, builder, f1 - 0.0F, 0.0F - f4, f5, maxU, maxV);
        fireVertex(matrixEntry, builder, -f1 - 0.0F, 0.0F - f4, f5, minU, maxV);
        fireVertex(matrixEntry, builder, -f1 - 0.0F, 1.4F - f4, f5, minU, minV);
        fireVertex(matrixEntry, builder, f1 - 0.0F, 1.4F - f4, f5, maxU, minV);
        f3 -= 0.45F;
        f4 -= 0.45F;
        f1 *= 0.9F;
        f5 += 0.03F;
    }
    matrixStack.pop();
}
Also used : TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) IVertexBuilder(com.mojang.blaze3d.vertex.IVertexBuilder)

Aggregations

IVertexBuilder (com.mojang.blaze3d.vertex.IVertexBuilder)8 IBakedModel (net.minecraft.client.renderer.model.IBakedModel)3 BlockPos (net.minecraft.util.math.BlockPos)3 BlockState (net.minecraft.block.BlockState)2 BlockRendererDispatcher (net.minecraft.client.renderer.BlockRendererDispatcher)2 RenderType (net.minecraft.client.renderer.RenderType)2 Matrix4f (net.minecraft.util.math.vector.Matrix4f)2 Vector3d (net.minecraft.util.math.vector.Vector3d)2 World (net.minecraft.world.World)2 BlockBPMultipart (com.bluepowermod.block.BlockBPMultipart)1 BlockGreenHouseAir (com.infinityraider.agricraft.content.world.BlockGreenHouseAir)1 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 Random (java.util.Random)1 ActiveRenderInfo (net.minecraft.client.renderer.ActiveRenderInfo)1 IRenderTypeBuffer (net.minecraft.client.renderer.IRenderTypeBuffer)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 Direction (net.minecraft.util.Direction)1 BlockRayTraceResult (net.minecraft.util.math.BlockRayTraceResult)1 RayTraceResult (net.minecraft.util.math.RayTraceResult)1