Fix Sodium block entity support (#108)

* Fix Sodium block entity support

* Fix production remapping

* Make sodium modCompileOnly

* Finalize Sodium compatibility

- Improve mixin to redirect getting of renderer instead of adding of
block entity
- Move mixins from mixin.sodium to fabric.mixin.sodium
- Remove Joml dependency

Co-authored-by: PepperCode1 <44146161+PepperCode1@users.noreply.github.com>
This commit is contained in:
IMS 2022-02-03 19:49:24 -08:00 committed by GitHub
parent e48ecccf32
commit bbc5cc60bf
Failed to generate hash of commit
5 changed files with 87 additions and 1 deletions

View file

@ -58,6 +58,7 @@ dependencies {
modCompileOnly 'curse.maven:starlight-521783:3554912'
modCompileOnly 'maven.modrinth:iris:1.18.x-v1.1.4'
modCompileOnly 'maven.modrinth:sodium:mc1.18.1-0.4.0-alpha6'
implementation 'com.google.code.findbugs:jsr305:3.0.2'
modCompileOnly 'maven.modrinth:indium:1.0.2-alpha1+mc1.18'

View file

@ -0,0 +1,29 @@
package com.jozufozu.flywheel.fabric.mixin.sodium;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher;
import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
import me.jellysquid.mods.sodium.client.render.chunk.tasks.ChunkRenderRebuildTask;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.world.level.block.entity.BlockEntity;
@Mixin(value = ChunkRenderRebuildTask.class, remap = false)
public class ChunkRenderRebuildTaskMixin {
@Redirect(method = "performBuild", 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;"))
private BlockEntityRenderer<?> redirectGetRenderer(BlockEntityRenderDispatcher dispatcher, BlockEntity blockEntity) {
if (Backend.canUseInstancing(blockEntity.getLevel())) {
if (InstancedRenderRegistry.canInstance(blockEntity.getType()))
InstancedRenderDispatcher.getBlockEntities(blockEntity.getLevel()).queueAdd(blockEntity);
if (InstancedRenderRegistry.shouldSkipRender(blockEntity))
return null;
}
return dispatcher.getRenderer(blockEntity);
}
}

View file

@ -0,0 +1,42 @@
package com.jozufozu.flywheel.fabric.mixin.sodium;
import net.fabricmc.loader.api.FabricLoader;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
import java.util.List;
import java.util.Set;
public class SodiumMixinPlugin implements IMixinConfigPlugin {
@Override
public void onLoad(String mixinPackage) {
}
@Override
public String getRefMapperConfig() {
return null;
}
@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
return FabricLoader.getInstance().isModLoaded("sodium");
}
@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) {
}
}

View file

@ -26,7 +26,8 @@
},
"mixins": [
"flywheel.mixins.json",
"flywheel.fabric.mixins.json"
"flywheel.fabric.mixins.json",
"flywheel.sodium.mixins.json"
],
"depends": {

View file

@ -0,0 +1,13 @@
{
"required": true,
"minVersion": "0.8",
"package": "com.jozufozu.flywheel.fabric.mixin.sodium",
"plugin": "com.jozufozu.flywheel.fabric.mixin.sodium.SodiumMixinPlugin",
"compatibilityLevel": "JAVA_17",
"client": [
"ChunkRenderRebuildTaskMixin"
],
"injectors": {
"defaultRequire": 1
}
}