Merge branch 'main' of gitlab.com:jeseibel/minecraft-lod-mod
This commit is contained in:
@@ -26,7 +26,10 @@ import com.seibel.lod.core.config.Config;
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import com.seibel.lod.common.wrappers.chunk.ChunkWrapper;
|
||||
|
||||
import com.seibel.lod.core.dependencyInjection.ModAccessorInjector;
|
||||
import com.seibel.lod.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.ISodiumAccessor;
|
||||
import com.seibel.lod.wrappers.modAccessor.SodiumAccessor;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientChunkEvents;
|
||||
@@ -98,13 +101,22 @@ public class FabricClientProxy
|
||||
// RendererStartupEvent - Done in MixinGameRenderer
|
||||
// RendererShutdownEvent - Done in MixinGameRenderer
|
||||
|
||||
SodiumAccessor sodiumAccessor = (SodiumAccessor) ModAccessorInjector.INSTANCE.get(ISodiumAccessor.class);
|
||||
|
||||
// ClientRenderLevelTerrainEvent
|
||||
WorldRenderEvents.AFTER_SETUP.register((renderContext) ->
|
||||
clientApi.renderLods(ClientLevelWrapper.getWrapper(renderContext.world()),
|
||||
McObjectConverter.Convert(renderContext.matrixStack().last().pose()),
|
||||
McObjectConverter.Convert(renderContext.projectionMatrix()),
|
||||
renderContext.tickDelta())
|
||||
WorldRenderEvents.AFTER_SETUP.register((renderContext) -> {
|
||||
if (sodiumAccessor != null) {
|
||||
sodiumAccessor.levelWrapper = ClientLevelWrapper.getWrapper(renderContext.world());
|
||||
sodiumAccessor.mcModelViewMatrix = McObjectConverter.Convert(renderContext.matrixStack().last().pose());
|
||||
sodiumAccessor.mcProjectionMatrix = McObjectConverter.Convert(renderContext.projectionMatrix());
|
||||
sodiumAccessor.partialTicks = renderContext.tickDelta();
|
||||
} else {
|
||||
clientApi.renderLods(ClientLevelWrapper.getWrapper(renderContext.world()),
|
||||
McObjectConverter.Convert(renderContext.matrixStack().last().pose()),
|
||||
McObjectConverter.Convert(renderContext.projectionMatrix()),
|
||||
renderContext.tickDelta());
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Debug keyboard event
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.seibel.lod;
|
||||
|
||||
import com.seibel.lod.core.dependencyInjection.ModAccessorInjector;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.ISodiumAccessor;
|
||||
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 FabricMixinPlugin implements IMixinConfigPlugin {
|
||||
|
||||
@Override
|
||||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
|
||||
if (mixinClassName.startsWith("mods.sodium")) {
|
||||
return ModAccessorInjector.INSTANCE.get(ISodiumAccessor.class) != null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onLoad(String mixinPackage) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRefMapperConfig() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@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) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.seibel.lod.mixins.mods.sodium;
|
||||
|
||||
import com.seibel.lod.core.api.internal.ClientApi;
|
||||
import com.seibel.lod.core.dependencyInjection.ModAccessorInjector;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.ISodiumAccessor;
|
||||
import com.seibel.lod.wrappers.modAccessor.SodiumAccessor;
|
||||
import me.jellysquid.mods.sodium.client.gl.device.CommandList;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.ChunkCameraContext;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.ChunkRenderList;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.ChunkRenderMatrices;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.RegionChunkRenderer;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.passes.BlockRenderPass;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(RegionChunkRenderer.class)
|
||||
public class MixinSodiumChunkRenderer {
|
||||
@Unique SodiumAccessor accessor = null;
|
||||
@Inject(remap = false, method = "render", at = @At(value = "INVOKE", target = "Lme/jellysquid/mods/sodium/client/render/chunk/ShaderChunkRenderer;begin(Lme/jellysquid/mods/sodium/client/render/chunk/passes/BlockRenderPass;)V", shift = At.Shift.AFTER))
|
||||
private void injectDHLoDRendering(ChunkRenderMatrices matrices, CommandList commandList, ChunkRenderList list, BlockRenderPass pass, ChunkCameraContext camera, CallbackInfo ci) {
|
||||
if (accessor == null) {
|
||||
accessor = (SodiumAccessor)ModAccessorInjector.INSTANCE.get(ISodiumAccessor.class);
|
||||
}
|
||||
if (pass.equals(BlockRenderPass.SOLID)) {
|
||||
//TODO: use matrices.modelView() and matrices.projection() instead of
|
||||
// SodiumAccessor.mcModelViewMatrix,
|
||||
// SodiumAccessor.mcProjectionMatrix,
|
||||
ClientApi.INSTANCE.renderLods(accessor.levelWrapper,
|
||||
accessor.mcModelViewMatrix,
|
||||
accessor.mcProjectionMatrix,
|
||||
accessor.partialTicks);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,11 +24,13 @@ import java.util.stream.Collectors;
|
||||
|
||||
import com.seibel.lod.core.pos.DhChunkPos;
|
||||
import com.seibel.lod.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.lod.core.util.math.Mat4f;
|
||||
import com.seibel.lod.core.wrapperInterfaces.IWrapperFactory;
|
||||
import com.seibel.lod.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.modAccessor.ISodiumAccessor;
|
||||
|
||||
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||
import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
#if PRE_MC_1_17_1
|
||||
@@ -46,6 +48,11 @@ public class SodiumAccessor implements ISodiumAccessor {
|
||||
private final IWrapperFactory factory = SingletonInjector.INSTANCE.get(IWrapperFactory.class);
|
||||
private final IMinecraftRenderWrapper MC_RENDER = SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class);
|
||||
|
||||
public IClientLevelWrapper levelWrapper;
|
||||
public Mat4f mcModelViewMatrix;
|
||||
public Mat4f mcProjectionMatrix;
|
||||
public float partialTicks;
|
||||
|
||||
@Override
|
||||
public String getModName() {
|
||||
return "Sodium-Fabric";
|
||||
|
||||
@@ -17,9 +17,11 @@
|
||||
"client.MixinLevelRenderer",
|
||||
"client.MixinLightmap",
|
||||
"client.MixinOptionsScreen",
|
||||
"client.MixinMinecraft"
|
||||
"client.MixinMinecraft",
|
||||
"mods.sodium.MixinSodiumChunkRenderer"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
},
|
||||
"plugin": "com.seibel.lod.FabricMixinPlugin"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user