Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove legacy Iris compatibility #22

Merged
merged 2 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ dependencies {
modApi "fuzs.forgeconfigapiport:forgeconfigapiport-fabric:${project.forgeconfigapiport_version}"

modCompileOnly "org.embeddedt:embeddium-1.20.1:${project.embeddedt_version}"
modCompileOnly "libs:iris:${project.iris_version}"
modCompileOnly "libs:iris_legacy:${project.iris_old_version}"
modCompileOnly "maven.modrinth:iris:${project.iris_version}"
modCompileOnly "maven.modrinth:carry-on:${project.carry_on_version}"
modCompileOnly "maven.modrinth:immediatelyfast:${project.immediatelyfast_version}"
modCompileOnly "maven.modrinth:zoomify:${project.zoomify_version}"
Expand Down
Binary file removed libs/mods/iris-1.7.0+mc1.20.1.jar
Binary file not shown.
Binary file removed libs/mods/iris_legacy-mc1.20.1-1.6.17.jar
Binary file not shown.
57 changes: 18 additions & 39 deletions src/main/java/com/tacz/guns/compat/iris/IrisCompat.java
Original file line number Diff line number Diff line change
@@ -1,62 +1,41 @@
package com.tacz.guns.compat.iris;

import com.tacz.guns.compat.iris.legacy.IrisCompatLegacy;
import com.tacz.guns.compat.iris.newly.IrisCompatNewly;
import com.tacz.guns.compat.iris.pbr.PBRRegister;
import com.tacz.guns.init.CompatRegistry;

import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.Version;
import net.fabricmc.loader.api.VersionParsingException;
import net.irisshaders.batchedentityrendering.impl.FullyBufferedMultiBufferSource;
import net.irisshaders.iris.api.v0.IrisApi;
import net.irisshaders.iris.shadows.ShadowRenderingState;
import net.minecraft.client.render.VertexConsumerProvider;

import java.util.function.Function;
import java.util.function.Supplier;

public final class IrisCompat {
private static final Version VERSION;
private static Function<VertexConsumerProvider.Immediate, Boolean> END_BATCH_FUNCTION;
private static Supplier<Boolean> IS_RENDER_SHADOW_SUPPER;
private static boolean isIrisLoaded = false;

public static void initCompat() {
FabricLoader.getInstance().getModContainer(CompatRegistry.IRIS).ifPresent(mod -> {
if (mod.getMetadata().getVersion().compareTo(VERSION) >= 0) {
END_BATCH_FUNCTION = IrisCompatNewly::endBatch;
IS_RENDER_SHADOW_SUPPER = IrisCompatNewly::isRenderShadow;
IrisCompatNewly.registerPBRLoader();
} else {
END_BATCH_FUNCTION = IrisCompatLegacy::endBatch;
IS_RENDER_SHADOW_SUPPER = IrisCompatLegacy::isRenderShadow;
IrisCompatLegacy.registerPBRLoader();
}
});
isIrisLoaded = FabricLoader.getInstance().isModLoaded(CompatRegistry.IRIS);

if (isIrisLoaded) {
PBRRegister.registerPBRLoader();
}
}

public static boolean isRenderShadow() {
if (FabricLoader.getInstance().isModLoaded(CompatRegistry.IRIS)) {
return IS_RENDER_SHADOW_SUPPER.get();
}
return false;
if (!isIrisLoaded) return false;
return ShadowRenderingState.areShadowsCurrentlyBeingRendered();
}

public static boolean isUsingRenderPack() {
if (FabricLoader.getInstance().isModLoaded(CompatRegistry.IRIS)) {
return IrisApi.getInstance().isShaderPackInUse();
}
return false;
if (!isIrisLoaded) return false;
return IrisApi.getInstance().isShaderPackInUse();
}

public static boolean endBatch(VertexConsumerProvider.Immediate bufferSource) {
if (FabricLoader.getInstance().isModLoaded(CompatRegistry.IRIS)) {
return END_BATCH_FUNCTION.apply(bufferSource);
if (!isIrisLoaded) return false;
if (bufferSource instanceof FullyBufferedMultiBufferSource fullyBufferedMultiBufferSource) {
fullyBufferedMultiBufferSource.draw();
return true;
}
return false;
}

static {
try {
VERSION = Version.parse("1.7.0");
} catch (VersionParsingException e) {
throw new RuntimeException(e);
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

24 changes: 0 additions & 24 deletions src/main/java/com/tacz/guns/compat/iris/newly/IrisCompatNewly.java

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.tacz.guns.compat.iris.pbr;

import com.tacz.guns.client.resource.texture.FilePackTexture;

import net.irisshaders.iris.texture.pbr.PBRType;
import net.irisshaders.iris.texture.pbr.loader.PBRTextureLoader;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.texture.TextureManager;
import net.minecraft.resource.ResourceManager;
import net.minecraft.util.Identifier;

public class FilePackTexturePBRLoader implements PBRTextureLoader<FilePackTexture> {
@Override
public void load(FilePackTexture filePackTexture, ResourceManager resourceManager, PBRTextureConsumer pbrTextureConsumer) {
loadPBRTextures(filePackTexture.getRegisterId(), pbrTextureConsumer);
}

static void loadPBRTextures(Identifier id, PBRTextureConsumer pbrTextureConsumer) {
TextureManager textureManager = MinecraftClient.getInstance().getTextureManager();
loadPBRTexture(id, PBRType.NORMAL, textureManager, pbrTextureConsumer::acceptNormalTexture);
loadPBRTexture(id, PBRType.SPECULAR, textureManager, pbrTextureConsumer::acceptSpecularTexture);
}

private static void loadPBRTexture(Identifier id, PBRType type, TextureManager textureManager, java.util.function.Consumer<net.minecraft.client.texture.AbstractTexture> consumer) {
Identifier pbrId = new Identifier(id.getNamespace(), id.getPath() + type.getSuffix());
if (textureManager.textures.containsKey(pbrId)) {
consumer.accept(textureManager.getTexture(pbrId));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.tacz.guns.compat.iris.newly.pbr;
package com.tacz.guns.compat.iris.pbr;

import com.tacz.guns.client.resource.texture.FilePackTexture;
import com.tacz.guns.client.resource.texture.ZipPackTexture;

import net.irisshaders.iris.texture.pbr.loader.PBRTextureLoaderRegistry;

public class PBRRegister {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.tacz.guns.compat.iris.pbr;

import com.tacz.guns.client.resource.texture.ZipPackTexture;

import net.irisshaders.iris.texture.pbr.loader.PBRTextureLoader;
import net.minecraft.resource.ResourceManager;

public class ZipPackTexturePBRLoader implements PBRTextureLoader<ZipPackTexture> {
@Override
public void load(ZipPackTexture zipPackTexture, ResourceManager resourceManager, PBRTextureConsumer pbrTextureConsumer) {
FilePackTexturePBRLoader.loadPBRTextures(zipPackTexture.getRegisterId(), pbrTextureConsumer);
}
}
3 changes: 3 additions & 0 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
"porting_lib_entity": ">=2.3.4+1.20.1",
"mkb": ">=1.2.0"
},
"breaks": {
qualk marked this conversation as resolved.
Show resolved Hide resolved
"iris": "<1.7.0"
},
"custom": {
"loom:injected_interfaces": {
"net/minecraft/class_276": [
Expand Down
Loading