diff --git a/src/main/java/com/gtnewhorizons/angelica/compat/mojang/Axis.java b/src/main/java/com/gtnewhorizons/angelica/compat/Axis.java similarity index 55% rename from src/main/java/com/gtnewhorizons/angelica/compat/mojang/Axis.java rename to src/main/java/com/gtnewhorizons/angelica/compat/Axis.java index 9d1dca10d..27fffa8e5 100644 --- a/src/main/java/com/gtnewhorizons/angelica/compat/mojang/Axis.java +++ b/src/main/java/com/gtnewhorizons/angelica/compat/Axis.java @@ -1,14 +1,13 @@ -package com.gtnewhorizons.angelica.compat.mojang; +package com.gtnewhorizons.angelica.compat; -import net.minecraftforge.common.util.ForgeDirection; +import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFacing; -@Deprecated public enum Axis { X, Y, Z; - public static Axis fromDirection(ForgeDirection dir) { + public static Axis fromDirection(ModelQuadFacing dir) { return switch (dir) { case DOWN, UP -> Y; case NORTH, SOUTH -> Z; diff --git a/src/main/java/com/gtnewhorizons/angelica/compat/forge/IForgeBakedModel.java b/src/main/java/com/gtnewhorizons/angelica/compat/forge/IForgeBakedModel.java deleted file mode 100644 index 01a7eb8a8..000000000 --- a/src/main/java/com/gtnewhorizons/angelica/compat/forge/IForgeBakedModel.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.gtnewhorizons.angelica.compat.forge; - -import com.gtnewhorizons.angelica.compat.mojang.BakedModel; -import com.gtnewhorizons.angelica.compat.mojang.BakedQuad; -import com.gtnewhorizons.angelica.compat.mojang.BlockState; -import net.minecraftforge.common.util.ForgeDirection; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.List; -import java.util.Random; - -public interface IForgeBakedModel { - default BakedModel getBakedModel() - { - return (BakedModel) this; - } - - default List getQuads(@Nullable BlockState state, @Nullable ForgeDirection side, @NotNull Random rand, @NotNull IModelData extraData) - { - return getBakedModel().getQuads(state, side, rand); - } -} diff --git a/src/main/java/com/gtnewhorizons/angelica/compat/mojang/BakedModel.java b/src/main/java/com/gtnewhorizons/angelica/compat/mojang/BakedModel.java deleted file mode 100644 index be0ef0d5f..000000000 --- a/src/main/java/com/gtnewhorizons/angelica/compat/mojang/BakedModel.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.gtnewhorizons.angelica.compat.mojang; - -import com.gtnewhorizons.angelica.compat.forge.IForgeBakedModel; -import com.gtnewhorizons.angelica.compat.forge.IModelData; -import net.minecraftforge.common.util.ForgeDirection; - -import java.util.List; -import java.util.Random; - -@Deprecated -public interface BakedModel extends IForgeBakedModel { - - List getQuads(BlockState state, ForgeDirection face, Random random); - - IModelData getModelData(BlockRenderView world, BlockPos pos, BlockState state, IModelData modelData); - - boolean isAmbientOcclusion(BlockState state); -} diff --git a/src/main/java/com/gtnewhorizons/angelica/compat/mojang/BakedQuad.java b/src/main/java/com/gtnewhorizons/angelica/compat/mojang/BakedQuad.java deleted file mode 100644 index 87966cd1c..000000000 --- a/src/main/java/com/gtnewhorizons/angelica/compat/mojang/BakedQuad.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.gtnewhorizons.angelica.compat.mojang; - -import com.gtnewhorizons.angelica.compat.forge.VertexLighterFlat; -import net.minecraftforge.common.util.ForgeDirection; - -@Deprecated -public class BakedQuad { - - public void pipe(VertexLighterFlat lighter) {} - - public boolean hasColor() { - return true; - } - - public ForgeDirection getFace() { - return ForgeDirection.UNKNOWN; - } - - public boolean hasShade() { - return true; - } -} diff --git a/src/main/java/com/gtnewhorizons/angelica/compat/mojang/BlockModels.java b/src/main/java/com/gtnewhorizons/angelica/compat/mojang/BlockModels.java deleted file mode 100644 index 4a432e064..000000000 --- a/src/main/java/com/gtnewhorizons/angelica/compat/mojang/BlockModels.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.gtnewhorizons.angelica.compat.mojang; - -@Deprecated -public class BlockModels { - - public BakedModel getModel(BlockState blockState) { return null; } -} diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/startup/MixinGameSettings.java b/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/startup/MixinGameSettings.java index d465a800e..3eb97abd9 100644 --- a/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/startup/MixinGameSettings.java +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/early/shaders/startup/MixinGameSettings.java @@ -13,8 +13,6 @@ public abstract class MixinGameSettings { @Unique private static boolean iris$shadersInitialized; - private static Iris iris$Instance; - @Inject(method="Lnet/minecraft/client/settings/GameSettings;loadOptions()V", at=@At("HEAD")) private void angelica$InitializeShaders(CallbackInfo ci) { if (iris$shadersInitialized) { @@ -22,8 +20,7 @@ public abstract class MixinGameSettings { } iris$shadersInitialized = true; - iris$Instance =new Iris(); - iris$Instance.onEarlyInitialize(); + Iris.INSTANCE.onEarlyInitialize(); } } diff --git a/src/main/java/com/gtnewhorizons/angelica/proxy/ClientProxy.java b/src/main/java/com/gtnewhorizons/angelica/proxy/ClientProxy.java index b8d4793c9..b4b3fca92 100644 --- a/src/main/java/com/gtnewhorizons/angelica/proxy/ClientProxy.java +++ b/src/main/java/com/gtnewhorizons/angelica/proxy/ClientProxy.java @@ -12,6 +12,7 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; import me.jellysquid.mods.sodium.client.SodiumDebugScreenHandler; +import net.coderbot.iris.Iris; import net.coderbot.iris.client.IrisDebugScreenHandler; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; @@ -48,6 +49,11 @@ public void init(FMLInitializationEvent event) { } if(AngelicaConfig.enableIris) { MinecraftForge.EVENT_BUS.register(IrisDebugScreenHandler.INSTANCE); + + Iris.INSTANCE.registerKeybindings(); + FMLCommonHandler.instance().bus().register(Iris.INSTANCE); + MinecraftForge.EVENT_BUS.register(Iris.INSTANCE); + } } diff --git a/src/main/java/me/jellysquid/mods/sodium/client/model/quad/properties/ModelQuadFlags.java b/src/main/java/me/jellysquid/mods/sodium/client/model/quad/properties/ModelQuadFlags.java index 6f082ce9f..3a55ed8db 100644 --- a/src/main/java/me/jellysquid/mods/sodium/client/model/quad/properties/ModelQuadFlags.java +++ b/src/main/java/me/jellysquid/mods/sodium/client/model/quad/properties/ModelQuadFlags.java @@ -1,8 +1,7 @@ package me.jellysquid.mods.sodium.client.model.quad.properties; -import com.gtnewhorizons.angelica.compat.mojang.Axis; -import com.gtnewhorizons.angelica.compat.mojang.BakedQuad; -import me.jellysquid.mods.sodium.client.model.quad.ModelQuadView; +import com.gtnewhorizons.angelica.compat.Axis; +import com.gtnewhorizons.angelica.compat.nd.Quad; import net.minecraftforge.common.util.ForgeDirection; public class ModelQuadFlags { @@ -33,10 +32,9 @@ public static boolean contains(int flags, int mask) { * Calculates the properties of the given quad. This data is used later by the light pipeline in order to make * certain optimizations. */ - public static int getQuadFlags(BakedQuad bakedQuad) { - final ModelQuadView quad = (ModelQuadView) bakedQuad; - final ForgeDirection face = bakedQuad.getFace(); - final Axis axis = Axis.fromDirection(face); + public static int getQuadFlags(Quad quad) { + final ForgeDirection face = quad.getFace(); + final Axis axis = Axis.fromDirection(quad.normal); float minX = 32.0F; float minY = 32.0F; diff --git a/src/main/java/me/jellysquid/mods/sodium/client/render/pipeline/context/ChunkRenderCacheLocal.java b/src/main/java/me/jellysquid/mods/sodium/client/render/pipeline/context/ChunkRenderCacheLocal.java index 76bbab8c8..22d3bc052 100644 --- a/src/main/java/me/jellysquid/mods/sodium/client/render/pipeline/context/ChunkRenderCacheLocal.java +++ b/src/main/java/me/jellysquid/mods/sodium/client/render/pipeline/context/ChunkRenderCacheLocal.java @@ -1,6 +1,6 @@ package me.jellysquid.mods.sodium.client.render.pipeline.context; -import com.gtnewhorizons.angelica.compat.mojang.BlockModels; +import lombok.Getter; import me.jellysquid.mods.sodium.client.model.light.LightPipelineProvider; import me.jellysquid.mods.sodium.client.model.light.cache.ArrayLightDataCache; import me.jellysquid.mods.sodium.client.render.pipeline.BlockRenderer; @@ -14,10 +14,11 @@ public class ChunkRenderCacheLocal extends ChunkRenderCache { private final ArrayLightDataCache lightDataCache; + @Getter private final BlockRenderer blockRenderer; + @Getter private final FluidRenderer fluidRenderer; - - private final BlockModels blockModels; + @Getter private final WorldSlice worldSlice; public ChunkRenderCacheLocal(Minecraft client, WorldClient world) { @@ -29,20 +30,6 @@ public ChunkRenderCacheLocal(Minecraft client, WorldClient world) { this.blockRenderer = new BlockRenderer(client); this.fluidRenderer = new FluidRenderer(lpp); - // TODO: Sodium - this.blockModels = null; // client.getBakedModelManager().getBlockModels(); - } - - public BlockModels getBlockModels() { - return this.blockModels; - } - - public BlockRenderer getBlockRenderer() { - return this.blockRenderer; - } - - public FluidRenderer getFluidRenderer() { - return this.fluidRenderer; } public void init(ChunkRenderContext context) { @@ -50,7 +37,4 @@ public void init(ChunkRenderContext context) { this.worldSlice.copyData(context); } - public WorldSlice getWorldSlice() { - return this.worldSlice; - } } diff --git a/src/main/java/net/coderbot/iris/Iris.java b/src/main/java/net/coderbot/iris/Iris.java index 737b3c3fc..2f667ed45 100644 --- a/src/main/java/net/coderbot/iris/Iris.java +++ b/src/main/java/net/coderbot/iris/Iris.java @@ -1,7 +1,11 @@ package net.coderbot.iris; +import com.google.common.base.Throwables; import com.gtnewhorizons.angelica.glsm.GLStateManager; import com.mojang.realmsclient.gui.ChatFormatting; +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.InputEvent; import lombok.Getter; import net.coderbot.iris.config.IrisConfig; import net.coderbot.iris.gl.GLDebug; @@ -23,7 +27,9 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.resources.I18n; +import net.minecraft.client.settings.KeyBinding; import net.minecraft.launchwrapper.Launch; +import net.minecraft.util.ChatComponentText; import org.jetbrains.annotations.NotNull; import org.lwjgl.opengl.ContextCapabilities; import org.lwjgl.opengl.GLContext; @@ -87,8 +93,14 @@ public class Iris { private static String IRIS_VERSION; private static boolean fallback; + private static final KeyBinding reloadKeybind = new KeyBinding("Reload Shaders", 0, "Iris Keybinds"); + private static final KeyBinding toggleShadersKeybind = new KeyBinding("Toggle Shaders", 0, "Iris Keybinds"); + private static final KeyBinding shaderpackScreenKeybind = new KeyBinding("Shaderpack Selection Screen", 0, "Iris Keybinds"); + + public static Iris INSTANCE = new Iris(); + // Wrapped in try-catch due to early initializing class - public Iris() { + private Iris() { isDevelopmentEnvironment = (boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment"); // TODO: Iris Backport // try { @@ -99,6 +111,36 @@ public Iris() { // }catch(Exception ignored) {} } + @SubscribeEvent + public void onKeypress(InputEvent.KeyInputEvent event) { + if (reloadKeybind.isPressed()) { + final Minecraft mc = Minecraft.getMinecraft(); + try { + reload(); + if (mc.thePlayer != null) mc.thePlayer.addChatMessage(new ChatComponentText("Shaders Reloaded!")); + + } catch (Exception e) { + logger.error("Error while reloading Shaders for Iris!", e); + if (mc.thePlayer != null) mc.thePlayer.addChatMessage(new ChatComponentText( "Failed tgo reload shaders! Reason: " + Throwables.getRootCause(e).getMessage())); + } + } else if (toggleShadersKeybind.isPressed()) { + final Minecraft mc = Minecraft.getMinecraft(); + try { + toggleShaders(mc, !irisConfig.areShadersEnabled()); + } catch (Exception e) { + logger.error("Error while toggling shaders!", e); + + if (mc.thePlayer != null) mc.thePlayer.addChatMessage(new ChatComponentText( "Failed tgo toggle shaders! Reason: " + Throwables.getRootCause(e).getMessage())); + setShadersDisabled(); + fallback = true; + } + } else if (shaderpackScreenKeybind.isPressed()) { + final Minecraft mc = Minecraft.getMinecraft(); + if (mc.thePlayer != null) mc.thePlayer.addChatMessage(new ChatComponentText( "Shaderpack selection screen is not implemented yet!")); +// minecraft.setScreen(new ShaderPackScreen(null)); + } + + } /** * Called very early on in Minecraft initialization. At this point we *cannot* safely access OpenGL, but we can do some very basic setup, config loading, * and environment checks. @@ -692,4 +734,10 @@ public static ShaderpackDirectoryManager getShaderpacksDirectoryManager() { return shaderpacksDirectoryManager; } + + public void registerKeybindings() { + ClientRegistry.registerKeyBinding(reloadKeybind); + ClientRegistry.registerKeyBinding(toggleShadersKeybind); + ClientRegistry.registerKeyBinding(shaderpackScreenKeybind); + } }