mirror of
https://github.com/wisplite/crystalline-sky.git
synced 2026-10-30 05:22:18 -05:00
Skybox X
neoforge sodium compat
This commit is contained in:
@@ -234,6 +234,7 @@ fun Project.setupRepositories() {
|
||||
exclusiveMaven("https://api.modrinth.com/maven", "maven.modrinth") // Axiom, Sodium
|
||||
exclusiveMaven("https://maven.terraformersmc.com/", "com.terraformersmc") // Mod Menu
|
||||
exclusiveMaven("https://maven.parchmentmc.org", "org.parchmentmc.data") // Parchment Mappings
|
||||
exclusiveMaven("https://maven.su5ed.dev/releases", "org.sinytra.forgified-fabric-api") // FFAPI, for NeoForge Sodium compat
|
||||
flatDir {
|
||||
dir("$rootDir/libs")
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,5 +1,6 @@
|
||||
package io.github.slimeistdev.crystalline_sky.compat.sodium;
|
||||
|
||||
import io.github.slimeistdev.crystalline_sky.mixin.client.TextureAtlasAccessor;
|
||||
import io.github.slimeistdev.crystalline_sky.registry.client.CrystallineAtlases;
|
||||
import io.github.slimeistdev.crystalline_sky.util.SharedRenderVariables;
|
||||
import net.caffeinemc.mods.sodium.client.gl.device.GLRenderDevice;
|
||||
@@ -7,7 +8,6 @@ import net.caffeinemc.mods.sodium.client.gl.shader.uniform.GlUniformFloat2v;
|
||||
import net.caffeinemc.mods.sodium.client.gl.shader.uniform.GlUniformMatrix4f;
|
||||
import net.caffeinemc.mods.sodium.client.render.chunk.shader.ChunkShaderOptions;
|
||||
import net.caffeinemc.mods.sodium.client.render.chunk.shader.ShaderBindingContext;
|
||||
import net.caffeinemc.mods.sodium.mixin.core.render.texture.TextureAtlasAccessor;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public class SkyboxShaderInterface extends SkyShaderInterface {
|
||||
@@ -29,8 +29,8 @@ public class SkyboxShaderInterface extends SkyShaderInterface {
|
||||
double subTexelPrecision = 1 << GLRenderDevice.INSTANCE.getSubTexelPrecisionBits();
|
||||
double subTexelOffset = 3.0517578E-5F;
|
||||
this.uniformTexCoordShrink.set(
|
||||
(float) (subTexelOffset - (double) 1.0F / (double) textureAtlas.getField_43113() / subTexelPrecision),
|
||||
(float) (subTexelOffset - (double) 1.0F / (double) textureAtlas.getField_43114() / subTexelPrecision)
|
||||
(float) (subTexelOffset - (double) 1.0F / (double) textureAtlas.crystalline_sky$getWidth() / subTexelPrecision),
|
||||
(float) (subTexelOffset - (double) 1.0F / (double) textureAtlas.crystalline_sky$getHeight() / subTexelPrecision)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package io.github.slimeistdev.crystalline_sky.mixin.client;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(TextureAtlas.class)
|
||||
public interface TextureAtlasAccessor {
|
||||
@Accessor("width")
|
||||
int crystalline_sky$getWidth();
|
||||
|
||||
@Accessor("height")
|
||||
int crystalline_sky$getHeight();
|
||||
}
|
||||
@@ -24,6 +24,7 @@
|
||||
"client.LevelRendererMixin",
|
||||
"client.ModelBlockRendererMixin",
|
||||
"client.RenderTargetMixin",
|
||||
"client.TextureAtlasAccessor",
|
||||
"client.compat.iris.ExtendedShaderMixin",
|
||||
"client.compat.iris.IrisRenderingPipelineAccessor",
|
||||
"client.compat.iris.IrisRenderingPipelineMixin",
|
||||
|
||||
+1
-1
@@ -26,6 +26,6 @@ modVersion=0.1.2
|
||||
compatibleVersions=1.21.1
|
||||
|
||||
# mod compat
|
||||
enable_sodium=false
|
||||
enable_sodium=true
|
||||
enable_iris=false
|
||||
enable_axiom=false
|
||||
|
||||
@@ -8,6 +8,7 @@ mc = "1.21.1"
|
||||
parchment = "2024.11.17"
|
||||
fl = "0.18.6"
|
||||
fapi = "0.116.10+1.21.1"
|
||||
ffapi-renderer = "3.4.1+9125b6dc19"
|
||||
nf = "21.1.215"
|
||||
jsr305 = "3.0.2"
|
||||
mixinextras = "0.5.0"
|
||||
@@ -34,6 +35,7 @@ parchment = { group = "org.parchmentmc.data", name = "parchment-1.21.1", version
|
||||
|
||||
fl = { group = "net.fabricmc", name = "fabric-loader", version.ref = "fl" }
|
||||
fapi = { group = "net.fabricmc.fabric-api", name = "fabric-api", version.ref = "fapi" }
|
||||
ffapi-renderer = { group = "org.sinytra.forgified-fabric-api", name = "fabric-renderer-api-v1", version.ref = "ffapi-renderer" }
|
||||
|
||||
nf = { group = "net.neoforged", name = "neoforge", version.ref = "nf" }
|
||||
|
||||
|
||||
@@ -16,15 +16,17 @@ repositories {
|
||||
name = "NeoForged"
|
||||
url = uri("https://maven.neoforged.net/releases")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
neoForge(libs.nf)
|
||||
|
||||
modCompileOnly(libs.ffapi.renderer) // only for sodium compat
|
||||
modCompileOnly(libs.sodium.neoforge)
|
||||
/*if (!inCI && "enable_sodium"().toBoolean()) { // this doesn't work, because of jar-in-jar
|
||||
if (!inCI && "enable_sodium"().toBoolean()) { // this doesn't work, because of jar-in-jar
|
||||
modLocalRuntime(libs.sodium.neoforge)
|
||||
}*/
|
||||
}
|
||||
|
||||
modCompileOnly(libs.iris.neoforge)
|
||||
if (!inCI && "enable_iris"().toBoolean()) { // this doesn't work, because of jar-in-jar
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package io.github.slimeistdev.crystalline_sky.neoforge.mixin.client.compat.sodium;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import io.github.slimeistdev.crystalline_sky.CrystallineSky;
|
||||
import io.github.slimeistdev.crystalline_sky.annotation.mixin.ConditionalMixin;
|
||||
import io.github.slimeistdev.crystalline_sky.compat.Mods;
|
||||
import net.caffeinemc.mods.sodium.client.gl.shader.ShaderLoader;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
@ConditionalMixin(mods = Mods.SODIUM)
|
||||
@Mixin(ShaderLoader.class)
|
||||
public class ShaderLoaderMixin {
|
||||
// thank you neoforge for making mods be in separate modules
|
||||
@SuppressWarnings("NameDoesntMatchTargetClass")
|
||||
@WrapOperation(method = "getShaderSource", at = @At(value = "INVOKE", target = "Ljava/lang/Class;getResourceAsStream(Ljava/lang/String;)Ljava/io/InputStream;"))
|
||||
private static InputStream getShadersInProperContext(Class<?> instance, String name, Operation<InputStream> original, ResourceLocation name$) {
|
||||
if (name$.getNamespace().equals(CrystallineSky.ID))
|
||||
return original.call(CrystallineSky.class, name);
|
||||
|
||||
return original.call(instance, name);
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package io.github.slimeistdev.crystalline_sky.neoforge.mixin.client.compat.sodium;
|
||||
|
||||
import io.github.slimeistdev.crystalline_sky.annotation.mixin.ConditionalMixin;
|
||||
import io.github.slimeistdev.crystalline_sky.compat.Mods;
|
||||
import io.github.slimeistdev.crystalline_sky.neoforge.skybox_model.SkyboxBakedModel;
|
||||
import io.github.slimeistdev.crystalline_sky.util.SharedRenderVariables;
|
||||
import net.caffeinemc.mods.sodium.client.render.frapi.render.AbstractBlockRenderContext;
|
||||
import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel;
|
||||
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@ConditionalMixin(mods = Mods.SODIUM)
|
||||
@Mixin(SkyboxBakedModel.class)
|
||||
public class SkyboxBakedModelMixin implements FabricBakedModel {
|
||||
@Override
|
||||
public void emitBlockQuads(BlockAndTintGetter blockView, BlockState state, BlockPos pos, Supplier<RandomSource> randomSupplier, RenderContext context) {
|
||||
SharedRenderVariables.pushShadeFullBright();
|
||||
((AbstractBlockRenderContext) context).bufferDefaultModel((BakedModel) this, state);
|
||||
SharedRenderVariables.popShadeFullBright();
|
||||
}
|
||||
}
|
||||
+1
-7
@@ -1,6 +1,5 @@
|
||||
package io.github.slimeistdev.crystalline_sky.neoforge.skybox_model;
|
||||
|
||||
import io.github.slimeistdev.crystalline_sky.util.SharedRenderVariables;
|
||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
@@ -84,13 +83,8 @@ public class SkyboxBakedModel<T extends BakedModel> extends BakedModelWrapper<T>
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, RandomSource rand) {
|
||||
CacheKey key = new CacheKey(state, side);
|
||||
return quadCache.computeIfAbsent(key, $ -> {
|
||||
SharedRenderVariables.pushShadeFullBright();
|
||||
|
||||
List<BakedQuad> quads = super.getQuads(state, side, rand);
|
||||
List<BakedQuad> out = process(quads);
|
||||
|
||||
SharedRenderVariables.popShadeFullBright();
|
||||
return out;
|
||||
return process(quads);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
"mixins": [
|
||||
],
|
||||
"client": [
|
||||
"client.RenderTypeMixin"
|
||||
"client.RenderTypeMixin",
|
||||
"client.compat.sodium.ShaderLoaderMixin",
|
||||
"client.compat.sodium.SkyboxBakedModelMixin"
|
||||
],
|
||||
"server": [
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user