All Downloads are FREE. Search and download functionalities are using the official Maven repository.

top.hendrixshen.magiclib.impl.render.context.RenderContextImpl Maven / Gradle / Ivy

There is a newer version: 0.6.59
Show newest version
/*
 * This file is part of the TweakerMore project, licensed under the
 * GNU Lesser General Public License v3.0
 *
 * Copyright (C) 2023  Fallen_Breath and contributors
 *
 * TweakerMore is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * TweakerMore is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with TweakerMore.  If not, see .
 */

package top.hendrixshen.magiclib.impl.render.context;

import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.class_332;
import net.minecraft.class_4587;
import org.joml.Matrix4f;
import top.hendrixshen.magiclib.api.render.context.RenderContext;
import org.jetbrains.annotations.NotNull;
//#else
//$$ import com.mojang.blaze3d.platform.GlStateManager;
//#endif

/**
 * Reference to TweakerMore
 */
//#if MC > 11502 && MC < 11700
//$$ @SuppressWarnings("deprecation")
//#endif
public class RenderContextImpl implements RenderContext {
    //#if MC > 11904
    //$$ private final GuiGraphics guiGraphics;
    //#endif

    //#if MC > 11502
    @NotNull
    private final class_4587 poseStack;
    //#endif

    public RenderContextImpl(
            //#if MC > 11904
            //$$ GuiGraphics guiGraphics,
            //#endif
            //#if MC > 11502
            @NotNull class_4587 poseStack
            //#endif
    ) {
        //#if MC > 11904
        //$$ this.guiGraphics = guiGraphics;
        //#endif
        //#if MC > 11502
        this.poseStack = poseStack;
        //#endif
    }

    @Override
    public class_332 getGuiComponent() {
        //#if MC > 11904
        //$$ return this.guiGraphics;
        //#else
        return new class_332() {
        };
        //#endif
    }

    //#if MC > 11502
    @Override
    public @NotNull class_4587 getPoseStack() {
        return this.poseStack;
    }
    //#endif

    @Override
    public void pushPose() {
        //#if MC > 11605
        this.poseStack.method_22903();
        //#elseif MC > 11404
        //$$ RenderSystem.pushMatrix();
        //#else
        //$$ GlStateManager.pushMatrix();
        //#endif
    }

    @Override
    public void popPose() {
        //#if MC > 11605
        this.poseStack.method_22909();
        //#elseif MC > 11404
        //$$ RenderSystem.pushMatrix();
        //#else
        //$$ GlStateManager.popMatrix();
        //#endif
    }

    @Override
    public void translate(double x, double y, double z) {
        //#if MC > 11605
        this.poseStack.method_22904(x, y, z);
        //#elseif MC > 11404
        //$$ RenderSystem.translated(x, y, z);
        //#else
        //$$ GlStateManager.translated(x, y, z);
        //#endif
    }

    @Override
    public void scale(double x, double y, double z) {
        //#if MC > 11605
        this.poseStack.method_22905((float) x, (float) y, (float) z);
        //#elseif MC > 11404
        //$$ RenderSystem.scaled(x, y, z);
        //#else
        //$$ GlStateManager.scaled(x, y, z);
        //#endif
    }

    @Override
    public void mulPoseMatrix(Matrix4f matrix4f) {
        //#if MC > 11605
        this.poseStack.method_34425(matrix4f);
        //#elseif MC > 11404
        //$$ RenderSystem.multMatrix(matrix4f);
        //#else
        //$$ GlStateManager.multMatrix(matrix4f);
        //#endif
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy