mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-20 04:19:40 +00:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8991d810c | ||
|
|
e3b02642ac | ||
|
|
2759dd6689 | ||
|
|
996dbaef2c | ||
|
|
72ca675c93 | ||
|
|
e6e230e270 | ||
|
|
43d7282ba5 |
No files matched your search
@@ -93,6 +93,8 @@ dependencies {
|
||||
compileOnly("com.github.GTNewHorizons:NotEnoughIds:2.1.10:dev") // Mixin Version
|
||||
compileOnly("com.github.GTNewHorizons:NotEnoughIds-Legacy:1.4.7:dev") // ASM Version
|
||||
|
||||
compileOnly(rfg.deobf("curse.maven:ntm-space-1121235:6974420"))
|
||||
|
||||
compileOnly(rfg.deobf("curse.maven:campfirebackport-387444:4611675"))
|
||||
compileOnly(rfg.deobf("curse.maven:xaeros-minimap-263420:5060684"))
|
||||
compileOnly(rfg.deobf("curse.maven:security-craft-64760:2818228"))
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.gtnewhorizons.angelica.compat.iris;
|
||||
|
||||
/**
|
||||
* Interface implemented by BiomeGenBase via mixin to cache biome category.
|
||||
* This avoids recomputing the category every frame for shader uniforms.
|
||||
*/
|
||||
public interface BiomeCategoryCache {
|
||||
/**
|
||||
* Gets the cached biome category ordinal, or -1 if not yet computed.
|
||||
*/
|
||||
int iris$getCachedCategory();
|
||||
|
||||
/**
|
||||
* Sets the cached biome category ordinal.
|
||||
*/
|
||||
void iris$setCachedCategory(int category);
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.gtnewhorizons.angelica.compat.iris;
|
||||
|
||||
import net.coderbot.iris.parsing.BiomeCategories;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Detects and categorizes biomes from popular modded biome mods using cached class checks.
|
||||
* Currently supports: BiomesOPlenty (BOP), Realistic World Gen (RWG)
|
||||
*/
|
||||
public class ModdedBiomeDetector {
|
||||
private static boolean initialized = false;
|
||||
|
||||
// BiomesOPlenty (BOP) cache - dimension-specific base classes
|
||||
// BOP 1.7.10 hierarchy: BOPBiome -> BOPEndBiome/BOPNetherBiome/BOPOverworldBiome -> specific biomes
|
||||
private static Class<?> bopEndBiomeClass = null;
|
||||
private static Class<?> bopNetherBiomeClass = null;
|
||||
private static Class<?> bopOceanBiomeClass = null;
|
||||
|
||||
// Realistic World Gen (RWG) cache - base biome classes that extend BiomeGenBase
|
||||
// LinkedHashMap maintains insertion order for deterministic behavior
|
||||
private static final Map<Class<?>, BiomeCategories> rwgClassMap = new LinkedHashMap<>();
|
||||
|
||||
private static synchronized void initialize() {
|
||||
if (initialized) return;
|
||||
initialized = true;
|
||||
|
||||
initializeBOP();
|
||||
initializeRWG();
|
||||
}
|
||||
|
||||
private static void initializeBOP() {
|
||||
try {
|
||||
bopEndBiomeClass = Class.forName("biomesoplenty.common.biome.BOPEndBiome");
|
||||
bopNetherBiomeClass = Class.forName("biomesoplenty.common.biome.BOPNetherBiome");
|
||||
bopOceanBiomeClass = Class.forName("biomesoplenty.common.biome.BOPOceanBiome");
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
// BOP not installed
|
||||
}
|
||||
}
|
||||
|
||||
private static void initializeRWG() {
|
||||
// RWG adds actual BiomeGenBase subclasses in rwg.biomes.base package
|
||||
tryAddRWGClass("rwg.biomes.base.BaseBiomeOcean", BiomeCategories.OCEAN);
|
||||
tryAddRWGClass("rwg.biomes.base.BaseBiomeRiver", BiomeCategories.RIVER);
|
||||
tryAddRWGClass("rwg.biomes.base.BaseBiomePlains", BiomeCategories.PLAINS);
|
||||
tryAddRWGClass("rwg.biomes.base.BaseBiomeColdPlains", BiomeCategories.PLAINS);
|
||||
tryAddRWGClass("rwg.biomes.base.BaseBiomeHotPlains", BiomeCategories.PLAINS);
|
||||
tryAddRWGClass("rwg.biomes.base.BaseBiomeHotDesert", BiomeCategories.DESERT);
|
||||
tryAddRWGClass("rwg.biomes.base.BaseBiomeSnowDesert", BiomeCategories.DESERT); // Cold desert, but still desert
|
||||
tryAddRWGClass("rwg.biomes.base.BaseBiomeJungle", BiomeCategories.JUNGLE);
|
||||
tryAddRWGClass("rwg.biomes.base.BaseBiomeTropicalIsland", BiomeCategories.JUNGLE); // Tropical islands are jungle-like
|
||||
tryAddRWGClass("rwg.biomes.base.BaseBiomeRedwood", BiomeCategories.FOREST); // Redwood/Sequoia forests
|
||||
tryAddRWGClass("rwg.biomes.base.BaseBiomeTemperateForest", BiomeCategories.FOREST);
|
||||
tryAddRWGClass("rwg.biomes.base.BaseBiomeColdForest", BiomeCategories.TAIGA); // Cold forests are taiga-like
|
||||
tryAddRWGClass("rwg.biomes.base.BaseBiomeHotForest", BiomeCategories.FOREST);
|
||||
tryAddRWGClass("rwg.biomes.base.BaseBiomeSnowForest", BiomeCategories.TAIGA); // Snow forests are taiga
|
||||
}
|
||||
|
||||
private static void tryAddRWGClass(String className, BiomeCategories category) {
|
||||
try {
|
||||
final Class<?> clazz = Class.forName(className);
|
||||
rwgClassMap.put(clazz, category);
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
// Class not available, RWG not installed or different version
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to detect the biome category for modded biomes.
|
||||
* Returns null if no modded biome detection applies.
|
||||
*/
|
||||
public static BiomeCategories detectModdedBiome(BiomeGenBase biome) {
|
||||
if (!initialized) {
|
||||
initialize();
|
||||
}
|
||||
|
||||
// BiomesOPlenty detection - dimension-specific classes give us clear categories
|
||||
if (bopEndBiomeClass != null && bopEndBiomeClass.isInstance(biome)) {
|
||||
return BiomeCategories.THE_END;
|
||||
}
|
||||
if (bopNetherBiomeClass != null && bopNetherBiomeClass.isInstance(biome)) {
|
||||
return BiomeCategories.NETHER;
|
||||
}
|
||||
if (bopOceanBiomeClass != null && bopOceanBiomeClass.isInstance(biome)) {
|
||||
return BiomeCategories.OCEAN;
|
||||
}
|
||||
// For other BOP overworld biomes (e.g., Alps, Arctic, BambooForest),
|
||||
// fall through to name/property-based detection
|
||||
|
||||
// Realistic World Gen detection
|
||||
for (Map.Entry<Class<?>, BiomeCategories> entry : rwgClassMap.entrySet()) {
|
||||
if (entry.getKey().isInstance(biome)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -9,35 +9,62 @@ import net.minecraft.util.MathHelper;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector4f;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
/**
|
||||
* Singleton camera instance that tracks the current camera position and orientation.
|
||||
*/
|
||||
@Getter
|
||||
public class Camera {
|
||||
final Vector3d pos = new Vector3d();
|
||||
final BlockPos blockPos = new BlockPos();
|
||||
float pitch;
|
||||
float yaw;
|
||||
EntityLivingBase entity;
|
||||
boolean thirdPerson;
|
||||
final float partialTicks;
|
||||
public static final Camera INSTANCE = new Camera();
|
||||
|
||||
public Camera(EntityLivingBase entity, float partialTicks) {
|
||||
private final Vector3d pos = new Vector3d();
|
||||
private final BlockPos blockPos = new BlockPos();
|
||||
private final Vector3f offset = new Vector3f();
|
||||
private final Matrix4f inverseModelView = new Matrix4f();
|
||||
|
||||
private float pitch;
|
||||
private float yaw;
|
||||
private EntityLivingBase entity;
|
||||
private boolean thirdPerson;
|
||||
private float partialTicks;
|
||||
|
||||
private Camera() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the camera position and orientation based on the current entity and partial ticks.
|
||||
*
|
||||
* @param entity The entity to track (usually the render view entity)
|
||||
* @param partialTicks The partial tick time for interpolation
|
||||
*/
|
||||
public void update(EntityLivingBase entity, float partialTicks) {
|
||||
this.partialTicks = partialTicks;
|
||||
final Vector4f offset = new Vector4f(); // third person offset
|
||||
final Matrix4f inverseModelView = new Matrix4f(RenderingState.INSTANCE.getModelViewMatrix()).invert();
|
||||
inverseModelView.transform(offset);
|
||||
|
||||
final double camX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks + offset.x;
|
||||
final double camY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks + offset.y;
|
||||
final double camZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks + offset.z;
|
||||
this.entity = entity;
|
||||
|
||||
// Entity position (interpolated, at feet level)
|
||||
final double entityX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks;
|
||||
final double entityY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks;
|
||||
final double entityZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks;
|
||||
final double eyeHeight = entity.getEyeHeight();
|
||||
|
||||
thirdPerson = Minecraft.getMinecraft().gameSettings.thirdPersonView > 0;
|
||||
|
||||
final double camX, camY, camZ;
|
||||
offset.set(0, 0, 0);
|
||||
|
||||
if (thirdPerson) {
|
||||
// Third person: use inverse modelview to find camera offset
|
||||
inverseModelView.set(RenderingState.INSTANCE.getModelViewMatrix()).invert();
|
||||
inverseModelView.transformPosition(offset);
|
||||
}
|
||||
camX = entityX + offset.x;
|
||||
camY = entityY + eyeHeight + offset.y;
|
||||
camZ = entityZ + offset.z;
|
||||
|
||||
pos.set(camX, camY, camZ);
|
||||
blockPos.set(MathHelper.floor_double(camX), MathHelper.floor_double(camY), MathHelper.floor_double(camZ));
|
||||
pitch = entity.cameraPitch;
|
||||
yaw = entity.rotationYaw;
|
||||
thirdPerson = Minecraft.getMinecraft().gameSettings.thirdPersonView == 1;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.gtnewhorizons.angelica.compat.mojang;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
||||
|
||||
public final class GameModeUtil {
|
||||
private GameModeUtil() {
|
||||
}
|
||||
|
||||
public static boolean isSpectator() {
|
||||
final PlayerControllerMP controller = Minecraft.getMinecraft().playerController;
|
||||
if (controller == null) {
|
||||
return false;
|
||||
}
|
||||
return controller.currentGameType.getID() == 3;
|
||||
}
|
||||
}
|
||||
@@ -167,6 +167,40 @@ public class AngelicaConfig {
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean removeUnicodeEvenScaling;
|
||||
|
||||
@Config.Comment({"Block corners and edges between chunks might have \"cracks\" (various lines/dots) in them.",
|
||||
"While using \"Compact Vertex Format\" makes the situation even worse.",
|
||||
"This option fixes it.",
|
||||
"Requires texture reloading (F3 + T) after changing this option to take effect"})
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean fixBlockCrack;
|
||||
|
||||
@Config.Comment({
|
||||
"The \"epsilon\" value for the fixBlockCrack option. ",
|
||||
"Set this a bit higher if you can still see lines/dots between solid blocks in dark areas.",
|
||||
"May cause intense flickering (z-fighting) between blocks if the value is too high"
|
||||
})
|
||||
@Config.RangeDouble(min = 0, max = 0.005)
|
||||
@Config.DefaultDouble(0.001)
|
||||
public static double blockCrackFixEpsilon;
|
||||
|
||||
@Config.Comment("Block classes that have bugs when rendering with the fixBlockCrack can be put here to avoid manipulating them")
|
||||
@Config.DefaultStringList({
|
||||
"net.minecraft.block.BlockCauldron",
|
||||
"net.minecraft.block.BlockStairs"
|
||||
})
|
||||
public static String[] blockCrackFixBlacklist;
|
||||
|
||||
@Config.Comment({"Block classes that have render pass other than 0 but still need to be manipulated.",
|
||||
"Add a block class here if you see flickering (z-fighting) with fixBlockCrack enabled"
|
||||
})
|
||||
@Config.DefaultStringList({
|
||||
"gregtech.common.blocks.BlockOres",
|
||||
"shukaro.artifice.block.world.BlockOre",
|
||||
"bartworks.system.material.BWMetaGeneratedOres",
|
||||
"gtPlusPlus.core.block.base.BlockBaseOre",
|
||||
})
|
||||
public static String[] blockCrackFixRenderPassWhitelist;
|
||||
|
||||
@Config.Comment("Register HardcodedCustomUniforms in Iris Shaders. May help with compatibility in certain shader packs")
|
||||
@Config.DefaultBoolean(false)
|
||||
public static boolean enableHardcodedCustomUniforms;
|
||||
|
||||
@@ -11,6 +11,7 @@ public class AngelicaGuiConfig extends SimpleGuiConfig {
|
||||
"Angelica",
|
||||
true,
|
||||
AngelicaConfig.class,
|
||||
CompatConfig.class,
|
||||
FontConfig.class
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.gtnewhorizons.angelica.config;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.config.Config;
|
||||
|
||||
@Config(modid = "angelica", filename = "angelica-compat")
|
||||
@Config(modid = "angelica", filename = "angelica-compat", category = "compat")
|
||||
public class CompatConfig {
|
||||
|
||||
@Config.Comment("Apply fixes to the LOTR mod")
|
||||
@@ -44,4 +44,24 @@ public class CompatConfig {
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean fixSecurityCraft;
|
||||
|
||||
@Config.Comment("Apply tweaks to NTM:Space")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean tweakNTMSpace;
|
||||
|
||||
@Config.Comment("Apply fixes to NTM:Space")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean fixNTMSpace;
|
||||
|
||||
@Config.Comment("Disables rendering of the planet below the player at high altitudes [Requires tweakNTMSpace]")
|
||||
@Config.DefaultEnum("ShadersOnly")
|
||||
public static altitudePlanetRendererState NTMSpace_disableAltitudePlanetRenderer;
|
||||
public enum altitudePlanetRendererState {
|
||||
Always,
|
||||
ShadersOnly,
|
||||
Never
|
||||
}
|
||||
|
||||
}
|
||||
@@ -125,9 +125,9 @@ public class AngelicaTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
boolean rfbLoaded = Launch.blackboard.getOrDefault("angelica.rfbPluginLoaded", Boolean.FALSE) == Boolean.TRUE;
|
||||
if (!rfbLoaded) {
|
||||
tweaks.add("com.gtnewhorizons.angelica.loading.fml.tweakers.AngelicaLateTweaker");
|
||||
}
|
||||
if (AngelicaConfig.enableSodium) {
|
||||
tweaks.add("com.gtnewhorizons.angelica.loading.fml.tweakers.SodiumLateTweaker");
|
||||
if (AngelicaConfig.enableSodium) {
|
||||
tweaks.add("com.gtnewhorizons.angelica.loading.fml.tweakers.SodiumLateTweaker");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ public class AngelicaRedirectorTransformer implements IClassTransformer {
|
||||
private final String[] exclusions;
|
||||
|
||||
public AngelicaRedirectorTransformer() {
|
||||
inner = new AngelicaRedirector(AngelicaTweaker.isObfEnv());
|
||||
inner = new AngelicaRedirector();
|
||||
exclusions = inner.getTransformerExclusions();
|
||||
}
|
||||
|
||||
|
||||
+24
-18
@@ -1,26 +1,24 @@
|
||||
package com.gtnewhorizons.angelica.loading.fml.transformers;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import com.gtnewhorizons.angelica.loading.shared.AngelicaClassDump;
|
||||
import com.gtnewhorizons.angelica.loading.shared.transformers.AngelicaRedirector;
|
||||
import com.gtnewhorizons.angelica.loading.shared.transformers.SodiumBlockTransform;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SodiumBlockTransformer implements IClassTransformer {
|
||||
|
||||
private static final List<Pair<String, String>> BlockBoundsFields = ImmutableList.of(
|
||||
Pair.of("minX", "field_149759_B"),
|
||||
Pair.of("minY", "field_149760_C"),
|
||||
Pair.of("minZ", "field_149754_D"),
|
||||
Pair.of("maxX", "field_149755_E"),
|
||||
Pair.of("maxY", "field_149756_F"),
|
||||
Pair.of("maxZ", "field_149757_G")
|
||||
);
|
||||
private final SodiumBlockTransform inner;
|
||||
private final String[] exclusions;
|
||||
|
||||
public SodiumBlockTransformer() {
|
||||
this.inner = new SodiumBlockTransform(AngelicaTweaker.isObfEnv());
|
||||
this.exclusions = inner.getTransformerExclusions();
|
||||
this.inner.setSodiumSetting();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the global vanilla bounding box fields off the Block object. {@link AngelicaRedirector}
|
||||
@@ -29,12 +27,20 @@ public class SodiumBlockTransformer implements IClassTransformer {
|
||||
@Override
|
||||
public byte[] transform(String name, String transformedName, byte[] basicClass) {
|
||||
if (basicClass == null) return null;
|
||||
if ("net.minecraft.block.Block".equals(transformedName)) {
|
||||
final ClassReader cr = new ClassReader(basicClass);
|
||||
final ClassNode cn = new ClassNode();
|
||||
cr.accept(cn, 0);
|
||||
cn.fields.removeIf(field -> BlockBoundsFields.stream().anyMatch(pair -> field.name.equals(pair.getLeft()) || field.name.equals(pair.getRight())));
|
||||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
||||
for (String exclusion : exclusions) {
|
||||
if (transformedName.startsWith(exclusion)) return basicClass;
|
||||
}
|
||||
|
||||
if (!inner.shouldTransform(basicClass)) {
|
||||
return basicClass;
|
||||
}
|
||||
|
||||
final ClassReader cr = new ClassReader(basicClass);
|
||||
final ClassNode cn = new ClassNode();
|
||||
cr.accept(cn, 0);
|
||||
final boolean changed = inner.transformClassNode(transformedName, cn);
|
||||
if (changed) {
|
||||
final ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
||||
cn.accept(cw);
|
||||
final byte[] bytes = cw.toByteArray();
|
||||
AngelicaClassDump.dumpClass(transformedName, basicClass, bytes, this);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.loading.rfb;
|
||||
|
||||
import com.gtnewhorizons.angelica.loading.rfb.transformers.RFBAngelicaRedirector;
|
||||
import com.gtnewhorizons.angelica.loading.rfb.transformers.RFBSodiumBlockTransformer;
|
||||
import com.gtnewhorizons.retrofuturabootstrap.api.PluginContext;
|
||||
import com.gtnewhorizons.retrofuturabootstrap.api.RetroFuturaBootstrap;
|
||||
import com.gtnewhorizons.retrofuturabootstrap.api.RfbClassTransformer;
|
||||
@@ -25,7 +26,8 @@ public class AngelicaRfbPlugin implements RfbPlugin {
|
||||
|
||||
final boolean isObf = RetroFuturaBootstrap.API.launchClassLoader().findClassMetadata("net.minecraft.world.World") == null;
|
||||
return new RfbClassTransformer[] {
|
||||
new RFBAngelicaRedirector(isObf)
|
||||
new RFBAngelicaRedirector(),
|
||||
new RFBSodiumBlockTransformer(isObf)
|
||||
};
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -16,8 +16,8 @@ public class RFBAngelicaRedirector implements RfbClassTransformer {
|
||||
|
||||
private final AngelicaRedirector inner;
|
||||
|
||||
public RFBAngelicaRedirector(boolean isObf) {
|
||||
inner = new AngelicaRedirector(isObf);
|
||||
public RFBAngelicaRedirector() {
|
||||
inner = new AngelicaRedirector();
|
||||
}
|
||||
|
||||
@Pattern("[a-z0-9-]+")
|
||||
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package com.gtnewhorizons.angelica.loading.rfb.transformers;
|
||||
|
||||
import com.gtnewhorizons.angelica.loading.shared.AngelicaClassDump;
|
||||
import com.gtnewhorizons.angelica.loading.shared.transformers.SodiumBlockTransform;
|
||||
import com.gtnewhorizons.retrofuturabootstrap.api.ClassNodeHandle;
|
||||
import com.gtnewhorizons.retrofuturabootstrap.api.ExtensibleClassLoader;
|
||||
import com.gtnewhorizons.retrofuturabootstrap.api.RfbClassTransformer;
|
||||
import org.intellij.lang.annotations.Pattern;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.jar.Manifest;
|
||||
|
||||
public class RFBSodiumBlockTransformer implements RfbClassTransformer {
|
||||
|
||||
private final SodiumBlockTransform inner;
|
||||
|
||||
public RFBSodiumBlockTransformer(boolean isObf) {
|
||||
inner = new SodiumBlockTransform(isObf);
|
||||
}
|
||||
|
||||
@Pattern("[a-z0-9-]+")
|
||||
@Override
|
||||
public @NotNull String id() {
|
||||
return "sodiumblocktransform";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String @Nullable [] sortAfter() {
|
||||
return new String[]{"*", "mixin:mixin"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String @Nullable [] sortBefore() {
|
||||
return new String[]{"lwjgl3ify:redirect"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String @Nullable [] additionalExclusions() {
|
||||
return inner.getTransformerExclusions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldTransformClass(@NotNull ExtensibleClassLoader classLoader,
|
||||
@NotNull RfbClassTransformer.Context context, @Nullable Manifest manifest, @NotNull String className,
|
||||
@NotNull ClassNodeHandle classNode) {
|
||||
if (!classNode.isPresent()) {
|
||||
return false;
|
||||
}
|
||||
if (!classNode.isOriginal()) {
|
||||
// If a class is already a transformed ClassNode, conservatively continue processing.
|
||||
return true;
|
||||
}
|
||||
return inner.shouldTransform(classNode.getOriginalBytes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transformClass(@NotNull ExtensibleClassLoader classLoader, @NotNull RfbClassTransformer.Context context,
|
||||
@Nullable Manifest manifest, @NotNull String className, @NotNull ClassNodeHandle classNode) {
|
||||
final boolean changed = inner.transformClassNode(className, classNode.getNode());
|
||||
if (changed) {
|
||||
classNode.computeMaxs();
|
||||
AngelicaClassDump.dumpRFBClass(className, classNode, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-135
@@ -26,7 +26,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* This transformer redirects many GL calls to our custom GLStateManager
|
||||
@@ -35,16 +34,6 @@ import java.util.stream.Collectors;
|
||||
* IT SHOULD NOT CALL ANY CODE FROM THE MAIN MOD
|
||||
*/
|
||||
public final class AngelicaRedirector {
|
||||
// TODO(Alexdoru) properly split this class in two because currently this class is doing
|
||||
// two very different things :
|
||||
// - redirect the GL calls to our GL manager class
|
||||
// - replace the block fields with a thread safe replacement (only if Sodium is enabled)
|
||||
|
||||
public AngelicaRedirector(boolean isObf) {
|
||||
IS_OBF = isObf;
|
||||
}
|
||||
|
||||
private final boolean IS_OBF;
|
||||
|
||||
private static final boolean ASSERT_MAIN_THREAD = Boolean.getBoolean("angelica.assertMainThread");
|
||||
private static final boolean LOG_SPAM = Boolean.getBoolean("angelica.redirectorLogspam");
|
||||
@@ -56,48 +45,20 @@ public final class AngelicaRedirector {
|
||||
private static final String GL14 = "org/lwjgl/opengl/GL14";
|
||||
private static final String GL20 = "org/lwjgl/opengl/GL20";
|
||||
private static final String Project = "org/lwjgl/util/glu/Project";
|
||||
|
||||
private static final String BlockClass = "net/minecraft/block/Block";
|
||||
private static final String BlockPackage = "net/minecraft/block/Block";
|
||||
|
||||
private static final String OpenGlHelper = "net/minecraft/client/renderer/OpenGlHelper";
|
||||
private static final String EXTBlendFunc = "org/lwjgl/opengl/EXTBlendFuncSeparate";
|
||||
private static final String ARBMultiTexture = "org/lwjgl/opengl/ARBMultitexture";
|
||||
private static final String MinecraftClient = "net.minecraft.client";
|
||||
private static final String SplashProgress = "cpw.mods.fml.client.SplashProgress";
|
||||
private static final String ThreadedBlockData = "com/gtnewhorizons/angelica/glsm/ThreadedBlockData";
|
||||
private static final Set<String> ExcludedMinecraftMainThreadChecks = ImmutableSet.of(
|
||||
"startGame", "func_71384_a",
|
||||
"initializeTextures", "func_77474_a"
|
||||
);
|
||||
private static final List<Pair<String, String>> BlockBoundsFields = ImmutableList.of(
|
||||
Pair.of("minX", "field_149759_B"),
|
||||
Pair.of("minY", "field_149760_C"),
|
||||
Pair.of("minZ", "field_149754_D"),
|
||||
Pair.of("maxX", "field_149755_E"),
|
||||
Pair.of("maxY", "field_149756_F"),
|
||||
Pair.of("maxZ", "field_149757_G")
|
||||
);
|
||||
/** All classes in <tt>net.minecraft.block.*</tt> are the block subclasses save for these. */
|
||||
private static final String[] VanillaBlockExclusions = {
|
||||
"net/minecraft/block/IGrowable",
|
||||
"net/minecraft/block/ITileEntityProvider",
|
||||
"net/minecraft/block/BlockEventData",
|
||||
"net/minecraft/block/BlockSourceImpl",
|
||||
"net/minecraft/block/material/"
|
||||
};
|
||||
|
||||
private static final ClassConstantPoolParser cstPoolParser = new ClassConstantPoolParser(GL11, GL13, GL14, GL20, OpenGlHelper, EXTBlendFunc, ARBMultiTexture, BlockPackage, Project);
|
||||
private static final ClassConstantPoolParser cstPoolParser = new ClassConstantPoolParser(GL11, GL13, GL14, GL20, OpenGlHelper, EXTBlendFunc, ARBMultiTexture, Project);
|
||||
private static final Map<String, Map<String, String>> methodRedirects = new HashMap<>();
|
||||
private static final Map<Integer, String> glCapRedirects = new HashMap<>();
|
||||
|
||||
private static final Set<String> moddedBlockSubclasses = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
// Block owners we *shouldn't* redirect because they shadow one of our fields
|
||||
private static final Set<String> blockOwnerExclusions = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
|
||||
// Needed because the config is loaded in LaunchClassLoader, but we need to access it in the parent system loader.
|
||||
private static final MethodHandle angelicaConfigSodiumEnabledGetter;
|
||||
|
||||
static {
|
||||
glCapRedirects.put(org.lwjgl.opengl.GL11.GL_ALPHA_TEST, "AlphaTest");
|
||||
glCapRedirects.put(org.lwjgl.opengl.GL11.GL_BLEND, "Blend");
|
||||
@@ -220,41 +181,6 @@ public final class AngelicaRedirector {
|
||||
methodRedirects.put(EXTBlendFunc, RedirectMap.newMap().add("glBlendFuncSeparateEXT", "tryBlendFuncSeparate"));
|
||||
methodRedirects.put(ARBMultiTexture, RedirectMap.newMap().add("glActiveTextureARB"));
|
||||
methodRedirects.put(Project, RedirectMap.newMap().add("gluPerspective"));
|
||||
|
||||
try {
|
||||
final Class<?> angelicaConfig = Class.forName("com.gtnewhorizons.angelica.config.AngelicaConfig", true, Launch.classLoader);
|
||||
angelicaConfigSodiumEnabledGetter = MethodHandles.lookup().findStaticGetter(angelicaConfig, "enableSodium", boolean.class);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isSodiumEnabled() {
|
||||
try {
|
||||
return (boolean) angelicaConfigSodiumEnabledGetter.invokeExact();
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isVanillaBlockSubclass(String className) {
|
||||
if (className.startsWith(BlockPackage)) {
|
||||
for (String exclusion : VanillaBlockExclusions) {
|
||||
if (className.startsWith(exclusion)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isBlockSubclass(String className) {
|
||||
return isVanillaBlockSubclass(className) || moddedBlockSubclasses.contains(className);
|
||||
}
|
||||
|
||||
private String getFieldName(Pair<String, String> fieldPair) {
|
||||
return IS_OBF ? fieldPair.getRight() : fieldPair.getLeft();
|
||||
}
|
||||
|
||||
public String[] getTransformerExclusions() {
|
||||
@@ -276,30 +202,6 @@ public final class AngelicaRedirector {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Track subclasses of Block
|
||||
if (!isVanillaBlockSubclass(cn.name) && isBlockSubclass(cn.superName)) {
|
||||
moddedBlockSubclasses.add(cn.name);
|
||||
cstPoolParser.addString(cn.name);
|
||||
}
|
||||
|
||||
// Check if this class shadows any fields of the parent class
|
||||
if (moddedBlockSubclasses.contains(cn.name)) {
|
||||
// If a superclass shadows, then so do we, because JVM will resolve a reference on our class to that
|
||||
// superclass
|
||||
boolean doWeShadow;
|
||||
if (blockOwnerExclusions.contains(cn.superName)) {
|
||||
doWeShadow = true;
|
||||
} else {
|
||||
// Check if we declare any known field names
|
||||
doWeShadow = BlockBoundsFields.stream().anyMatch(pair ->
|
||||
cn.fields.stream().anyMatch(field -> field.name.equals(getFieldName(pair))));
|
||||
}
|
||||
if (doWeShadow) {
|
||||
LOGGER.info("Class '{}' shadows one or more block bounds fields, these accesses won't be redirected!", cn.name);
|
||||
blockOwnerExclusions.add(cn.name);
|
||||
}
|
||||
}
|
||||
|
||||
boolean changed = false;
|
||||
for (MethodNode mn : cn.methods) {
|
||||
if (transformedName.equals("net.minecraft.client.renderer.OpenGlHelper") && (mn.name.equals("glBlendFunc") || mn.name.equals("func_148821_a"))) {
|
||||
@@ -360,42 +262,6 @@ public final class AngelicaRedirector {
|
||||
redirectInMethod = true;
|
||||
}
|
||||
}
|
||||
} else if ((node.getOpcode() == Opcodes.GETFIELD || node.getOpcode() == Opcodes.PUTFIELD) && node instanceof FieldInsnNode fNode) {
|
||||
if (!blockOwnerExclusions.contains(fNode.owner) && isBlockSubclass(fNode.owner) && isSodiumEnabled()) {
|
||||
Pair<String, String> fieldToRedirect = BlockBoundsFields.stream()
|
||||
.filter(pair -> fNode.name.equals(getFieldName(pair)))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (fieldToRedirect != null) {
|
||||
if (LOG_SPAM) {
|
||||
LOGGER.info("Redirecting Block.{} in {} to thread-safe wrapper", fNode.name, transformedName);
|
||||
}
|
||||
// Perform the redirect
|
||||
fNode.name = fieldToRedirect.getLeft(); // use unobfuscated name
|
||||
fNode.owner = ThreadedBlockData;
|
||||
// Inject getter before the field access, to turn Block -> ThreadedBlockData
|
||||
final MethodInsnNode getter = new MethodInsnNode(Opcodes.INVOKESTATIC, ThreadedBlockData, "get", "(L" + BlockClass + ";)L" + ThreadedBlockData + ";", false);
|
||||
if (node.getOpcode() == Opcodes.GETFIELD) {
|
||||
mn.instructions.insertBefore(fNode, getter);
|
||||
} else if (node.getOpcode() == Opcodes.PUTFIELD) {
|
||||
// FIXME: this code assumes doubles
|
||||
// Stack: Block, double
|
||||
final InsnList beforePut = new InsnList();
|
||||
beforePut.add(new InsnNode(Opcodes.DUP2_X1));
|
||||
// Stack: double, Block, double
|
||||
beforePut.add(new InsnNode(Opcodes.POP2));
|
||||
// Stack: double, Block
|
||||
beforePut.add(getter);
|
||||
// Stack: double, ThreadedBlockData
|
||||
beforePut.add(new InsnNode(Opcodes.DUP_X2));
|
||||
// Stack: ThreadedBlockData, double, ThreadedBlockData
|
||||
beforePut.add(new InsnNode(Opcodes.POP));
|
||||
// Stack: ThreadedBlockData, double
|
||||
mn.instructions.insertBefore(fNode, beforePut);
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ASSERT_MAIN_THREAD && redirectInMethod && !transformedName.startsWith(SplashProgress) && !(transformedName.startsWith(MinecraftClient) && ExcludedMinecraftMainThreadChecks.contains(mn.name))) {
|
||||
|
||||
+211
@@ -0,0 +1,211 @@
|
||||
package com.gtnewhorizons.angelica.loading.shared.transformers;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizon.gtnhlib.asm.ClassConstantPoolParser;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.FieldInsnNode;
|
||||
import org.objectweb.asm.tree.FieldNode;
|
||||
import org.objectweb.asm.tree.InsnList;
|
||||
import org.objectweb.asm.tree.InsnNode;
|
||||
import org.objectweb.asm.tree.MethodInsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class SodiumBlockTransform {
|
||||
|
||||
public SodiumBlockTransform(boolean isObf) {
|
||||
this.IS_OBF = isObf;
|
||||
}
|
||||
|
||||
private final boolean IS_OBF;
|
||||
|
||||
private static final boolean LOG_SPAM = Boolean.getBoolean("angelica.redirectorLogspam");
|
||||
private static final Logger LOGGER = LogManager.getLogger("SodiumBlockTransformer");
|
||||
private static final String BlockClass = "net/minecraft/block/Block";
|
||||
private static final String BlockPackage = "net/minecraft/block/Block";
|
||||
private static final String ThreadedBlockData = "com/gtnewhorizons/angelica/glsm/ThreadedBlockData";
|
||||
private static final List<Pair<String, String>> BlockBoundsFields = ImmutableList.of(
|
||||
Pair.of("minX", "field_149759_B"),
|
||||
Pair.of("minY", "field_149760_C"),
|
||||
Pair.of("minZ", "field_149754_D"),
|
||||
Pair.of("maxX", "field_149755_E"),
|
||||
Pair.of("maxY", "field_149756_F"),
|
||||
Pair.of("maxZ", "field_149757_G")
|
||||
);
|
||||
/** All classes in <tt>net.minecraft.block.*</tt> are the block subclasses save for these. */
|
||||
private static final String[] VanillaBlockExclusions = {
|
||||
"net/minecraft/block/IGrowable",
|
||||
"net/minecraft/block/ITileEntityProvider",
|
||||
"net/minecraft/block/BlockEventData",
|
||||
"net/minecraft/block/BlockSourceImpl",
|
||||
"net/minecraft/block/material/"
|
||||
};
|
||||
|
||||
private static final ClassConstantPoolParser cstPoolParser = new ClassConstantPoolParser(BlockPackage);
|
||||
private static final Set<String> moddedBlockSubclasses = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
// Block owners we *shouldn't* redirect because they shadow one of our fields
|
||||
private static final Set<String> blockOwnerExclusions = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
// Needed because the config is loaded in LaunchClassLoader, but we need to access it in the parent system loader.
|
||||
private static final MethodHandle angelicaConfigSodiumEnabledGetter;
|
||||
private static boolean isSodiumEnabled;
|
||||
|
||||
static {
|
||||
try {
|
||||
final Class<?> angelicaConfig = Class.forName("com.gtnewhorizons.angelica.config.AngelicaConfig", true, Launch.classLoader);
|
||||
angelicaConfigSodiumEnabledGetter = MethodHandles.lookup().findStaticGetter(angelicaConfig, "enableSodium", boolean.class);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isSodiumEnabled() {
|
||||
if (isSodiumEnabled) return true;
|
||||
try {
|
||||
return (boolean) angelicaConfigSodiumEnabledGetter.invokeExact();
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isVanillaBlockSubclass(String className) {
|
||||
if (className.startsWith(BlockPackage)) {
|
||||
for (String exclusion : VanillaBlockExclusions) {
|
||||
if (className.startsWith(exclusion)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isBlockSubclass(String className) {
|
||||
return isVanillaBlockSubclass(className) || moddedBlockSubclasses.contains(className);
|
||||
}
|
||||
|
||||
private String getFieldName(Pair<String, String> fieldPair) {
|
||||
return IS_OBF ? fieldPair.getRight() : fieldPair.getLeft();
|
||||
}
|
||||
|
||||
public String[] getTransformerExclusions() {
|
||||
return new String[]{
|
||||
"org.lwjgl",
|
||||
"com.gtnewhorizons.angelica.glsm.",
|
||||
"com.gtnewhorizons.angelica.transform",
|
||||
"me.eigenraven.lwjgl3ify"
|
||||
};
|
||||
}
|
||||
|
||||
public boolean shouldTransform(byte[] basicClass) {
|
||||
return cstPoolParser.find(basicClass, true);
|
||||
}
|
||||
|
||||
/** @return Was the class changed? */
|
||||
public boolean transformClassNode(String transformedName, ClassNode cn) {
|
||||
if (cn == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ("net.minecraft.block.Block".equals(transformedName) && isSodiumEnabled()) {
|
||||
cn.fields.removeIf(field -> BlockBoundsFields.stream().anyMatch(pair -> field.name.equals(pair.getLeft()) || field.name.equals(pair.getRight())));
|
||||
}
|
||||
|
||||
// Track subclasses of Block
|
||||
if (!isVanillaBlockSubclass(cn.name) && isBlockSubclass(cn.superName)) {
|
||||
moddedBlockSubclasses.add(cn.name);
|
||||
cstPoolParser.addString(cn.name);
|
||||
}
|
||||
|
||||
// Check if this class shadows any fields of the parent class
|
||||
if (moddedBlockSubclasses.contains(cn.name)) {
|
||||
// If a superclass shadows, then so do we, because JVM will resolve a reference on our class to that
|
||||
// superclass
|
||||
boolean doWeShadow;
|
||||
if (blockOwnerExclusions.contains(cn.superName)) {
|
||||
doWeShadow = true;
|
||||
} else {
|
||||
// Check if we declare any known field names
|
||||
boolean b = false;
|
||||
for (Pair<String, String> pair : BlockBoundsFields) {
|
||||
boolean result = false;
|
||||
for (FieldNode field : cn.fields) {
|
||||
if (field.name.equals(getFieldName(pair))) {
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (result) {
|
||||
b = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
doWeShadow = b;
|
||||
}
|
||||
if (doWeShadow) {
|
||||
LOGGER.info("Class '{}' shadows one or more block bounds fields, these accesses won't be redirected!", cn.name);
|
||||
blockOwnerExclusions.add(cn.name);
|
||||
}
|
||||
}
|
||||
|
||||
boolean changed = false;
|
||||
for (MethodNode mn : cn.methods) {
|
||||
for (AbstractInsnNode node : mn.instructions.toArray()) {
|
||||
if ((node.getOpcode() == Opcodes.GETFIELD || node.getOpcode() == Opcodes.PUTFIELD) && node instanceof FieldInsnNode fNode) {
|
||||
if (!blockOwnerExclusions.contains(fNode.owner) && isBlockSubclass(fNode.owner) && isSodiumEnabled()) {
|
||||
Pair<String, String> fieldToRedirect = BlockBoundsFields.stream()
|
||||
.filter(pair -> fNode.name.equals(getFieldName(pair)))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (fieldToRedirect != null) {
|
||||
if (LOG_SPAM) {
|
||||
LOGGER.info("Redirecting Block.{} in {} to thread-safe wrapper", fNode.name, transformedName);
|
||||
}
|
||||
// Perform the redirect
|
||||
fNode.name = fieldToRedirect.getLeft(); // use unobfuscated name
|
||||
fNode.owner = ThreadedBlockData;
|
||||
// Inject getter before the field access, to turn Block -> ThreadedBlockData
|
||||
final MethodInsnNode getter = new MethodInsnNode(Opcodes.INVOKESTATIC, ThreadedBlockData, "get", "(L" + BlockClass + ";)L" + ThreadedBlockData + ";", false);
|
||||
if (node.getOpcode() == Opcodes.GETFIELD) {
|
||||
mn.instructions.insertBefore(fNode, getter);
|
||||
} else if (node.getOpcode() == Opcodes.PUTFIELD) {
|
||||
// FIXME: this code assumes doubles
|
||||
// Stack: Block, double
|
||||
final InsnList beforePut = new InsnList();
|
||||
beforePut.add(new InsnNode(Opcodes.DUP2_X1));
|
||||
// Stack: double, Block, double
|
||||
beforePut.add(new InsnNode(Opcodes.POP2));
|
||||
// Stack: double, Block
|
||||
beforePut.add(getter);
|
||||
// Stack: double, ThreadedBlockData
|
||||
beforePut.add(new InsnNode(Opcodes.DUP_X2));
|
||||
// Stack: ThreadedBlockData, double, ThreadedBlockData
|
||||
beforePut.add(new InsnNode(Opcodes.POP));
|
||||
// Stack: ThreadedBlockData, double
|
||||
mn.instructions.insertBefore(fNode, beforePut);
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
public void setSodiumSetting() {
|
||||
isSodiumEnabled = true;
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,14 @@ public enum Mixins implements IMixins {
|
||||
, "angelica.dynamiclights.MixinItemRenderer"
|
||||
)
|
||||
),
|
||||
|
||||
|
||||
ANGELICA_FIX_BLOCK_CRACK(
|
||||
new MixinBuilder("Block corners and edges between chunks might have \"cracks\" in them. This option fixes it")
|
||||
.setPhase(Phase.EARLY)
|
||||
.addClientMixins("angelica.bugfixes.MixinRenderBlocks_CrackFix")
|
||||
.addExcludedMod(TargetedMod.FALSETWEAKS)
|
||||
.setApplyIf(() -> AngelicaConfig.fixBlockCrack)),
|
||||
|
||||
ANGELICA_FIX_FLUID_RENDERER_CHECKING_BLOCK_AGAIN(
|
||||
new MixinBuilder("Fix RenderBlockFluid reading the block type from the world access multiple times")
|
||||
.setPhase(Phase.EARLY)
|
||||
@@ -276,6 +283,17 @@ public enum Mixins implements IMixins {
|
||||
.addRequiredMod(TargetedMod.MINEFACTORY_RELOADED)
|
||||
.setApplyIf(() -> CompatConfig.fixMinefactoryReloaded)
|
||||
.addClientMixins("client.minefactoryreloaded.MixinRedNetCableRenderer")),
|
||||
|
||||
NTM_SPACE_TWEAKS(new MixinBuilder("Support for 'Disable Horizon' & 'disableAltitudePlanetRenderer' options in NTM:Space")
|
||||
.setPhase(Phase.LATE)
|
||||
.addRequiredMod(TargetedMod.NTM_SPACE)
|
||||
.setApplyIf(() -> CompatConfig.tweakNTMSpace)
|
||||
.addClientMixins("client.ntmSpace.MixinSkyProviderCelestial_Tweaks")),
|
||||
NTM_SPACE_SHADER_COMPAT(new MixinBuilder("Multiple shader fixes for NTM:Space")
|
||||
.setPhase(Phase.LATE)
|
||||
.addRequiredMod(TargetedMod.NTM_SPACE)
|
||||
.setApplyIf(() -> CompatConfig.fixNTMSpace && AngelicaConfig.enableIris)
|
||||
.addClientMixins("client.ntmSpace.MixinSkyProviderCelestial_ShaderCompat")),
|
||||
|
||||
SPEEDUP_CAMPFIRE_BACKPORT_ANIMATIONS(new MixinBuilder("Add animation speedup support to Campfire Backport")
|
||||
.setPhase(Phase.LATE)
|
||||
|
||||
@@ -14,7 +14,9 @@ public enum TargetedMod implements ITargetMod {
|
||||
DYNAMIC_SURROUNDINGS_MIST("org.blockartistry.mod.DynSurround.mixinplugin.DynamicSurroundingsEarlyMixins", "dsurround"),
|
||||
DYNAMIC_SURROUNDINGS_ORIGINAL("org.blockartistry.mod.DynSurround.asm.TransformLoader", "dsurround"),
|
||||
EXTRAUTILS(null, "ExtraUtilities"),
|
||||
FALSETWEAKS("com.falsepattern.falsetweaks.asm.CoreLoadingPlugin", "falsetweaks"),
|
||||
MINEFACTORY_RELOADED(null, "MineFactoryReloaded"),
|
||||
NTM_SPACE("com.hbm.dim.SolarSystem"),
|
||||
IC2("ic2.core.coremod.IC2core", "IC2"),
|
||||
NATURA(null, "Natura"),
|
||||
SECURITYCRAFT(null, "securitycraft"),
|
||||
@@ -24,7 +26,10 @@ public enum TargetedMod implements ITargetMod {
|
||||
WITCHERY(null, "witchery");
|
||||
|
||||
private final TargetModBuilder builder;
|
||||
|
||||
|
||||
TargetedMod(String targetClass) {
|
||||
this.builder = new TargetModBuilder().setTargetClass(targetClass);
|
||||
}
|
||||
TargetedMod(String coreModClass, String modId) {
|
||||
this.builder = new TargetModBuilder().setCoreModClass(coreModClass).setModId(modId);
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ public enum Settings {
|
||||
DynamicLights.ShaderForce = (boolean) this.option.getStore();
|
||||
}
|
||||
},
|
||||
HORIZON_DISABLE(new NotFineOptionTickBox(true, OptionImpact.LOW)),
|
||||
FOG_DISABLE(new NotFineOptionTickBox(false, OptionImpact.LOW)),
|
||||
FOG_NEAR_DISTANCE(new NotFineOptionSliderPercentage(75, 1, 100, 1, OptionImpact.LOW)),
|
||||
GUI_BACKGROUND(new NotFineOptionCycling<>(BackgroundSelect.DEFAULT, null)) {
|
||||
|
||||
@@ -213,6 +213,7 @@ public class NotFineGameOptionPages {
|
||||
.add(Settings.MODE_CLOUD_TRANSLUCENCY.option)
|
||||
.add(Settings.MODE_STARS.option)
|
||||
.add(Settings.TOTAL_STARS.option)
|
||||
.add(Settings.HORIZON_DISABLE.option)
|
||||
.add(Settings.FOG_DISABLE.option)
|
||||
.add(Settings.FOG_NEAR_DISTANCE.option)
|
||||
.build());
|
||||
|
||||
@@ -16,7 +16,8 @@ public abstract class Type {
|
||||
public static final Primitive[] AllPrimitives = {Type.Boolean, Type.Int, Type.Float};
|
||||
|
||||
public static UniformType convert(Type type) {
|
||||
if (type == Type.Int || type == Type.Boolean) return UniformType.INT;
|
||||
if (type == Type.Int) return UniformType.INT;
|
||||
else if (type == Type.Boolean) return UniformType.INT;
|
||||
else if (type == Type.Float) return UniformType.FLOAT;
|
||||
else if (type == VectorType.VEC2) return UniformType.VEC2;
|
||||
else if (type == VectorType.VEC3) return UniformType.VEC3;
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import java.util.function.Consumer;
|
||||
|
||||
public class ScrollBarComponent extends AbstractWidget {
|
||||
|
||||
protected static final int SCROLL_OFFSET = 6;
|
||||
protected static final int SCROLL_OFFSET = 15;
|
||||
|
||||
protected final Dim2i dim;
|
||||
|
||||
|
||||
@@ -89,6 +89,7 @@ public class SodiumGameOptionPages {
|
||||
.add(Settings.MODE_CLOUD_TRANSLUCENCY.option)
|
||||
.add(Settings.MODE_STARS.option)
|
||||
.add(Settings.TOTAL_STARS.option)
|
||||
.add(Settings.HORIZON_DISABLE.option)
|
||||
.add(Settings.FOG_DISABLE.option)
|
||||
.add(Settings.FOG_NEAR_DISTANCE.option)
|
||||
.add(Settings.VOID_FOG.option);
|
||||
|
||||
@@ -203,43 +203,45 @@ public class ProgramUniforms {
|
||||
final int size = sizeType.get(0);
|
||||
final int type = sizeType.get(1);
|
||||
|
||||
UniformType provided = uniformNames.get(name);
|
||||
final UniformType provided = uniformNames.get(name);
|
||||
final UniformType expected = getExpectedType(type);
|
||||
|
||||
if (provided == null && !name.startsWith("gl_")) {
|
||||
final String typeName = getTypeName(type);
|
||||
if(AngelicaConfig.enableHardcodedCustomUniforms) {
|
||||
// Legacy Checks from hardcoded custom uniforms
|
||||
if (provided == null && !name.startsWith("gl_")) {
|
||||
final String typeName = getTypeName(type);
|
||||
|
||||
if (isSampler(type) || isImage(type)) {
|
||||
// don't print a warning, samplers and images are managed elsewhere.
|
||||
// TODO: Detect unsupported samplers/images?
|
||||
continue;
|
||||
}
|
||||
if (isSampler(type) || isImage(type)) {
|
||||
// don't print a warning, samplers and images are managed elsewhere.
|
||||
continue;
|
||||
}
|
||||
|
||||
final UniformType externalProvided = externalUniformNames.get(name);
|
||||
final UniformType externalProvided = externalUniformNames.get(name);
|
||||
|
||||
if (externalProvided != null) {
|
||||
if (externalProvided != expected) {
|
||||
String expectedName;
|
||||
if (externalProvided != null) {
|
||||
if (externalProvided != expected) {
|
||||
final String expectedName;
|
||||
|
||||
if (expected != null) {
|
||||
expectedName = expected.toString();
|
||||
} else {
|
||||
expectedName = "(unsupported type: " + getTypeName(type) + ")";
|
||||
if (expected != null) {
|
||||
expectedName = expected.toString();
|
||||
} else {
|
||||
expectedName = "(unsupported type: " + getTypeName(type) + ")";
|
||||
}
|
||||
|
||||
Iris.logger.error("[" + this.name + "] Wrong uniform type for externally-managed uniform " + name + ": " + externalProvided + " is provided but the program expects " + expectedName + ".");
|
||||
}
|
||||
|
||||
Iris.logger.error("[" + this.name + "] Wrong uniform type for externally-managed uniform " + name + ": " + externalProvided + " is provided but the program expects " + expectedName + ".");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (size == 1) {
|
||||
Iris.logger.warn("[" + this.name + "] Unsupported uniform: " + typeName + " " + name);
|
||||
} else {
|
||||
Iris.logger.warn("[" + this.name + "] Unsupported uniform: " + name + " of size " + size + " and type " + typeName);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (size == 1) {
|
||||
Iris.logger.warn("[" + this.name + "] Unsupported uniform: " + typeName + " " + name);
|
||||
} else {
|
||||
Iris.logger.warn("[" + this.name + "] Unsupported uniform: " + name + " of size " + size + " and type " + typeName);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (provided != null && provided != expected) {
|
||||
@@ -291,6 +293,7 @@ public class ProgramUniforms {
|
||||
return switch(type) {
|
||||
case GL11.GL_FLOAT -> "float";
|
||||
case GL11.GL_INT -> "int";
|
||||
case GL20.GL_BOOL -> "bool";
|
||||
case GL20.GL_FLOAT_MAT4 -> "mat4";
|
||||
case GL20.GL_FLOAT_VEC4 -> "vec4";
|
||||
case GL20.GL_FLOAT_MAT3 -> "mat3";
|
||||
@@ -316,12 +319,13 @@ public class ProgramUniforms {
|
||||
return switch (type) {
|
||||
case GL11.GL_FLOAT -> UniformType.FLOAT;
|
||||
case GL11.GL_INT -> UniformType.INT;
|
||||
case GL20.GL_BOOL -> UniformType.INT;
|
||||
case GL20.GL_FLOAT_MAT4 -> UniformType.MAT4;
|
||||
case GL20.GL_FLOAT_VEC4 -> UniformType.VEC4;
|
||||
case GL20.GL_INT_VEC4 -> UniformType.VEC4I;
|
||||
case GL20.GL_FLOAT_VEC3 -> UniformType.VEC3;
|
||||
case GL20.GL_FLOAT_MAT3 -> null;
|
||||
case GL20.GL_INT_VEC3 -> null;
|
||||
case GL20.GL_FLOAT_MAT3 -> UniformType.MAT3;
|
||||
case GL20.GL_INT_VEC3 -> UniformType.VEC3I;
|
||||
case GL20.GL_FLOAT_MAT2 -> null;
|
||||
case GL20.GL_FLOAT_VEC2 -> UniformType.VEC2;
|
||||
case GL20.GL_INT_VEC2 -> UniformType.VEC2I;
|
||||
|
||||
@@ -3,11 +3,13 @@ package net.coderbot.iris.gl.shader;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizons.angelica.Tags;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import net.coderbot.iris.parsing.BiomeCategories;
|
||||
import net.coderbot.iris.pipeline.HandRenderer;
|
||||
import net.coderbot.iris.pipeline.WorldRenderingPhase;
|
||||
import net.coderbot.iris.shaderpack.StringPair;
|
||||
import net.coderbot.iris.texture.format.TextureFormat;
|
||||
import net.coderbot.iris.texture.format.TextureFormatLoader;
|
||||
import net.coderbot.iris.uniforms.VanillaBiomeList;
|
||||
import org.lwjgl.LWJGLUtil;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
@@ -88,6 +90,9 @@ public class StandardMacros {
|
||||
define(standardDefines, irisDefine);
|
||||
}
|
||||
|
||||
getBiomeCategoryDefines().forEach((category, ordinal) -> define(standardDefines, category, ordinal));
|
||||
getVanillaBiomeDefines().forEach((biome, id) -> define(standardDefines, biome, id));
|
||||
|
||||
return ImmutableList.copyOf(standardDefines);
|
||||
}
|
||||
|
||||
@@ -98,7 +103,7 @@ public class StandardMacros {
|
||||
* @see <a href="https://github.com/sp614x/optifine/blob/9c6a5b5326558ccc57c6490b66b3be3b2dc8cbef/OptiFineDoc/doc/shaders.txt#L696-L699">Optifine Doc</a>
|
||||
*/
|
||||
public static String getMcVersion() {
|
||||
final String version = Loader.MC_VERSION;;
|
||||
final String version = Loader.MC_VERSION;
|
||||
|
||||
String[] splitVersion = version.split("\\.");
|
||||
|
||||
@@ -117,10 +122,10 @@ public class StandardMacros {
|
||||
}
|
||||
|
||||
if (minor.length() == 1) {
|
||||
minor = 0 + minor;
|
||||
minor = "0" + minor;
|
||||
}
|
||||
if (bugfix.length() == 1) {
|
||||
bugfix = 0 + bugfix;
|
||||
bugfix = "0" + bugfix;
|
||||
}
|
||||
|
||||
return major + minor + bugfix;
|
||||
@@ -283,4 +288,47 @@ public class StandardMacros {
|
||||
|
||||
return defines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns biome category defines for use in shaders.
|
||||
* Generates #define CAT_<CATEGORY_NAME> <ordinal> for each BiomeCategories enum value.
|
||||
*
|
||||
* @return Map of biome category defines and their ordinal values
|
||||
*/
|
||||
public static Map<String, String> getBiomeCategoryDefines() {
|
||||
Map<String, String> defines = new HashMap<>();
|
||||
for (BiomeCategories category : BiomeCategories.values()) {
|
||||
defines.put("CAT_" + category.name(), String.valueOf(category.ordinal()));
|
||||
}
|
||||
return defines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns vanilla biome ID defines for use in shaders.
|
||||
* Generates #define BIOME_<BIOME_NAME> <biomeID> for all vanilla biomes.
|
||||
*
|
||||
* @return Map of vanilla biome defines and their IDs
|
||||
*/
|
||||
public static Map<String, String> getVanillaBiomeDefines() {
|
||||
final Map<String, String> defines = new HashMap<>();
|
||||
|
||||
for (VanillaBiomeList.BiomeEntry entry : VanillaBiomeList.getVanillaBiomes()) {
|
||||
if (entry.biome != null) {
|
||||
defines.put("BIOME_" + entry.name, String.valueOf(entry.biome.biomeID));
|
||||
}
|
||||
}
|
||||
|
||||
// Modern biomes that don't exist in 1.7.10 - add dummy IDs that will never match
|
||||
// This allows shader expressions to parse without errors while always evaluating to false/0
|
||||
// Using negative IDs to avoid conflicts with actual biome IDs
|
||||
defines.put("BIOME_NETHER_WASTES", "-1000");
|
||||
defines.put("BIOME_SOUL_SAND_VALLEY", "-1001");
|
||||
defines.put("BIOME_CRIMSON_FOREST", "-1002");
|
||||
defines.put("BIOME_WARPED_FOREST", "-1003");
|
||||
defines.put("BIOME_BASALT_DELTAS", "-1004");
|
||||
defines.put("BIOME_LUSH_CAVES", "-1005");
|
||||
defines.put("BIOME_PALE_GARDEN", "-1006");
|
||||
|
||||
return defines;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,9 @@ package net.coderbot.iris.gl.uniform;
|
||||
|
||||
public enum UniformType {
|
||||
INT,
|
||||
BOOL,
|
||||
FLOAT,
|
||||
MAT3,
|
||||
MAT4,
|
||||
VEC2,
|
||||
VEC2I,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.coderbot.iris.pipeline;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.Camera;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.GameModeUtil;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.InteractionHand;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
@@ -26,7 +27,7 @@ public class HandRenderer {
|
||||
public static final float DEPTH = 0.125F;
|
||||
|
||||
private void setupGlState(RenderGlobal gameRenderer, Camera camera, float tickDelta) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
||||
GL11.glLoadIdentity();
|
||||
@@ -72,8 +73,7 @@ public class HandRenderer {
|
||||
mc.gameSettings.thirdPersonView == 0 &&
|
||||
!camera.getEntity().isPlayerSleeping() &&
|
||||
!mc.gameSettings.hideGUI &&
|
||||
// TODO: SPECTATOR
|
||||
// mc.playerController.currentGameType
|
||||
!GameModeUtil.isSpectator() &&
|
||||
!mc.playerController.enableEverythingIsScrewedUpMode();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.coderbot.iris.pipeline.transform.TransformPatcher;
|
||||
import net.coderbot.iris.shaderpack.ProgramSet;
|
||||
import net.coderbot.iris.shaderpack.ProgramSource;
|
||||
import net.coderbot.iris.uniforms.CommonUniforms;
|
||||
import net.coderbot.iris.uniforms.ExternallyManagedUniforms;
|
||||
import net.coderbot.iris.uniforms.builtin.BuiltinReplacementUniforms;
|
||||
import net.coderbot.iris.uniforms.custom.CustomUniforms;
|
||||
|
||||
@@ -143,6 +144,8 @@ public class SodiumTerrainPipeline {
|
||||
CommonUniforms.addDynamicUniforms(uniforms);
|
||||
customUniforms.assignTo(uniforms);
|
||||
|
||||
ExternallyManagedUniforms.addExternallyManagedUniforms116(uniforms);
|
||||
|
||||
BuiltinReplacementUniforms.addBuiltinReplacementUniforms(uniforms);
|
||||
return uniforms;
|
||||
}
|
||||
|
||||
@@ -18,13 +18,17 @@ import net.coderbot.iris.gl.blending.BlendModeFunction;
|
||||
import net.coderbot.iris.gl.blending.BlendModeOverride;
|
||||
import net.coderbot.iris.gl.blending.BufferBlendInformation;
|
||||
import net.coderbot.iris.gl.texture.TextureScaleOverride;
|
||||
import net.coderbot.iris.pipeline.PatchedShaderPrinter;
|
||||
import net.coderbot.iris.shaderpack.option.ShaderPackOptions;
|
||||
import net.coderbot.iris.shaderpack.preprocessor.PropertiesPreprocessor;
|
||||
import net.coderbot.iris.shaderpack.texture.TextureStage;
|
||||
import net.coderbot.iris.uniforms.custom.CustomUniforms;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumMap;
|
||||
@@ -98,6 +102,15 @@ public class ShaderProperties {
|
||||
public ShaderProperties(String contents, ShaderPackOptions shaderPackOptions, Iterable<StringPair> environmentDefines) {
|
||||
final String preprocessedContents = PropertiesPreprocessor.preprocessSource(contents, shaderPackOptions, environmentDefines);
|
||||
|
||||
if (PatchedShaderPrinter.prettyPrintShaders) {
|
||||
try {
|
||||
Files.write(Minecraft.getMinecraft().mcDataDir.toPath().resolve("preprocessed.properties"), preprocessedContents.getBytes(StandardCharsets.UTF_8));
|
||||
Files.write(Minecraft.getMinecraft().mcDataDir.toPath().resolve("original.properties"), contents.getBytes(StandardCharsets.UTF_8));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
final Properties preprocessed = new OrderBackedProperties();
|
||||
final Properties original = new OrderBackedProperties();
|
||||
try {
|
||||
@@ -181,7 +194,7 @@ public class ShaderProperties {
|
||||
});
|
||||
|
||||
handlePassDirective("alphaTest.", key, value, pass -> {
|
||||
if ("off".equals(value)) {
|
||||
if ("off".equals(value) || "false".equals(value)) {
|
||||
alphaTestOverrides.put(pass, AlphaTestOverride.OFF);
|
||||
return;
|
||||
}
|
||||
|
||||
+20
-14
@@ -6,6 +6,7 @@ import net.coderbot.iris.shaderpack.option.ShaderPackOptions;
|
||||
import org.anarres.cpp.Feature;
|
||||
import org.anarres.cpp.LexerException;
|
||||
import org.anarres.cpp.Preprocessor;
|
||||
import org.anarres.cpp.PreprocessorCommand;
|
||||
import org.anarres.cpp.StringLexerSource;
|
||||
import org.anarres.cpp.Token;
|
||||
|
||||
@@ -14,18 +15,19 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PropertiesPreprocessor {
|
||||
// Derived from ShaderProcessor.glslPreprocessSource, which is derived from GlShader from Canvas, licenced under LGPL
|
||||
public static String preprocessSource(String source, ShaderPackOptions shaderPackOptions, Iterable<StringPair> environmentDefines) {
|
||||
if (source.contains(PropertyCollectingListener.PROPERTY_MARKER)) {
|
||||
if (source.contains(PropertyCollectingListener.PROPERTY_MARKER) || source.contains("IRIS_PASSTHROUGHBACKSLASH")) {
|
||||
throw new RuntimeException("Some shader author is trying to exploit internal Iris implementation details, stop!");
|
||||
}
|
||||
|
||||
List<String> booleanValues = getBooleanValues(shaderPackOptions);
|
||||
Map<String, String> stringValues = getStringValues(shaderPackOptions);
|
||||
final List<String> booleanValues = getBooleanValues(shaderPackOptions);
|
||||
final Map<String, String> stringValues = getStringValues(shaderPackOptions);
|
||||
|
||||
try (Preprocessor pp = new Preprocessor()) {
|
||||
for (String value : booleanValues) {
|
||||
@@ -57,7 +59,7 @@ public class PropertiesPreprocessor {
|
||||
throw new RuntimeException("Some shader author is trying to exploit internal Iris implementation details, stop!");
|
||||
}
|
||||
|
||||
Preprocessor preprocessor = new Preprocessor();
|
||||
final Preprocessor preprocessor = new Preprocessor();
|
||||
|
||||
try {
|
||||
for (StringPair envDefine : environmentDefines) {
|
||||
@@ -78,19 +80,23 @@ public class PropertiesPreprocessor {
|
||||
// Not super efficient, but this removes trailing whitespace on lines, fixing an issue with whitespace after
|
||||
// line continuations (see PreprocessorTest#testWeirdPropertiesLineContinuation)
|
||||
// Required for Voyager Shader
|
||||
source = Arrays.stream(source.split("\\R")).map(String::trim)
|
||||
source = Arrays.stream(source.split("\\R")).map(String::trim).filter(s -> !s.isEmpty())
|
||||
.map(line -> {
|
||||
if (line.startsWith("#")) {
|
||||
// In PropertyCollectingListener we suppress "unknown preprocessor directive errors" and
|
||||
// assume the line to be a comment, since in .properties files `#` also functions as a comment
|
||||
// marker.
|
||||
return line;
|
||||
} else {
|
||||
// This is a hack to ensure that non-macro lines don't have any preprocessing applied...
|
||||
// In properties files, we don't substitute #define values except on macro lines.
|
||||
return "#warning IRIS_PASSTHROUGH " + line;
|
||||
for (PreprocessorCommand command : PreprocessorCommand.values()) {
|
||||
if (line.startsWith("#" + (command.name().replace("PP_", "").toLowerCase(Locale.ROOT)))) {
|
||||
return line;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
// In PropertyCollectingListener we suppress "unknown preprocessor directive errors" and
|
||||
// assume the line to be a comment, since in .properties files `#` also functions as a comment
|
||||
// marker.
|
||||
return line.replace("#", "");
|
||||
}).collect(Collectors.joining("\n")) + "\n";
|
||||
// TODO: This is a horrible fix to trick the preprocessor into not seeing the backslashes during processing. We need a better way to do this.
|
||||
source = source.replace("\\", "IRIS_PASSTHROUGHBACKSLASH");
|
||||
|
||||
preprocessor.addInput(new StringLexerSource(source, true));
|
||||
preprocessor.addFeature(Feature.KEEPCOMMENTS);
|
||||
@@ -110,7 +116,7 @@ public class PropertiesPreprocessor {
|
||||
|
||||
source = builder.toString();
|
||||
|
||||
return listener.collectLines() + source;
|
||||
return (listener.collectLines() + source).replace("IRIS_PASSTHROUGHBACKSLASH", "\\");
|
||||
}
|
||||
|
||||
private static List<String> getBooleanValues(ShaderPackOptions shaderPackOptions) {
|
||||
|
||||
@@ -0,0 +1,369 @@
|
||||
package net.coderbot.iris.uniforms;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.iris.BiomeCategoryCache;
|
||||
import com.gtnewhorizons.angelica.compat.iris.ModdedBiomeDetector;
|
||||
import net.coderbot.iris.gl.uniform.UniformHolder;
|
||||
import net.coderbot.iris.parsing.BiomeCategories;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.biome.BiomeGenBeach;
|
||||
import net.minecraft.world.biome.BiomeGenDesert;
|
||||
import net.minecraft.world.biome.BiomeGenEnd;
|
||||
import net.minecraft.world.biome.BiomeGenForest;
|
||||
import net.minecraft.world.biome.BiomeGenHell;
|
||||
import net.minecraft.world.biome.BiomeGenHills;
|
||||
import net.minecraft.world.biome.BiomeGenJungle;
|
||||
import net.minecraft.world.biome.BiomeGenMesa;
|
||||
import net.minecraft.world.biome.BiomeGenMushroomIsland;
|
||||
import net.minecraft.world.biome.BiomeGenMutated;
|
||||
import net.minecraft.world.biome.BiomeGenOcean;
|
||||
import net.minecraft.world.biome.BiomeGenPlains;
|
||||
import net.minecraft.world.biome.BiomeGenRiver;
|
||||
import net.minecraft.world.biome.BiomeGenSavanna;
|
||||
import net.minecraft.world.biome.BiomeGenSnow;
|
||||
import net.minecraft.world.biome.BiomeGenStoneBeach;
|
||||
import net.minecraft.world.biome.BiomeGenSwamp;
|
||||
import net.minecraft.world.biome.BiomeGenTaiga;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.coderbot.iris.gl.uniform.UniformUpdateFrequency.PER_TICK;
|
||||
|
||||
public class BiomeUniforms {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger("BiomeUniforms");
|
||||
private static final Minecraft client = Minecraft.getMinecraft();
|
||||
|
||||
// Cache to avoid multiple biome lookups per tick
|
||||
private static BiomeGenBase cachedBiome = null;
|
||||
private static long cachedWorldTime = -1;
|
||||
private static int cachedPlayerX = Integer.MIN_VALUE;
|
||||
private static int cachedPlayerZ = Integer.MIN_VALUE;
|
||||
|
||||
/**
|
||||
* Adds biome-related uniforms that change based on the player's current biome.
|
||||
*/
|
||||
public static void addBiomeUniforms(UniformHolder uniforms) {
|
||||
uniforms.uniform1i(PER_TICK, "biome", BiomeUniforms::getBiomeId)
|
||||
.uniform1i(PER_TICK, "biome_category", BiomeUniforms::getBiomeCategory)
|
||||
.uniform1i(PER_TICK, "biome_precipitation", BiomeUniforms::getBiomePrecipitation)
|
||||
.uniform1f(PER_TICK, "rainfall", BiomeUniforms::getBiomeRainfall)
|
||||
.uniform1f(PER_TICK, "temperature", BiomeUniforms::getBiomeTemperature);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current biome, with caching to avoid repeated lookups within the same tick.
|
||||
* Returns null if player or world is not available.
|
||||
*/
|
||||
private static BiomeGenBase getCachedBiome() {
|
||||
if (client.thePlayer == null || client.theWorld == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final long worldTime = client.theWorld.getTotalWorldTime();
|
||||
final int playerX = MathHelper.floor_double(client.thePlayer.posX);
|
||||
final int playerZ = MathHelper.floor_double(client.thePlayer.posZ);
|
||||
|
||||
// Invalidate cache if time or position changed
|
||||
if (cachedBiome == null || cachedWorldTime != worldTime || cachedPlayerX != playerX || cachedPlayerZ != playerZ) {
|
||||
cachedBiome = client.theWorld.getBiomeGenForCoords(playerX, playerZ);
|
||||
cachedWorldTime = worldTime;
|
||||
cachedPlayerX = playerX;
|
||||
cachedPlayerZ = playerZ;
|
||||
}
|
||||
|
||||
return cachedBiome;
|
||||
}
|
||||
|
||||
public static int getBiomePrecipitation() {
|
||||
final BiomeGenBase biome = getCachedBiome();
|
||||
if (biome == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!biome.enableRain && !biome.enableSnow) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
final float temp = biome.getFloatTemperature(
|
||||
MathHelper.floor_double(client.thePlayer.posX),
|
||||
MathHelper.floor_double(client.thePlayer.posY),
|
||||
MathHelper.floor_double(client.thePlayer.posZ));
|
||||
|
||||
return temp > 0.15F ? 1 : 2;
|
||||
}
|
||||
|
||||
public static float getBiomeRainfall() {
|
||||
final BiomeGenBase biome = getCachedBiome();
|
||||
return biome != null ? biome.rainfall : 0.0F;
|
||||
}
|
||||
|
||||
public static float getBiomeTemperature() {
|
||||
final BiomeGenBase biome = getCachedBiome();
|
||||
return biome != null ? biome.temperature : 0.0F;
|
||||
}
|
||||
|
||||
public static int getBiomeId() {
|
||||
final BiomeGenBase biome = getCachedBiome();
|
||||
return biome != null ? biome.biomeID : 0;
|
||||
}
|
||||
|
||||
public static int getBiomeCategory() {
|
||||
final BiomeGenBase biome = getCachedBiome();
|
||||
if (biome == null) {
|
||||
return BiomeCategories.NONE.ordinal();
|
||||
}
|
||||
|
||||
// Check cache first
|
||||
if (biome instanceof BiomeCategoryCache cache) {
|
||||
final int cached = cache.iris$getCachedCategory();
|
||||
if (cached != -1) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
// Not cached yet, determine and cache it
|
||||
final int category = determineBiomeCategory(biome);
|
||||
cache.iris$setCachedCategory(category);
|
||||
final BiomeCategories[] categories = BiomeCategories.values();
|
||||
final String categoryName = (category >= 0 && category < categories.length)
|
||||
? categories[category].name()
|
||||
: "INVALID(" + category + ")";
|
||||
LOGGER.debug("Cached biome category for '{}': {}", biome.biomeName, categoryName);
|
||||
|
||||
return category;
|
||||
}
|
||||
|
||||
// Fallback if mixin didn't apply (shouldn't happen)
|
||||
return determineBiomeCategory(biome);
|
||||
}
|
||||
|
||||
private static int determineBiomeCategory(BiomeGenBase biome) {
|
||||
// Tier 1: Hardcoded vanilla biome IDs
|
||||
BiomeGenBase lookupBiome = biome;
|
||||
if (biome instanceof BiomeGenMutated mutated && mutated.baseBiome != null) {
|
||||
lookupBiome = mutated.baseBiome;
|
||||
}
|
||||
|
||||
BiomeCategories category = getVanillaBiomeCategory(lookupBiome.biomeID);
|
||||
if (category != null) {
|
||||
return category.ordinal();
|
||||
}
|
||||
|
||||
// Tier 2: Class-based detection for vanilla biome types
|
||||
category = detectVanillaBiomeByClass(biome);
|
||||
if (category != null) {
|
||||
return category.ordinal();
|
||||
}
|
||||
|
||||
// Tier 3: Modded biome detection (BiomesOPlenty, Realistic World Gen)
|
||||
category = detectModdedBiome(biome);
|
||||
if (category != null) {
|
||||
return category.ordinal();
|
||||
}
|
||||
|
||||
// Tier 4: Name pattern matching
|
||||
category = detectBiomeByName(biome);
|
||||
if (category != null) {
|
||||
return category.ordinal();
|
||||
}
|
||||
|
||||
// Tier 5: Temperature/rainfall heuristics
|
||||
category = detectBiomeByProperties(biome);
|
||||
if (category != null) {
|
||||
return category.ordinal();
|
||||
}
|
||||
|
||||
// Default: NONE
|
||||
return BiomeCategories.NONE.ordinal();
|
||||
}
|
||||
|
||||
private static BiomeCategories getVanillaBiomeCategory(int biomeID) {
|
||||
return switch (biomeID) {
|
||||
// OCEAN
|
||||
case 0, 10, 24 -> BiomeCategories.OCEAN; // ocean, frozenOcean, deepOcean
|
||||
|
||||
// PLAINS
|
||||
case 1 -> BiomeCategories.PLAINS; // plains
|
||||
|
||||
// DESERT
|
||||
case 2, 17 -> BiomeCategories.DESERT; // desert, desertHills
|
||||
|
||||
// EXTREME_HILLS (Vanilla mountains)
|
||||
case 3, 20, 34 -> BiomeCategories.EXTREME_HILLS; // extremeHills, extremeHillsEdge, extremeHillsPlus
|
||||
|
||||
// FOREST
|
||||
case 4, 18, 27, 28, 29 ->
|
||||
BiomeCategories.FOREST; // forest, forestHills, birchForest, birchForestHills, roofedForest
|
||||
|
||||
// TAIGA
|
||||
case 5, 19, 30, 31, 32, 33 ->
|
||||
BiomeCategories.TAIGA; // taiga, taigaHills, coldTaiga, coldTaigaHills, megaTaiga, megaTaigaHills
|
||||
|
||||
// SWAMP
|
||||
case 6 -> BiomeCategories.SWAMP; // swampland
|
||||
|
||||
// RIVER
|
||||
case 7, 11 -> BiomeCategories.RIVER; // river, frozenRiver
|
||||
|
||||
// NETHER
|
||||
case 8 -> BiomeCategories.NETHER; // hell
|
||||
|
||||
// THE_END
|
||||
case 9 -> BiomeCategories.THE_END; // sky
|
||||
|
||||
// ICY
|
||||
case 12, 13 -> BiomeCategories.ICY; // icePlains, iceMountains
|
||||
|
||||
// MUSHROOM
|
||||
case 14, 15 -> BiomeCategories.MUSHROOM; // mushroomIsland, mushroomIslandShore
|
||||
|
||||
// BEACH
|
||||
case 16, 25, 26 -> BiomeCategories.BEACH; // beach, stoneBeach, coldBeach
|
||||
|
||||
// JUNGLE
|
||||
case 21, 22, 23 -> BiomeCategories.JUNGLE; // jungle, jungleHills, jungleEdge
|
||||
|
||||
// SAVANNA
|
||||
case 35, 36 -> BiomeCategories.SAVANNA; // savanna, savannaPlateau
|
||||
|
||||
// MESA
|
||||
case 37, 38, 39 -> BiomeCategories.MESA; // mesa, mesaPlateau_F, mesaPlateau
|
||||
|
||||
default -> null; // Not a vanilla biome or unknown
|
||||
};
|
||||
}
|
||||
|
||||
private static final Map<Class<? extends BiomeGenBase>, BiomeCategories> VANILLA_CLASS_MAP = createVanillaClassMap();
|
||||
|
||||
private static Map<Class<? extends BiomeGenBase>, BiomeCategories> createVanillaClassMap() {
|
||||
final Map<Class<? extends BiomeGenBase>, BiomeCategories> map = new HashMap<>();
|
||||
// Most specific first (subclasses before superclasses)
|
||||
map.put(BiomeGenStoneBeach.class, BiomeCategories.BEACH);
|
||||
map.put(BiomeGenBeach.class, BiomeCategories.BEACH);
|
||||
map.put(BiomeGenMushroomIsland.class, BiomeCategories.MUSHROOM);
|
||||
map.put(BiomeGenOcean.class, BiomeCategories.OCEAN);
|
||||
map.put(BiomeGenPlains.class, BiomeCategories.PLAINS);
|
||||
map.put(BiomeGenDesert.class, BiomeCategories.DESERT);
|
||||
map.put(BiomeGenHills.class, BiomeCategories.EXTREME_HILLS);
|
||||
map.put(BiomeGenForest.class, BiomeCategories.FOREST);
|
||||
map.put(BiomeGenTaiga.class, BiomeCategories.TAIGA);
|
||||
map.put(BiomeGenSwamp.class, BiomeCategories.SWAMP);
|
||||
map.put(BiomeGenRiver.class, BiomeCategories.RIVER);
|
||||
map.put(BiomeGenHell.class, BiomeCategories.NETHER);
|
||||
map.put(BiomeGenEnd.class, BiomeCategories.THE_END);
|
||||
map.put(BiomeGenSnow.class, BiomeCategories.ICY);
|
||||
map.put(BiomeGenJungle.class, BiomeCategories.JUNGLE);
|
||||
map.put(BiomeGenSavanna.class, BiomeCategories.SAVANNA);
|
||||
map.put(BiomeGenMesa.class, BiomeCategories.MESA);
|
||||
return map;
|
||||
}
|
||||
|
||||
private static BiomeCategories detectVanillaBiomeByClass(BiomeGenBase biome) {
|
||||
// Direct class lookup (O(1) for exact matches)
|
||||
final BiomeCategories direct = VANILLA_CLASS_MAP.get(biome.getClass());
|
||||
if (direct != null) {
|
||||
return direct;
|
||||
}
|
||||
|
||||
// Fallback: instanceof checks for subclasses (modded biomes extending vanilla)
|
||||
for (Map.Entry<Class<? extends BiomeGenBase>, BiomeCategories> entry : VANILLA_CLASS_MAP.entrySet()) {
|
||||
if (entry.getKey().isInstance(biome)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static BiomeCategories detectModdedBiome(BiomeGenBase biome) {
|
||||
return ModdedBiomeDetector.detectModdedBiome(biome);
|
||||
}
|
||||
|
||||
private static BiomeCategories detectBiomeByName(BiomeGenBase biome) {
|
||||
if (biome.biomeName == null) return null;
|
||||
|
||||
final String name = biome.biomeName.toLowerCase();
|
||||
|
||||
// Check for keywords in biome names
|
||||
// Priority order matters - check more specific terms first
|
||||
|
||||
if (name.contains("nether")) return BiomeCategories.NETHER;
|
||||
if (name.contains("end")) return BiomeCategories.THE_END;
|
||||
|
||||
if (name.contains("ocean") || name.contains("sea")) return BiomeCategories.OCEAN;
|
||||
if (name.contains("river") || name.contains("stream")) return BiomeCategories.RIVER;
|
||||
if (name.contains("beach") || name.contains("shore") || name.contains("coast")) return BiomeCategories.BEACH;
|
||||
|
||||
if (name.contains("mushroom")) return BiomeCategories.MUSHROOM;
|
||||
if (name.contains("swamp") || name.contains("marsh") || name.contains("bog")) return BiomeCategories.SWAMP;
|
||||
|
||||
if (name.contains("jungle")) return BiomeCategories.JUNGLE;
|
||||
if (name.contains("savanna") || name.contains("savannah")) return BiomeCategories.SAVANNA;
|
||||
if (name.contains("mesa") || name.contains("badlands")) return BiomeCategories.MESA;
|
||||
if (name.contains("desert")) return BiomeCategories.DESERT;
|
||||
|
||||
// Mountain detection - for modded biomes
|
||||
if (name.contains("mountain") || name.contains("peak") || name.contains("alpine") ||
|
||||
name.contains("cliff") || name.contains("crag")) return BiomeCategories.MOUNTAIN;
|
||||
|
||||
// Ice/Snow detection
|
||||
if (name.contains("ice") || name.contains("frozen") || name.contains("snow") ||
|
||||
name.contains("arctic") || name.contains("tundra") || name.contains("glacier")) return BiomeCategories.ICY;
|
||||
|
||||
if (name.contains("taiga") || name.contains("boreal") || name.contains("conifer")) return BiomeCategories.TAIGA;
|
||||
|
||||
if (name.contains("forest") || name.contains("wood") || name.contains("grove") ||
|
||||
name.contains("thicket")) return BiomeCategories.FOREST;
|
||||
|
||||
if (name.contains("plain") || name.contains("field") || name.contains("meadow") ||
|
||||
name.contains("grassland") || name.contains("prairie")) return BiomeCategories.PLAINS;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static BiomeCategories detectBiomeByProperties(BiomeGenBase biome) {
|
||||
final float temp = biome.temperature;
|
||||
final float rain = biome.rainfall;
|
||||
|
||||
// Very cold biomes with snow
|
||||
if (temp <= 0.0F && biome.enableSnow) {
|
||||
return BiomeCategories.ICY;
|
||||
}
|
||||
|
||||
// Hot, dry biomes
|
||||
if (temp >= 2.0F && !biome.enableRain) {
|
||||
return BiomeCategories.DESERT;
|
||||
}
|
||||
|
||||
// Warm, dry biomes (savanna-like)
|
||||
if (temp >= 1.0F && rain <= 0.1F && !biome.enableRain) {
|
||||
return BiomeCategories.SAVANNA;
|
||||
}
|
||||
|
||||
// Wet biomes with high rainfall
|
||||
if (rain >= 0.85F && temp >= 0.5F && temp <= 1.0F) {
|
||||
return BiomeCategories.SWAMP;
|
||||
}
|
||||
|
||||
// Cold forested biomes
|
||||
if (temp >= 0.0F && temp <= 0.4F && rain >= 0.4F) {
|
||||
return BiomeCategories.TAIGA;
|
||||
}
|
||||
|
||||
// Temperate forested biomes
|
||||
if (temp >= 0.4F && temp <= 0.9F && rain >= 0.5F) {
|
||||
return BiomeCategories.FOREST;
|
||||
}
|
||||
|
||||
// Default to plains for temperate, moderate biomes
|
||||
if (temp >= 0.4F && temp <= 1.0F && rain >= 0.3F && rain <= 0.6F) {
|
||||
return BiomeCategories.PLAINS;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -20,14 +20,11 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.AbstractTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import org.joml.Math;
|
||||
import org.joml.Vector2f;
|
||||
import org.joml.Vector2i;
|
||||
@@ -53,6 +50,7 @@ public final class CommonUniforms {
|
||||
ViewportUniforms.addViewportUniforms(uniforms);
|
||||
WorldTimeUniforms.addWorldTimeUniforms(uniforms);
|
||||
SystemTimeUniforms.addSystemTimeUniforms(uniforms);
|
||||
BiomeUniforms.addBiomeUniforms(uniforms);
|
||||
new CelestialUniforms(directives.getSunPathRotation()).addCelestialUniforms(uniforms);
|
||||
IrisExclusiveUniforms.addIrisExclusiveUniforms(uniforms);
|
||||
IdMapUniforms.addIdMapUniforms(updateNotifier, uniforms, idMap, directives.isOldHandLight());
|
||||
@@ -67,6 +65,7 @@ public final class CommonUniforms {
|
||||
|
||||
// Needs to use a LocationalUniformHolder as we need it for the common uniforms
|
||||
public static void addDynamicUniforms(DynamicUniformHolder uniforms) {
|
||||
ExternallyManagedUniforms.addExternallyManagedUniforms116(uniforms);
|
||||
IdMapUniforms.addEntityIdMapUniforms(uniforms);
|
||||
FogUniforms.addFogUniforms(uniforms);
|
||||
|
||||
@@ -113,6 +112,7 @@ public final class CommonUniforms {
|
||||
|
||||
uniforms
|
||||
.uniform1f(ONCE, "darknessFactor", () -> 0.0F) // This is PER_FRAME in modern, it is an effect added by The Warden. We're just setting to 0 because 1.7.10 doesn't have it.
|
||||
.uniform1f(ONCE, "darknessLightFactor", () -> 0.0F) // Warden darkness current light factor - 1.7.10 doesn't have it so hardcode to 0
|
||||
.uniform1b(PER_FRAME, "hideGUI", () -> client.gameSettings.hideGUI)
|
||||
.uniform1i(PER_FRAME, "isEyeInWater", CommonUniforms::isEyeInWater)
|
||||
.uniform1f(PER_FRAME, "blindness", CommonUniforms::getBlindness)
|
||||
@@ -137,11 +137,7 @@ public final class CommonUniforms {
|
||||
.uniform1f(PER_TICK, "rainStrength", CommonUniforms::getRainStrength)
|
||||
.uniform1f(PER_TICK, "wetness", new SmoothedFloat(directives.getWetnessHalfLife(), directives.getDrynessHalfLife(), CommonUniforms::getRainStrength, updateNotifier))
|
||||
.uniform3d(PER_FRAME, "skyColor", CommonUniforms::getSkyColor)
|
||||
.uniform3d(PER_FRAME, "fogColor", GLStateManager::getFogColor)
|
||||
|
||||
.uniform1i(PER_TICK, "biome_precipitation", CommonUniforms::getBiomePrecipitation)
|
||||
.uniform1f(PER_TICK, "rainfall", CommonUniforms::getBiomeRainfall)
|
||||
.uniform1f(PER_TICK, "temperature", CommonUniforms::getBiomeTemperature);
|
||||
.uniform3d(PER_FRAME, "fogColor", GLStateManager::getFogColor);
|
||||
}
|
||||
|
||||
private static boolean isOnGround() {
|
||||
@@ -153,38 +149,7 @@ public final class CommonUniforms {
|
||||
return (client.thePlayer != null && client.thePlayer.hurtTime > 0);
|
||||
}
|
||||
|
||||
private static BiomeGenBase getBiome() {
|
||||
return client.theWorld.getBiomeGenForCoords(MathHelper.floor_double(client.thePlayer.posX), MathHelper.floor_double(client.thePlayer.posZ));
|
||||
}
|
||||
|
||||
private static int getBiomePrecipitation() {
|
||||
if (client.thePlayer == null || client.theWorld == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
BiomeGenBase biome = getBiome();
|
||||
float temp = biome.getFloatTemperature(MathHelper.floor_double(client.thePlayer.posX), MathHelper.floor_double(client.thePlayer.posY), MathHelper.floor_double(client.thePlayer.posZ));
|
||||
|
||||
if (!biome.enableRain && !biome.enableSnow) {
|
||||
return 0;
|
||||
} else if (temp > 0.15F) {
|
||||
return 1;
|
||||
} else {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
private static float getBiomeRainfall() {
|
||||
if (client.thePlayer == null || client.theWorld == null) return 0.0F;
|
||||
return getBiome().rainfall;
|
||||
}
|
||||
|
||||
private static float getBiomeTemperature() {
|
||||
if (client.thePlayer == null || client.theWorld == null) return 0.0F;
|
||||
return getBiome().temperature;
|
||||
}
|
||||
|
||||
private static boolean isInvisible() {
|
||||
private static boolean isInvisible() {
|
||||
return (client.thePlayer != null && client.thePlayer.isInvisible());
|
||||
}
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ public class ExternallyManagedUniforms {
|
||||
addMat4(uniformHolder, "iris_ModelViewMatrix");
|
||||
addMat4(uniformHolder, "u_ModelViewProjectionMatrix");
|
||||
addMat4(uniformHolder, "iris_NormalMatrix");
|
||||
// Exclusive to pre-1.19
|
||||
addFloat(uniformHolder, "darknessFactor");
|
||||
addFloat(uniformHolder, "darknessLightFactor");
|
||||
|
||||
// 1.21.6+
|
||||
uniformHolder.externallyManagedUniform("heavyFog", UniformType.BOOL);
|
||||
}
|
||||
|
||||
public static void addExternallyManagedUniforms116(UniformHolder uniformHolder) {
|
||||
|
||||
@@ -1,16 +1,28 @@
|
||||
package net.coderbot.iris.uniforms;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.Camera;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.GameModeUtil;
|
||||
import net.coderbot.iris.gl.uniform.UniformHolder;
|
||||
import net.coderbot.iris.gl.uniform.UniformUpdateFrequency;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.effect.EntityLightningBolt;
|
||||
import org.joml.Math;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector3dc;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class IrisExclusiveUniforms {
|
||||
// Reusable vectors to avoid allocations every frame
|
||||
private static final Vector3d eyePositionCache = new Vector3d();
|
||||
private static final Vector3d relativeEyePositionCache = new Vector3d();
|
||||
private static final Vector4f lightningBoltPositionCache = new Vector4f();
|
||||
private static final Vector4f ZERO_VECTOR_4f = new Vector4f(0, 0, 0, 0);
|
||||
|
||||
public static void addIrisExclusiveUniforms(UniformHolder uniforms) {
|
||||
WorldInfoUniforms.addWorldInfoUniforms(uniforms);
|
||||
|
||||
@@ -24,20 +36,10 @@ public class IrisExclusiveUniforms {
|
||||
uniforms.uniform1f(UniformUpdateFrequency.PER_TICK, "maxPlayerAir", IrisExclusiveUniforms::getMaxAir);
|
||||
uniforms.uniform1b(UniformUpdateFrequency.PER_FRAME, "firstPersonCamera", IrisExclusiveUniforms::isFirstPersonCamera);
|
||||
uniforms.uniform1b(UniformUpdateFrequency.PER_TICK, "isSpectator", IrisExclusiveUniforms::isSpectator);
|
||||
uniforms.uniform1b(UniformUpdateFrequency.PER_TICK, "isRightHanded", () -> true); // 1.7.10 doesn't support left-handed mode
|
||||
uniforms.uniform3d(UniformUpdateFrequency.PER_FRAME, "eyePosition", IrisExclusiveUniforms::getEyePosition);
|
||||
// TODO: Iris Shaders
|
||||
// Vector4f zero = new Vector4f(0, 0, 0, 0);
|
||||
// uniforms.uniform4f(UniformUpdateFrequency.PER_TICK, "lightningBoltPosition", () -> {
|
||||
// if (Minecraft.getMinecraft().theWorld != null) {
|
||||
// return StreamSupport.stream(Minecraft.getMinecraft().theWorld.entitiesForRendering().spliterator(), false).filter(bolt -> bolt instanceof LightningBolt).findAny().map(bolt -> {
|
||||
// Vector3d unshiftedCameraPosition = CameraUniforms.getUnshiftedCameraPosition();
|
||||
// Vec3 vec3 = bolt.getPosition(Minecraft.getMinecraft().getDeltaFrameTime());
|
||||
// return new Vector4f((float) (vec3.x - unshiftedCameraPosition.x), (float) (vec3.y - unshiftedCameraPosition.y), (float) (vec3.z - unshiftedCameraPosition.z), 1);
|
||||
// }).orElse(zero);
|
||||
// } else {
|
||||
// return zero;
|
||||
// }
|
||||
// });
|
||||
uniforms.uniform3d(UniformUpdateFrequency.PER_FRAME, "relativeEyePosition", IrisExclusiveUniforms::getRelativeEyePosition);
|
||||
uniforms.uniform4f(UniformUpdateFrequency.PER_TICK, "lightningBoltPosition", IrisExclusiveUniforms::getLightningBoltPosition);
|
||||
}
|
||||
|
||||
private static float getThunderStrength() {
|
||||
@@ -88,21 +90,40 @@ public class IrisExclusiveUniforms {
|
||||
|
||||
private static boolean isFirstPersonCamera() {
|
||||
// If camera type is not explicitly third-person, assume it's first-person.
|
||||
return (Minecraft.getMinecraft().gameSettings.thirdPersonView == 1);
|
||||
return !Camera.INSTANCE.isThirdPerson();
|
||||
}
|
||||
|
||||
private static boolean isSpectator() {
|
||||
final PlayerControllerMP controller = Minecraft.getMinecraft().playerController;
|
||||
if(controller == null)
|
||||
return false;
|
||||
return controller.currentGameType.getID() == 3;
|
||||
return GameModeUtil.isSpectator();
|
||||
}
|
||||
|
||||
private static Vector3d getEyePosition() {
|
||||
// Objects.requireNonNull(Minecraft.getMinecraft().getCameraEntity());
|
||||
// return new Vector3d(Minecraft.getMinecraft().getCameraEntity().getX(), Minecraft.getMinecraft().getCameraEntity().getEyeY(), Minecraft.getMinecraft().getCameraEntity().getZ());
|
||||
final EntityLivingBase eye = Minecraft.getMinecraft().renderViewEntity;
|
||||
return new Vector3d(eye.posX, eye.posY, eye.posZ);
|
||||
return eyePositionCache.set(eye.posX, eye.posY + eye.getEyeHeight(), eye.posZ);
|
||||
}
|
||||
|
||||
private static Vector3d getRelativeEyePosition() {
|
||||
final Vector3dc cameraPos = CameraUniforms.getUnshiftedCameraPosition();
|
||||
final Vector3d eyePos = getEyePosition();
|
||||
return relativeEyePositionCache.set(eyePos).sub(cameraPos);
|
||||
}
|
||||
|
||||
private static Vector4f getLightningBoltPosition() {
|
||||
if (Minecraft.getMinecraft().theWorld != null) {
|
||||
final List<Entity> weatherEffects = Minecraft.getMinecraft().theWorld.weatherEffects;
|
||||
for (Entity entity : weatherEffects) {
|
||||
if (entity instanceof EntityLightningBolt bolt) {
|
||||
final Vector3dc cameraPos = CameraUniforms.getUnshiftedCameraPosition();
|
||||
return lightningBoltPositionCache.set(
|
||||
(float)(bolt.posX - cameraPos.x()),
|
||||
(float)(bolt.posY - cameraPos.y()),
|
||||
(float)(bolt.posZ - cameraPos.z()),
|
||||
1.0f
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ZERO_VECTOR_4f;
|
||||
}
|
||||
|
||||
public static class WorldInfoUniforms {
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package net.coderbot.iris.uniforms;
|
||||
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class VanillaBiomeList {
|
||||
public static class BiomeEntry {
|
||||
public final BiomeGenBase biome;
|
||||
public final String name;
|
||||
|
||||
public BiomeEntry(BiomeGenBase biome, String name) {
|
||||
this.biome = biome;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
private static final List<BiomeEntry> VANILLA_BIOMES = createVanillaBiomeList();
|
||||
|
||||
private static List<BiomeEntry> createVanillaBiomeList() {
|
||||
final List<BiomeEntry> biomes = new ArrayList<>();
|
||||
|
||||
// Vanilla biomes from BiomeGenBase static fields (IDs 0-39)
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.ocean, "OCEAN"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.plains, "PLAINS"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.desert, "DESERT"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.extremeHills, "EXTREME_HILLS"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.forest, "FOREST"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.taiga, "TAIGA"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.swampland, "SWAMPLAND"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.river, "RIVER"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.hell, "HELL"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.sky, "SKY"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.frozenOcean, "FROZEN_OCEAN"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.frozenRiver, "FROZEN_RIVER"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.icePlains, "ICE_PLAINS"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.iceMountains, "ICE_MOUNTAINS"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.mushroomIsland, "MUSHROOM_ISLAND"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.mushroomIslandShore, "MUSHROOM_ISLAND_SHORE"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.beach, "BEACH"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.desertHills, "DESERT_HILLS"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.forestHills, "FOREST_HILLS"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.taigaHills, "TAIGA_HILLS"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.extremeHillsEdge, "EXTREME_HILLS_EDGE"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.jungle, "JUNGLE"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.jungleHills, "JUNGLE_HILLS"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.jungleEdge, "JUNGLE_EDGE"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.deepOcean, "DEEP_OCEAN"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.stoneBeach, "STONE_BEACH"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.coldBeach, "COLD_BEACH"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.birchForest, "BIRCH_FOREST"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.birchForestHills, "BIRCH_FOREST_HILLS"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.roofedForest, "ROOFED_FOREST"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.coldTaiga, "COLD_TAIGA"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.coldTaigaHills, "COLD_TAIGA_HILLS"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.megaTaiga, "MEGA_TAIGA"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.megaTaigaHills, "MEGA_TAIGA_HILLS"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.extremeHillsPlus, "EXTREME_HILLS_PLUS"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.savanna, "SAVANNA"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.savannaPlateau, "SAVANNA_PLATEAU"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.mesa, "MESA"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.mesaPlateau_F, "MESA_PLATEAU_F"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.mesaPlateau, "MESA_PLATEAU"));
|
||||
|
||||
// Modern End biome variants (1.9+) - all map to the single End biome in 1.7.10
|
||||
// This allows shaders expecting these constants to work
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.sky, "THE_END"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.sky, "SMALL_END_ISLANDS"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.sky, "END_MIDLANDS"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.sky, "END_HIGHLANDS"));
|
||||
biomes.add(new BiomeEntry(BiomeGenBase.sky, "END_BARRENS"));
|
||||
|
||||
return Collections.unmodifiableList(biomes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cached list of all vanilla biomes with their shader-friendly names.
|
||||
* The list is immutable and created once during class initialization.
|
||||
*/
|
||||
public static List<BiomeEntry> getVanillaBiomes() {
|
||||
return VANILLA_BIOMES;
|
||||
}
|
||||
}
|
||||
@@ -86,3 +86,4 @@ public net.minecraft.block.material.Material field_76240_I # isTranslucent
|
||||
|
||||
public net.minecraft.world.biome.BiomeGenBase field_76765_S # enableRain
|
||||
public net.minecraft.world.biome.BiomeGenBase field_76766_R # enableSnow
|
||||
public net.minecraft.world.biome.BiomeGenMutated field_150611_aD # baseBiome
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 127 B |
@@ -20,6 +20,8 @@ options.downfall_distance=Weather Effects
|
||||
options.downfall_distance.tooltip=Weather Effects
|
||||
options.dynamic_fov=Dynamic FOV
|
||||
options.dynamic_fov.tooltip=If enabled, the game's field of view will change based on the player's speed.
|
||||
options.horizon_disable=Disable Horizon
|
||||
options.horizon_disable.tooltip=Disable Horizon
|
||||
options.fog_disable=Disable Terrain Fog
|
||||
options.fog_disable.tooltip=Disable Terrain Fog
|
||||
options.fog_near_distance=Near Fog Distance
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
"package": "com.gtnewhorizons.angelica.mixins.early",
|
||||
"refmap": "mixins.angelica.refmap.json",
|
||||
"target": "@env(DEFAULT)",
|
||||
"injectors":{
|
||||
"maxShiftBy": 2
|
||||
},
|
||||
"compatibilityLevel": "JAVA_8"
|
||||
}
|
||||
|
||||
+9
-5
@@ -1,5 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.angelica;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.Camera;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.EntityRendererAccessor;
|
||||
import com.gtnewhorizons.angelica.rendering.RenderingState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -19,15 +20,18 @@ public abstract class MixinEntityRenderer implements EntityRendererAccessor {
|
||||
@Invoker
|
||||
public abstract float invokeGetNightVisionBrightness(EntityPlayer entityPlayer, float partialTicks);
|
||||
|
||||
@Inject(method = "setupCameraTransform", at = @At(value = "TAIL"))
|
||||
private void angelica$captureCameraMatrix(float partialTicks, int startTime, CallbackInfo ci) {
|
||||
@Inject(method = "renderWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/ActiveRenderInfo;updateRenderInfo(Lnet/minecraft/entity/player/EntityPlayer;Z)V", shift = At.Shift.AFTER))
|
||||
private void angelica$captureCameraMatrix(float partialTicks, long finishTimeNano, CallbackInfo ci) {
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
final EntityLivingBase viewEntity = mc.renderViewEntity;
|
||||
|
||||
Camera.INSTANCE.update(viewEntity, partialTicks);
|
||||
|
||||
// Set RenderingState to use the correct camera position
|
||||
RenderingState.INSTANCE.setCameraPosition(
|
||||
viewEntity.lastTickPosX + (viewEntity.posX - viewEntity.lastTickPosX) * partialTicks,
|
||||
viewEntity.lastTickPosY + (viewEntity.posY - viewEntity.lastTickPosY) * partialTicks,
|
||||
viewEntity.lastTickPosZ + (viewEntity.posZ - viewEntity.lastTickPosZ) * partialTicks
|
||||
Camera.INSTANCE.getPos().x,
|
||||
Camera.INSTANCE.getPos().y,
|
||||
Camera.INSTANCE.getPos().z
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+259
@@ -0,0 +1,259 @@
|
||||
/*
|
||||
* This file is part of FalseTweaks.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* Modifications by Angelica in accordance with LGPL v3.0
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalseTweaks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalseTweaks is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalseTweaks. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.gtnewhorizons.angelica.mixins.early.angelica.bugfixes;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
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;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
@Mixin(RenderBlocks.class)
|
||||
public class MixinRenderBlocks_CrackFix {
|
||||
|
||||
@Unique
|
||||
private static String[] angelica$currentCrackFixBlacklistArr;
|
||||
@Unique
|
||||
private static String[] angelica$currentCrackFixWhitelistArr;
|
||||
@Unique
|
||||
private static Class<?>[] angelica$currentCrackFixBlacklistClasses;
|
||||
@Unique
|
||||
private static Class<?>[] angelica$currentCrackFixWhitelistClasses;
|
||||
@Shadow
|
||||
public double renderMinX;
|
||||
@Shadow
|
||||
public double renderMinY;
|
||||
@Shadow
|
||||
public double renderMinZ;
|
||||
@Shadow
|
||||
public double renderMaxX;
|
||||
@Shadow
|
||||
public double renderMaxY;
|
||||
@Shadow
|
||||
public double renderMaxZ;
|
||||
@Unique
|
||||
private double[] angelica$bounds;
|
||||
@Unique
|
||||
private boolean angelica$disableCrackFix;
|
||||
@Unique
|
||||
private boolean angelica$bypassRenderPassCheck;
|
||||
|
||||
@ModifyExpressionValue(method = "renderFaceXNeg",
|
||||
at = @At(value = "FIELD",
|
||||
target = "Lnet/minecraft/client/renderer/RenderBlocks;renderMinX:D",
|
||||
ordinal = 0),
|
||||
require = 1)
|
||||
private double xNegBounds(double original) {
|
||||
angelica$preBounds(ForgeDirection.WEST);
|
||||
return renderMinX;
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(method = "renderFaceXPos",
|
||||
at = @At(value = "FIELD",
|
||||
target = "Lnet/minecraft/client/renderer/RenderBlocks;renderMaxX:D",
|
||||
ordinal = 0),
|
||||
require = 1)
|
||||
private double xPosBounds(double original) {
|
||||
angelica$preBounds(ForgeDirection.EAST);
|
||||
return renderMaxX;
|
||||
}
|
||||
|
||||
@SuppressWarnings("SuspiciousNameCombination")
|
||||
@ModifyExpressionValue(method = "renderFaceYNeg",
|
||||
at = @At(value = "FIELD",
|
||||
target = "Lnet/minecraft/client/renderer/RenderBlocks;renderMinX:D",
|
||||
ordinal = 5),
|
||||
require = 1)
|
||||
private double yNegBounds(double original) {
|
||||
angelica$preBounds(ForgeDirection.DOWN);
|
||||
return renderMinX;
|
||||
}
|
||||
|
||||
@SuppressWarnings("SuspiciousNameCombination")
|
||||
@ModifyExpressionValue(method = "renderFaceYPos",
|
||||
at = @At(value = "FIELD",
|
||||
target = "Lnet/minecraft/client/renderer/RenderBlocks;renderMinX:D",
|
||||
ordinal = 5),
|
||||
require = 1)
|
||||
private double yPosBounds(double original) {
|
||||
angelica$preBounds(ForgeDirection.UP);
|
||||
return renderMinX;
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(method = "renderFaceZNeg",
|
||||
at = @At(value = "FIELD",
|
||||
target = "Lnet/minecraft/client/renderer/RenderBlocks;renderMinX:D",
|
||||
ordinal = 6),
|
||||
require = 1)
|
||||
private double zNegBounds(double original) {
|
||||
angelica$preBounds(ForgeDirection.NORTH);
|
||||
return renderMinX;
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(method = "renderFaceZPos",
|
||||
at = @At(value = "FIELD",
|
||||
target = "Lnet/minecraft/client/renderer/RenderBlocks;renderMinX:D",
|
||||
ordinal = 5),
|
||||
require = 1)
|
||||
private double zPosBounds(double original) {
|
||||
angelica$preBounds(ForgeDirection.SOUTH);
|
||||
return renderMinX;
|
||||
}
|
||||
|
||||
@Unique
|
||||
private void angelica$preBounds(ForgeDirection skipDir) {
|
||||
if (angelica$crackFixOff()) {
|
||||
return;
|
||||
}
|
||||
if (angelica$bounds == null) {
|
||||
angelica$bounds = new double[6];
|
||||
}
|
||||
angelica$bounds[0] = renderMinX;
|
||||
angelica$bounds[1] = renderMinY;
|
||||
angelica$bounds[2] = renderMinZ;
|
||||
angelica$bounds[3] = renderMaxX;
|
||||
angelica$bounds[4] = renderMaxY;
|
||||
angelica$bounds[5] = renderMaxZ;
|
||||
|
||||
if (ForgeHooksClient.getWorldRenderPass() != 0 && !angelica$bypassRenderPassCheck) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (renderMinX != 0 || renderMinY != 0 || renderMinZ != 0 || renderMaxX != 1 || renderMaxY != 1 || renderMaxZ != 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
double EPSILON = AngelicaConfig.blockCrackFixEpsilon;
|
||||
|
||||
renderMinX -= EPSILON;
|
||||
renderMinY -= EPSILON;
|
||||
renderMinZ -= EPSILON;
|
||||
renderMaxX += EPSILON;
|
||||
renderMaxY += EPSILON;
|
||||
renderMaxZ += EPSILON;
|
||||
|
||||
switch (skipDir) {
|
||||
case WEST: renderMinX = angelica$bounds[0]; break;
|
||||
case DOWN: renderMinY = angelica$bounds[1]; break;
|
||||
case NORTH: renderMinZ = angelica$bounds[2]; break;
|
||||
case EAST: renderMaxX = angelica$bounds[3]; break;
|
||||
case UP: renderMaxY = angelica$bounds[4]; break;
|
||||
case SOUTH: renderMaxZ = angelica$bounds[5]; break;
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = {"renderFaceXNeg", "renderFaceXPos", "renderFaceYNeg", "renderFaceYPos", "renderFaceZNeg", "renderFaceZPos"},
|
||||
at = @At(value = "RETURN"),
|
||||
require = 6)
|
||||
private void postBounds(Block p_147798_1_, double p_147798_2_, double p_147798_4_, double p_147798_6_, IIcon p_147798_8_, CallbackInfo ci) {
|
||||
if (angelica$crackFixOff() || angelica$bounds == null) {
|
||||
return;
|
||||
}
|
||||
renderMinX = angelica$bounds[0];
|
||||
renderMinY = angelica$bounds[1];
|
||||
renderMinZ = angelica$bounds[2];
|
||||
renderMaxX = angelica$bounds[3];
|
||||
renderMaxY = angelica$bounds[4];
|
||||
renderMaxZ = angelica$bounds[5];
|
||||
}
|
||||
|
||||
@Inject(method = "renderBlockByRenderType",
|
||||
at = @At("HEAD"),
|
||||
require = 1)
|
||||
private void exclusion(Block block, int x, int y, int z, CallbackInfoReturnable<Boolean> cir) {
|
||||
angelica$disableCrackFix = angelica$isListed(block.getClass(), false);
|
||||
angelica$bypassRenderPassCheck = angelica$isListed(block.getClass(), true);
|
||||
}
|
||||
|
||||
@Inject(method = "renderBlockByRenderType",
|
||||
at = @At("RETURN"),
|
||||
require = 1)
|
||||
private void endExclusion(Block p_147805_1_, int p_147805_2_, int p_147805_3_, int p_147805_4_, CallbackInfoReturnable<Boolean> cir) {
|
||||
angelica$disableCrackFix = false;
|
||||
angelica$bypassRenderPassCheck = false;
|
||||
}
|
||||
|
||||
@Unique
|
||||
private static boolean angelica$isListed(Class<?> clazz, boolean whitelist) {
|
||||
Class<?>[] list = whitelist ? angelica$getCrackFixRenderPassWhitelist() : angelica$getCrackFixBlacklist();
|
||||
if (list == null) {
|
||||
return false;
|
||||
}
|
||||
for (Class<?> element : list) {
|
||||
if (element.isAssignableFrom(clazz)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Unique
|
||||
private static Class<?>[] angelica$getCrackFixBlacklist() {
|
||||
if (angelica$currentCrackFixBlacklistArr != AngelicaConfig.blockCrackFixBlacklist) {
|
||||
angelica$currentCrackFixBlacklistArr = AngelicaConfig.blockCrackFixBlacklist;
|
||||
angelica$currentCrackFixBlacklistClasses = Arrays.stream(angelica$currentCrackFixBlacklistArr).map((name) -> {
|
||||
try {
|
||||
return Class.forName(name);
|
||||
} catch (ClassNotFoundException e) {
|
||||
AngelicaTweaker.LOGGER.debug("Could not find class " + name + " for crack fix blacklist!");
|
||||
return null;
|
||||
}
|
||||
}).filter(Objects::nonNull).toArray(Class<?>[]::new);
|
||||
}
|
||||
return angelica$currentCrackFixBlacklistClasses;
|
||||
}
|
||||
@Unique
|
||||
private static Class<?>[] angelica$getCrackFixRenderPassWhitelist() {
|
||||
if (angelica$currentCrackFixWhitelistArr != AngelicaConfig.blockCrackFixRenderPassWhitelist) {
|
||||
angelica$currentCrackFixWhitelistArr = AngelicaConfig.blockCrackFixRenderPassWhitelist;
|
||||
angelica$currentCrackFixWhitelistClasses = Arrays.stream(angelica$currentCrackFixWhitelistArr).map((name) -> {
|
||||
try {
|
||||
return Class.forName(name);
|
||||
} catch (ClassNotFoundException e) {
|
||||
AngelicaTweaker.LOGGER.debug("Could not find class " + name + " for crack fix whitelist!");
|
||||
return null;
|
||||
}
|
||||
}).filter(Objects::nonNull).toArray(Class<?>[]::new);
|
||||
}
|
||||
return angelica$currentCrackFixWhitelistClasses;
|
||||
}
|
||||
@Unique
|
||||
private boolean angelica$crackFixOff() {
|
||||
return !AngelicaConfig.fixBlockCrack || angelica$disableCrackFix;
|
||||
}
|
||||
}
|
||||
+8
-1
@@ -32,7 +32,14 @@ public abstract class MixinRenderGlobal {
|
||||
return (boolean)Settings.MODE_SKY.option.getStore();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@WrapWithCondition(
|
||||
method = "renderSky(F)V",
|
||||
at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glCallList(I)V", ordinal = 3, remap = false))
|
||||
private boolean conditionalDisableHorizon(int i) {
|
||||
return !(boolean)Settings.HORIZON_DISABLE.option.getStore();
|
||||
}
|
||||
|
||||
@WrapWithCondition(
|
||||
method = "renderSky(F)V",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/IRenderHandler;render(FLnet/minecraft/client/multiplayer/WorldClient;Lnet/minecraft/client/Minecraft;)V", remap = false))
|
||||
|
||||
+2
-4
@@ -49,8 +49,7 @@ public abstract class MixinEntityRenderer implements IResourceManagerReloadListe
|
||||
@Inject(method = "renderWorld(FJ)V", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/ForgeHooksClient;dispatchRenderLast(Lnet/minecraft/client/renderer/RenderGlobal;F)V", remap = false))
|
||||
private void iris$endLevelRender(float partialTicks, long limitTime, CallbackInfo callback, @Share("pipeline") LocalRef<WorldRenderingPipeline> pipeline) {
|
||||
// TODO: Iris
|
||||
final Camera camera = new Camera(mc.renderViewEntity, partialTicks);
|
||||
HandRenderer.INSTANCE.renderTranslucent(partialTicks, camera, mc.renderGlobal, pipeline.get());
|
||||
HandRenderer.INSTANCE.renderTranslucent(partialTicks, Camera.INSTANCE, mc.renderGlobal, pipeline.get());
|
||||
Minecraft.getMinecraft().mcProfiler.endStartSection("iris_final");
|
||||
pipeline.get().finalizeLevelRendering();
|
||||
pipeline.set(null);
|
||||
@@ -67,8 +66,7 @@ public abstract class MixinEntityRenderer implements IResourceManagerReloadListe
|
||||
|
||||
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderGlobal;clipRenderersByFrustum(Lnet/minecraft/client/renderer/culling/ICamera;F)V", shift = At.Shift.AFTER), method = "renderWorld(FJ)V")
|
||||
private void iris$beginEntities(float partialTicks, long startTime, CallbackInfo ci, @Share("pipeline") LocalRef<WorldRenderingPipeline> pipeline) {
|
||||
final Camera camera = new Camera(mc.renderViewEntity, partialTicks);
|
||||
pipeline.get().renderShadows((EntityRenderer) (Object) this, camera);
|
||||
pipeline.get().renderShadows((EntityRenderer) (Object) this, Camera.INSTANCE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+16
-3
@@ -1,5 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.sodium;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.iris.BiomeCategoryCache;
|
||||
import com.gtnewhorizons.angelica.utils.EventUtils;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraftforge.event.terraingen.BiomeEvent;
|
||||
@@ -9,9 +10,11 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(BiomeGenBase.class)
|
||||
public class MixinBiomeGenBase {
|
||||
private final ThreadLocal<BiomeEvent.GetWaterColor> waterColorEventLocal = ThreadLocal.withInitial(() -> new BiomeEvent.GetWaterColor((BiomeGenBase)(Object)this, 0));;
|
||||
private final ThreadLocal<BiomeEvent.GetGrassColor> grassColorEventLocal = ThreadLocal.withInitial(() -> new BiomeEvent.GetGrassColor((BiomeGenBase)(Object)this, 0));;
|
||||
public class MixinBiomeGenBase implements BiomeCategoryCache {
|
||||
@Unique
|
||||
private int cachedBiomeCategory = -1;
|
||||
private final ThreadLocal<BiomeEvent.GetWaterColor> waterColorEventLocal = ThreadLocal.withInitial(() -> new BiomeEvent.GetWaterColor((BiomeGenBase)(Object)this, 0));
|
||||
private final ThreadLocal<BiomeEvent.GetGrassColor> grassColorEventLocal = ThreadLocal.withInitial(() -> new BiomeEvent.GetGrassColor((BiomeGenBase)(Object)this, 0));
|
||||
private final ThreadLocal<BiomeEvent.GetFoliageColor> foliageColorEventLocal = ThreadLocal.withInitial(() -> new BiomeEvent.GetFoliageColor((BiomeGenBase)(Object)this, 0));
|
||||
|
||||
@Unique
|
||||
@@ -41,4 +44,14 @@ public class MixinBiomeGenBase {
|
||||
prepareEvent(event, original);
|
||||
return event;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int iris$getCachedCategory() {
|
||||
return cachedBiomeCategory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void iris$setCachedCategory(int category) {
|
||||
this.cachedBiomeCategory = category;
|
||||
}
|
||||
}
|
||||
+5
-11
@@ -1,6 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.sodium;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.Camera;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.GameModeUtil;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.MatrixStack;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.IRenderGlobalExt;
|
||||
@@ -20,7 +21,6 @@ import net.coderbot.iris.pipeline.WorldRenderingPhase;
|
||||
import net.coderbot.iris.pipeline.WorldRenderingPipeline;
|
||||
import net.coderbot.iris.uniforms.CapturedRenderingState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
@@ -162,10 +162,8 @@ public class MixinRenderGlobal implements IRenderGlobalExt {
|
||||
if(pass == 0) {
|
||||
pipeline.setPhase(WorldRenderingPhase.TERRAIN_CUTOUT);
|
||||
} else if(pass == 1) {
|
||||
final Camera camera = new Camera(mc.renderViewEntity, (float) partialTicks);
|
||||
|
||||
if (!ShadowRenderer.ACTIVE) {
|
||||
iris$beginTranslucents(pipeline, camera);
|
||||
iris$beginTranslucents(pipeline, Camera.INSTANCE);
|
||||
}
|
||||
|
||||
pipeline.setPhase(WorldRenderingPhase.TERRAIN_TRANSLUCENT);
|
||||
@@ -204,10 +202,7 @@ public class MixinRenderGlobal implements IRenderGlobalExt {
|
||||
}
|
||||
|
||||
private boolean isSpectatorMode() {
|
||||
final PlayerControllerMP controller = Minecraft.getMinecraft().playerController;
|
||||
if(controller == null)
|
||||
return false;
|
||||
return controller.currentGameType.getID() == 3;
|
||||
return GameModeUtil.isSpectator();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -222,11 +217,10 @@ public class MixinRenderGlobal implements IRenderGlobalExt {
|
||||
final Frustrum frustum = (Frustrum) frustrum;
|
||||
boolean hasForcedFrustum = false;
|
||||
boolean spectator = isSpectatorMode();
|
||||
Camera camera = new Camera(mc.renderViewEntity, partialTicks);
|
||||
frustum.setPosition(camera.getPos().x, camera.getPos().y, camera.getPos().z);
|
||||
frustum.setPosition(Camera.INSTANCE.getPos().x, Camera.INSTANCE.getPos().y, Camera.INSTANCE.getPos().z);
|
||||
|
||||
try {
|
||||
this.renderer.updateChunks(camera, frustum, hasForcedFrustum, sodium$frame++, spectator);
|
||||
this.renderer.updateChunks(Camera.INSTANCE, frustum, hasForcedFrustum, sodium$frame++, spectator);
|
||||
} finally {
|
||||
RenderDevice.exitManagedCode();
|
||||
}
|
||||
|
||||
+239
@@ -0,0 +1,239 @@
|
||||
package com.gtnewhorizons.angelica.mixins.late.client.ntmSpace;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.hbm.dim.SkyProviderCelestial;
|
||||
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.llamalad7.mixinextras.sugar.Share;
|
||||
import com.llamalad7.mixinextras.sugar.ref.LocalIntRef;
|
||||
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.pipeline.WorldRenderingPhase;
|
||||
import net.coderbot.iris.pipeline.WorldRenderingPipeline;
|
||||
import net.irisshaders.iris.api.v0.IrisApi;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
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.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.Slice;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
/**
|
||||
* Ported with additional fixes from the ShaderFixer mod
|
||||
* @author kotmatross28729
|
||||
*/
|
||||
@Mixin(value = SkyProviderCelestial.class, priority = 100)
|
||||
public class MixinSkyProviderCelestial_ShaderCompat {
|
||||
|
||||
@Unique
|
||||
private static ResourceLocation GL_TEXTURE_2D_WORKAROUND = new ResourceLocation("angelica:textures/shaders_workaround.png"); /// Simple white 2x2 texture
|
||||
|
||||
/// Fixes
|
||||
|
||||
/**
|
||||
* Forces sunset to render with the default program
|
||||
* <p>
|
||||
* Fixes sunset not rendering at all with shaders enabled
|
||||
*/
|
||||
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lcom/hbm/dim/SkyProviderCelestial;renderSunset(FLnet/minecraft/client/multiplayer/WorldClient;Lnet/minecraft/client/Minecraft;)V"), remap = false)
|
||||
public void iris$sunset$renderInDefaultProgram(CallbackInfo ci, @Share("sunset$previousProgram") LocalIntRef sunset$previousProgram) {
|
||||
sunset$previousProgram.set(GLStateManager.getActiveProgram());
|
||||
GLStateManager.glUseProgram(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the program back before {@link #iris$sunset$renderInDefaultProgram(CallbackInfo, LocalIntRef)} call
|
||||
*/
|
||||
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lcom/hbm/dim/SkyProviderCelestial;renderSunset(FLnet/minecraft/client/multiplayer/WorldClient;Lnet/minecraft/client/Minecraft;)V", shift = At.Shift.AFTER), remap = false)
|
||||
public void iris$sunset$restorePreviousProgram(CallbackInfo ci, @Share("sunset$previousProgram") LocalIntRef sunset$previousProgram) {
|
||||
GLStateManager.glUseProgram(sunset$previousProgram.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables sun blanking with shaders enabled (shaders ignore it anyway)
|
||||
* <p>
|
||||
* Fixes the huge white square near the sun with shaders enabled
|
||||
*/
|
||||
@Inject(method = "renderSun", at = @At(value="INVOKE", target="Lnet/minecraft/client/renderer/Tessellator;draw()I", ordinal = 1))
|
||||
private void iris$sun$disableBlanking(CallbackInfo ci) {
|
||||
if(IrisApi.getInstance().isShaderPackInUse())
|
||||
Tessellator.instance.vertexCount = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the sun a little closer to the camera
|
||||
* <p>
|
||||
* Fixes z-fighting between the sun and the shader skybox
|
||||
*/
|
||||
@ModifyArg(method = "renderSun",
|
||||
slice = @Slice(
|
||||
from = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/Tessellator;addVertexWithUV(DDDDD)V", ordinal = 8),
|
||||
to = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/Tessellator;draw()I", ordinal = 3)),
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/Tessellator;addVertexWithUV(DDDDD)V"),
|
||||
index = 1)
|
||||
private double iris$sun$offsetY(double original) {
|
||||
return original - 0.3D;
|
||||
}
|
||||
|
||||
/**
|
||||
* In accordance with {@link #iris$sun$offsetY(double)} - moves the flare closer to the camera
|
||||
*/
|
||||
@ModifyArg(method = "renderSun",
|
||||
slice = @Slice(
|
||||
from = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/Tessellator;addVertexWithUV(DDDDD)V", ordinal = 12),
|
||||
to = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/Tessellator;draw()I", ordinal = 4)),
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/Tessellator;addVertexWithUV(DDDDD)V"),
|
||||
index = 1)
|
||||
private double iris$sunFlare$offsetY(double original) {
|
||||
return original - 0.3D;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables {@link GL11#glDisable(int GL_TEXTURE_2D)} call
|
||||
* @see #iris$atmosphereBlend$renderInDefaultProgram(CallbackInfo, Minecraft, LocalIntRef)
|
||||
*/
|
||||
@WrapWithCondition(method = "renderCelestials", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glDisable(I)V", ordinal = 2), remap = false)
|
||||
private boolean iris$atmosphereBlend$revertTextureDisable(int i) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables {@link GL11#glEnable(int GL_TEXTURE_2D)} call
|
||||
* @see #iris$atmosphereBlend$renderInDefaultProgram(CallbackInfo, Minecraft, LocalIntRef)
|
||||
*/
|
||||
@WrapWithCondition(method = "renderCelestials", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glEnable(I)V", ordinal = 3), remap = false)
|
||||
private boolean iris$atmosphereBlend$revertTextureEnable(int i) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces atmosphere blend to render with the default program
|
||||
* <p>
|
||||
* Sometimes shaders have serious visual issues if something is rendered with {@link GL11#glDisable(int GL_TEXTURE_2D)}
|
||||
* <p>
|
||||
* Using {@link net.minecraft.client.renderer.texture.TextureManager#bindTexture(ResourceLocation GL_TEXTURE_2D_WORKAROUND)}, we achieve the same effect as {@link GL11#glDisable(int GL_TEXTURE_2D)}, except it works with shaders
|
||||
*/
|
||||
@Inject(method = "renderCelestials", at = @At(value="INVOKE", target="Lnet/minecraft/client/renderer/Tessellator;startDrawingQuads()V", ordinal = 10))
|
||||
private void iris$atmosphereBlend$renderInDefaultProgram(CallbackInfo ci, @Local(argsOnly = true) Minecraft mc, @Share("atmo$previousProgram") LocalIntRef atmo$previousProgram) {
|
||||
atmo$previousProgram.set(GLStateManager.getActiveProgram());
|
||||
GLStateManager.glUseProgram(0);
|
||||
mc.getTextureManager().bindTexture(GL_TEXTURE_2D_WORKAROUND);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the program back before {@link #iris$atmosphereBlend$renderInDefaultProgram(CallbackInfo, Minecraft, LocalIntRef)} call
|
||||
*/
|
||||
@Inject(method = "renderCelestials", at = @At(value="INVOKE", target="Lnet/minecraft/client/renderer/Tessellator;draw()I", ordinal = 10, shift = At.Shift.AFTER))
|
||||
private void iris$atmosphereBlend$restorePreviousProgram(CallbackInfo ci, @Share("atmo$previousProgram") LocalIntRef atmo$previousProgram) {
|
||||
GLStateManager.glUseProgram(atmo$previousProgram.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces celestial bodies to render with the default program
|
||||
* <p>
|
||||
* Requires `iris$atmosphereBlend$.*`
|
||||
* <p>
|
||||
* Fixes many bugs, such as:
|
||||
* <p>
|
||||
* - [All Shaders] At certain time, celestial bodies are rendered as a just solid color squares
|
||||
* <p>
|
||||
* - [All Shaders] Some celestial bodies appear as heavily (70-90%) translucent
|
||||
* <p>
|
||||
* - [Complementary 5.5/6.x] Stars render on top of celestial bodies; not behind them
|
||||
* <p>
|
||||
* - [Complementary 5.5.x] Celestial bodies have incorrect colors near the sun
|
||||
* <p>
|
||||
* - [Complementary 5.6.x] Celestial bodies don't render at all far from the sun
|
||||
*/
|
||||
@Inject(method = "renderCelestials", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/Tessellator;startDrawingQuads()V", ordinal = 5))
|
||||
private void iris$celestials$renderInDefaultProgram(CallbackInfo ci, @Share("celestials$previousProgram") LocalIntRef celestials$previousProgram) {
|
||||
celestials$previousProgram.set(GLStateManager.getActiveProgram());
|
||||
GLStateManager.glUseProgram(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the program back before {@link #iris$celestials$renderInDefaultProgram(CallbackInfo, LocalIntRef)} call
|
||||
*/
|
||||
@Inject(method = "renderCelestials", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/Tessellator;draw()I", ordinal = 5, shift = At.Shift.AFTER))
|
||||
private void iris$celestials$restorePreviousProgram(CallbackInfo ci, @Share("celestials$previousProgram") LocalIntRef celestials$previousProgram) {
|
||||
GLStateManager.glUseProgram(celestials$previousProgram.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces celestial body ring (back) to render with the default program
|
||||
* @see #iris$celestials$renderInDefaultProgram(CallbackInfo, LocalIntRef)
|
||||
*/
|
||||
@Inject(method = "renderCelestials", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/Tessellator;startDrawingQuads()V", ordinal = 0))
|
||||
private void iris$ringsBack$renderInDefaultProgram(CallbackInfo ci, @Share("ringsBack$previousProgram") LocalIntRef ringsBack$previousProgram) {
|
||||
ringsBack$previousProgram.set(GLStateManager.getActiveProgram());
|
||||
GLStateManager.glUseProgram(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the program back before {@link #iris$ringsBack$renderInDefaultProgram(CallbackInfo, LocalIntRef)} call
|
||||
*/
|
||||
@Inject(method = "renderCelestials", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/Tessellator;draw()I", ordinal = 0, shift = At.Shift.AFTER))
|
||||
private void iris$ringsBack$restorePreviousProgram(CallbackInfo ci, @Share("ringsBack$previousProgram") LocalIntRef ringsBack$previousProgram) {
|
||||
GLStateManager.glUseProgram(ringsBack$previousProgram.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces celestial body ring (front) to render with the default program
|
||||
* @see #iris$celestials$renderInDefaultProgram(CallbackInfo, LocalIntRef)
|
||||
*/
|
||||
@Inject(method = "renderCelestials", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/Tessellator;startDrawingQuads()V", ordinal = 11))
|
||||
private void iris$ringsFront$renderInDefaultProgram(CallbackInfo ci, @Share("ringsFront$previousProgram") LocalIntRef ringsFront$previousProgram) {
|
||||
ringsFront$previousProgram.set(GLStateManager.getActiveProgram());
|
||||
GLStateManager.glUseProgram(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the program back before {@link #iris$ringsFront$renderInDefaultProgram(CallbackInfo, LocalIntRef)} call
|
||||
*/
|
||||
@Inject(method = "renderCelestials", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/Tessellator;draw()I", ordinal = 11, shift = At.Shift.AFTER))
|
||||
private void iris$ringsFront$restorePreviousProgram(CallbackInfo ci, @Share("ringsFront$previousProgram") LocalIntRef ringsFront$previousProgram) {
|
||||
GLStateManager.glUseProgram(ringsFront$previousProgram.get());
|
||||
}
|
||||
|
||||
/// Pipeline setup
|
||||
|
||||
@Inject(method = "render", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/Tessellator;instance:Lnet/minecraft/client/renderer/Tessellator;"))
|
||||
private void iris$renderSky$beginNormalSky(CallbackInfo ci, @Share("pipeline") LocalRef<WorldRenderingPipeline> pipeline) {
|
||||
pipeline.set(Iris.getPipelineManager().getPipelineNullable());
|
||||
if(pipeline.get() != null)
|
||||
pipeline.get().setPhase(WorldRenderingPhase.SKY);
|
||||
}
|
||||
|
||||
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/EntityClientPlayerMP;getPosition(F)Lnet/minecraft/util/Vec3;"))
|
||||
private void iris$setVoidRenderStage(CallbackInfo ci, @Share("pipeline") LocalRef<WorldRenderingPipeline> pipeline) {
|
||||
if(pipeline.get() != null)
|
||||
pipeline.get().setPhase(WorldRenderingPhase.VOID);
|
||||
}
|
||||
|
||||
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glRotatef(FFFF)V", ordinal = 2), remap = false)
|
||||
private void iris$renderSky$tiltSun(CallbackInfo ci, @Share("pipeline") LocalRef<WorldRenderingPipeline> pipeline) {
|
||||
if(pipeline.get() != null)
|
||||
GL11.glRotatef(pipeline.get().getSunPathRotation(), 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
@Inject(method = "renderSun", at = @At(value = "FIELD", target = "Lcom/hbm/dim/CelestialBody;texture:Lnet/minecraft/util/ResourceLocation;"), remap = false)
|
||||
private void iris$setSunRenderStage(CallbackInfo ci) {
|
||||
Iris.getPipelineManager().getPipeline().ifPresent(p -> p.setPhase(WorldRenderingPhase.SUN));
|
||||
}
|
||||
|
||||
@Inject(method = "renderSunset", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/WorldProvider;calcSunriseSunsetColors(FF)[F"))
|
||||
private void iris$setSunsetRenderStage(CallbackInfo ci) {
|
||||
Iris.getPipelineManager().getPipeline().ifPresent(p -> p.setPhase(WorldRenderingPhase.SUNSET));
|
||||
}
|
||||
|
||||
@Inject(method = "renderStars", at = @At(value = "HEAD"), remap = false)
|
||||
private void iris$setStarRenderStage(CallbackInfo ci, @Share("pipeline") LocalRef<WorldRenderingPipeline> pipeline) {
|
||||
Iris.getPipelineManager().getPipeline().ifPresent(p -> p.setPhase(WorldRenderingPhase.STARS));
|
||||
}
|
||||
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.gtnewhorizons.angelica.mixins.late.client.ntmSpace;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.CompatConfig;
|
||||
import com.hbm.dim.SkyProviderCelestial;
|
||||
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
|
||||
import jss.notfine.core.Settings;
|
||||
import net.irisshaders.iris.api.v0.IrisApi;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(value = SkyProviderCelestial.class, priority = 100)
|
||||
public class MixinSkyProviderCelestial_Tweaks {
|
||||
|
||||
@WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glCallList(I)V", ordinal = 2), remap = false)
|
||||
private boolean angelica$disableHorizon(int i) {
|
||||
return !(boolean) Settings.HORIZON_DISABLE.option.getStore();
|
||||
}
|
||||
|
||||
@Inject(method = "render", at = @At(value="INVOKE", target="Lnet/minecraft/client/renderer/Tessellator;draw()I", ordinal = 1))
|
||||
private void angelica$disableAltitudePlanetRenderer(CallbackInfo ci) {
|
||||
if(CompatConfig.NTMSpace_disableAltitudePlanetRenderer == CompatConfig.altitudePlanetRendererState.Always || (IrisApi.getInstance().isShaderPackInUse() && CompatConfig.NTMSpace_disableAltitudePlanetRenderer == CompatConfig.altitudePlanetRendererState.ShadersOnly)) {
|
||||
Tessellator.instance.vertexCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,27 +20,35 @@ public class GLSM_VAO_UnitTest {
|
||||
void testDefaultStates() {
|
||||
verifyState(GL30.GL_VERTEX_ARRAY_BINDING, 0, "GL_VERTEX_ARRAY_BINDING Initial State");
|
||||
verifyState(GL13.GL_CLIENT_ACTIVE_TEXTURE, GL13.GL_TEXTURE0, "GL_CLIENT_ACTIVE_TEXTURE Initial State");
|
||||
testClientStates();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testVAOPreservesStates() {
|
||||
boolean vertexStateEnabled = GL11.glIsEnabled(GL11.GL_VERTEX_ARRAY);
|
||||
|
||||
// Stride = vertexSize * byte size of the type (= 4 for both GL_FLOAT and GL_INT)
|
||||
final boolean defaultVertexEnabled = false;
|
||||
final int defaultVertexSize = 2;
|
||||
final int defaultVertexType = GL11.GL_FLOAT;
|
||||
final int defaultVertexStride = defaultVertexSize * 4;
|
||||
|
||||
final boolean vaoVertexEnabled = true;
|
||||
final int vaoVertexSize = 4;
|
||||
final int vaoVertexType = GL11.GL_INT;
|
||||
final int vaoVertexStride = vaoVertexSize * 4;
|
||||
|
||||
GL13.glClientActiveTexture(GL13.GL_TEXTURE1);
|
||||
verifyState(GL13.GL_CLIENT_ACTIVE_TEXTURE, GL13.GL_TEXTURE1, "GL_CLIENT_ACTIVE_TEXTURE - Setup");
|
||||
|
||||
// Set the vertex attrib to a defined state
|
||||
int vbo = GL15.glGenBuffers();
|
||||
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);
|
||||
|
||||
GL11.glVertexPointer(defaultVertexSize, defaultVertexType, defaultVertexStride, 0);
|
||||
|
||||
GLSMUtil.setClientState(GL11.GL_NORMAL_ARRAY, true);
|
||||
verifyState(GL11.GL_NORMAL_ARRAY, true, "GL_NORMAL_ARRAY - Enabled");
|
||||
|
||||
verifyState(GL11.GL_VERTEX_ARRAY_SIZE, defaultVertexSize, "GL_VERTEX_ARRAY_SIZE - Setup");
|
||||
verifyState(GL11.GL_VERTEX_ARRAY_TYPE, defaultVertexType, "GL_VERTEX_ARRAY_TYPE - Setup");
|
||||
verifyState(GL11.GL_VERTEX_ARRAY_STRIDE, defaultVertexStride, "GL_VERTEX_ARRAY_STRIDE - Setup");
|
||||
@@ -49,7 +57,7 @@ public class GLSM_VAO_UnitTest {
|
||||
|
||||
// Verify VAO & VBO creation
|
||||
int vao = UniversalVAO.genVertexArrays();
|
||||
Assertions.assertNotEquals(0, vao, "GL_VERTEX_ARRAY_BINDING - VAO Created");
|
||||
Assertions.assertTrue(vao > 0, "GL_VERTEX_ARRAY_BINDING - VAO Created");
|
||||
|
||||
UniversalVAO.bindVertexArray(vao);
|
||||
verifyState(GL30.GL_VERTEX_ARRAY_BINDING, vao, "GL_VERTEX_ARRAY_BINDING - Bound");
|
||||
@@ -57,9 +65,15 @@ public class GLSM_VAO_UnitTest {
|
||||
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);
|
||||
verifyState(GL15.GL_ARRAY_BUFFER_BINDING, vbo, "GL_ARRAY_BUFFER_BINDING - Bound");
|
||||
|
||||
verifyState(GL13.GL_CLIENT_ACTIVE_TEXTURE, GL13.GL_TEXTURE1, "GL_CLIENT_ACTIVE_TEXTURE - Preserved");
|
||||
|
||||
// Set & Verify the VAO states
|
||||
GLSMUtil.setClientState(GL11.GL_VERTEX_ARRAY, !vertexStateEnabled);
|
||||
verifyState(GL11.GL_VERTEX_ARRAY, !vertexStateEnabled, "GL_VERTEX_ARRAY - Set");
|
||||
|
||||
// VAO's have every client state back to its default state, so GL_NORMAL_ARRAY should be false now
|
||||
testClientStates();
|
||||
|
||||
GLSMUtil.setClientState(GL11.GL_VERTEX_ARRAY, vaoVertexEnabled);
|
||||
verifyState(GL11.GL_VERTEX_ARRAY, vaoVertexEnabled, "GL_VERTEX_ARRAY - Enabled");
|
||||
|
||||
GL11.glVertexPointer(vaoVertexSize, vaoVertexType, vaoVertexStride, 0);
|
||||
|
||||
@@ -74,18 +88,20 @@ public class GLSM_VAO_UnitTest {
|
||||
verifyState(GL30.GL_VERTEX_ARRAY_BINDING, 0, "GL_VERTEX_ARRAY_BINDING - Unbound");
|
||||
verifyState(GL15.GL_ARRAY_BUFFER_BINDING, 0, "GL_ARRAY_BUFFER_BINDING - Unbound");
|
||||
|
||||
verifyState(GL11.GL_VERTEX_ARRAY, vertexStateEnabled, "GL_VERTEX_ARRAY - Reset");
|
||||
verifyState(GL11.GL_VERTEX_ARRAY, defaultVertexEnabled, "GL_VERTEX_ARRAY - Reset");
|
||||
verifyState(GL11.GL_VERTEX_ARRAY_SIZE, defaultVertexSize, "GL_VERTEX_ARRAY_SIZE - Reset");
|
||||
verifyState(GL11.GL_VERTEX_ARRAY_TYPE, defaultVertexType, "GL_VERTEX_ARRAY_TYPE - Reset");
|
||||
verifyState(GL11.GL_VERTEX_ARRAY_STRIDE, defaultVertexStride, "GL_VERTEX_ARRAY_STRIDE - Reset");
|
||||
|
||||
verifyState(GL11.GL_NORMAL_ARRAY, true, "GL_NORMAL_ARRAY - Reset");
|
||||
|
||||
// Check if the VAO states are still valid after re-binding it
|
||||
UniversalVAO.bindVertexArray(vao);
|
||||
|
||||
verifyState(GL11.GL_VERTEX_ARRAY, !vertexStateEnabled, "GL_VERTEX_ARRAY - Rebound");
|
||||
verifyState(GL11.GL_VERTEX_ARRAY_SIZE, vaoVertexSize, "GL_VERTEX_ARRAY_SIZE - Rebound");
|
||||
verifyState(GL11.GL_VERTEX_ARRAY_TYPE, vaoVertexType, "GL_VERTEX_ARRAY_TYPE - Rebound");
|
||||
verifyState(GL11.GL_VERTEX_ARRAY_STRIDE, vaoVertexStride, "GL_VERTEX_ARRAY_STRIDE - Rebound");
|
||||
verifyState(GL11.GL_VERTEX_ARRAY, vaoVertexEnabled, "GL_VERTEX_ARRAY - Preserved");
|
||||
verifyState(GL11.GL_VERTEX_ARRAY_SIZE, vaoVertexSize, "GL_VERTEX_ARRAY_SIZE - Preserved");
|
||||
verifyState(GL11.GL_VERTEX_ARRAY_TYPE, vaoVertexType, "GL_VERTEX_ARRAY_TYPE - Preserved");
|
||||
verifyState(GL11.GL_VERTEX_ARRAY_STRIDE, vaoVertexStride, "GL_VERTEX_ARRAY_STRIDE - Preserved");
|
||||
|
||||
UniversalVAO.bindVertexArray(0);
|
||||
|
||||
@@ -93,4 +109,12 @@ public class GLSM_VAO_UnitTest {
|
||||
GL15.glDeleteBuffers(vbo);
|
||||
UniversalVAO.deleteVertexArrays(vao);
|
||||
}
|
||||
|
||||
private static void testClientStates() {
|
||||
verifyState(GL11.GL_VERTEX_ARRAY, false, "GL_VERTEX_ARRAY Default State");
|
||||
verifyState(GL11.GL_TEXTURE_COORD_ARRAY, false, "GL_TEXTURE_COORD_ARRAY Default State");
|
||||
verifyState(GL11.GL_NORMAL_ARRAY, false, "GL_NORMAL_ARRAY Default State");
|
||||
verifyState(GL11.GL_COLOR_ARRAY, false, "GL_COLOR_ARRAY Default State");
|
||||
verifyState(GL11.GL_INDEX_ARRAY, false, "GL_INDEX_ARRAY Default State");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user