mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-23 03:17:53 +01:00
Add sodium 0.6 compat
This commit is contained in:
parent
42290b207f
commit
fc61ff1c98
18 changed files with 63 additions and 181 deletions
|
@ -89,6 +89,9 @@ class SubprojectPlugin: Plugin<Project> {
|
|||
includeGroup("maven.modrinth")
|
||||
}
|
||||
}
|
||||
flatDir {
|
||||
dirs = setOf(project.rootProject.file("libs"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,6 +72,8 @@ jarSets {
|
|||
dependencies {
|
||||
modCompileOnly("net.fabricmc:fabric-loader:${property("fabric_loader_version")}")
|
||||
|
||||
modCompileOnly(":sodium-fabric-0.6.0-beta.2+mc1.21.1")
|
||||
|
||||
testImplementation("org.junit.jupiter:junit-jupiter:5.8.1")
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package dev.engine_room.flywheel.impl.compat;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.google.common.base.Suppliers;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
|
||||
public enum CompatMods {
|
||||
SODIUM,
|
||||
EMBEDDIUM;
|
||||
|
||||
private final Supplier<Boolean> isLoaded;
|
||||
|
||||
CompatMods() {
|
||||
isLoaded = Suppliers.memoize(() -> FabricLoader.getInstance().isModLoaded(name()));
|
||||
}
|
||||
|
||||
public boolean isLoaded() {
|
||||
return isLoaded.get();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package dev.engine_room.flywheel.impl.compat;
|
||||
|
||||
import dev.engine_room.flywheel.lib.visualization.VisualizationHelper;
|
||||
import net.caffeinemc.mods.sodium.api.blockentity.BlockEntityRenderHandler;
|
||||
import net.caffeinemc.mods.sodium.api.blockentity.BlockEntityRenderPredicate;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
|
||||
public class SodiumCompat {
|
||||
public static <T extends BlockEntity> Object forBlockEntityType(BlockEntityType<T> type) {
|
||||
BlockEntityRenderPredicate<T> predicate = (getter, pos, be) -> VisualizationHelper.tryAddBlockEntity(be);
|
||||
BlockEntityRenderHandler.instance().addRenderPredicate(type, predicate);
|
||||
return predicate;
|
||||
}
|
||||
|
||||
public static <T extends BlockEntity> void removePredicate(BlockEntityType<T> type, Object predicate) {
|
||||
BlockEntityRenderHandler.instance().removeRenderPredicate(type, (BlockEntityRenderPredicate<T>) predicate);
|
||||
}
|
||||
}
|
|
@ -5,6 +5,8 @@ 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;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
|
@ -12,8 +14,13 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
|
|||
@Mixin(BlockEntityType.class)
|
||||
abstract class BlockEntityTypeMixin<T extends BlockEntity> implements BlockEntityTypeExtension<T> {
|
||||
@Unique
|
||||
@Nullable
|
||||
private BlockEntityVisualizer<? super T> flywheel$visualizer;
|
||||
|
||||
@Unique
|
||||
@Nullable
|
||||
private Object flywheel$sodiumPredicate;
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public BlockEntityVisualizer<? super T> flywheel$getVisualizer() {
|
||||
|
@ -22,6 +29,13 @@ abstract class BlockEntityTypeMixin<T extends BlockEntity> implements BlockEntit
|
|||
|
||||
@Override
|
||||
public void flywheel$setVisualizer(@Nullable BlockEntityVisualizer<? super T> visualizer) {
|
||||
if (CompatMods.SODIUM.isLoaded() && !CompatMods.EMBEDDIUM.isLoaded()) {
|
||||
if (flywheel$visualizer == null && visualizer != null) {
|
||||
flywheel$sodiumPredicate = SodiumCompat.forBlockEntityType((BlockEntityType<?>) (Object) this);
|
||||
} else if (flywheel$visualizer != null && visualizer == null && flywheel$sodiumPredicate != null) {
|
||||
SodiumCompat.removePredicate((BlockEntityType<?>) (Object) this, flywheel$sodiumPredicate);
|
||||
}
|
||||
}
|
||||
this.flywheel$visualizer = visualizer;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ dependencies {
|
|||
modImplementation("net.fabricmc:fabric-loader:${property("fabric_loader_version")}")
|
||||
modApi("net.fabricmc.fabric-api:fabric-api:${property("fabric_api_version")}")
|
||||
|
||||
modCompileOnly("maven.modrinth:sodium:${property("sodium_version")}-fabric")
|
||||
modCompileOnly(":sodium-fabric-0.6.0-beta.2+mc1.21.1")
|
||||
modCompileOnly("maven.modrinth:iris:${property("iris_version")}-fabric")
|
||||
|
||||
"forApi"(project(path = ":common", configuration = "commonApiOnly"))
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
package dev.engine_room.flywheel.impl.mixin.sodium;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import dev.engine_room.flywheel.lib.visualization.VisualizationHelper;
|
||||
import net.caffeinemc.mods.sodium.client.render.chunk.compile.tasks.ChunkBuilderMeshingTask;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
||||
@Mixin(value = ChunkBuilderMeshingTask.class, remap = false)
|
||||
abstract class ChunkBuilderMeshingTaskMixin {
|
||||
@Redirect(method = "execute(Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildContext;Lnet/caffeinemc/mods/sodium/client/util/task/CancellationToken;)Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildOutput;", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/blockentity/BlockEntityRenderDispatcher;getRenderer(Lnet/minecraft/world/level/block/entity/BlockEntity;)Lnet/minecraft/client/renderer/blockentity/BlockEntityRenderer;", remap = true))
|
||||
private BlockEntityRenderer<?> flywheel$redirectGetRenderer(BlockEntityRenderDispatcher dispatcher, BlockEntity blockEntity) {
|
||||
if (VisualizationHelper.tryAddBlockEntity(blockEntity)) {
|
||||
return null;
|
||||
}
|
||||
return dispatcher.getRenderer(blockEntity);
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
package dev.engine_room.flywheel.impl.mixin.sodium;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||
|
||||
import com.google.common.base.Suppliers;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
|
||||
public class SodiumMixinPlugin implements IMixinConfigPlugin {
|
||||
private static final Supplier<Boolean> IS_SODIUM_LOADED = Suppliers.memoize(() -> FabricLoader.getInstance().isModLoaded("sodium"));
|
||||
|
||||
@Override
|
||||
public void onLoad(String mixinPackage) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRefMapperConfig() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
|
||||
return IS_SODIUM_LOADED.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMixins() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||
}
|
||||
}
|
|
@ -24,7 +24,6 @@
|
|||
"mixins": [
|
||||
"flywheel.backend.mixins.json",
|
||||
"flywheel.impl.mixins.json",
|
||||
"flywheel.impl.sodium.mixins.json",
|
||||
"flywheel.impl.fabric.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
|
@ -32,6 +31,6 @@
|
|||
"fabric-api": "${fabric_api_version_range}"
|
||||
},
|
||||
"breaks": {
|
||||
"sodium": "<0.5.0"
|
||||
"sodium": ["<0.6.0-beta.2"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "dev.engine_room.flywheel.impl.mixin.sodium",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"refmap": "flywheel.refmap.json",
|
||||
"plugin": "dev.engine_room.flywheel.impl.mixin.sodium.SodiumMixinPlugin",
|
||||
"client": [
|
||||
"ChunkBuilderMeshingTaskMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
|
@ -67,12 +67,6 @@ loom {
|
|||
add(backend, "backend-flywheel.refmap.json")
|
||||
}
|
||||
|
||||
forge {
|
||||
mixinConfig("flywheel.backend.mixins.json")
|
||||
mixinConfig("flywheel.impl.mixins.json")
|
||||
mixinConfig("flywheel.impl.sodium.mixins.json")
|
||||
}
|
||||
|
||||
runs {
|
||||
configureEach {
|
||||
property("forge.logging.markers", "")
|
||||
|
@ -88,7 +82,7 @@ repositories {
|
|||
dependencies {
|
||||
neoForge("net.neoforged:neoforge:${property("neoforge_version")}")
|
||||
|
||||
modCompileOnly("maven.modrinth:sodium:${property("sodium_version")}-neoforge")
|
||||
modCompileOnly(":sodium-neoforge-0.6.0-beta.2+mc1.21.1")
|
||||
modCompileOnly("maven.modrinth:iris:${property("iris_version")}-neoforge")
|
||||
|
||||
//modCompileOnly("maven.modrinth:embeddium:${property("embeddium_version")}")
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
package dev.engine_room.flywheel.impl.mixin.sodium;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import dev.engine_room.flywheel.lib.visualization.VisualizationHelper;
|
||||
import net.caffeinemc.mods.sodium.client.render.chunk.compile.tasks.ChunkBuilderMeshingTask;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
||||
@Mixin(value = ChunkBuilderMeshingTask.class, remap = false)
|
||||
abstract class ChunkBuilderMeshingTaskMixin {
|
||||
@Redirect(method = "execute(Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildContext;Lnet/caffeinemc/mods/sodium/client/util/task/CancellationToken;)Lnet/caffeinemc/mods/sodium/client/render/chunk/compile/ChunkBuildOutput;", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/blockentity/BlockEntityRenderDispatcher;getRenderer(Lnet/minecraft/world/level/block/entity/BlockEntity;)Lnet/minecraft/client/renderer/blockentity/BlockEntityRenderer;", remap = true))
|
||||
private BlockEntityRenderer<?> flywheel$redirectGetRenderer(BlockEntityRenderDispatcher dispatcher, BlockEntity blockEntity) {
|
||||
if (VisualizationHelper.tryAddBlockEntity(blockEntity)) {
|
||||
return null;
|
||||
}
|
||||
return dispatcher.getRenderer(blockEntity);
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
package dev.engine_room.flywheel.impl.mixin.sodium;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||
|
||||
import com.google.common.base.Suppliers;
|
||||
|
||||
import net.neoforged.fml.loading.LoadingModList;
|
||||
|
||||
public class SodiumMixinPlugin implements IMixinConfigPlugin {
|
||||
private static final Supplier<Boolean> IS_SODIUM_LOADED = Suppliers.memoize(() -> LoadingModList.get().getModFileById("sodium") != null);
|
||||
|
||||
@Override
|
||||
public void onLoad(String mixinPackage) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRefMapperConfig() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
|
||||
return IS_SODIUM_LOADED.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMixins() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||
}
|
||||
}
|
|
@ -18,8 +18,6 @@ displayTest = "IGNORE_ALL_VERSION"
|
|||
config = "flywheel.backend.mixins.json"
|
||||
[[mixins]]
|
||||
config = "flywheel.impl.mixins.json"
|
||||
[[mixins]]
|
||||
config = "flywheel.impl.sodium.mixins.json"
|
||||
|
||||
[[dependencies.${mod_id}]]
|
||||
modId = "minecraft"
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "dev.engine_room.flywheel.impl.mixin.sodium",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"refmap": "flywheel.refmap.json",
|
||||
"plugin": "dev.engine_room.flywheel.impl.mixin.sodium.SodiumMixinPlugin",
|
||||
"client": [
|
||||
"ChunkBuilderMeshingTaskMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
|
@ -20,7 +20,6 @@ neoforge_version_range = [21.0.167,)
|
|||
# General build dependency versions
|
||||
java_version = 21
|
||||
arch_loom_version=1.7.412
|
||||
cursegradle_version = 1.4.0
|
||||
parchment_version = 2024.07.07
|
||||
|
||||
# Minecraft build dependency versions
|
||||
|
|
BIN
libs/sodium-fabric-0.6.0-beta.2+mc1.21.1.jar
Normal file
BIN
libs/sodium-fabric-0.6.0-beta.2+mc1.21.1.jar
Normal file
Binary file not shown.
BIN
libs/sodium-neoforge-0.6.0-beta.2+mc1.21.1.jar
Normal file
BIN
libs/sodium-neoforge-0.6.0-beta.2+mc1.21.1.jar
Normal file
Binary file not shown.
Loading…
Reference in a new issue