-
Notifications
You must be signed in to change notification settings - Fork 142
Expand file tree
/
Copy pathOculusCompat.java
More file actions
53 lines (46 loc) · 2.01 KB
/
Copy pathOculusCompat.java
File metadata and controls
53 lines (46 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package com.tacz.guns.compat.oculus;
import com.tacz.guns.compat.oculus.legacy.OculusCompatLegacy;
import com.tacz.guns.compat.oculus.newly.OculusCompatNewly;
import com.tacz.guns.init.CompatRegistry;
import net.irisshaders.iris.api.v0.IrisApi;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraftforge.fml.ModList;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import java.util.function.Function;
import java.util.function.Supplier;
public final class OculusCompat {
private static final DefaultArtifactVersion VERSION = new DefaultArtifactVersion("1.7.0");
private static Function<MultiBufferSource.BufferSource, Boolean> END_BATCH_FUNCTION;
private static Supplier<Boolean> IS_RENDER_SHADOW_SUPPER;
public static void initCompat() {
Minecraft.getInstance().getMainRenderTarget().enableStencil();
ModList.get().getModContainerById(CompatRegistry.OCULUS).ifPresent(mod -> {
if (mod.getModInfo().getVersion().compareTo(VERSION) >= 0) {
END_BATCH_FUNCTION = OculusCompatNewly::endBatch;
IS_RENDER_SHADOW_SUPPER = OculusCompatNewly::isRenderShadow;
} else {
END_BATCH_FUNCTION = OculusCompatLegacy::endBatch;
IS_RENDER_SHADOW_SUPPER = OculusCompatLegacy::isRenderShadow;
}
});
}
public static boolean isRenderShadow() {
if (ModList.get().isLoaded(CompatRegistry.OCULUS)) {
return IS_RENDER_SHADOW_SUPPER.get();
}
return false;
}
public static boolean isUsingRenderPack() {
if (ModList.get().isLoaded(CompatRegistry.OCULUS)) {
return IrisApi.getInstance().isShaderPackInUse();
}
return false;
}
public static boolean endBatch(MultiBufferSource.BufferSource bufferSource) {
if (ModList.get().isLoaded(CompatRegistry.OCULUS)) {
return END_BATCH_FUNCTION.apply(bufferSource);
}
return false;
}
}