Skip to content

Commit

Permalink
yarn updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sakura-ryoko committed Aug 22, 2024
1 parent d3194af commit 958c82e
Show file tree
Hide file tree
Showing 9 changed files with 259 additions and 107 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ mod_version = 0.20.999-snap
# Minecraft, Fabric Loader and API and mappings versions
minecraft_version_out = 24w34a
minecraft_version = 24w34a
mappings_version = 24w34a+build.1
mappings_version = 24w34a+build.3

fabric_loader_version = 0.16.2
mod_menu_version = 11.0.1
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/fi/dy/masa/malilib/MaLiLibInitHandler.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package fi.dy.masa.malilib;

import fi.dy.masa.malilib.config.ConfigManager;
import fi.dy.masa.malilib.event.FramebufferHandler;
import fi.dy.masa.malilib.event.InputEventHandler;
import fi.dy.masa.malilib.gui.GuiBase;
import fi.dy.masa.malilib.hotkeys.IHotkeyCallback;
import fi.dy.masa.malilib.hotkeys.IKeybind;
import fi.dy.masa.malilib.hotkeys.KeyAction;
import fi.dy.masa.malilib.interfaces.IInitializationHandler;
import fi.dy.masa.malilib.render.MaLiLibRenderer;

public class MaLiLibInitHandler implements IInitializationHandler
{
Expand All @@ -17,6 +19,8 @@ public void registerModHandlers()

InputEventHandler.getKeybindManager().registerKeybindProvider(MaLiLibInputHandler.getInstance());
MaLiLibConfigs.Generic.OPEN_GUI_CONFIGS.getKeybind().setCallback(new CallbackOpenConfigGui());

FramebufferHandler.getInstance().registerFramebufferHandler(new MaLiLibRenderer());
}

private static class CallbackOpenConfigGui implements IHotkeyCallback
Expand Down
11 changes: 2 additions & 9 deletions src/main/java/fi/dy/masa/malilib/mixin/MixinWorldRenderer.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
package fi.dy.masa.malilib.mixin;

import com.llamalad7.mixinextras.sugar.Local;
import org.joml.Matrix4f;

import fi.dy.masa.malilib.event.RenderEventHandler;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gl.PostEffectProcessor;
import net.minecraft.client.gl.SimpleFramebufferFactory;
import net.minecraft.client.render.*;
import net.minecraft.client.util.ObjectAllocator;
import org.joml.Matrix4f;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import fi.dy.masa.malilib.event.RenderEventHandler;

@Mixin(value = WorldRenderer.class)
public abstract class MixinWorldRenderer
{
@Shadow @Final private MinecraftClient client;
//@Shadow @Nullable private PostEffectProcessor transparencyPostProcessor;
@Shadow @Final private DefaultFramebufferSet framebufferSet;
@Unique private SimpleFramebufferFactory factory = null;

@Inject(method = "render",
at = @At(value = "INVOKE",
Expand Down
126 changes: 70 additions & 56 deletions src/main/java/fi/dy/masa/malilib/render/MaLiLibRenderer.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
package fi.dy.masa.malilib.render;

import javax.annotation.Nullable;
import org.joml.Matrix4f;

import net.minecraft.class_10149;
import net.minecraft.class_10156;
import fi.dy.masa.malilib.MaLiLib;
import fi.dy.masa.malilib.MaLiLibReference;
import fi.dy.masa.malilib.event.FramebufferHandler;
import fi.dy.masa.malilib.interfaces.IFramebufferFactory;
import fi.dy.masa.malilib.render.shader.ShaderEntry;
import fi.dy.masa.malilib.render.shader.ShaderPrograms;
import net.minecraft.class_9916;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gl.Framebuffer;
import net.minecraft.client.gl.PostEffectProcessor;
import net.minecraft.client.gl.ShaderProgram;
import net.minecraft.client.gl.SimpleFramebufferFactory;
import net.minecraft.client.render.*;
import net.minecraft.util.Identifier;
import net.minecraft.util.profiler.Profiler;
import org.joml.Matrix4f;

import fi.dy.masa.malilib.MaLiLibReference;
import fi.dy.masa.malilib.event.FramebufferHandler;
import fi.dy.masa.malilib.interfaces.IFramebufferFactory;
import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;

public class MaLiLibRenderer implements IFramebufferFactory, AutoCloseable
{
//private final Identifier shaderPostProcessor = Identifier.of(MaLiLibReference.MOD_ID, "shaders/transparency.json");
private final Identifier shaderPostProcessor = null;
private RenderTarget renderPhase;
private Framebuffer framebuffer;
private class_9916 renderStageNode;
Expand All @@ -33,14 +32,8 @@ public class MaLiLibRenderer implements IFramebufferFactory, AutoCloseable
private Fog fog = Fog.DUMMY;
private RenderTickCounter tickCounter;
private Profiler profiler;
@Nullable
private PostEffectProcessor transparencyPostProcessor;
@Nullable
private class_10156 shader = new class_10156(Identifier.ofVanilla("core/terrain"), VertexFormats.POSITION_COLOR_TEXTURE_LIGHT_NORMAL, class_10149.field_53930);
@Nullable
private ShaderProgram shaderProgram;
@Nullable
private PostEffectProcessor shaderPostEffects;
private final ShaderEntry vanillaTransparency = new ShaderEntry("vanilla_transparency", null, Identifier.ofVanilla("transparency"));
private final Map<String, ShaderEntry> shaders = new HashMap<>();

@Override
public String getName()
Expand Down Expand Up @@ -75,39 +68,73 @@ public Framebuffer getFramebuffer()
@Override
public void onReload(MinecraftClient mc)
{
/*
if (MinecraftClient.isFabulousGraphicsOrBetter())
{
this.loadTransparencyPostProcessor(mc);
}
*/

this.clear();
this.buildShaders();

if (this.shader != null)
if (this.shaders.isEmpty() == false)
{
this.loadShader();
this.loadShaders(mc);
}
}

private void loadShader()
private void buildShaders()
{
this.shaders.computeIfAbsent("position_color", (entry) -> new ShaderEntry(entry, ShaderPrograms.POSITION_COLOR, null));
this.shaders.computeIfAbsent("position_color_tex", (entry) -> new ShaderEntry(entry, ShaderPrograms.POSITION_COLOR_TEX, null));
this.shaders.computeIfAbsent("rendertype_solid", (entry) -> new ShaderEntry(entry, ShaderPrograms.RENDERTYPE_SOLID, null));
}

private void loadShaders(MinecraftClient mc)
{
// Load shader
/*
try
for (ShaderEntry entry : this.shaders.values())
{
ShaderProgram shaderProgram = RenderSystem.setShader(this.shader);
if (shaderProgram != null)
try
{
entry.load(mc.method_62887());
}
catch (Exception e)
{
this.shaderProgram = shaderProgram;
MaLiLib.logger.error("MaLiLibRenderer: Error loading ShaderEntry \"{}\": [{}]", entry.getName(), e.getMessage());
}
//this.shaderPostEffects;
}
catch (Exception e)
}

private boolean startProgram(String name, MinecraftClient mc)
{
if (this.shaders.containsKey(name))
{
// Ignored
return this.shaders.get(name).startProgram(mc.method_62887());
}
*/

return false;
}

private boolean runProgram(String name)
{
if (this.shaders.containsKey(name))
{
return this.shaders.get(name).runProgram();
}

return false;
}

private void runPostEffects(FrameGraphBuilder frameGraphBuilder, int width, int height, DefaultFramebufferSet framebufferSet)
{
for (ShaderEntry entry : this.shaders.values())
{
entry.runPostEffects(frameGraphBuilder, width, height, framebufferSet);
}
}

private void endShaders()
{
for (ShaderEntry entry : this.shaders.values())
{
entry.end();
}

this.vanillaTransparency.end();
}

@Override
Expand Down Expand Up @@ -135,7 +162,7 @@ public void onFramebufferBasicSetup(Matrix4f posMatrix, Matrix4f projMatrix, Min
this.renderStageNode = this.createStageNode(frameGraphBuilder, this.getName());
this.posMatrix = posMatrix;
this.projMatrix = projMatrix;
this.transparencyPostProcessor = postEffectProcessor;
this.vanillaTransparency.setPostEffects(postEffectProcessor);
}

@Override
Expand All @@ -160,15 +187,7 @@ public void onRenderNode(FrameGraphBuilder frameGraphBuilder, Matrix4f posMatrix
{
this.profiler.push(this::getName);
this.runStage(this.renderStageNode);

if (this.transparencyPostProcessor != null)
{
this.transparencyPostProcessor.method_62234(frameGraphBuilder, mc.getFramebuffer().textureWidth, mc.getFramebuffer().textureHeight, framebufferSet);
}
if (this.shaderPostEffects != null)
{
this.shaderPostEffects.method_62234(frameGraphBuilder, mc.getFramebuffer().textureWidth, mc.getFramebuffer().textureHeight, framebufferSet);
}
this.runPostEffects(frameGraphBuilder, mc.getFramebuffer().textureWidth, mc.getFramebuffer().textureHeight, framebufferSet);
}

@Override
Expand All @@ -181,6 +200,7 @@ public void preDraw()
public void draw()
{
// Items for drawing go here
MaLiLib.logger.error("MaLiLibRenderer() --> draw()");
}

@Override
Expand All @@ -205,13 +225,7 @@ public void clear()
this.tickCounter = null;
this.profiler = null;
this.renderStageNode = null;
this.transparencyPostProcessor = null;
this.shaderPostEffects = null;
if (this.shaderProgram != null)
{
this.shaderProgram.close();
this.shaderProgram = null;
}
this.endShaders();
}

@Override
Expand Down
27 changes: 12 additions & 15 deletions src/main/java/fi/dy/masa/malilib/render/RenderUtils.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
package fi.dy.masa.malilib.render;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.joml.Matrix4f;
import org.joml.Matrix4fStack;

import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import fi.dy.masa.malilib.config.HudAlignment;
import fi.dy.masa.malilib.gui.GuiBase;
import fi.dy.masa.malilib.render.shader.ShaderPrograms;
import fi.dy.masa.malilib.util.*;
import fi.dy.masa.malilib.util.PositionUtils.HitPart;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.ShulkerBoxBlock;
import net.minecraft.block.entity.ShulkerBoxBlockEntity;
import net.minecraft.class_10149;
import net.minecraft.class_10156;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
Expand Down Expand Up @@ -47,12 +42,14 @@
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.random.LocalRandom;
import org.joml.Matrix4f;
import org.joml.Matrix4fStack;

import fi.dy.masa.malilib.config.HudAlignment;
import fi.dy.masa.malilib.gui.GuiBase;
import fi.dy.masa.malilib.render.shader.ShaderPrograms;
import fi.dy.masa.malilib.util.*;
import fi.dy.masa.malilib.util.PositionUtils.HitPart;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class RenderUtils
{
Expand Down
Loading

0 comments on commit 958c82e

Please sign in to comment.