diff --git a/common/build.gradle.kts b/common/build.gradle.kts index ffbfa98a2..7e411feb9 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -78,6 +78,7 @@ dependencies { modCompileOnly("net.fabricmc:fabric-loader:${property("fabric_loader_version")}") modCompileOnly("maven.modrinth:sodium:${property("sodium_version")}-fabric") + modCompileOnly("maven.modrinth:iris:${property("iris_version")}-fabric") testImplementation("org.junit.jupiter:junit-jupiter:5.8.1") } diff --git a/common/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplat.java b/common/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplat.java index c8fb9fec1..898f8791d 100644 --- a/common/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplat.java +++ b/common/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplat.java @@ -13,8 +13,4 @@ public interface FlwImplXplat { String getVersionStr(); FlwConfig getConfig(); - - boolean useSodium0_6Compat(); - - boolean useIrisCompat(); } diff --git a/common/src/main/java/dev/engine_room/flywheel/impl/compat/CompatMod.java b/common/src/main/java/dev/engine_room/flywheel/impl/compat/CompatMod.java index 725208bfa..c53fa9ecd 100644 --- a/common/src/main/java/dev/engine_room/flywheel/impl/compat/CompatMod.java +++ b/common/src/main/java/dev/engine_room/flywheel/impl/compat/CompatMod.java @@ -3,9 +3,7 @@ import dev.engine_room.flywheel.impl.FlwImplXplat; public enum CompatMod { - EMBEDDIUM("embeddium"), IRIS("iris"), - OCULUS("oculus"), SODIUM("sodium"); public final String id; diff --git a/common/src/main/java/dev/engine_room/flywheel/impl/compat/CompatMods.java b/common/src/main/java/dev/engine_room/flywheel/impl/compat/CompatMods.java deleted file mode 100644 index 756360d01..000000000 --- a/common/src/main/java/dev/engine_room/flywheel/impl/compat/CompatMods.java +++ /dev/null @@ -1,14 +0,0 @@ -package dev.engine_room.flywheel.impl.compat; - -import dev.engine_room.flywheel.impl.FlwImplXplat; - -public enum CompatMods { - IRIS("iris"), - SODIUM("sodium"); - - public final boolean isLoaded; - - CompatMods(String modId) { - isLoaded = FlwImplXplat.INSTANCE.isModLoaded(modId); - } -} diff --git a/common/src/main/java/dev/engine_room/flywheel/impl/compat/IrisCompat.java b/common/src/main/java/dev/engine_room/flywheel/impl/compat/IrisCompat.java index 97fc5f5e5..7f6500536 100644 --- a/common/src/main/java/dev/engine_room/flywheel/impl/compat/IrisCompat.java +++ b/common/src/main/java/dev/engine_room/flywheel/impl/compat/IrisCompat.java @@ -1,11 +1,10 @@ package dev.engine_room.flywheel.impl.compat; import dev.engine_room.flywheel.impl.FlwImpl; -import dev.engine_room.flywheel.impl.FlwImplXplat; import net.irisshaders.iris.api.v0.IrisApi; public final class IrisCompat { - public static final boolean ACTIVE = FlwImplXplat.INSTANCE.useIrisCompat(); + public static final boolean ACTIVE = CompatMod.IRIS.isLoaded; static { if (ACTIVE) { diff --git a/common/src/main/java/dev/engine_room/flywheel/impl/compat/SodiumCompat.java b/common/src/main/java/dev/engine_room/flywheel/impl/compat/SodiumCompat.java index 76fa1d499..9afe75a77 100644 --- a/common/src/main/java/dev/engine_room/flywheel/impl/compat/SodiumCompat.java +++ b/common/src/main/java/dev/engine_room/flywheel/impl/compat/SodiumCompat.java @@ -4,7 +4,6 @@ import dev.engine_room.flywheel.api.visualization.BlockEntityVisualizer; import dev.engine_room.flywheel.impl.FlwImpl; -import dev.engine_room.flywheel.impl.FlwImplXplat; import dev.engine_room.flywheel.lib.visualization.VisualizationHelper; import net.caffeinemc.mods.sodium.api.blockentity.BlockEntityRenderHandler; import net.caffeinemc.mods.sodium.api.blockentity.BlockEntityRenderPredicate; @@ -12,11 +11,11 @@ import net.minecraft.world.level.block.entity.BlockEntityType; public final class SodiumCompat { - public static final boolean USE_0_6_COMPAT = FlwImplXplat.INSTANCE.useSodium0_6Compat(); + public static final boolean ACTIVE = CompatMod.SODIUM.isLoaded; static { - if (USE_0_6_COMPAT) { - FlwImpl.LOGGER.debug("Detected Sodium 0.6"); + if (ACTIVE) { + FlwImpl.LOGGER.debug("Detected Sodium"); } } @@ -25,7 +24,7 @@ private SodiumCompat() { @Nullable public static Object onSetBlockEntityVisualizer(BlockEntityType type, @Nullable BlockEntityVisualizer oldVisualizer, @Nullable BlockEntityVisualizer newVisualizer, @Nullable Object predicate) { - if (!USE_0_6_COMPAT) { + if (!ACTIVE) { return null; } diff --git a/common/src/main/java/dev/engine_room/flywheel/impl/mixin/BlockEntityTypeMixin.java b/common/src/main/java/dev/engine_room/flywheel/impl/mixin/BlockEntityTypeMixin.java index 901c12957..c429dae95 100644 --- a/common/src/main/java/dev/engine_room/flywheel/impl/mixin/BlockEntityTypeMixin.java +++ b/common/src/main/java/dev/engine_room/flywheel/impl/mixin/BlockEntityTypeMixin.java @@ -5,7 +5,6 @@ import org.spongepowered.asm.mixin.Unique; import dev.engine_room.flywheel.api.visualization.BlockEntityVisualizer; -import dev.engine_room.flywheel.impl.compat.CompatMods; import dev.engine_room.flywheel.impl.compat.SodiumCompat; import dev.engine_room.flywheel.impl.extension.BlockEntityTypeExtension; import net.minecraft.world.level.block.entity.BlockEntity; @@ -29,7 +28,7 @@ abstract class BlockEntityTypeMixin implements BlockEntit @Override public void flywheel$setVisualizer(@Nullable BlockEntityVisualizer visualizer) { - if (SodiumCompat.USE_0_6_COMPAT) { + if (SodiumCompat.ACTIVE) { flywheel$sodiumPredicate = SodiumCompat.onSetBlockEntityVisualizer((BlockEntityType) (Object) this, flywheel$visualizer, visualizer, flywheel$sodiumPredicate); } diff --git a/common/src/stubs/java/net/caffeinemc/mods/sodium/api/blockentity/BlockEntityRenderHandler.java b/common/src/stubs/java/net/caffeinemc/mods/sodium/api/blockentity/BlockEntityRenderHandler.java deleted file mode 100644 index 5c4a588d7..000000000 --- a/common/src/stubs/java/net/caffeinemc/mods/sodium/api/blockentity/BlockEntityRenderHandler.java +++ /dev/null @@ -1,38 +0,0 @@ -// https://github.com/CaffeineMC/sodium-fabric/blob/e7643f4544f61180ed2f0ff4952d7daa2c1feaf4/common/src/api/java/net/caffeinemc/mods/sodium/api/blockentity/BlockEntityRenderHandler.java -// PolyForm Shield License 1.0.0 - -package net.caffeinemc.mods.sodium.api.blockentity; - -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.entity.BlockEntityType; -import org.jetbrains.annotations.ApiStatus; - -@ApiStatus.Experimental -@ApiStatus.AvailableSince("0.6.0") -public interface BlockEntityRenderHandler { - BlockEntityRenderHandler INSTANCE = null; - - static BlockEntityRenderHandler instance() { - return INSTANCE; - } - - /** - * Adds a predicate to determine if a block entity should be rendered. - * - *

Upon chunk bake, block entities of the given type will have {@code shouldRender} evaluated. - *
If all predicates returns {@code true} (and the block entity has a renderer), the block entity will be - * added to the chunk for future rendering.

- * @param type The block entity type to associate the given predicate with. - * @param shouldRender The predicate for the block entity to evaluate. - */ - void addRenderPredicate(BlockEntityType type, BlockEntityRenderPredicate shouldRender); - - /** - * Removes a predicate added by {@code addRenderPredicate}. It must be the same object that was added. - * - * @param type The block entity type to associate the given predicate with. - * @param shouldRender The predicate to remove. - * @return If the predicate existed and was removed. - */ - boolean removeRenderPredicate(BlockEntityType type, BlockEntityRenderPredicate shouldRender); -} diff --git a/common/src/stubs/java/net/caffeinemc/mods/sodium/api/blockentity/BlockEntityRenderPredicate.java b/common/src/stubs/java/net/caffeinemc/mods/sodium/api/blockentity/BlockEntityRenderPredicate.java deleted file mode 100644 index 8734005f2..000000000 --- a/common/src/stubs/java/net/caffeinemc/mods/sodium/api/blockentity/BlockEntityRenderPredicate.java +++ /dev/null @@ -1,16 +0,0 @@ -// https://github.com/CaffeineMC/sodium-fabric/blob/e7643f4544f61180ed2f0ff4952d7daa2c1feaf4/common/src/api/java/net/caffeinemc/mods/sodium/api/blockentity/BlockEntityRenderPredicate.java -// PolyForm Shield License 1.0.0 - -package net.caffeinemc.mods.sodium.api.blockentity; - -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.block.entity.BlockEntity; -import org.jetbrains.annotations.ApiStatus; - -@ApiStatus.Experimental -@ApiStatus.AvailableSince("0.6.0") -@FunctionalInterface -public interface BlockEntityRenderPredicate { - boolean shouldRender(BlockGetter blockGetter, BlockPos blockPos, T entity); -} diff --git a/common/src/stubs/java/net/irisshaders/iris/api/v0/IrisApi.java b/common/src/stubs/java/net/irisshaders/iris/api/v0/IrisApi.java deleted file mode 100644 index 571667e1c..000000000 --- a/common/src/stubs/java/net/irisshaders/iris/api/v0/IrisApi.java +++ /dev/null @@ -1,114 +0,0 @@ -// https://github.com/IrisShaders/Iris/blob/20be7fc1ff8a48048cb4eb787e1299782bb1caa4/src/main/java/net/irisshaders/iris/api/v0/IrisApi.java -// GNU Lesser General Public License v3.0 - -package net.irisshaders.iris.api.v0; - -/** - * The entry point to the Iris API, major version 0. This is currently the latest - * version of the API. - * - * To access the API, use {@link #getInstance()}. - */ -public interface IrisApi { - /** - * @since API v0.0 - */ - static IrisApi getInstance() { - return null; - } - - /** - * Gets the minor revision of this API. This is incremented when - * new methods are added without breaking API. Mods can check this - * if they wish to check whether given API calls are available on - * the currently installed Iris version. - * - * @return The current minor revision. Currently, revision 2. - */ - int getMinorApiRevision(); - - /** - * Checks whether a shader pack is currently in use and being used - * for rendering. If there is no shader pack enabled or a shader - * pack failed to compile and is therefore not in use, this will - * return false. - * - *

Mods that need to enable custom workarounds for shaders - * should use this method. - * - * @return Whether shaders are being used for rendering. - * @since {@link #getMinorApiRevision() API v0.0} - */ - boolean isShaderPackInUse(); - - /** - * Checks whether the shadow pass is currently being rendered. - * - *

Generally, mods won't need to call this function for much. - * Mods should be fine with things being rendered multiple times - * each frame from different camera perspectives. Often, there's - * a better approach to fixing bugs than calling this function. - * - *

Pretty much the main legitimate use for this function that - * I've seen is in a mod like Immersive Portals, where it has - * very custom culling that doesn't work when the Iris shadow - * pass is active. - * - *

Naturally, this function can only return true if - * {@link #isShaderPackInUse()} returns true. - * - * @return Whether Iris is currently rendering the shadow pass. - * @since API v0.0 - */ - boolean isRenderingShadowPass(); - - /** - * Opens the main Iris GUI screen. It's up to Iris to decide - * what this screen is, but generally this is the shader selection - * screen. - * - * This method takes and returns Objects instead of any concrete - * Minecraft screen class to avoid referencing Minecraft classes. - * Nevertheless, the passed parent must either be null, or an - * object that is a subclass of the appropriate {@code Screen} - * class for the given Minecraft version. - * - * @param parent The parent screen, an instance of the appropriate - * {@code Screen} class. - * @return A {@code Screen} class for the main Iris GUI screen. - * @since API v0.0 - */ - Object openMainIrisScreenObj(Object parent); - - /** - * Gets the language key of the main screen. Currently, this - * is "options.iris.shaderPackSelection". - * - * @return the language key, for use with {@code TranslatableText} - * / {@code TranslatableComponent} - * @since API v0.0 - */ - String getMainScreenLanguageKey(); - -// /** -// * Gets a config object that can edit the Iris configuration. -// * @since API v0.0 -// */ -// IrisApiConfig getConfig(); - -// /** -// * Gets a text vertex sink to render into. -// * @param maxQuadCount Maximum amount of quads that will be rendered with this sink -// * @param bufferProvider An IntFunction that can provide a {@code ByteBuffer} with at minimum the bytes provided by the input parameter -// * @since API 0.1 -// */ -// IrisTextVertexSink createTextVertexSink(int maxQuadCount, IntFunction bufferProvider); - - /** - * Gets the sun path rotation used by the current shader pack. - * - * @return The sun path rotation as specified by the shader pack, or 0 if no shader pack is in use. - * @since API v0.2 - */ - float getSunPathRotation(); -} diff --git a/fabric/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplatImpl.java b/fabric/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplatImpl.java index 8c2f7069d..65225906f 100644 --- a/fabric/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplatImpl.java +++ b/fabric/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplatImpl.java @@ -1,8 +1,6 @@ package dev.engine_room.flywheel.impl; import dev.engine_room.flywheel.api.event.ReloadLevelRendererCallback; -import dev.engine_room.flywheel.impl.compat.CompatMods; -import dev.engine_room.flywheel.impl.compat.FabricSodiumCompat; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.multiplayer.ClientLevel; @@ -26,14 +24,4 @@ public String getVersionStr() { public FlwConfig getConfig() { return FabricFlwConfig.INSTANCE; } - - @Override - public boolean useSodium0_6Compat() { - return FabricSodiumCompat.USE_0_6_COMPAT; - } - - @Override - public boolean useIrisCompat() { - return CompatMods.IRIS.isLoaded; - } } diff --git a/fabric/src/main/java/dev/engine_room/flywheel/impl/compat/FabricSodiumCompat.java b/fabric/src/main/java/dev/engine_room/flywheel/impl/compat/FabricSodiumCompat.java deleted file mode 100644 index 4a6ee1da4..000000000 --- a/fabric/src/main/java/dev/engine_room/flywheel/impl/compat/FabricSodiumCompat.java +++ /dev/null @@ -1,48 +0,0 @@ -package dev.engine_room.flywheel.impl.compat; - -import java.util.Optional; - -import dev.engine_room.flywheel.impl.FlwImpl; -import net.fabricmc.loader.api.FabricLoader; -import net.fabricmc.loader.api.ModContainer; -import net.fabricmc.loader.api.Version; -import net.fabricmc.loader.api.VersionParsingException; -import net.fabricmc.loader.api.metadata.version.VersionPredicate; - -public final class FabricSodiumCompat { - public static final boolean USE_0_5_COMPAT; - public static final boolean USE_0_6_COMPAT; - - static { - boolean use0_5Compat = false; - boolean use0_6Compat = false; - - Optional optionalModContainer = FabricLoader.getInstance().getModContainer(CompatMod.SODIUM.id); - - if (optionalModContainer.isPresent()) { - ModContainer modContainer = optionalModContainer.get(); - Version sodiumVersion = modContainer.getMetadata().getVersion(); - - try { - VersionPredicate predicate0_5 = VersionPredicate.parse("~0.5.0"); - VersionPredicate predicate0_6 = VersionPredicate.parse(">=0.6.0-beta.2"); - use0_5Compat = predicate0_5.test(sodiumVersion); - use0_6Compat = predicate0_6.test(sodiumVersion); - } catch (VersionParsingException e) { - FlwImpl.LOGGER.debug("Failed to parse Sodium version predicates", e); - } - } - - USE_0_5_COMPAT = use0_5Compat; - USE_0_6_COMPAT = use0_6Compat; - } - - static { - if (USE_0_5_COMPAT) { - FlwImpl.LOGGER.debug("Detected Sodium 0.5"); - } - } - - private FabricSodiumCompat() { - } -} diff --git a/forge/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplatImpl.java b/forge/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplatImpl.java index d27e2bb0b..151af23b0 100644 --- a/forge/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplatImpl.java +++ b/forge/src/main/java/dev/engine_room/flywheel/impl/FlwImplXplatImpl.java @@ -26,14 +26,4 @@ public String getVersionStr() { public FlwConfig getConfig() { return NeoForgeFlwConfig.INSTANCE; } - - @Override - public boolean useSodium0_6Compat() { - return CompatMod.SODIUM.isLoaded && !CompatMod.EMBEDDIUM.isLoaded; - } - - @Override - public boolean useIrisCompat() { - return CompatMod.IRIS.isLoaded || CompatMod.OCULUS.isLoaded; - } }