mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-23 03:17:53 +01:00
Twas a snowy night full of scripting the builds
- Post merge fixes - Remove stubs
This commit is contained in:
parent
ad938399b4
commit
d881ba5302
13 changed files with 7 additions and 267 deletions
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -13,8 +13,4 @@ public interface FlwImplXplat {
|
|||
String getVersionStr();
|
||||
|
||||
FlwConfig getConfig();
|
||||
|
||||
boolean useSodium0_6Compat();
|
||||
|
||||
boolean useIrisCompat();
|
||||
}
|
||||
|
|
|
@ -3,9 +3,7 @@ package dev.engine_room.flywheel.impl.compat;
|
|||
import dev.engine_room.flywheel.impl.FlwImplXplat;
|
||||
|
||||
public enum CompatMod {
|
||||
EMBEDDIUM("embeddium"),
|
||||
IRIS("iris"),
|
||||
OCULUS("oculus"),
|
||||
SODIUM("sodium");
|
||||
|
||||
public final String id;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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) {
|
||||
|
|
|
@ -4,7 +4,6 @@ import org.jetbrains.annotations.Nullable;
|
|||
|
||||
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.BlockEntity;
|
|||
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 @@ public final class SodiumCompat {
|
|||
|
||||
@Nullable
|
||||
public static <T extends BlockEntity> Object onSetBlockEntityVisualizer(BlockEntityType<T> type, @Nullable BlockEntityVisualizer<? super T> oldVisualizer, @Nullable BlockEntityVisualizer<? super T> newVisualizer, @Nullable Object predicate) {
|
||||
if (!USE_0_6_COMPAT) {
|
||||
if (!ACTIVE) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import org.spongepowered.asm.mixin.Mixin;
|
|||
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<T extends BlockEntity> implements BlockEntit
|
|||
|
||||
@Override
|
||||
public void flywheel$setVisualizer(@Nullable BlockEntityVisualizer<? super T> visualizer) {
|
||||
if (SodiumCompat.USE_0_6_COMPAT) {
|
||||
if (SodiumCompat.ACTIVE) {
|
||||
flywheel$sodiumPredicate = SodiumCompat.onSetBlockEntityVisualizer((BlockEntityType<T>) (Object) this, flywheel$visualizer, visualizer, flywheel$sodiumPredicate);
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* <p>Upon chunk bake, block entities of the given type will have {@code shouldRender} evaluated.
|
||||
* <br>If <b>all predicates</b> returns {@code true} (and the block entity has a renderer), the block entity will be
|
||||
* added to the chunk for future rendering.</p>
|
||||
* @param type The block entity type to associate the given predicate with.
|
||||
* @param shouldRender The predicate for the block entity to evaluate.
|
||||
*/
|
||||
<T extends BlockEntity> void addRenderPredicate(BlockEntityType<T> type, BlockEntityRenderPredicate<T> shouldRender);
|
||||
|
||||
/**
|
||||
* Removes a predicate added by {@code addRenderPredicate}. <b>It must be the same object that was added.</b>
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
<T extends BlockEntity> boolean removeRenderPredicate(BlockEntityType<T> type, BlockEntityRenderPredicate<T> shouldRender);
|
||||
}
|
|
@ -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<T extends BlockEntity> {
|
||||
boolean shouldRender(BlockGetter blockGetter, BlockPos blockPos, T entity);
|
||||
}
|
|
@ -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.
|
||||
*
|
||||
* <p>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.
|
||||
*
|
||||
* <p>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.
|
||||
*
|
||||
* <p>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.
|
||||
*
|
||||
* <p>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<ByteBuffer> 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();
|
||||
}
|
|
@ -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 class FlwImplXplatImpl implements FlwImplXplat {
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ModContainer> 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() {
|
||||
}
|
||||
}
|
|
@ -26,14 +26,4 @@ public class FlwImplXplatImpl implements FlwImplXplat {
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue