Yooshyasha
Yooshyasha

Reputation: 11

Rendering minecraft fabric error: cannot find symbol

I want to create my own ClickGUI for minecraft mod, for some reason it outputs an error. I do it according to the guide https://fabric.moddedmc.wiki/rendering /.

my code:

package org.sgx.nihao.ui.screen.clickgui;

import com.mojang.blaze3d.systems.RenderSystem;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.minecraft.client.render.*;
import net.minecraft.util.Identifier;
import org.joml.Matrix4f;

public class ClickGUI {
    public void onInitializeClient(){
        HudRenderCallback.EVENT.register((drawContext, tickDelta) -> {
            Matrix4f positionMatrix = drawContext.getMatrices().peek().getPositionMatrix();
            Tessellator tessellator = Tessellator.getInstance();
            BufferBuilder buffer = tessellator.getBuffer();
            buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR_TEXTURE);
            buffer.vertex(positionMatrix, 20, 20, 0).color(1f, 1f, 1f, 1f).texture(0f, 0f).next();
            buffer.vertex(positionMatrix, 20, 60, 0).color(1f, 0f, 0f, 1f).texture(0f, 1f).next();
            buffer.vertex(positionMatrix, 60, 60, 0).color(0f, 1f, 0f, 1f).texture(1f, 1f).next();
            buffer.vertex(positionMatrix, 60, 20, 0).color(0f, 0f, 1f, 1f).texture(1f, 0f).next();

            RenderSystem.setShader(GameRenderer::getPositionColorTexProgram);
            RenderSystem.setShaderTexture(0, new Identifier("nihao_mod", "icon.png"));
            RenderSystem.setShaderColor(1f, 1f, 1f, 1f);

            tessellator.draw();

        });
    }

}

error:

*path*\ClickGUI.java:12: error: cannot find symbol
            Matrix4f positionMatrix = drawContext.getMatrices().peek().getPositionMatrix();
                                                 ^
  symbol:   method getMatrices()
  location: variable drawContext of type MatrixStack

it may be useful: I have a year and a half of experience in Python, 1 week in Java

I have no idea what to try, I tried to find a solution to the problem, unsuccessfully. we need the following result: https://fabric.moddedmc.wiki/assets/basics_0.hRPTS0c9.png

Upvotes: 0

Views: 452

Answers (1)

Yooshyasha
Yooshyasha

Reputation: 11

I found a solution to the problem. Who cares, I just changed the matrix call. Matrix4f positionMatrix = drawContext.peek().getPositionMatrix();

Upvotes: 0

Related Questions