aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/mixin/citenchantment/RenderPhaseAccessor.java23
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CITEnchantment.java40
2 files changed, 32 insertions, 31 deletions
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/citenchantment/RenderPhaseAccessor.java b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/citenchantment/RenderPhaseAccessor.java
index b7e995e..24e7c3c 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/citenchantment/RenderPhaseAccessor.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/citenchantment/RenderPhaseAccessor.java
@@ -6,7 +6,6 @@ import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(RenderPhase.class)
public interface RenderPhaseAccessor {
- @Accessor("GLINT_TRANSPARENCY") static RenderPhase.Transparency GLINT_TRANSPARENCY() { throw new RuntimeException(); }
@Accessor("ARMOR_GLINT_SHADER") static RenderPhase.Shader ARMOR_GLINT_SHADER() { throw new RuntimeException(); }
@Accessor("ARMOR_ENTITY_GLINT_SHADER") static RenderPhase.Shader ARMOR_ENTITY_GLINT_SHADER() { throw new RuntimeException(); }
@Accessor("TRANSLUCENT_GLINT_SHADER") static RenderPhase.Shader TRANSLUCENT_GLINT_SHADER() { throw new RuntimeException(); }
@@ -14,31 +13,9 @@ public interface RenderPhaseAccessor {
@Accessor("DIRECT_GLINT_SHADER") static RenderPhase.Shader DIRECT_GLINT_SHADER() { throw new RuntimeException(); }
@Accessor("ENTITY_GLINT_SHADER") static RenderPhase.Shader ENTITY_GLINT_SHADER() { throw new RuntimeException(); }
@Accessor("DIRECT_ENTITY_GLINT_SHADER") static RenderPhase.Shader DIRECT_ENTITY_GLINT_SHADER() { throw new RuntimeException(); }
- @Accessor("MIPMAP_BLOCK_ATLAS_TEXTURE") static RenderPhase.Texture MIPMAP_BLOCK_ATLAS_TEXTURE() { throw new RuntimeException(); }
- @Accessor("BLOCK_ATLAS_TEXTURE") static RenderPhase.Texture BLOCK_ATLAS_TEXTURE() { throw new RuntimeException(); }
- @Accessor("DEFAULT_TEXTURING") static RenderPhase.Texturing DEFAULT_TEXTURING() { throw new RuntimeException(); }
- @Accessor("GLINT_TEXTURING") static RenderPhase.Texturing GLINT_TEXTURING() { throw new RuntimeException(); }
- @Accessor("ENTITY_GLINT_TEXTURING") static RenderPhase.Texturing ENTITY_GLINT_TEXTURING() { throw new RuntimeException(); }
- @Accessor("ENABLE_LIGHTMAP") static RenderPhase.Lightmap ENABLE_LIGHTMAP() { throw new RuntimeException(); }
- @Accessor("DISABLE_LIGHTMAP") static RenderPhase.Lightmap DISABLE_LIGHTMAP() { throw new RuntimeException(); }
- @Accessor("ENABLE_OVERLAY_COLOR") static RenderPhase.Overlay ENABLE_OVERLAY_COLOR() { throw new RuntimeException(); }
- @Accessor("DISABLE_OVERLAY_COLOR") static RenderPhase.Overlay DISABLE_OVERLAY_COLOR() { throw new RuntimeException(); }
- @Accessor("ENABLE_CULLING") static RenderPhase.Cull ENABLE_CULLING() { throw new RuntimeException(); }
@Accessor("DISABLE_CULLING") static RenderPhase.Cull DISABLE_CULLING() { throw new RuntimeException(); }
- @Accessor("ALWAYS_DEPTH_TEST") static RenderPhase.DepthTest ALWAYS_DEPTH_TEST() { throw new RuntimeException(); }
@Accessor("EQUAL_DEPTH_TEST") static RenderPhase.DepthTest EQUAL_DEPTH_TEST() { throw new RuntimeException(); }
- @Accessor("LEQUAL_DEPTH_TEST") static RenderPhase.DepthTest LEQUAL_DEPTH_TEST() { throw new RuntimeException(); }
- @Accessor("ALL_MASK") static RenderPhase.WriteMaskState ALL_MASK() { throw new RuntimeException(); }
@Accessor("COLOR_MASK") static RenderPhase.WriteMaskState COLOR_MASK() { throw new RuntimeException(); }
- @Accessor("DEPTH_MASK") static RenderPhase.WriteMaskState DEPTH_MASK() { throw new RuntimeException(); }
- @Accessor("NO_LAYERING") static RenderPhase.Layering NO_LAYERING() { throw new RuntimeException(); }
- @Accessor("POLYGON_OFFSET_LAYERING") static RenderPhase.Layering POLYGON_OFFSET_LAYERING() { throw new RuntimeException(); }
@Accessor("VIEW_OFFSET_Z_LAYERING") static RenderPhase.Layering VIEW_OFFSET_Z_LAYERING() { throw new RuntimeException(); }
- @Accessor("MAIN_TARGET") static RenderPhase.Target MAIN_TARGET() { throw new RuntimeException(); }
- @Accessor("OUTLINE_TARGET") static RenderPhase.Target OUTLINE_TARGET() { throw new RuntimeException(); }
- @Accessor("TRANSLUCENT_TARGET") static RenderPhase.Target TRANSLUCENT_TARGET() { throw new RuntimeException(); }
- @Accessor("PARTICLES_TARGET") static RenderPhase.Target PARTICLES_TARGET() { throw new RuntimeException(); }
- @Accessor("WEATHER_TARGET") static RenderPhase.Target WEATHER_TARGET() { throw new RuntimeException(); }
- @Accessor("CLOUDS_TARGET") static RenderPhase.Target CLOUDS_TARGET() { throw new RuntimeException(); }
@Accessor("ITEM_TARGET") static RenderPhase.Target ITEM_TARGET() { throw new RuntimeException(); }
}
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CITEnchantment.java b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CITEnchantment.java
index 70ad618..d738570 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CITEnchantment.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CITEnchantment.java
@@ -8,6 +8,7 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
import net.minecraft.util.math.Matrix4f;
import net.minecraft.util.math.Vec3f;
+import org.lwjgl.opengl.GL11;
import shcm.shsupercm.fabric.citresewn.CITResewn;
import shcm.shsupercm.fabric.citresewn.config.CITResewnConfig;
import shcm.shsupercm.fabric.citresewn.ex.CITParseException;
@@ -186,19 +187,24 @@ public class CITEnchantment extends CIT {
}
public static class Blend extends RenderPhase.Transparency {
- private final int src;
- private final int dst;
+ private final int src, dst, srcAlpha, dstAlpha;
- private Blend(String name, int src, int dst) {
+ private Blend(String name, int src, int dst, int srcAlpha, int dstAlpha) {
super(name + "_glint_transparency", null, null);
this.src = src;
this.dst = dst;
+ this.srcAlpha = srcAlpha;
+ this.dstAlpha = dstAlpha;
+ }
+
+ private Blend(String name, int src, int dst) {
+ this(name, src, dst, GL_ZERO, GL_ONE);
}
@Override
public void startDrawing() {
enableBlend();
- blendFuncSeparate(src, dst, GL_ZERO, GL_ONE);
+ blendFuncSeparate(src, dst, srcAlpha, dstAlpha);
}
@Override
@@ -212,12 +218,22 @@ public class CITEnchantment extends CIT {
return Named.valueOf(blendString.toUpperCase(Locale.ENGLISH)).blend;
} catch (IllegalArgumentException ignored) { // create custom blending function
try {
- String[] split = blendString.split("[ ,_]+");
- if (split.length != 2)
+ String[] split = blendString.split(" ");
+ int src, dst, srcAlpha, dstAlpha;
+ if (split.length == 2) {
+ src = parseGLConstant(split[0]);
+ dst = parseGLConstant(split[1]);
+ srcAlpha = GL_ZERO;
+ dstAlpha = GL_ONE;
+ } else if (split.length == 4) {
+ src = parseGLConstant(split[0]);
+ dst = parseGLConstant(split[1]);
+ srcAlpha = parseGLConstant(split[2]);
+ dstAlpha = parseGLConstant(split[3]);
+ } else
throw new Exception();
- int src = Integer.parseInt(split[0]), dst = Integer.parseInt(split[1]);
- return new Blend("custom_" + src + "_" + dst, src, dst);
+ return new Blend("custom_" + src + "_" + dst + "_" + srcAlpha + "_" + dstAlpha, src, dst, srcAlpha, dstAlpha);
} catch (Exception e) {
throw new BlendFormatException();
}
@@ -248,6 +264,14 @@ public class CITEnchantment extends CIT {
}
}
+ private static int parseGLConstant(String s) throws Exception {
+ try {
+ return GL11.class.getDeclaredField(s).getInt(null);
+ } catch (NoSuchFieldException ignored) { }
+
+ return s.startsWith("0x") ? Integer.parseInt(s.substring(2), 16) : Integer.parseInt(s);
+ }
+
public static class BlendFormatException extends Exception {
public BlendFormatException() {
super("Not a valid blending method");