mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-16 10:45:09 +00:00
Compare commits
21
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1968914582 | ||
|
|
a70bd76ff3 | ||
|
|
db919b5f37 | ||
|
|
cde47ea423 | ||
|
|
5ef6cb11c0 | ||
|
|
b7015bf10e | ||
|
|
46602ab921 | ||
|
|
63e9fa0df1 | ||
|
|
dcea970a77 | ||
|
|
b29240d6da | ||
|
|
9d5a02ed21 | ||
|
|
b454483aae | ||
|
|
72b13543c6 | ||
|
|
36d98fcb22 | ||
|
|
44c5b9617a | ||
|
|
f3f1677db8 | ||
|
|
d396b611ad | ||
|
|
08f4c0f9db | ||
|
|
50b0d22dc2 | ||
|
|
7fed54264e | ||
|
|
be87401be6 |
No files matched your search
+1
-1
@@ -16,5 +16,5 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("com.gtnewhorizons.gtnhsettingsconvention") version("2.0.13")
|
||||
id("com.gtnewhorizons.gtnhsettingsconvention") version("2.0.18")
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.gtnewhorizons.angelica.compat;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.opengl.ARBDebugOutput;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
|
||||
/**
|
||||
* Checks for known problematic driver configurations and applies workarounds. Adapted from Embeddium/Sodium's LateDriverScanner.
|
||||
*
|
||||
* <p>The NVIDIA workaround can be disabled via: {@code -Dangelica.disableNvidiaWorkaround=true}
|
||||
*/
|
||||
public class DriverCompatabilityCheck {
|
||||
private static final Logger LOGGER = LogManager.getLogger("Angelica");
|
||||
|
||||
private static final boolean DISABLE_NVIDIA_WORKAROUND = Boolean.getBoolean("angelica.disableNvidiaWorkaround");
|
||||
|
||||
/**
|
||||
* Should be called after GL context is created and GLStateManager is initialized.
|
||||
*/
|
||||
public static void checkDriverCompatibility() {
|
||||
final String vendor = GL11.glGetString(GL11.GL_VENDOR);
|
||||
final String renderer = GL11.glGetString(GL11.GL_RENDERER);
|
||||
final String version = GL11.glGetString(GL11.GL_VERSION);
|
||||
|
||||
LOGGER.info("OpenGL Vendor: {}", vendor);
|
||||
LOGGER.info("OpenGL Renderer: {}", renderer);
|
||||
LOGGER.info("OpenGL Version: {}", version);
|
||||
|
||||
if (vendor != null && vendor.contains("NVIDIA")) {
|
||||
if (DISABLE_NVIDIA_WORKAROUND) {
|
||||
LOGGER.info("NVIDIA workaround disabled via -Dangelica.disableNvidiaWorkaround=true");
|
||||
} else {
|
||||
applyNvidiaWorkaround();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* https://github.com/godotengine/godot/issues/33969#issuecomment-917846774
|
||||
* Attempt to force the driver to disable its submission thread by enabling synchronous debug output.
|
||||
* This usually suppresses bad behavior from NVIDIA's "Threaded Optimizations" feature.
|
||||
*/
|
||||
private static void applyNvidiaWorkaround() {
|
||||
if (!GLStateManager.capabilities.GL_ARB_debug_output) {
|
||||
LOGGER.warn("Cannot apply NVIDIA workaround: ARB_debug_output not available");
|
||||
return;
|
||||
}
|
||||
|
||||
LOGGER.info("Enabling workaround for NVIDIA threaded optimizations");
|
||||
GL11.glEnable(ARBDebugOutput.GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.compat.iris;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import net.coderbot.iris.parsing.BiomeCategories;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
@@ -8,7 +9,7 @@ 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)
|
||||
* Currently supports: BiomesOPlenty (BOP), Realistic World Gen (RWG), lotr (b36.15)
|
||||
*/
|
||||
public class ModdedBiomeDetector {
|
||||
private static boolean initialized = false;
|
||||
@@ -23,12 +24,15 @@ public class ModdedBiomeDetector {
|
||||
// LinkedHashMap maintains insertion order for deterministic behavior
|
||||
private static final Map<Class<?>, BiomeCategories> rwgClassMap = new LinkedHashMap<>();
|
||||
|
||||
private static Class<?> lotrBiomeClass = null;
|
||||
|
||||
private static synchronized void initialize() {
|
||||
if (initialized) return;
|
||||
initialized = true;
|
||||
|
||||
initializeBOP();
|
||||
initializeRWG();
|
||||
initializeLOTR();
|
||||
}
|
||||
|
||||
private static void initializeBOP() {
|
||||
@@ -59,6 +63,16 @@ public class ModdedBiomeDetector {
|
||||
tryAddRWGClass("rwg.biomes.base.BaseBiomeSnowForest", BiomeCategories.TAIGA); // Snow forests are taiga
|
||||
}
|
||||
|
||||
private static void initializeLOTR() {
|
||||
if (ModStatus.isLotrLoaded) {
|
||||
try {
|
||||
lotrBiomeClass = Class.forName("lotr.common.world.biome.LOTRBiome");
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
// lotr not installed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void tryAddRWGClass(String className, BiomeCategories category) {
|
||||
try {
|
||||
final Class<?> clazz = Class.forName(className);
|
||||
@@ -91,12 +105,64 @@ public class ModdedBiomeDetector {
|
||||
// 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();
|
||||
if (biome.getBiomeClass().getName().contains("rwg.biomes")) {
|
||||
for (Map.Entry<Class<?>, BiomeCategories> entry : rwgClassMap.entrySet()) {
|
||||
if (entry.getKey().isInstance(biome)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// lotr
|
||||
if (lotrBiomeClass.isInstance(biome)) {
|
||||
return detectLOTRBiome(biome);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static BiomeCategories detectLOTRBiome(BiomeGenBase biome) {
|
||||
return switch (biome.biomeName) {
|
||||
case "river", "farHaradJungleLake", "lake" -> BiomeCategories.RIVER;
|
||||
case "rohan", "rivendell", "rhunIsland", "rhunLandHills", "rhunLandSteppe", "rhunLand", "andrast",
|
||||
"blackrootVale", "lamedon", "imlothMelui", "towerHills", "dorwinion", "dale", "shireMoors", "wold",
|
||||
"anduinVale", "rhun", "lebennin", "pertorogwaith", "breeland", "island", "pinnathGelin",
|
||||
"minhiriath", "pelennor", "adornland", "nanCurunir", "ithilienWasteland", "fangornClearing",
|
||||
"barrowDowns", "dorEnErnilHills", "dorEnErnil", "nurn", "wilderland", "eastBight", "lindon",
|
||||
"eregion", "enedwaith", "meneltarma", "anduinHills", "eriador", "angle", "loneLandsHills",
|
||||
"loneLands", "pelargir", "rohanUrukHighlands", "celebrant", "gondor", "shire", "nurnen", "farHarad" ->
|
||||
BiomeCategories.PLAINS;
|
||||
case "mistyMountains", "windMountains", "farHaradVolcano", "redMountains", "haradMountains",
|
||||
"angmarMountains", "blueMountains", "greyMountains", "whiteMountains", "mordorMountains" ->
|
||||
BiomeCategories.MOUNTAIN;
|
||||
case "shireWoodlands", "rhunIslandForest", "rhunRedForest", "pukel", "lossarnach", "gulfHaradForest",
|
||||
"nearHaradFertileForest", "dolGuldur", "rhunForest", "tauredainClearing", "umbarForest",
|
||||
"farHaradForest", "chetwood", "woodlandRealmHills", "mirkwoodNorth", "whiteDowns", "ithilienHills",
|
||||
"gondorWoodlands", "rohanWoodlands", "fangornWasteland", "mirkwoodMountains", "lindonWoodlands",
|
||||
"lothlorienEdge", "erynVorn", "oldForest", "fangorn", "dunland", "ithilien", "mirkwoodCorrupted",
|
||||
"woodlandRealm", "trollshaws", "lothlorien", "farHaradKanuka" -> BiomeCategories.FOREST;
|
||||
case "mordor", "lastDesert", "harnedor", "easternDesolation", "morgulVale", "gorgoroth", "udun",
|
||||
"nearHaradRedDesert", "nearHaradSemiDesert", "lostladen",
|
||||
"nearHaradHills", "nearHarad", "nanUngol", "dagorlad", "brownLands" -> BiomeCategories.DESERT;
|
||||
case "ironHills", "rivendellHills", "windMountainsFoothills", "lamedonHills", "redMountainsFoothills",
|
||||
"tolfalas", "dorwinionHills", "whiteMountainsFoothills", "blueMountainsFoothills",
|
||||
"greyMountainsFoothills", "mistyMountainsFoothills", "erebor", "angmar", "eriadorDowns",
|
||||
"ettenmoors", "emynMuil" -> BiomeCategories.EXTREME_HILLS;
|
||||
case "deadMarshes", "shireMarshes", "farHaradMangrove", "farHaradSwamp", "swanfleet", "nindalf",
|
||||
"longMarshes", "entwashMouth", "nurnMarshes", "gladdenFields", "midgewater", "anduinMouth" ->
|
||||
BiomeCategories.SWAMP;
|
||||
case "harondor", "nearHaradOasis", "nearHaradRiverbank", "farHaradBushlandHills", "farHaradBushland",
|
||||
"gulfHarad", "nearHaradFertile", "umbarHills", "umbar", "farHaradAridHills", "farHaradArid" ->
|
||||
BiomeCategories.SAVANNA;
|
||||
case "ocean" -> BiomeCategories.OCEAN;
|
||||
case "forodwaith", "forodwaithGlacier", "tundra", "forodwaithMountains" -> BiomeCategories.ICY;
|
||||
case "lindonCoast", "beachWhite", "farHaradCoast", "forodwaithCoast", "beachGravel", "beach" ->
|
||||
BiomeCategories.BEACH;
|
||||
case "coldfells", "wilderlandNorth", "taiga" -> BiomeCategories.TAIGA;
|
||||
case "farHaradJungle", "halfTrollForest", "farHaradJungleMountains",
|
||||
"farHaradCloudForest", "farHaradJungleEdge" -> BiomeCategories.JUNGLE;
|
||||
case "utumno" -> BiomeCategories.NONE;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -200,7 +200,7 @@ public class AngelicaConfig {
|
||||
"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"
|
||||
})
|
||||
@@ -221,4 +221,8 @@ public class AngelicaConfig {
|
||||
@Config.DefaultBoolean(false)
|
||||
public static boolean useVanillaChunkTracking;
|
||||
|
||||
@Config.Comment("Disables additional F3 information added by Angelica.")
|
||||
@Config.DefaultBoolean(false)
|
||||
public static boolean disableF3Additions;
|
||||
|
||||
}
|
||||
@@ -52,6 +52,7 @@ public class DynamicLights {
|
||||
private static final double MAX_RADIUS_SQUARED = MAX_RADIUS * MAX_RADIUS;
|
||||
private final Set<IDynamicLightSource> dynamicLightSources = new ObjectOpenHashSet<>();
|
||||
private final ReentrantReadWriteLock lightSourcesLock = new ReentrantReadWriteLock();
|
||||
private volatile int lightSourceCount = 0;
|
||||
private final ChunkRebuildManager chunkRebuildManager = new ChunkRebuildManager();
|
||||
private long lastUpdate = System.currentTimeMillis();
|
||||
private int lastUpdateCount = 0;
|
||||
@@ -70,6 +71,10 @@ public class DynamicLights {
|
||||
(ShaderForce || !IrisApi.getInstance().isShaderPackInUse());
|
||||
}
|
||||
|
||||
public boolean hasLightSources() {
|
||||
return lightSourceCount > 0;
|
||||
}
|
||||
|
||||
public static IDynamicLightWorldRenderer getActiveRenderer() {
|
||||
return activeRenderer;
|
||||
}
|
||||
@@ -142,7 +147,9 @@ public class DynamicLights {
|
||||
|
||||
public void addLightSource(IDynamicLightSource lightSource) {
|
||||
this.lightSourcesLock.writeLock().lock();
|
||||
this.dynamicLightSources.add(lightSource);
|
||||
if (this.dynamicLightSources.add(lightSource)) {
|
||||
this.lightSourceCount = this.dynamicLightSources.size();
|
||||
}
|
||||
this.lightSourcesLock.writeLock().unlock();
|
||||
}
|
||||
|
||||
@@ -160,6 +167,7 @@ public class DynamicLights {
|
||||
it = dynamicLightSources.next();
|
||||
if (it.equals(lightSource)) {
|
||||
dynamicLightSources.remove();
|
||||
this.lightSourceCount = this.dynamicLightSources.size();
|
||||
if (activeRenderer != null)
|
||||
lightSource.angelica$scheduleTrackedChunksRebuild(activeRenderer);
|
||||
break;
|
||||
@@ -183,6 +191,7 @@ public class DynamicLights {
|
||||
it = dynamicLightSources.next();
|
||||
if (filter.test(it)) {
|
||||
dynamicLightSources.remove();
|
||||
this.lightSourceCount = this.dynamicLightSources.size();
|
||||
if (activeRenderer != null) {
|
||||
if (it.angelica$getLuminance() > 0)
|
||||
it.angelica$resetDynamicLight();
|
||||
@@ -212,6 +221,7 @@ public class DynamicLights {
|
||||
it.angelica$scheduleTrackedChunksRebuild(activeRenderer);
|
||||
}
|
||||
}
|
||||
this.lightSourceCount = 0;
|
||||
|
||||
this.lightSourcesLock.writeLock().unlock();
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ import org.lwjgl.opengl.GL12;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.lwjgl.opengl.GL14;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
import org.lwjgl.opengl.Display;
|
||||
import org.lwjgl.opengl.GLContext;
|
||||
import org.lwjgl.opengl.KHRDebug;
|
||||
@@ -3786,4 +3787,56 @@ public class GLStateManager {
|
||||
return VENDOR == NVIDIA;
|
||||
}
|
||||
|
||||
@Getter protected static int drawFramebuffer = 0;
|
||||
@Getter protected static int readFramebuffer = 0;
|
||||
|
||||
public static void glBindFramebuffer(int target, int framebuffer) {
|
||||
if (target == GL30.GL_FRAMEBUFFER) {
|
||||
if (drawFramebuffer == framebuffer && readFramebuffer == framebuffer) return;
|
||||
drawFramebuffer = framebuffer;
|
||||
readFramebuffer = framebuffer;
|
||||
} else if (target == GL30.GL_DRAW_FRAMEBUFFER) {
|
||||
if (drawFramebuffer == framebuffer) return;
|
||||
drawFramebuffer = framebuffer;
|
||||
} else if (target == GL30.GL_READ_FRAMEBUFFER) {
|
||||
if (readFramebuffer == framebuffer) return;
|
||||
readFramebuffer = framebuffer;
|
||||
}
|
||||
GL30.glBindFramebuffer(target, framebuffer);
|
||||
}
|
||||
|
||||
public static void glDeleteFramebuffers(int framebuffer) {
|
||||
if (drawFramebuffer == framebuffer) drawFramebuffer = 0;
|
||||
if (readFramebuffer == framebuffer) readFramebuffer = 0;
|
||||
GL30.glDeleteFramebuffers(framebuffer);
|
||||
}
|
||||
|
||||
public static int glGenFramebuffers() {
|
||||
return GL30.glGenFramebuffers();
|
||||
}
|
||||
|
||||
public static int glCheckFramebufferStatus(int target) {
|
||||
return GL30.glCheckFramebufferStatus(target);
|
||||
}
|
||||
|
||||
public static void glFramebufferTexture2D(int target, int attachment, int textarget, int texture, int level) {
|
||||
GL30.glFramebufferTexture2D(target, attachment, textarget, texture, level);
|
||||
}
|
||||
|
||||
public static void setActiveTexture(int textureUnit) {
|
||||
glActiveTexture(textureUnit);
|
||||
}
|
||||
|
||||
public static void setLightmapTextureCoords(int unit, float x, float y) {
|
||||
GL13.glMultiTexCoord2f(unit, x, y);
|
||||
if (unit == GL13.GL_TEXTURE1) {
|
||||
OpenGlHelper.lastBrightnessX = x;
|
||||
OpenGlHelper.lastBrightnessY = y;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isFramebufferEnabled() {
|
||||
return OpenGlHelper.framebufferSupported && Minecraft.getMinecraft().gameSettings.fboEnable;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package com.gtnewhorizons.angelica.glsm.dsa;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
@@ -77,13 +76,13 @@ public class DSAUnsupported implements DSAAccess {
|
||||
|
||||
@Override
|
||||
public void readBuffer(int framebuffer, int buffer) {
|
||||
OpenGlHelper.func_153171_g/*glBindFramebuffer*/(GL30.GL_FRAMEBUFFER, framebuffer);
|
||||
GLStateManager.glBindFramebuffer(GL30.GL_FRAMEBUFFER, framebuffer);
|
||||
GL11.glReadBuffer(buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBuffers(int framebuffer, IntBuffer buffers) {
|
||||
OpenGlHelper.func_153171_g/*glBindFramebuffer*/(GL30.GL_FRAMEBUFFER, framebuffer);
|
||||
GLStateManager.glBindFramebuffer(GL30.GL_FRAMEBUFFER, framebuffer);
|
||||
GL20.glDrawBuffers(buffers);
|
||||
}
|
||||
|
||||
@@ -135,21 +134,21 @@ public class DSAUnsupported implements DSAAccess {
|
||||
@Override
|
||||
public void blitFramebuffer(int source, int dest, int offsetX, int offsetY, int width, int height, int offsetX2, int offsetY2, int width2, int height2,
|
||||
int bufferChoice, int filter) {
|
||||
OpenGlHelper.func_153171_g/*glBindFramebuffer*/(GL30.GL_READ_FRAMEBUFFER, source);
|
||||
OpenGlHelper.func_153171_g/*glBindFramebuffer*/(GL30.GL_DRAW_FRAMEBUFFER, dest);
|
||||
GLStateManager.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, source);
|
||||
GLStateManager.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, dest);
|
||||
GL30.glBlitFramebuffer(offsetX, offsetY, width, height, offsetX2, offsetY2, width2, height2, bufferChoice, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void framebufferTexture2D(int fb, int fbtarget, int attachment, int target, int texture, int levels) {
|
||||
OpenGlHelper.func_153171_g/*glBindFramebuffer*/(fbtarget, fb);
|
||||
GLStateManager.glBindFramebuffer(fbtarget, fb);
|
||||
GL30.glFramebufferTexture2D(fbtarget, attachment, target, texture, levels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int createFramebuffer() {
|
||||
final int framebuffer = OpenGlHelper.func_153165_e/*glGenFramebuffers*/();
|
||||
OpenGlHelper.func_153171_g/*glBindFramebuffer*/(GL30.GL_FRAMEBUFFER, framebuffer);
|
||||
final int framebuffer = GLStateManager.glGenFramebuffers();
|
||||
GLStateManager.glBindFramebuffer(GL30.GL_FRAMEBUFFER, framebuffer);
|
||||
return framebuffer;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiIngame;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraftforge.client.GuiIngameForge;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -68,7 +67,7 @@ public class HUDCaching {
|
||||
XaeroMinimapCore.beforeIngameGuiRender(partialTicks);
|
||||
}
|
||||
|
||||
if (!OpenGlHelper.isFramebufferEnabled()) {
|
||||
if (!GLStateManager.isFramebufferEnabled()) {
|
||||
ingame.renderGameOverlay(partialTicks, hasScreen, mouseX, mouseY);
|
||||
return;
|
||||
}
|
||||
|
||||
+14
-1
@@ -45,6 +45,7 @@ public final class AngelicaRedirector {
|
||||
private static final String GL13 = "org/lwjgl/opengl/GL13";
|
||||
private static final String GL14 = "org/lwjgl/opengl/GL14";
|
||||
private static final String GL20 = "org/lwjgl/opengl/GL20";
|
||||
private static final String GL30 = "org/lwjgl/opengl/GL30";
|
||||
private static final String Project = "org/lwjgl/util/glu/Project";
|
||||
private static final String OpenGlHelper = "net/minecraft/client/renderer/OpenGlHelper";
|
||||
private static final String EXTBlendFunc = "org/lwjgl/opengl/EXTBlendFuncSeparate";
|
||||
@@ -231,9 +232,21 @@ public final class AngelicaRedirector {
|
||||
.add("glStencilOpSeparate")
|
||||
.add("glUseProgram")
|
||||
);
|
||||
methodRedirects.put(GL30, RedirectMap.newMap()
|
||||
.add("glBindFramebuffer")
|
||||
);
|
||||
methodRedirects.put(OpenGlHelper, RedirectMap.newMap()
|
||||
.add("glBlendFunc", "tryBlendFuncSeparate")
|
||||
.add("func_148821_a", "tryBlendFuncSeparate"));
|
||||
.add("func_148821_a", "tryBlendFuncSeparate")
|
||||
.add("func_153171_g", "glBindFramebuffer")
|
||||
.add("func_153174_h", "glDeleteFramebuffers")
|
||||
.add("func_153165_e", "glGenFramebuffers")
|
||||
.add("func_153167_i", "glCheckFramebufferStatus")
|
||||
.add("func_153188_a", "glFramebufferTexture2D")
|
||||
.add("setActiveTexture")
|
||||
.add("setLightmapTextureCoords")
|
||||
.add("isFramebufferEnabled")
|
||||
);
|
||||
methodRedirects.put(EXTBlendFunc, RedirectMap.newMap().add("glBlendFuncSeparateEXT", "tryBlendFuncSeparate"));
|
||||
methodRedirects.put(ARBMultiTexture, RedirectMap.newMap().add("glActiveTextureARB"));
|
||||
methodRedirects.put(Project, RedirectMap.newMap().add("gluPerspective"));
|
||||
|
||||
@@ -188,6 +188,7 @@ public enum Mixins implements IMixins {
|
||||
, "celeritas.biome_blending.MixinBlockLeaves"
|
||||
, "celeritas.biome_blending.MixinBlockLiquid"
|
||||
, "celeritas.threading.MixinForgeHooksClient"
|
||||
, "celeritas.terrain.MixinChunk"
|
||||
)
|
||||
),
|
||||
|
||||
@@ -195,12 +196,12 @@ public enum Mixins implements IMixins {
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableIris)
|
||||
.addClientMixins(
|
||||
"shaders.MixinEntityRenderer"
|
||||
"shaders.MixinEntityPickupFX"
|
||||
, "shaders.MixinEntityRenderer"
|
||||
, "shaders.MixinGuiIngameForge"
|
||||
, "shaders.MixinFramebuffer"
|
||||
, "shaders.MixinItem"
|
||||
, "shaders.MixinLocale"
|
||||
, "shaders.MixinOpenGlHelper"
|
||||
, "shaders.MixinRender"
|
||||
, "shaders.MixinRenderBiped"
|
||||
, "shaders.MixinRenderEntityFlame"
|
||||
@@ -208,6 +209,8 @@ public enum Mixins implements IMixins {
|
||||
, "shaders.MixinRenderGlobal"
|
||||
, "shaders.MixinRenderHorse"
|
||||
, "shaders.MixinRenderItem"
|
||||
, "shaders.MixinRenderManager"
|
||||
, "shaders.MixinRenderNameTag"
|
||||
, "shaders.MixinRenderPlayerArmor"
|
||||
, "shaders.MixinTileEntityBeaconRenderer"
|
||||
)
|
||||
@@ -315,7 +318,7 @@ public enum Mixins implements IMixins {
|
||||
.setPhase(Phase.LATE)
|
||||
.addRequiredMod(TargetedMod.NTM_SPACE)
|
||||
.setApplyIf(() -> CompatConfig.fixNTMSpace && AngelicaConfig.enableIris)
|
||||
.addClientMixins("client.ntmSpace.MixinSkyProviderCelestial_ShaderCompat")),
|
||||
.addClientMixins("client.ntmSpace.MixinSkyProviderCelestial_ShaderCompat", "client.ntmSpace.MixinSkyProviderLaytheSunset")),
|
||||
|
||||
SPEEDUP_CAMPFIRE_BACKPORT_ANIMATIONS(new MixinBuilder("Add animation speedup support to Campfire Backport")
|
||||
.setPhase(Phase.LATE)
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.mixins.interfaces;
|
||||
|
||||
import com.gtnewhorizons.angelica.utils.ConcurrentTileEntityMap;
|
||||
|
||||
public interface IChunkTileEntityMapHolder {
|
||||
ConcurrentTileEntityMap angelica$getConcurrentTEMap();
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.gtnewhorizons.angelica.mixins.interfaces;
|
||||
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
|
||||
public interface ITileEntityBoundingBoxCache {
|
||||
AxisAlignedBB angelica$getCachedRenderBoundingBox();
|
||||
|
||||
boolean angelica$isInfiniteExtent();
|
||||
}
|
||||
@@ -31,7 +31,6 @@ import jss.notfine.core.Settings;
|
||||
import jss.notfine.gui.options.named.GraphicsQualityOff;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import net.minecraft.client.resources.IReloadableResourceManager;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
@@ -40,6 +39,7 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Vec3;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
|
||||
public class CloudRenderer implements IResourceManagerReloadListener {
|
||||
// Shared constants.
|
||||
@@ -337,12 +337,12 @@ public class CloudRenderer implements IResourceManagerReloadListener {
|
||||
texColor = newColor;
|
||||
}
|
||||
|
||||
GLStateManager.glActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
GLStateManager.glActiveTexture(GL13.GL_TEXTURE1);
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, COLOR_TEX.getGlTextureId());
|
||||
GLStateManager.enableTexture();
|
||||
|
||||
// Bind the clouds texture last so the shader's sampler2D is correct.
|
||||
GLStateManager.glActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
GLStateManager.glActiveTexture(GL13.GL_TEXTURE0);
|
||||
mc.renderEngine.bindTexture(texture);
|
||||
|
||||
vbo.setupState();
|
||||
@@ -384,9 +384,9 @@ public class CloudRenderer implements IResourceManagerReloadListener {
|
||||
vbo.cleanupState(); // Unbind buffer and disable pointers.
|
||||
|
||||
// Disable our coloring.
|
||||
GLStateManager.glActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
GLStateManager.glActiveTexture(GL13.GL_TEXTURE1);
|
||||
GLStateManager.disableTexture();
|
||||
GLStateManager.glActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
GLStateManager.glActiveTexture(GL13.GL_TEXTURE0);
|
||||
|
||||
// Reset texture matrix.
|
||||
GLStateManager.glMatrixMode(GL11.GL_TEXTURE);
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.gtnewhorizons.angelica.rendering;
|
||||
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.world.WorldSlice;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class RenderThreadContext {
|
||||
|
||||
private static final ThreadLocal<WorldSlice> currentWorldSlice = new ThreadLocal<>();
|
||||
|
||||
public static void set(WorldSlice slice) {
|
||||
currentWorldSlice.set(slice);
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
currentWorldSlice.remove();
|
||||
}
|
||||
|
||||
public static TileEntity getSnapshotTE(int x, int y, int z) {
|
||||
final WorldSlice slice = currentWorldSlice.get();
|
||||
if (slice == null) return null;
|
||||
return slice.getTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
public static boolean hasWorldSlice() {
|
||||
return currentWorldSlice.get() != null;
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package com.gtnewhorizons.angelica.rendering;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ByteOpenHashMap;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
|
||||
/**
|
||||
* Registry for tracking which TileEntity classes always return INFINITE_EXTENT_AABB.
|
||||
*/
|
||||
public final class TileEntityRenderBoundsRegistry {
|
||||
private static final byte UNKNOWN = 0;
|
||||
private static final byte FINITE = 1;
|
||||
private static final byte INFINITE = 2;
|
||||
|
||||
private static final Reference2ByteOpenHashMap<Class<? extends TileEntity>> classRegistry = new Reference2ByteOpenHashMap<>();
|
||||
|
||||
static {
|
||||
classRegistry.defaultReturnValue(UNKNOWN);
|
||||
}
|
||||
|
||||
private TileEntityRenderBoundsRegistry() {}
|
||||
|
||||
public static boolean isInfiniteExtentsBox(AxisAlignedBB box) {
|
||||
return box == null || Double.isInfinite(box.minX) || Double.isInfinite(box.minY) || Double.isInfinite(box.minZ) || Double.isInfinite(box.maxX) || Double.isInfinite(box.maxY) || Double.isInfinite(box.maxZ);
|
||||
}
|
||||
|
||||
public static boolean isAlwaysInfiniteExtent(TileEntity te) {
|
||||
final Class<? extends TileEntity> clazz = te.getClass();
|
||||
byte result = classRegistry.getByte(clazz);
|
||||
|
||||
if (result != UNKNOWN) {
|
||||
return result == INFINITE;
|
||||
}
|
||||
|
||||
return probeAndCache(te, clazz);
|
||||
}
|
||||
|
||||
private static boolean probeAndCache(TileEntity te, Class<? extends TileEntity> clazz) {
|
||||
boolean isInfinite = false;
|
||||
try {
|
||||
AxisAlignedBB aabb = te.getRenderBoundingBox();
|
||||
isInfinite = isInfiniteExtentsBox(aabb);
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
classRegistry.put(clazz, isInfinite ? INFINITE : FINITE);
|
||||
return isInfinite;
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
classRegistry.clear();
|
||||
}
|
||||
}
|
||||
+20
-7
@@ -7,6 +7,8 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.iris.BlockRenderContext;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.iris.IrisExtendedChunkVertexEncoder;
|
||||
import org.embeddedt.embeddium.impl.model.light.LightPipeline;
|
||||
import org.embeddedt.embeddium.impl.model.light.flat.FlatLightPipeline;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.ChunkColorWriter;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.light.LightDataCache;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.light.QuadLightingHelper;
|
||||
@@ -49,16 +51,19 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
|
||||
private final LightDataCache lightDataCache = new LightDataCache();
|
||||
private final SmoothLightPipeline smoothLightPipeline;
|
||||
private final FlatLightPipeline flatLightPipeline;
|
||||
private final QuadLightData quadLightData = new QuadLightData();
|
||||
private final VertexArrayQuadView quadView;
|
||||
private boolean lightPipelineReady = false;
|
||||
private int originX, originY, originZ;
|
||||
private IBlockAccess blockAccess;
|
||||
|
||||
public AngelicaChunkBuildContext(RenderPassConfiguration<?> renderPassConfiguration, WorldClient world) {
|
||||
super(renderPassConfiguration);
|
||||
this.textureAtlas = (TextureMapExtension) Minecraft.getMinecraft().getTextureMapBlocks();
|
||||
this.worldSlice = new WorldSlice(world);
|
||||
this.smoothLightPipeline = new SmoothLightPipeline(lightDataCache, VanillaDiffuseProvider.INSTANCE, false);
|
||||
this.flatLightPipeline = new FlatLightPipeline(lightDataCache, VanillaDiffuseProvider.INSTANCE, false);
|
||||
this.quadView = new VertexArrayQuadView(vertices);
|
||||
}
|
||||
|
||||
@@ -67,12 +72,14 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
}
|
||||
|
||||
public void setupLightPipeline(IBlockAccess blockAccess, int minBlockX, int minBlockY, int minBlockZ) {
|
||||
this.blockAccess = blockAccess;
|
||||
this.originX = minBlockX;
|
||||
this.originY = minBlockY;
|
||||
this.originZ = minBlockZ;
|
||||
lightDataCache.setWorld(blockAccess);
|
||||
lightDataCache.reset(minBlockX, minBlockY, minBlockZ);
|
||||
smoothLightPipeline.reset();
|
||||
flatLightPipeline.reset();
|
||||
lightPipelineReady = true;
|
||||
}
|
||||
|
||||
@@ -103,7 +110,8 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void copyRawBuffer(int[] rawBuffer, int vertexCount, ChunkBuildBuffers buffers, Material material, boolean isShaderPackOverride) {
|
||||
public void copyRawBuffer(int[] rawBuffer, int vertexCount, ChunkBuildBuffers buffers, Material material, boolean isShaderPackOverride,
|
||||
boolean blockAllowsSmoothLighting) {
|
||||
if (vertexCount == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -126,6 +134,14 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
int ptr = 0;
|
||||
final int numQuads = vertexCount / 4;
|
||||
|
||||
final int blockX = blockRenderContext.localPosX;
|
||||
final int blockY = blockRenderContext.localPosY;
|
||||
final int blockZ = blockRenderContext.localPosZ;
|
||||
final int worldX = originX + blockX;
|
||||
final int worldY = originY + blockY;
|
||||
final int worldZ = originZ + blockZ;
|
||||
final boolean isEmissive = useAoCalculation && QuadLightingHelper.isBlockEmissive(blockAccess, worldX, worldY, worldZ);
|
||||
|
||||
for (int quadIdx = 0; quadIdx < numQuads; quadIdx++) {
|
||||
float uSum = 0, vSum = 0;
|
||||
|
||||
@@ -165,11 +181,6 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
}
|
||||
|
||||
if (useAoCalculation) {
|
||||
final int blockX = blockRenderContext.localPosX;
|
||||
final int blockY = blockRenderContext.localPosY;
|
||||
final int blockZ = blockRenderContext.localPosZ;
|
||||
|
||||
final boolean isEmissive = LightDataAccess.unpackEM(lightDataCache.get(originX + blockX, originY + blockY, originZ + blockZ));
|
||||
final boolean quadIsFullBright = QuadLightingHelper.isQuadFullBright(vertices);
|
||||
|
||||
if (isEmissive || quadIsFullBright) {
|
||||
@@ -184,7 +195,9 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
} else {
|
||||
quadView.setup(trueNormal, blockX, blockY, blockZ);
|
||||
final ModelQuadFacing lightFace = quadView.getLightFace();
|
||||
smoothLightPipeline.calculate(quadView, originX + blockX, originY + blockY, originZ + blockZ, quadLightData, lightFace, lightFace, shade, true);
|
||||
final LightPipeline pipeline = blockAllowsSmoothLighting ? smoothLightPipeline : flatLightPipeline;
|
||||
final ModelQuadFacing cullFace = quadView.getCullFace();
|
||||
pipeline.calculate(quadView, worldX, worldY, worldZ, quadLightData, cullFace, lightFace, shade, true);
|
||||
}
|
||||
|
||||
for (int vIdx = 0; vIdx < 4; vIdx++) {
|
||||
|
||||
+10
-1
@@ -9,6 +9,7 @@ import com.gtnewhorizons.angelica.rendering.celeritas.iris.ContextAwareChunkVert
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ReferenceMap;
|
||||
import net.coderbot.iris.vertices.ExtendedDataHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
@@ -247,7 +248,15 @@ public abstract class AngelicaChunkBuilderMeshingTask extends ChunkBuilderTask<C
|
||||
block.canRenderInPass(pass);
|
||||
tessellator.startDrawingQuads();
|
||||
renderBlocks.renderBlockByRenderType(block, x, y, z);
|
||||
buildContext.copyRawBuffer(tessellator.rawBuffer, tessellator.vertexCount, buffers, passMaterial, isShaderPackOverride);
|
||||
// In modern versions, block models can specify whether to enable AO or not, but here we must
|
||||
// rely on render ID heuristics to figure out which models would have turned it off
|
||||
int vanillaRenderId = block.getRenderType();
|
||||
boolean blockAllowsSmoothLighting = Minecraft.isAmbientOcclusionEnabled() // smooth lighting on
|
||||
&& block.getLightValue() == 0 // does not emit real block light
|
||||
&& vanillaRenderId != 1 // is not a "cross" block
|
||||
&& vanillaRenderId != 40; // is not a double plant block
|
||||
buildContext.copyRawBuffer(tessellator.rawBuffer, tessellator.vertexCount, buffers, passMaterial,
|
||||
isShaderPackOverride, blockAllowsSmoothLighting);
|
||||
tessellator.reset();
|
||||
tessellator.isDrawing = false;
|
||||
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.rendering.celeritas;
|
||||
|
||||
import com.gtnewhorizons.angelica.Tags;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.states.FogState;
|
||||
@@ -20,7 +21,7 @@ public class CeleritasDebugScreenHandler {
|
||||
@SubscribeEvent(priority = EventPriority.LOW)
|
||||
public void onRenderGameOverlayTextEvent(RenderGameOverlayEvent.Text event) {
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
if (!mc.gameSettings.showDebugInfo) {
|
||||
if (!mc.gameSettings.showDebugInfo || AngelicaConfig.disableF3Additions) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -3,7 +3,9 @@ package com.gtnewhorizons.angelica.rendering.celeritas;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.IDynamicLightWorldRenderer;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ITileEntityBoundingBoxCache;
|
||||
import com.gtnewhorizons.angelica.rendering.RenderingState;
|
||||
import com.gtnewhorizons.angelica.rendering.TileEntityRenderBoundsRegistry;
|
||||
import net.coderbot.iris.pipeline.ShadowRenderer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
@@ -227,10 +229,13 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
|
||||
return;
|
||||
}
|
||||
|
||||
final AxisAlignedBB aabb = tileEntity.getRenderBoundingBox();
|
||||
final ITileEntityBoundingBoxCache teCache = (ITileEntityBoundingBoxCache) tileEntity;
|
||||
|
||||
if (aabb != TileEntity.INFINITE_EXTENT_AABB && !this.currentViewport.isBoxVisible(aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ)) {
|
||||
return;
|
||||
if (!teCache.angelica$isInfiniteExtent()) {
|
||||
final AxisAlignedBB aabb = teCache.angelica$getCachedRenderBoundingBox();
|
||||
if (aabb != null && !this.currentViewport.isBoxVisible(aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -244,11 +249,6 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isInfiniteExtentsBox(AxisAlignedBB box) {
|
||||
return box == null || Double.isInfinite(box.minX) || Double.isInfinite(box.minY) || Double.isInfinite(box.minZ)
|
||||
|| Double.isInfinite(box.maxX) || Double.isInfinite(box.maxY) || Double.isInfinite(box.maxZ);
|
||||
}
|
||||
|
||||
public boolean isEntityVisible(Entity entity) {
|
||||
// During shadow pass, don't cull entities - shadow rendering uses different frustum
|
||||
if (!this.useEntityCulling || this.renderSectionManager.isInShadowPass()) {
|
||||
@@ -260,7 +260,7 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
|
||||
box = entity.boundingBox;
|
||||
}
|
||||
|
||||
if (isInfiniteExtentsBox(box)) {
|
||||
if (TileEntityRenderBoundsRegistry.isInfiniteExtentsBox(box)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+21
-1
@@ -12,6 +12,7 @@ public class VertexArrayQuadView implements ModelQuadView {
|
||||
private int trueNormal;
|
||||
private int blockX, blockY, blockZ;
|
||||
private ModelQuadFacing lightFace;
|
||||
private int flags;
|
||||
|
||||
public VertexArrayQuadView(ChunkVertexEncoder.Vertex[] vertices) {
|
||||
this.vertices = vertices;
|
||||
@@ -23,6 +24,7 @@ public class VertexArrayQuadView implements ModelQuadView {
|
||||
this.blockY = blockY;
|
||||
this.blockZ = blockZ;
|
||||
this.lightFace = null; // Reset cached lightFace
|
||||
this.flags = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -62,7 +64,10 @@ public class VertexArrayQuadView implements ModelQuadView {
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return ModelQuadFlags.getQuadFlags(this, getLightFace());
|
||||
if (flags == 0) {
|
||||
flags = ModelQuadFlags.getQuadFlags(this, getLightFace());
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -98,6 +103,21 @@ public class VertexArrayQuadView implements ModelQuadView {
|
||||
return trueNormal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cull face of a quad. This is distinct from the light face, as it will not be set for non-axis-aligned
|
||||
* and non-block-grid-aligned quads (i.e. quads on the surface of the 1x1x1 cube).
|
||||
* @return the cull face if present, or UNASSIGNED
|
||||
*/
|
||||
public ModelQuadFacing getCullFace() {
|
||||
// In modern, only quads that are aligned to the block grid can have a cull face, as otherwise
|
||||
// they should not participate in face culling (an adjacent block wouldn't obscure an inset quad)
|
||||
if ((getFlags() & ModelQuadFlags.IS_ALIGNED) == 0) {
|
||||
return ModelQuadFacing.UNASSIGNED;
|
||||
}
|
||||
|
||||
return getNormalFace();
|
||||
}
|
||||
|
||||
private static ModelQuadFacing computeLightFace(int normal) {
|
||||
final float nx = NormI8.unpackX(normal);
|
||||
final float ny = NormI8.unpackY(normal);
|
||||
|
||||
+1
-12
@@ -35,17 +35,6 @@ public class LightDataCache extends LightDataAccess {
|
||||
// Opacity check - true if block is view-blocking (solid blocks)
|
||||
final boolean op = block.getMaterial().isOpaque() && block.getLightOpacity() > 0;
|
||||
|
||||
boolean em;
|
||||
if (lu > 0) {
|
||||
em = true;
|
||||
} else {
|
||||
try {
|
||||
em = block.getMixedBrightnessForBlock(EmptyBlockAccess.INSTANCE, x, y, z) == QuadLightingHelper.FULL_BRIGHT_15;
|
||||
} catch (Exception e) {
|
||||
em = false;
|
||||
}
|
||||
}
|
||||
|
||||
return packFC(fc) | packFO(fo) | packOP(op) | packEM(em) | packAO(ao) | packLU(lu) | packSL(sl) | packBL(bl);
|
||||
return packFC(fc) | packFO(fo) | packOP(op) | packAO(ao) | packLU(lu) | packSL(sl) | packBL(bl);
|
||||
}
|
||||
}
|
||||
+11
@@ -1,5 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.rendering.celeritas.light;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.vertex.format.ChunkVertexEncoder;
|
||||
|
||||
public final class QuadLightingHelper {
|
||||
@@ -9,6 +11,15 @@ public final class QuadLightingHelper {
|
||||
public static final int FULL_BRIGHT_15 = (15 << 20) | (15 << 4); // 15728880
|
||||
public static final int FULL_BRIGHT_14 = (14 << 20) | (14 << 4); // 14680288
|
||||
|
||||
public static boolean isBlockEmissive(IBlockAccess world, int x, int y, int z) {
|
||||
final Block block = world.getBlock(x, y, z);
|
||||
try {
|
||||
return block.getMixedBrightnessForBlock(EmptyBlockAccess.INSTANCE, x, y, z) == FULL_BRIGHT_15;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isQuadFullBright(ChunkVertexEncoder.Vertex[] vertices) {
|
||||
final int first = vertices[0].light;
|
||||
|
||||
|
||||
+5
@@ -2,6 +2,7 @@ package com.gtnewhorizons.angelica.rendering.celeritas.threading;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager;
|
||||
import com.gtnewhorizons.angelica.rendering.AngelicaBlockSafetyRegistry;
|
||||
import com.gtnewhorizons.angelica.rendering.RenderThreadContext;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.AngelicaChunkBuilderMeshingTask;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.SmoothBiomeColorCache;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.WorldClientExtension;
|
||||
@@ -103,12 +104,16 @@ public class ThreadedAngelicaChunkBuilderMeshingTask extends AngelicaChunkBuilde
|
||||
enteredLocalMode = !TessellatorManager.isOnMainThread();
|
||||
if (enteredLocalMode) {
|
||||
TessellatorManager.enterLocalMode();
|
||||
if (blockAccess instanceof WorldSlice worldSlice) {
|
||||
RenderThreadContext.set(worldSlice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onExitExecute() {
|
||||
if (enteredLocalMode) {
|
||||
RenderThreadContext.clear();
|
||||
RenderPassHelper.resetWorldRenderPass();
|
||||
TessellatorManager.exitLocalMode();
|
||||
}
|
||||
|
||||
+38
-23
@@ -4,11 +4,17 @@ import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
|
||||
import com.gtnewhorizons.angelica.compat.ExtendedBlockStorageExt;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.ChunkSectionPos;
|
||||
import it.unimi.dsi.fastutil.shorts.Short2ObjectMap;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.IChunkTileEntityMapHolder;
|
||||
import com.gtnewhorizons.angelica.utils.ConcurrentTileEntityMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMaps;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap;
|
||||
import mega.fluidlogged.internal.mixin.hook.FLSubChunk;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
import net.minecraft.world.EnumSkyBlock;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
@@ -27,7 +33,7 @@ public class ClonedChunkSection {
|
||||
private ChunkSectionPos pos;
|
||||
private ExtendedBlockStorageExt data;
|
||||
private BiomeGenBase[] biomeData;
|
||||
private final Short2ObjectMap<TileEntity> tileEntities;
|
||||
private final Short2ObjectOpenHashMap<TileEntity> tileEntities;
|
||||
|
||||
private long lastUsedTimestamp = Long.MAX_VALUE;
|
||||
|
||||
@@ -53,7 +59,7 @@ public class ClonedChunkSection {
|
||||
this.pos = pos;
|
||||
this.data = new ExtendedBlockStorageExt(chunk, section);
|
||||
|
||||
int bArrLength;
|
||||
final int bArrLength;
|
||||
if (ModStatus.isEIDBiomeLoaded) {
|
||||
bArrLength = ((ChunkBiomeHook) chunk).getBiomeShortArray().length;
|
||||
} else {
|
||||
@@ -61,26 +67,7 @@ public class ClonedChunkSection {
|
||||
}
|
||||
this.biomeData = new BiomeGenBase[bArrLength];
|
||||
|
||||
this.tileEntities.clear();
|
||||
|
||||
// Check for tile entities
|
||||
for (int y = pos.getMinY(); y <= pos.getMaxY(); y++) {
|
||||
for (int z = pos.getMinZ(); z <= pos.getMaxZ(); z++) {
|
||||
for (int x = pos.getMinX(); x <= pos.getMaxX(); x++) {
|
||||
final int lX = x & 15, lY = y & 15, lZ = z & 15;
|
||||
// We have to use this insanity because in 1.7 the tile entity isn't guaranteed to be created
|
||||
// when the chunk gets scheduled for rendering. So we might have to create it.
|
||||
// Cloning is done on the main thread so this will not introduce threading issues
|
||||
final Block block = data.getBlockByExtId(lX, lY, lZ);
|
||||
if (block.hasTileEntity(data.getExtBlockMetadata(lX, lY, lZ))) {
|
||||
final TileEntity tileEntity = chunk.func_150806_e(x & 15, y, z & 15);
|
||||
if (tileEntity != null) {
|
||||
this.tileEntities.put(ChunkSectionPos.packLocal(tileEntity.xCoord & 15, tileEntity.yCoord & 15, tileEntity.zCoord & 15), tileEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
copyBlockEntities(chunk, pos);
|
||||
|
||||
// Fill biome data
|
||||
for (int z = pos.getMinZ(); z <= pos.getMaxZ(); z++) {
|
||||
@@ -90,6 +77,34 @@ public class ClonedChunkSection {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void copyBlockEntities(Chunk chunk, ChunkSectionPos pos) {
|
||||
this.tileEntities.clear();
|
||||
|
||||
final ConcurrentTileEntityMap map = ((IChunkTileEntityMapHolder) chunk).angelica$getConcurrentTEMap();
|
||||
|
||||
map.withReadLock(() -> {
|
||||
final Object2ObjectOpenHashMap<ChunkPosition, TileEntity> delegate = map.getDelegate();
|
||||
|
||||
if (delegate.isEmpty()) return;
|
||||
|
||||
final int minY = pos.getMinY();
|
||||
final int maxY = pos.getMaxY();
|
||||
|
||||
for (Object2ObjectMap.Entry<ChunkPosition, TileEntity> entry : Object2ObjectMaps.fastIterable(delegate)) {
|
||||
final ChunkPosition tePos = entry.getKey();
|
||||
if (tePos.chunkPosY < minY || tePos.chunkPosY > maxY) continue;
|
||||
|
||||
final TileEntity te = entry.getValue();
|
||||
if (te != null && !te.isInvalid()) {
|
||||
this.tileEntities.put(ChunkSectionPos.packLocal(tePos.chunkPosX & 15, tePos.chunkPosY & 15, tePos.chunkPosZ & 15), te);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.tileEntities.trim();
|
||||
}
|
||||
|
||||
public Block getBlock(int x, int y, int z) {
|
||||
return data.getBlockByExtId(x, y, z);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,203 @@
|
||||
package com.gtnewhorizons.angelica.utils;
|
||||
|
||||
import com.gtnewhorizons.angelica.rendering.RenderThreadContext;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
/**
|
||||
* Thread-safe wrapper around Object2ObjectOpenHashMap for chunkTileEntityMap.
|
||||
*/
|
||||
public class ConcurrentTileEntityMap implements Map<ChunkPosition, TileEntity> {
|
||||
private final Object2ObjectOpenHashMap<ChunkPosition, TileEntity> delegate = new Object2ObjectOpenHashMap<>();
|
||||
private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
private final ConcurrentLinkedQueue<ChunkPosition> invalidationQueue = new ConcurrentLinkedQueue<>();
|
||||
|
||||
public void queueInvalidation(ChunkPosition pos) {
|
||||
invalidationQueue.add(pos);
|
||||
}
|
||||
|
||||
private void processInvalidationQueue() {
|
||||
ChunkPosition pos;
|
||||
while ((pos = invalidationQueue.poll()) != null) {
|
||||
final TileEntity te = delegate.get(pos);
|
||||
if (te != null && te.isInvalid()) {
|
||||
delegate.remove(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void withReadLock(Runnable action) {
|
||||
lock.readLock().lock();
|
||||
try {
|
||||
action.run();
|
||||
} finally {
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void withWriteLock(Runnable action) {
|
||||
lock.writeLock().lock();
|
||||
try {
|
||||
action.run();
|
||||
} finally {
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public Object2ObjectOpenHashMap<ChunkPosition, TileEntity> getDelegate() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
public TileEntity putDirect(ChunkPosition key, TileEntity value) {
|
||||
return delegate.put(key, value);
|
||||
}
|
||||
|
||||
private static boolean isRenderWorkerThread() {
|
||||
return RenderThreadContext.hasWorldSlice();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TileEntity get(Object key) {
|
||||
if (!isRenderWorkerThread()) return delegate.get(key);
|
||||
|
||||
lock.readLock().lock();
|
||||
try {
|
||||
final TileEntity te = delegate.get(key);
|
||||
if (te != null && te.isInvalid()) {
|
||||
if (key instanceof ChunkPosition pos) {
|
||||
invalidationQueue.add(pos);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return te;
|
||||
} finally {
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity put(ChunkPosition key, TileEntity value) {
|
||||
lock.writeLock().lock();
|
||||
try {
|
||||
processInvalidationQueue();
|
||||
return delegate.put(key, value);
|
||||
} finally {
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity remove(Object key) {
|
||||
if (isRenderWorkerThread()) {
|
||||
if (key instanceof ChunkPosition pos) {
|
||||
invalidationQueue.add(pos);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
lock.writeLock().lock();
|
||||
try {
|
||||
processInvalidationQueue();
|
||||
return delegate.remove(key);
|
||||
} finally {
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(Map<? extends ChunkPosition, ? extends TileEntity> m) {
|
||||
lock.writeLock().lock();
|
||||
try {
|
||||
processInvalidationQueue();
|
||||
delegate.putAll(m);
|
||||
} finally {
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
lock.writeLock().lock();
|
||||
try {
|
||||
invalidationQueue.clear();
|
||||
delegate.clear();
|
||||
} finally {
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
if (!isRenderWorkerThread()) return delegate.size();
|
||||
lock.readLock().lock();
|
||||
try {
|
||||
return delegate.size();
|
||||
} finally {
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
if (!isRenderWorkerThread()) return delegate.isEmpty();
|
||||
lock.readLock().lock();
|
||||
try {
|
||||
return delegate.isEmpty();
|
||||
} finally {
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
if (!isRenderWorkerThread()) return delegate.containsKey(key);
|
||||
lock.readLock().lock();
|
||||
try {
|
||||
return delegate.containsKey(key);
|
||||
} finally {
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsValue(Object value) {
|
||||
if (!isRenderWorkerThread()) return delegate.containsValue(value);
|
||||
lock.readLock().lock();
|
||||
try {
|
||||
return delegate.containsValue(value);
|
||||
} finally {
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ChunkPosition> keySet() {
|
||||
if (isRenderWorkerThread()) {
|
||||
throw new IllegalStateException("keySet() called from render worker. Use withReadLock() for iteration.");
|
||||
}
|
||||
return delegate.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<TileEntity> values() {
|
||||
if (isRenderWorkerThread()) {
|
||||
throw new IllegalStateException("values() called from render worker. Use withReadLock() for iteration.");
|
||||
}
|
||||
return delegate.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Entry<ChunkPosition, TileEntity>> entrySet() {
|
||||
if (isRenderWorkerThread()) {
|
||||
throw new IllegalStateException("entrySet() called from render worker. Use withReadLock() for iteration.");
|
||||
}
|
||||
return delegate.entrySet();
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,8 @@ import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.IIcon;
|
||||
@@ -37,6 +39,7 @@ public class CTMUtils {
|
||||
private static TileLoader tileLoader;
|
||||
|
||||
private static TileOverride lastOverride;
|
||||
private static final Lock lock = new ReentrantLock();
|
||||
|
||||
private static final TileOverrideIterator.IJK ijkIterator = newIJKIterator();
|
||||
private static final TileOverrideIterator.Metadata metadataIterator = newMetadataIterator();
|
||||
@@ -52,64 +55,76 @@ public class CTMUtils {
|
||||
} catch (Exception ignore) {}
|
||||
|
||||
TexturePackChangeHandler.register(new TexturePackChangeHandler(MCPatcherUtils.CONNECTED_TEXTURES, 3) {
|
||||
|
||||
@Override
|
||||
public void initialize() {}
|
||||
public void initialize() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeChange() {
|
||||
RenderPassAPI.instance.clear();
|
||||
lock.lock();
|
||||
try {
|
||||
GlassPaneRenderer.clear();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
renderBlockState.clear();
|
||||
ijkIterator.clear();
|
||||
metadataIterator.clear();
|
||||
allOverrides.clear();
|
||||
blockOverrides.clear();
|
||||
tileOverrides.clear();
|
||||
lastOverride = null;
|
||||
RenderBlocksUtils.blankIcon = null;
|
||||
tileLoader = new TileLoader("textures/blocks", logger);
|
||||
RenderPassAPI.instance.refreshBlendingOptions();
|
||||
|
||||
if (MCPatcherForgeConfig.ConnectedTextures.standard || MCPatcherForgeConfig.ConnectedTextures.nonStandard) {
|
||||
for (ResourceLocation resource : ResourceList.getInstance()
|
||||
.listResources(TexturePackAPI.MCPATCHER_SUBDIR + "ctm", ".properties", true)) {
|
||||
registerOverride(TileOverride.create(resource, tileLoader));
|
||||
RenderPassAPI.instance.clear();
|
||||
try {
|
||||
GlassPaneRenderer.clear();
|
||||
} catch (NoClassDefFoundError e) {
|
||||
// nothing
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
for (ResourceLocation resource : BlendMethod.getAllBlankResources()) {
|
||||
tileLoader.preloadTile(resource, false);
|
||||
renderBlockState.clear();
|
||||
ijkIterator.clear();
|
||||
metadataIterator.clear();
|
||||
allOverrides.clear();
|
||||
blockOverrides.clear();
|
||||
tileOverrides.clear();
|
||||
lastOverride = null;
|
||||
RenderBlocksUtils.blankIcon = null;
|
||||
tileLoader = new TileLoader("textures/blocks", logger);
|
||||
RenderPassAPI.instance.refreshBlendingOptions();
|
||||
|
||||
if (MCPatcherForgeConfig.ConnectedTextures.standard || MCPatcherForgeConfig.ConnectedTextures.nonStandard) {
|
||||
for (ResourceLocation resource : ResourceList.getInstance()
|
||||
.listResources(TexturePackAPI.MCPATCHER_SUBDIR + "ctm", ".properties", true)) {
|
||||
registerOverride(TileOverride.create(resource, tileLoader));
|
||||
}
|
||||
}
|
||||
for (ResourceLocation resource : BlendMethod.getAllBlankResources()) {
|
||||
tileLoader.preloadTile(resource, false);
|
||||
}
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterChange() {
|
||||
for (TileOverride override : allOverrides) {
|
||||
override.registerIcons();
|
||||
}
|
||||
for (Map.Entry<Block, List<BlockStateMatcher>> entry : blockOverrides.entrySet()) {
|
||||
for (BlockStateMatcher matcher : entry.getValue()) {
|
||||
TileOverride override = (TileOverride) matcher.getData();
|
||||
if (override.getRenderPass() >= 0) {
|
||||
RenderPassAPI.instance.setRenderPassForBlock(entry.getKey(), override.getRenderPass());
|
||||
lock.lock();
|
||||
try {
|
||||
for (TileOverride override : allOverrides) {
|
||||
override.registerIcons();
|
||||
}
|
||||
for (Map.Entry<Block, List<BlockStateMatcher>> entry : blockOverrides.entrySet()) {
|
||||
for (BlockStateMatcher matcher : entry.getValue()) {
|
||||
TileOverride override = (TileOverride) matcher.getData();
|
||||
if (override.getRenderPass() >= 0) {
|
||||
RenderPassAPI.instance.setRenderPassForBlock(entry.getKey(), override.getRenderPass());
|
||||
}
|
||||
}
|
||||
}
|
||||
for (List<BlockStateMatcher> overrides : blockOverrides.values()) {
|
||||
overrides.sort((m1, m2) -> {
|
||||
TileOverride o1 = (TileOverride) m1.getData();
|
||||
TileOverride o2 = (TileOverride) m2.getData();
|
||||
return o1.compareTo(o2);
|
||||
});
|
||||
}
|
||||
for (List<TileOverride> overrides : tileOverrides.values()) {
|
||||
Collections.sort(overrides);
|
||||
}
|
||||
setBlankResource();
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
for (List<BlockStateMatcher> overrides : blockOverrides.values()) {
|
||||
overrides.sort((m1, m2) -> {
|
||||
TileOverride o1 = (TileOverride) m1.getData();
|
||||
TileOverride o2 = (TileOverride) m2.getData();
|
||||
return o1.compareTo(o2);
|
||||
});
|
||||
}
|
||||
for (List<TileOverride> overrides : tileOverrides.values()) {
|
||||
Collections.sort(overrides);
|
||||
}
|
||||
setBlankResource();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -118,40 +133,53 @@ public class CTMUtils {
|
||||
haveBlockFace = false;
|
||||
}
|
||||
|
||||
public static synchronized IIcon getBlockIcon(IIcon icon, Block block, IBlockAccess blockAccess,
|
||||
int x, int y, int z, int face) {
|
||||
lastOverride = null;
|
||||
if (blockAccess != null && checkFace(face)) {
|
||||
if (!haveBlockFace) {
|
||||
renderBlockState.setBlock(block, blockAccess, x, y, z);
|
||||
renderBlockState.setFace(face);
|
||||
}
|
||||
lastOverride = ijkIterator.go(renderBlockState, icon);
|
||||
if (lastOverride != null) {
|
||||
icon = ijkIterator.getIcon();
|
||||
public static IIcon getBlockIcon(IIcon icon, Block block, IBlockAccess blockAccess,
|
||||
int x, int y, int z, int face) {
|
||||
lock.lock();
|
||||
try {
|
||||
lastOverride = null;
|
||||
if (blockAccess != null && checkFace(face)) {
|
||||
if (!haveBlockFace) {
|
||||
renderBlockState.setBlock(block, blockAccess, x, y, z);
|
||||
renderBlockState.setFace(face);
|
||||
}
|
||||
lastOverride = ijkIterator.go(renderBlockState, icon);
|
||||
if (lastOverride != null) {
|
||||
icon = ijkIterator.getIcon();
|
||||
}
|
||||
}
|
||||
clearBlockFace();
|
||||
IIcon result = lastOverride == null && skipDefaultRendering(block) ? RenderBlocksUtils.blankIcon : icon;
|
||||
return result;
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
clearBlockFace();
|
||||
return lastOverride == null && skipDefaultRendering(block) ? RenderBlocksUtils.blankIcon : icon;
|
||||
}
|
||||
|
||||
public static synchronized IIcon getBlockIcon(IIcon icon, Block block, int face, int metadata) {
|
||||
lastOverride = null;
|
||||
if (checkFace(face) && checkRenderType(block)) {
|
||||
renderBlockState.setBlockMetadata(block, metadata, face);
|
||||
lastOverride = metadataIterator.go(renderBlockState, icon);
|
||||
if (lastOverride != null) {
|
||||
icon = metadataIterator.getIcon();
|
||||
public static IIcon getBlockIcon(IIcon icon, Block block, int face, int metadata) {
|
||||
lock.lock();
|
||||
try {
|
||||
lastOverride = null;
|
||||
if (checkFace(face) && checkRenderType(block)) {
|
||||
renderBlockState.setBlockMetadata(block, metadata, face);
|
||||
lastOverride = metadataIterator.go(renderBlockState, icon);
|
||||
if (lastOverride != null) {
|
||||
icon = metadataIterator.getIcon();
|
||||
}
|
||||
}
|
||||
return icon;
|
||||
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
public static IIcon getBlockIcon(IIcon icon, Block block, int face) {
|
||||
return getBlockIcon(icon, block, face, 0);
|
||||
}
|
||||
|
||||
public static void reset() {}
|
||||
public static void reset() {
|
||||
}
|
||||
|
||||
private static boolean checkFace(int face) {
|
||||
return face < 0 ? MCPatcherForgeConfig.ConnectedTextures.nonStandard : MCPatcherForgeConfig.ConnectedTextures.standard;
|
||||
@@ -165,50 +193,60 @@ public class CTMUtils {
|
||||
};
|
||||
}
|
||||
|
||||
private static synchronized boolean skipDefaultRendering(Block block) {
|
||||
private static boolean skipDefaultRendering(Block block) {
|
||||
return RenderPassAPI.instance.skipDefaultRendering(block);
|
||||
}
|
||||
|
||||
private static synchronized void registerOverride(TileOverride override) {
|
||||
if (override != null && !override.isDisabled()) {
|
||||
boolean registered = false;
|
||||
List<BlockStateMatcher> matchingBlocks = override.getMatchingBlocks();
|
||||
if (!MCPatcherUtils.isNullOrEmpty(matchingBlocks)) {
|
||||
for (BlockStateMatcher matcher : matchingBlocks) {
|
||||
if (matcher == null) {
|
||||
continue;
|
||||
private static void registerOverride(TileOverride override) {
|
||||
lock.lock();
|
||||
try {
|
||||
if (override != null && !override.isDisabled()) {
|
||||
boolean registered = false;
|
||||
List<BlockStateMatcher> matchingBlocks = override.getMatchingBlocks();
|
||||
if (!MCPatcherUtils.isNullOrEmpty(matchingBlocks)) {
|
||||
for (BlockStateMatcher matcher : matchingBlocks) {
|
||||
if (matcher == null) {
|
||||
continue;
|
||||
}
|
||||
Block block = matcher.getBlock();
|
||||
List<BlockStateMatcher> list = blockOverrides.computeIfAbsent(block, k -> new ArrayList<>());
|
||||
list.add(matcher);
|
||||
logger.fine("using %s for block %s", override, BlockAPI.getBlockName(block));
|
||||
registered = true;
|
||||
}
|
||||
Block block = matcher.getBlock();
|
||||
List<BlockStateMatcher> list = blockOverrides.computeIfAbsent(block, k -> new ArrayList<>());
|
||||
list.add(matcher);
|
||||
logger.fine("using %s for block %s", override, BlockAPI.getBlockName(block));
|
||||
registered = true;
|
||||
}
|
||||
Set<String> matchingTiles = override.getMatchingTiles();
|
||||
if (!MCPatcherUtils.isNullOrEmpty(matchingTiles)) {
|
||||
for (String name : matchingTiles) {
|
||||
List<TileOverride> list = tileOverrides.computeIfAbsent(name, k -> new ArrayList<>());
|
||||
list.add(override);
|
||||
logger.fine("using %s for tile %s", override, name);
|
||||
registered = true;
|
||||
}
|
||||
}
|
||||
if (registered) {
|
||||
allOverrides.add(override);
|
||||
}
|
||||
}
|
||||
Set<String> matchingTiles = override.getMatchingTiles();
|
||||
if (!MCPatcherUtils.isNullOrEmpty(matchingTiles)) {
|
||||
for (String name : matchingTiles) {
|
||||
List<TileOverride> list = tileOverrides.computeIfAbsent(name, k -> new ArrayList<>());
|
||||
list.add(override);
|
||||
logger.fine("using %s for tile %s", override, name);
|
||||
registered = true;
|
||||
}
|
||||
}
|
||||
if (registered) {
|
||||
allOverrides.add(override);
|
||||
}
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized void setBlankResource() {
|
||||
RenderBlocksUtils.blankIcon = tileLoader.getIcon(RenderPassAPI.instance.getBlankResource());
|
||||
public static void setBlankResource() {
|
||||
lock.lock();
|
||||
try {
|
||||
RenderBlocksUtils.blankIcon = tileLoader.getIcon(RenderPassAPI.instance.getBlankResource());
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public static TileOverrideIterator.IJK newIJKIterator() {
|
||||
private static TileOverrideIterator.IJK newIJKIterator() {
|
||||
return new TileOverrideIterator.IJK(blockOverrides, tileOverrides);
|
||||
}
|
||||
|
||||
public static TileOverrideIterator.Metadata newMetadataIterator() {
|
||||
private static TileOverrideIterator.Metadata newMetadataIterator() {
|
||||
return new TileOverrideIterator.Metadata(blockOverrides, tileOverrides);
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ abstract public class TileOverrideIterator implements Iterator<TileOverride> {
|
||||
this.allTileOverrides = allTileOverrides;
|
||||
}
|
||||
|
||||
synchronized void clear() {
|
||||
void clear() {
|
||||
currentIcon = null;
|
||||
blockOverrides = null;
|
||||
tileOverrides = null;
|
||||
@@ -46,7 +46,7 @@ abstract public class TileOverrideIterator implements Iterator<TileOverride> {
|
||||
skipOverrides.clear();
|
||||
}
|
||||
|
||||
private synchronized void resetForNextPass() {
|
||||
private void resetForNextPass() {
|
||||
blockOverrides = null;
|
||||
tileOverrides = allTileOverrides.get(currentIcon.getIconName());
|
||||
blockPos = 0;
|
||||
@@ -55,7 +55,7 @@ abstract public class TileOverrideIterator implements Iterator<TileOverride> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean hasNext() {
|
||||
public boolean hasNext() {
|
||||
if (foundNext) {
|
||||
return true;
|
||||
}
|
||||
@@ -80,7 +80,7 @@ abstract public class TileOverrideIterator implements Iterator<TileOverride> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized TileOverride next() {
|
||||
public TileOverride next() {
|
||||
if (!foundNext) {
|
||||
throw new IllegalStateException("next called before hasNext() == true");
|
||||
}
|
||||
@@ -89,11 +89,11 @@ abstract public class TileOverrideIterator implements Iterator<TileOverride> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void remove() {
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException("remove not supported");
|
||||
}
|
||||
|
||||
private synchronized boolean checkOverride(TileOverride override) {
|
||||
private boolean checkOverride(TileOverride override) {
|
||||
if (override != null && !override.isDisabled() && !skipOverrides.contains(override)) {
|
||||
foundNext = true;
|
||||
nextOverride = override;
|
||||
@@ -103,7 +103,7 @@ abstract public class TileOverrideIterator implements Iterator<TileOverride> {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized TileOverride go(RenderBlockState renderBlockState, IIcon origIcon) {
|
||||
public TileOverride go(RenderBlockState renderBlockState, IIcon origIcon) {
|
||||
this.renderBlockState = renderBlockState;
|
||||
renderBlockState.setFilter(null);
|
||||
currentIcon = origIcon;
|
||||
@@ -133,7 +133,7 @@ abstract public class TileOverrideIterator implements Iterator<TileOverride> {
|
||||
return lastMatchedOverride;
|
||||
}
|
||||
|
||||
public synchronized IIcon getIcon() {
|
||||
public IIcon getIcon() {
|
||||
return currentIcon;
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ abstract public class TileOverrideIterator implements Iterator<TileOverride> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected synchronized IIcon getTile(TileOverride override, RenderBlockState renderBlockState, IIcon origIcon) {
|
||||
protected IIcon getTile(TileOverride override, RenderBlockState renderBlockState, IIcon origIcon) {
|
||||
return override.getTileWorld(renderBlockState, origIcon);
|
||||
}
|
||||
}
|
||||
@@ -158,7 +158,7 @@ abstract public class TileOverrideIterator implements Iterator<TileOverride> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected synchronized IIcon getTile(TileOverride override, RenderBlockState renderBlockState, IIcon origIcon) {
|
||||
protected IIcon getTile(TileOverride override, RenderBlockState renderBlockState, IIcon origIcon) {
|
||||
return override.getTileHeld(renderBlockState, origIcon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,6 +397,12 @@ public class SodiumGameOptionPages {
|
||||
groups.add(OptionGroup.createBuilder()
|
||||
.add(Settings.MODE_GUI_BACKGROUND.option)
|
||||
.add(Settings.GUI_BACKGROUND.option)
|
||||
.add(OptionImpl.createBuilder(boolean.class, angelicaOpts)
|
||||
.setName(I18n.format("options.angelica.disablef3"))
|
||||
.setTooltip(I18n.format("options.angelica.disablef3.tooltip"))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setBinding((opts, value) -> AngelicaConfig.disableF3Additions = value, opts -> AngelicaConfig.disableF3Additions)
|
||||
.build())
|
||||
.build());
|
||||
|
||||
return new OptionPage(I18n.format("sodium.options.pages.advanced"), ImmutableList.copyOf(groups));
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.coderbot.iris.pipeline.transform.PatchShaderType;
|
||||
import net.coderbot.iris.rendertarget.RenderTargets;
|
||||
import net.coderbot.iris.uniforms.CommonUniforms;
|
||||
import net.coderbot.iris.uniforms.builtin.BuiltinReplacementUniforms;
|
||||
import net.coderbot.iris.shaderpack.ProgramSource;
|
||||
import net.coderbot.iris.uniforms.custom.CustomUniforms;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -60,124 +61,82 @@ public class CeleritasTerrainPipeline {
|
||||
IntFunction<ProgramImages> createTerrainImages,
|
||||
IntFunction<ProgramImages> createShadowImages,
|
||||
CustomUniforms customUniforms,
|
||||
String terrainSourceName,
|
||||
String translucentSourceName,
|
||||
String shadowSourceName,
|
||||
Optional<ProgramSource> terrainSource,
|
||||
Optional<ProgramSource> translucentSource,
|
||||
Optional<ProgramSource> shadowSource,
|
||||
CompletableFuture<Map<PatchShaderType, String>> terrainFuture,
|
||||
CompletableFuture<Map<PatchShaderType, String>> translucentFuture,
|
||||
CompletableFuture<Map<PatchShaderType, String>> shadowFuture,
|
||||
RenderTargets renderTargets,
|
||||
ImmutableSet<Integer> flippedAfterPrepare,
|
||||
ImmutableSet<Integer> flippedAfterTranslucent,
|
||||
@Nullable GlFramebuffer shadowFramebuffer,
|
||||
int[] terrainDrawBuffers
|
||||
@Nullable GlFramebuffer shadowFramebuffer
|
||||
) {
|
||||
this.customUniforms = customUniforms;
|
||||
|
||||
// Initialize PassInfo for each pass
|
||||
for (IrisTerrainPass pass : IrisTerrainPass.VALUES) {
|
||||
passInfoMap.put(pass, new PassInfo());
|
||||
}
|
||||
|
||||
// Process terrain shaders (used for GBUFFER_SOLID and GBUFFER_CUTOUT)
|
||||
if (terrainFuture != null) {
|
||||
try {
|
||||
final Map<PatchShaderType, String> result = terrainFuture.join();
|
||||
final PassInfo solidInfo = passInfoMap.get(IrisTerrainPass.GBUFFER_SOLID);
|
||||
final PassInfo cutoutInfo = passInfoMap.get(IrisTerrainPass.GBUFFER_CUTOUT);
|
||||
|
||||
solidInfo.setSource(PatchShaderType.VERTEX, result.get(PatchShaderType.VERTEX));
|
||||
solidInfo.setSource(PatchShaderType.GEOMETRY, result.get(PatchShaderType.GEOMETRY));
|
||||
solidInfo.setSource(PatchShaderType.FRAGMENT, result.get(PatchShaderType.FRAGMENT));
|
||||
|
||||
cutoutInfo.setSource(PatchShaderType.VERTEX, result.get(PatchShaderType.VERTEX));
|
||||
cutoutInfo.setSource(PatchShaderType.GEOMETRY, result.get(PatchShaderType.GEOMETRY));
|
||||
cutoutInfo.setSource(PatchShaderType.FRAGMENT, result.get(PatchShaderType.FRAGMENT));
|
||||
|
||||
PatchedShaderPrinter.debugPatchedShaders(terrainSourceName + "_celeritas",
|
||||
result.get(PatchShaderType.VERTEX), result.get(PatchShaderType.GEOMETRY), result.get(PatchShaderType.FRAGMENT));
|
||||
} catch (Exception e) {
|
||||
Iris.logger.error("Failed to transform terrain shader for Celeritas: {}", terrainSourceName, e);
|
||||
throw new RuntimeException("Shader transformation failed for " + terrainSourceName, e);
|
||||
}
|
||||
}
|
||||
|
||||
// Process translucent shaders (used for GBUFFER_TRANSLUCENT)
|
||||
if (translucentFuture != null) {
|
||||
try {
|
||||
final Map<PatchShaderType, String> result = translucentFuture.join();
|
||||
final PassInfo translucentInfo = passInfoMap.get(IrisTerrainPass.GBUFFER_TRANSLUCENT);
|
||||
|
||||
translucentInfo.setSource(PatchShaderType.VERTEX, result.get(PatchShaderType.VERTEX));
|
||||
translucentInfo.setSource(PatchShaderType.GEOMETRY, result.get(PatchShaderType.GEOMETRY));
|
||||
translucentInfo.setSource(PatchShaderType.FRAGMENT, result.get(PatchShaderType.FRAGMENT));
|
||||
|
||||
PatchedShaderPrinter.debugPatchedShaders(translucentSourceName + "_celeritas",
|
||||
result.get(PatchShaderType.VERTEX), result.get(PatchShaderType.GEOMETRY), result.get(PatchShaderType.FRAGMENT));
|
||||
} catch (Exception e) {
|
||||
Iris.logger.error("Failed to transform translucent shader for Celeritas: {}", translucentSourceName, e);
|
||||
throw new RuntimeException("Shader transformation failed for " + translucentSourceName, e);
|
||||
}
|
||||
}
|
||||
|
||||
// Process shadow shaders (used for SHADOW and SHADOW_CUTOUT)
|
||||
if (shadowFuture != null) {
|
||||
try {
|
||||
final Map<PatchShaderType, String> result = shadowFuture.join();
|
||||
final PassInfo shadowInfo = passInfoMap.get(IrisTerrainPass.SHADOW);
|
||||
final PassInfo shadowCutoutInfo = passInfoMap.get(IrisTerrainPass.SHADOW_CUTOUT);
|
||||
|
||||
shadowInfo.setSource(PatchShaderType.VERTEX, result.get(PatchShaderType.VERTEX));
|
||||
shadowInfo.setSource(PatchShaderType.GEOMETRY, result.get(PatchShaderType.GEOMETRY));
|
||||
shadowInfo.setSource(PatchShaderType.FRAGMENT, result.get(PatchShaderType.FRAGMENT));
|
||||
|
||||
shadowCutoutInfo.setSource(PatchShaderType.VERTEX, result.get(PatchShaderType.VERTEX));
|
||||
shadowCutoutInfo.setSource(PatchShaderType.GEOMETRY, result.get(PatchShaderType.GEOMETRY));
|
||||
shadowCutoutInfo.setSource(PatchShaderType.FRAGMENT, result.get(PatchShaderType.FRAGMENT));
|
||||
|
||||
PatchedShaderPrinter.debugPatchedShaders(shadowSourceName + "_celeritas",
|
||||
result.get(PatchShaderType.VERTEX), result.get(PatchShaderType.GEOMETRY), result.get(PatchShaderType.FRAGMENT));
|
||||
} catch (Exception e) {
|
||||
Iris.logger.error("Failed to transform shadow shader for Celeritas: {}", shadowSourceName, e);
|
||||
throw new RuntimeException("Shader transformation failed for " + shadowSourceName, e);
|
||||
}
|
||||
}
|
||||
|
||||
// Set up framebuffers for each pass
|
||||
// Shadow passes use the shadow framebuffer
|
||||
if (shadowFramebuffer != null) {
|
||||
passInfoMap.get(IrisTerrainPass.SHADOW).framebuffer = shadowFramebuffer;
|
||||
passInfoMap.get(IrisTerrainPass.SHADOW_CUTOUT).framebuffer = shadowFramebuffer;
|
||||
}
|
||||
|
||||
// GBuffer passes use render target framebuffers
|
||||
if (renderTargets != null && terrainDrawBuffers != null) {
|
||||
final GlFramebuffer solidFb = renderTargets.createGbufferFramebuffer(flippedAfterPrepare, terrainDrawBuffers);
|
||||
final GlFramebuffer translucentFb = renderTargets.createGbufferFramebuffer(flippedAfterTranslucent, terrainDrawBuffers);
|
||||
|
||||
passInfoMap.get(IrisTerrainPass.GBUFFER_SOLID).framebuffer = solidFb;
|
||||
passInfoMap.get(IrisTerrainPass.GBUFFER_CUTOUT).framebuffer = solidFb;
|
||||
passInfoMap.get(IrisTerrainPass.GBUFFER_TRANSLUCENT).framebuffer = translucentFb;
|
||||
}
|
||||
|
||||
// Set blend mode overrides
|
||||
passInfoMap.get(IrisTerrainPass.GBUFFER_SOLID).blendModeOverride = BlendModeOverride.OFF;
|
||||
passInfoMap.get(IrisTerrainPass.GBUFFER_CUTOUT).blendModeOverride = BlendModeOverride.OFF;
|
||||
passInfoMap.get(IrisTerrainPass.GBUFFER_TRANSLUCENT).blendModeOverride = null; // Default blending
|
||||
passInfoMap.get(IrisTerrainPass.SHADOW).blendModeOverride = BlendModeOverride.OFF;
|
||||
passInfoMap.get(IrisTerrainPass.SHADOW_CUTOUT).blendModeOverride = BlendModeOverride.OFF;
|
||||
|
||||
// Set alpha references
|
||||
passInfoMap.get(IrisTerrainPass.GBUFFER_SOLID).alphaReference = 0.0f;
|
||||
passInfoMap.get(IrisTerrainPass.GBUFFER_CUTOUT).alphaReference = 0.1f;
|
||||
passInfoMap.get(IrisTerrainPass.GBUFFER_TRANSLUCENT).alphaReference = 0.0f;
|
||||
passInfoMap.get(IrisTerrainPass.SHADOW).alphaReference = 0.0f;
|
||||
passInfoMap.get(IrisTerrainPass.SHADOW_CUTOUT).alphaReference = 0.1f;
|
||||
|
||||
this.createTerrainSamplers = createTerrainSamplers;
|
||||
this.createShadowSamplers = createShadowSamplers;
|
||||
this.createTerrainImages = createTerrainImages;
|
||||
this.createShadowImages = createShadowImages;
|
||||
|
||||
// Build program source map (local - only needed during construction)
|
||||
final EnumMap<IrisTerrainPass, Optional<ProgramSource>> gbufferProgramSource = new EnumMap<>(IrisTerrainPass.class);
|
||||
gbufferProgramSource.put(IrisTerrainPass.GBUFFER_SOLID, terrainSource);
|
||||
gbufferProgramSource.put(IrisTerrainPass.GBUFFER_CUTOUT, terrainSource);
|
||||
gbufferProgramSource.put(IrisTerrainPass.GBUFFER_TRANSLUCENT, translucentSource.isPresent() ? translucentSource : terrainSource);
|
||||
gbufferProgramSource.put(IrisTerrainPass.SHADOW, shadowSource);
|
||||
|
||||
// Initialize PassInfo, framebuffers, blend modes, and alpha in single pass
|
||||
for (IrisTerrainPass pass : IrisTerrainPass.VALUES) {
|
||||
PassInfo passInfo = new PassInfo();
|
||||
passInfoMap.put(pass, passInfo);
|
||||
|
||||
// Set up framebuffer
|
||||
if (pass == IrisTerrainPass.SHADOW || pass == IrisTerrainPass.SHADOW_CUTOUT) {
|
||||
passInfo.framebuffer = shadowFramebuffer;
|
||||
} else if (renderTargets != null) {
|
||||
ImmutableSet<Integer> flipped = pass == IrisTerrainPass.GBUFFER_TRANSLUCENT ? flippedAfterTranslucent : flippedAfterPrepare;
|
||||
|
||||
Optional<ProgramSource> programSource = gbufferProgramSource.get(pass);
|
||||
programSource.ifPresentOrElse(source -> passInfo.framebuffer = renderTargets.createGbufferFramebuffer(flipped, source.getDirectives().getDrawBuffers()), () -> passInfo.framebuffer = renderTargets.createGbufferFramebuffer(flipped, new int[] {0}));
|
||||
}
|
||||
|
||||
// Set blend mode override
|
||||
passInfo.blendModeOverride = switch (pass) {
|
||||
case GBUFFER_TRANSLUCENT -> null; // Default blending
|
||||
default -> BlendModeOverride.OFF;
|
||||
};
|
||||
|
||||
// Set alpha reference
|
||||
passInfo.alphaReference = switch (pass) {
|
||||
case GBUFFER_CUTOUT, SHADOW_CUTOUT -> 0.1f;
|
||||
default -> 0.0f;
|
||||
};
|
||||
}
|
||||
|
||||
// Process and apply shader sources
|
||||
processShaderFuture(terrainFuture, terrainSource, passInfoMap.get(IrisTerrainPass.GBUFFER_SOLID), passInfoMap.get(IrisTerrainPass.GBUFFER_CUTOUT));
|
||||
processShaderFuture(translucentFuture, translucentSource, passInfoMap.get(IrisTerrainPass.GBUFFER_TRANSLUCENT));
|
||||
processShaderFuture(shadowFuture, shadowSource, passInfoMap.get(IrisTerrainPass.SHADOW), passInfoMap.get(IrisTerrainPass.SHADOW_CUTOUT));
|
||||
}
|
||||
|
||||
private void processShaderFuture(@Nullable CompletableFuture<Map<PatchShaderType, String>> future, Optional<ProgramSource> source, PassInfo... targets) {
|
||||
if (future == null || source.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
final String sourceName = source.get().getName();
|
||||
try {
|
||||
final Map<PatchShaderType, String> result = future.join();
|
||||
for (PassInfo target : targets) {
|
||||
target.setSource(PatchShaderType.VERTEX, result.get(PatchShaderType.VERTEX));
|
||||
target.setSource(PatchShaderType.GEOMETRY, result.get(PatchShaderType.GEOMETRY));
|
||||
target.setSource(PatchShaderType.FRAGMENT, result.get(PatchShaderType.FRAGMENT));
|
||||
}
|
||||
PatchedShaderPrinter.debugPatchedShaders(sourceName + "_celeritas",
|
||||
result.get(PatchShaderType.VERTEX), result.get(PatchShaderType.GEOMETRY), result.get(PatchShaderType.FRAGMENT));
|
||||
} catch (Exception e) {
|
||||
Iris.logger.error("Failed to transform shader for Celeritas: {}", sourceName, e);
|
||||
throw new RuntimeException("Shader transformation failed for " + sourceName, e);
|
||||
}
|
||||
}
|
||||
|
||||
public PassInfo getPassInfo(IrisTerrainPass pass) {
|
||||
|
||||
@@ -37,7 +37,7 @@ public class IrisDebugScreenHandler {
|
||||
@SubscribeEvent(priority = EventPriority.LOW)
|
||||
public void onRenderGameOverlayTextEvent(RenderGameOverlayEvent.Text event) {
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
if (mc.gameSettings.showDebugInfo) {
|
||||
if (mc.gameSettings.showDebugInfo && !AngelicaConfig.disableF3Additions) {
|
||||
event.right.add(Math.min(event.right.size(), 2), "Direct Buffers: +" + iris$humanReadableByteCountBin(iris$directPool.getMemoryUsed()));
|
||||
|
||||
if (Iris.getIrisConfig().areShadersEnabled()) {
|
||||
|
||||
@@ -96,7 +96,7 @@ public class ShaderPackScreen extends GuiScreen implements HudHideable {
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float delta) {
|
||||
GLStateManager.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT);
|
||||
|
||||
|
||||
if(dirty) {
|
||||
dirty = false;
|
||||
this.initGui();
|
||||
@@ -174,7 +174,7 @@ public class ShaderPackScreen extends GuiScreen implements HudHideable {
|
||||
} else {
|
||||
this.fontRendererObj.drawStringWithShadow(irisTextComponent, 2, this.height - 10, 0xFFFFFF);
|
||||
}
|
||||
|
||||
|
||||
GLStateManager.glPopAttrib();
|
||||
}
|
||||
|
||||
@@ -507,7 +507,7 @@ public class ShaderPackScreen extends GuiScreen implements HudHideable {
|
||||
}
|
||||
|
||||
public boolean isDisplayingComment() {
|
||||
return this.hoveredElementCommentTimer > 20 &&
|
||||
return this.hoveredElementCommentTimer > 10 &&
|
||||
this.hoveredElementCommentTitle.isPresent() &&
|
||||
!this.hoveredElementCommentBody.isEmpty();
|
||||
}
|
||||
|
||||
@@ -524,19 +524,16 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
final GlFramebuffer celeritasShadowFb = (shadowRenderTargets != null && shadowRenderer != null)
|
||||
? shadowRenderTargets.createShadowFramebuffer(shadowRenderTargets.snapshot(), new int[] {0, 1})
|
||||
: null;
|
||||
final int[] celeritasTerrainDrawBuffers = terrainSource
|
||||
.map(source -> source.getDirectives().getDrawBuffers())
|
||||
.orElse(new int[] {0});
|
||||
|
||||
this.celeritasTerrainPipeline = new CeleritasTerrainPipeline(createTerrainSamplers,
|
||||
shadowRenderer == null ? null : createShadowTerrainSamplers, createTerrainImages,
|
||||
shadowRenderer == null ? null : createShadowTerrainImages, this.customUniforms,
|
||||
terrainSource.map(ProgramSource::getName).orElse(null),
|
||||
translucentSource.map(ProgramSource::getName).orElse(null),
|
||||
shadowSource.map(ProgramSource::getName).orElse(null),
|
||||
terrainSource,
|
||||
translucentSource,
|
||||
shadowSource,
|
||||
celeritasTerrainFuture, celeritasTranslucentFuture, celeritasShadowFuture,
|
||||
renderTargets, flippedAfterPrepare, flippedAfterTranslucent,
|
||||
celeritasShadowFb, celeritasTerrainDrawBuffers);
|
||||
celeritasShadowFb);
|
||||
|
||||
this.dhCompat = new DHCompat();
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ import net.coderbot.iris.uniforms.CelestialUniforms;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.client.renderer.culling.Frustrum;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
@@ -538,7 +537,7 @@ public class ShadowRenderer {
|
||||
return;
|
||||
}
|
||||
int brightness = tile.getWorldObj().getLightBrightnessForSkyBlocks(tile.xCoord, tile.yCoord, tile.zCoord, 0);
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) brightness % 65536, (float) brightness / 65536);
|
||||
GLStateManager.setLightmapTextureCoords(GL13.GL_TEXTURE1, (float) brightness % 65536, (float) brightness / 65536);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
TileEntityRendererDispatcher.instance.renderTileEntityAt(tile,
|
||||
(double)tile.xCoord - cameraX,
|
||||
|
||||
@@ -73,6 +73,7 @@ public class ShaderPack {
|
||||
|
||||
private final Map<String, String> dimensionMap;
|
||||
private final Map<String, ProgramSet> dimensionProgramSets;
|
||||
private final Set<String> foldersWithShaderFiles;
|
||||
private final Function<AbsolutePackPath, String> sourceProvider;
|
||||
private final ShaderProperties shaderProperties;
|
||||
private boolean hasLoggedCacheLimitReached = false;
|
||||
@@ -114,6 +115,7 @@ public class ShaderPack {
|
||||
|
||||
// Parse dimension.properties to get dimension name -> folder mappings
|
||||
this.dimensionMap = new HashMap<>();
|
||||
this.foldersWithShaderFiles = new HashSet<>();
|
||||
|
||||
Iris.logger.info("Dimension shader cache size: {} (3 vanilla pinned + {} modded), configurable via -Diris.dimensionCacheSize",
|
||||
MAX_DIMENSION_CACHE, Math.max(0, MAX_DIMENSION_CACHE - PINNED_DIMENSIONS.size()));
|
||||
@@ -135,7 +137,9 @@ public class ShaderPack {
|
||||
if (!dimensionFolders.isEmpty()) {
|
||||
for (String folderName : dimensionFolders) {
|
||||
boolean folderExists = checkAndAddDimensionFolder(starts, root, potentialFileNames, folderName);
|
||||
if (!folderExists) {
|
||||
if (folderExists) {
|
||||
foldersWithShaderFiles.add(folderName);
|
||||
} else {
|
||||
Iris.logger.warn("dimension.properties references folder '{}' but it doesn't exist or has no shader files", folderName);
|
||||
}
|
||||
}
|
||||
@@ -164,6 +168,7 @@ public class ShaderPack {
|
||||
boolean exists = checkAndAddDimensionFolder(starts, root, potentialFileNames, folderName);
|
||||
if (exists) {
|
||||
foundFolders.add(folderName);
|
||||
foldersWithShaderFiles.add(folderName);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Iris.logger.warn("Failed to scan dimension folder: {}", folderName, e);
|
||||
@@ -173,8 +178,8 @@ public class ShaderPack {
|
||||
Iris.logger.warn("Failed to scan for dimension folders", e);
|
||||
}
|
||||
|
||||
// Set up default name mappings for vanilla dimensions only
|
||||
// Other world{ID} folders are handled via dimension ID fallback at runtime
|
||||
// Set up dimension mappings
|
||||
// If world0 folder exists with shader files, use it for Overworld. Otherwise use base for all oher dims.
|
||||
if (foundFolders.contains("world0")) {
|
||||
dimensionMap.put("Overworld", "world0");
|
||||
}
|
||||
@@ -203,7 +208,14 @@ public class ShaderPack {
|
||||
this.shaderPackOptions = new ShaderPackOptions(graph, changedConfigs);
|
||||
graph = this.shaderPackOptions.getIncludes();
|
||||
|
||||
Iterable<StringPair> finalEnvironmentDefines = environmentDefines;
|
||||
List<StringPair> finalEnvironmentDefines = new ArrayList<>();
|
||||
environmentDefines.forEach(finalEnvironmentDefines::add);
|
||||
for (FeatureFlags flag : FeatureFlags.values()) {
|
||||
if (flag.isUsable()) {
|
||||
finalEnvironmentDefines.add(new StringPair("IRIS_FEATURE_" + flag.name(), ""));
|
||||
}
|
||||
}
|
||||
|
||||
this.shaderProperties = Optional.ofNullable(readProperties(root, "shaders.properties"))
|
||||
.map(source -> new ShaderProperties(source, shaderPackOptions, finalEnvironmentDefines))
|
||||
.orElseGet(ShaderProperties::empty);
|
||||
@@ -220,15 +232,6 @@ public class ShaderPack {
|
||||
IrisApi.getInstance().getConfig().setShadersEnabledAndApply(false);
|
||||
}
|
||||
|
||||
List<String> optionalFeatureFlags = shaderProperties.getOptionalFeatureFlags().stream().filter(flag -> !FeatureFlags.isInvalid(flag)).collect(Collectors.toList());
|
||||
|
||||
if (!optionalFeatureFlags.isEmpty()) {
|
||||
List<StringPair> newEnvDefines = new ArrayList<>();
|
||||
environmentDefines.forEach(newEnvDefines::add);
|
||||
optionalFeatureFlags.forEach(flag -> newEnvDefines.add(new StringPair("IRIS_FEATURE_" + flag, "")));
|
||||
environmentDefines = ImmutableList.copyOf(newEnvDefines);
|
||||
}
|
||||
|
||||
ProfileSet profiles = ProfileSet.fromTree(shaderProperties.getProfiles(), this.shaderPackOptions.getOptionSet());
|
||||
this.profile = profiles.scan(this.shaderPackOptions.getOptionSet(), this.shaderPackOptions.getOptionValues());
|
||||
|
||||
@@ -574,15 +577,24 @@ public class ShaderPack {
|
||||
* The LinkedHashMap maintains access order, so oldest entries are at the front.
|
||||
*/
|
||||
private void evictOldDimensions() {
|
||||
// If cache is disabled, evict everything except pinned
|
||||
// Build set of pinned folders (folders that vanilla dimensions map to)
|
||||
Set<String> pinnedFolders = new HashSet<>();
|
||||
for (String pinnedDimName : PINNED_DIMENSIONS) {
|
||||
String folder = dimensionMap.get(pinnedDimName);
|
||||
if (folder != null) {
|
||||
pinnedFolders.add(folder);
|
||||
}
|
||||
}
|
||||
|
||||
// If cache is disabled, evict everything except pinned folders
|
||||
if (MAX_DIMENSION_CACHE == 0) {
|
||||
dimensionProgramSets.entrySet().removeIf(e -> !PINNED_DIMENSIONS.contains(e.getKey()));
|
||||
dimensionProgramSets.entrySet().removeIf(e -> !pinnedFolders.contains(e.getKey()));
|
||||
return;
|
||||
}
|
||||
|
||||
// Count non-pinned entries
|
||||
long nonPinnedCount = dimensionProgramSets.entrySet().stream()
|
||||
.filter(e -> !PINNED_DIMENSIONS.contains(e.getKey()))
|
||||
.filter(e -> !pinnedFolders.contains(e.getKey()))
|
||||
.count();
|
||||
|
||||
int maxNonPinned = Math.max(0, MAX_DIMENSION_CACHE - PINNED_DIMENSIONS.size());
|
||||
@@ -599,7 +611,7 @@ public class ShaderPack {
|
||||
// Find the first (oldest/least recently used) non-pinned entry
|
||||
String toEvict = null;
|
||||
for (Map.Entry<String, ProgramSet> entry : dimensionProgramSets.entrySet()) {
|
||||
if (!PINNED_DIMENSIONS.contains(entry.getKey())) {
|
||||
if (!pinnedFolders.contains(entry.getKey())) {
|
||||
toEvict = entry.getKey();
|
||||
break;
|
||||
}
|
||||
@@ -645,16 +657,20 @@ public class ShaderPack {
|
||||
}
|
||||
|
||||
// If still no match, try world{ID} folder as fallback for backward compatibility
|
||||
// But only if that folder actually has shader files!
|
||||
if (folderName == null) {
|
||||
folderName = "world" + dimensionId;
|
||||
String worldFolder = "world" + dimensionId;
|
||||
if (foldersWithShaderFiles.contains(worldFolder)) {
|
||||
folderName = worldFolder;
|
||||
}
|
||||
}
|
||||
|
||||
// If we have a folder name, try to get or create its ProgramSet
|
||||
if (folderName != null) {
|
||||
// If we have a folder name that contains shader files, try to get or create its ProgramSet
|
||||
if (folderName != null && foldersWithShaderFiles.contains(folderName)) {
|
||||
ProgramSet programSet = dimensionProgramSets.get(folderName);
|
||||
|
||||
if (programSet == null) {
|
||||
// Create ProgramSet on-demand for any dimension folder
|
||||
// Create ProgramSet on-demand for dimension folder
|
||||
try {
|
||||
programSet = new ProgramSet(
|
||||
AbsolutePackPath.fromAbsolutePath("/" + folderName),
|
||||
@@ -662,23 +678,14 @@ public class ShaderPack {
|
||||
shaderProperties,
|
||||
this
|
||||
);
|
||||
} catch (Exception e) {
|
||||
// If the folder doesn't exist, just fall back to base silently.
|
||||
// Expected since I don't think literally anyone has ever done custom dimension shaders
|
||||
String message = e.getMessage();
|
||||
if (message != null && (message.contains("does not contain") || message.contains("No sources found"))) {
|
||||
Iris.logger.debug("Dimension folder '" + folderName + "' not found, using base shaders");
|
||||
} else {
|
||||
Iris.logger.error("Failed to create ProgramSet for dimension folder '{}', falling back to base", folderName, e);
|
||||
}
|
||||
programSet = null;
|
||||
}
|
||||
|
||||
if (programSet != null) {
|
||||
dimensionProgramSets.put(folderName, programSet);
|
||||
|
||||
// Check cache size limit and evict LRU dimensions if needed
|
||||
// Check cache size limit and evict LRU dimensions if needed
|
||||
evictOldDimensions();
|
||||
} catch (Exception e) {
|
||||
// This shouldn't happen but just in case.
|
||||
Iris.logger.error("Failed to create ProgramSet for dimension folder '{}', falling back to base", folderName, e);
|
||||
programSet = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,11 @@ 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 net.minecraftforge.common.BiomeDictionary;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -107,6 +109,9 @@ public class BiomeUniforms {
|
||||
return biome != null ? biome.temperature : 0.0F;
|
||||
}
|
||||
|
||||
/**
|
||||
* Biome ids in 1.7.10 are not unique, instead of this the biome category should be used
|
||||
*/
|
||||
public static int getBiomeId() {
|
||||
final BiomeGenBase biome = getCachedBiome();
|
||||
return biome != null ? biome.biomeID : 0;
|
||||
@@ -142,36 +147,51 @@ public class BiomeUniforms {
|
||||
}
|
||||
|
||||
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);
|
||||
BiomeCategories category = null;
|
||||
|
||||
// Tier 1: Hardcoded vanilla biome IDs
|
||||
// biomes not in the biomeGenArray are also not registered to the forge biomeDictionary
|
||||
if (Arrays.asList(BiomeGenBase.getBiomeGenArray()).contains(biome)) {
|
||||
category = getVanillaBiomeCategory(lookupBiome.biomeID);
|
||||
|
||||
if (category != null) {
|
||||
return category.ordinal();
|
||||
}
|
||||
|
||||
// Tier 2: forge BiomeDictionary detection
|
||||
if (BiomeDictionary.isBiomeRegistered(biome)) {
|
||||
category = detectBiomeByBiomeDictionary(biome);
|
||||
}
|
||||
}
|
||||
|
||||
if (category != null) {
|
||||
return category.ordinal();
|
||||
}
|
||||
|
||||
// Tier 2: Class-based detection for vanilla biome types
|
||||
// Tier 3: 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)
|
||||
// Tier 4: Modded biome detection (BiomesOPlenty, Realistic World Gen, lotr)
|
||||
category = detectModdedBiome(biome);
|
||||
if (category != null) {
|
||||
return category.ordinal();
|
||||
}
|
||||
|
||||
// Tier 4: Name pattern matching
|
||||
// Tier 5: Name pattern matching
|
||||
category = detectBiomeByName(biome);
|
||||
if (category != null) {
|
||||
return category.ordinal();
|
||||
}
|
||||
|
||||
// Tier 5: Temperature/rainfall heuristics
|
||||
// Tier 6: Temperature/rainfall heuristics
|
||||
category = detectBiomeByProperties(biome);
|
||||
if (category != null) {
|
||||
return category.ordinal();
|
||||
@@ -366,4 +386,42 @@ public class BiomeUniforms {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the forge BiomeDictionary when available
|
||||
*/
|
||||
private static BiomeCategories detectBiomeByBiomeDictionary(BiomeGenBase biome) {
|
||||
|
||||
var biomeDictTypes = Arrays.asList(BiomeDictionary.getTypesForBiome(biome));
|
||||
|
||||
if (biomeDictTypes.contains(BiomeDictionary.Type.SAVANNA)) {
|
||||
return BiomeCategories.SAVANNA;
|
||||
} else if (biomeDictTypes.contains(BiomeDictionary.Type.JUNGLE)) {
|
||||
return BiomeCategories.JUNGLE;
|
||||
} else if (biomeDictTypes.contains(BiomeDictionary.Type.NETHER)) {
|
||||
return BiomeCategories.NETHER;
|
||||
} else if (biomeDictTypes.contains(BiomeDictionary.Type.END)) {
|
||||
return BiomeCategories.THE_END;
|
||||
} else if (biomeDictTypes.contains(BiomeDictionary.Type.MUSHROOM)) {
|
||||
return BiomeCategories.MUSHROOM;
|
||||
} else if (biomeDictTypes.contains(BiomeDictionary.Type.OCEAN)) {
|
||||
return BiomeCategories.OCEAN;
|
||||
} else if (biomeDictTypes.contains(BiomeDictionary.Type.RIVER)) {
|
||||
return BiomeCategories.RIVER;
|
||||
} else if (biomeDictTypes.contains(BiomeDictionary.Type.MESA)) {
|
||||
return BiomeCategories.MESA;
|
||||
} else if (biomeDictTypes.contains(BiomeDictionary.Type.FOREST)) {
|
||||
return BiomeCategories.FOREST;
|
||||
} else if (biomeDictTypes.contains(BiomeDictionary.Type.PLAINS)) {
|
||||
return BiomeCategories.PLAINS;
|
||||
} else if (biomeDictTypes.contains(BiomeDictionary.Type.MOUNTAIN)) {
|
||||
return BiomeCategories.MOUNTAIN;
|
||||
} else if (biomeDictTypes.contains(BiomeDictionary.Type.SWAMP)) {
|
||||
return BiomeCategories.SWAMP;
|
||||
} else if (biomeDictTypes.contains(BiomeDictionary.Type.SANDY)) {
|
||||
return BiomeCategories.DESERT;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -26,10 +26,11 @@ public class ItemMaterialHelper {
|
||||
|
||||
/**
|
||||
* Get the material ID for an ItemStack.
|
||||
* Checks item.properties first, then block.properties if the item is an ItemBlock.
|
||||
* For ItemBlock: checks block.properties first, then item.properties.
|
||||
* For other items: checks item.properties only.
|
||||
*
|
||||
* @param itemStack The item stack to get material ID for
|
||||
* @return The material ID, or -1 if not found in either map
|
||||
* @return The material ID, or -1 if not found
|
||||
*/
|
||||
public static int getMaterialId(ItemStack itemStack) {
|
||||
if (itemStack == null || itemStack.getItem() == null) {
|
||||
@@ -68,50 +69,42 @@ public class ItemMaterialHelper {
|
||||
|
||||
/**
|
||||
* Perform the actual material ID lookup without caching.
|
||||
*
|
||||
* For block items (ItemBlock): use block.properties first, then fall back to item.properties.
|
||||
* For non-block items: use item.properties only.
|
||||
*
|
||||
* This matches modern Iris behavior where block items use block IDs and non-block items use item IDs.
|
||||
*/
|
||||
private static int lookupMaterialId(Item item, int metadata) {
|
||||
String itemIdString = (String) Item.itemRegistry.getNameForObject(item);
|
||||
if (itemIdString == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ResourceLocation itemId = new ResourceLocation(itemIdString);
|
||||
NamespacedId namespacedId = new NamespacedId(itemId.getResourceDomain(), itemId.getResourcePath());
|
||||
|
||||
// First, check item.properties
|
||||
Object2IntFunction<NamespacedId> itemIds = BlockRenderingSettings.INSTANCE.getItemIds();
|
||||
if (itemIds != null) {
|
||||
int id = itemIds.applyAsInt(namespacedId);
|
||||
if (id != -1) {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
// Second, check block.properties if this is an ItemBlock
|
||||
// For ItemBlock: check block.properties first
|
||||
if (item instanceof ItemBlock) {
|
||||
ItemBlock itemBlock = (ItemBlock) item;
|
||||
Block block = itemBlock.field_150939_a; // The block this item places
|
||||
final ItemBlock itemBlock = (ItemBlock) item;
|
||||
final Block block = itemBlock.field_150939_a; // The block this item places
|
||||
|
||||
if (block == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Convert item damage to block metadata
|
||||
int blockMeta = itemBlock.getMetadata(metadata);
|
||||
|
||||
Reference2ObjectMap<Block, Int2IntMap> blockMetaMatches = BlockRenderingSettings.INSTANCE.getBlockMetaMatches();
|
||||
if (blockMetaMatches != null) {
|
||||
Int2IntMap metaMap = blockMetaMatches.get(block);
|
||||
if (metaMap != null) {
|
||||
int id = metaMap.get(blockMeta);
|
||||
if (id != -1) {
|
||||
return id;
|
||||
if (block != null) {
|
||||
Reference2ObjectMap<Block, Int2IntMap> blockMetaMatches = BlockRenderingSettings.INSTANCE.getBlockMetaMatches();
|
||||
if (blockMetaMatches != null) {
|
||||
Int2IntMap metaMap = blockMetaMatches.get(block);
|
||||
if (metaMap != null) {
|
||||
int id = metaMap.get(itemBlock.getMetadata(metadata));
|
||||
if (id != -1) {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Not found in either map
|
||||
// Fall back to item.properties
|
||||
Object2IntFunction<NamespacedId> itemIds = BlockRenderingSettings.INSTANCE.getItemIds();
|
||||
if (itemIds != null) {
|
||||
String itemIdString = (String) Item.itemRegistry.getNameForObject(item);
|
||||
if (itemIdString != null) {
|
||||
ResourceLocation itemId = new ResourceLocation(itemIdString);
|
||||
return itemIds.applyAsInt(new NamespacedId(itemId.getResourceDomain(), itemId.getResourcePath()));
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ options.chunks=%s chunks
|
||||
options.entityShadows=Entity Shadows
|
||||
options.droppedItems=%s items
|
||||
options.droppedItems.max=Unlimited
|
||||
|
||||
sodium.option_impact.low=Low
|
||||
sodium.option_impact.medium=Medium
|
||||
sodium.option_impact.high=High
|
||||
@@ -90,11 +91,14 @@ sodium.options.default=Default
|
||||
sodium.options.buttons.undo=Undo
|
||||
sodium.options.buttons.apply=Apply
|
||||
sodium.options.buttons.donate=Buy coffee for JellySquid!
|
||||
|
||||
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.framerate=%s FPS
|
||||
|
||||
iris.shaders.toggled=Toggled shaders to %s!
|
||||
iris.shaders.disabled=Shaders disabled!
|
||||
|
||||
options.iris.apply=Apply
|
||||
options.iris.refresh=Refresh
|
||||
options.iris.openShaderPackFolder=Open Shader Pack Folder...
|
||||
@@ -131,6 +135,7 @@ options.iris.shadowDistance.enabled=Allows you to change the maximum distance fo
|
||||
options.iris.shadowDistance.disabled=Your current shader pack has already set a render distance for shadows; you cannot change it.
|
||||
options.iris.gui.hide=Hide GUI
|
||||
options.iris.gui.show=Show GUI
|
||||
|
||||
options.dynamic_lights=Dynamic Lights
|
||||
options.dynamic_lights.tooltip=Enables dynamic lights. Modes: OFF - off, FASTEST - 500ms delay, FAST - 250ms delay, FANCY - 50ms delay, REALTIME - no delay.
|
||||
options.dynamic_lights_shader_force=Dynamic Lights - Forced With Shaders
|
||||
@@ -153,6 +158,7 @@ options.dynamiclights.entities.title=Dynamic Lights - Entities
|
||||
options.dynamiclights.entities.info=Toggle which entity types emit dynamic light. Some entries are for mod compatibility.
|
||||
options.dynamiclights.entities.search=Search (@mod, $on, $off)
|
||||
options.dynamiclights.entity.tooltip=Toggle dynamic lighting for %s entities. Disable to improve performance if this entity type emits unwanted lights.
|
||||
|
||||
options.angelica.search.no_results=No matching options
|
||||
options.angelica.fontconfig=Font Configuration...
|
||||
options.angelica.fontconfig.title=Font Configuration
|
||||
@@ -199,9 +205,13 @@ options.angelica.sleepbeforeswap=Alternate FPS Limiter
|
||||
options.angelica.sleepbeforeswap.tooltip=Switches to an alternate FPS limiter that gives more stable frametimes, in exchange for slightly more latency. Will never introduce more than one frame of latency, and has a lower impact at higher framerates.
|
||||
options.angelica.threadedChunkBuilding=Threaded Chunk Building
|
||||
options.angelica.threadedChunkBuilding.tooltip=If enabled, chunk meshing will be performed on multiple threads in parallel, significantly improving chunk build speed. Disable if you experience rendering issues with mods that have custom block renderers. Requires renderer reload to take effect.
|
||||
|
||||
pack.iris.select.title=Select
|
||||
pack.iris.configure.title=Configure
|
||||
label.iris.true=On
|
||||
label.iris.false=Off
|
||||
|
||||
options.angelica.aggressiveChunkLoading=Aggressive Chunk Loading
|
||||
options.angelica.aggressiveChunkLoading.tooltip=Renders chunks immediately when loaded, even if neighbors aren't ready yet. Improves perceived loading speed at render distance edges. Chunks rebuild automatically when neighbors load. Useful for low render distance servers.
|
||||
options.angelica.disablef3=Disable F3 Additions
|
||||
options.angelica.disablef3.tooltip=Disables Angelica's additions to the F3 debug screen.
|
||||
+8
-3
@@ -14,10 +14,15 @@ public class MixinItemRenderer {
|
||||
@WrapOperation(method = "renderItemInFirstPerson", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/WorldClient;getLightBrightnessForSkyBlocks(IIII)I"))
|
||||
private int angelica$dynamiclights_renderItemInFirstPerson(WorldClient theWorld, int posX, int posY, int posZ, int p_72802_4_, Operation<Integer> original){
|
||||
int lightmap = original.call(theWorld, posX, posY, posZ, p_72802_4_);
|
||||
if (DynamicLights.isEnabled()){
|
||||
lightmap = (int)DynamicLights.get().getLightmapWithDynamicLight(posX, posY, posZ, lightmap);
|
||||
if (DynamicLights.isEnabled()) {
|
||||
final DynamicLights dl = DynamicLights.get();
|
||||
if (dl.hasLightSources()) {
|
||||
final double dynamicLightLevel = dl.getDynamicLightLevel(posX, posY, posZ);
|
||||
if (dynamicLightLevel > 0) {
|
||||
lightmap = dl.getLightmapWithDynamicLight(dynamicLightLevel, lightmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return lightmap;
|
||||
}
|
||||
}
|
||||
+5
-3
@@ -30,9 +30,11 @@ public abstract class MixinWorld {
|
||||
|
||||
@ModifyReturnValue(method = "getLightBrightnessForSkyBlocks", at = @At(value = "RETURN"))
|
||||
private int angelica$dynamiclights_getLightBrightnessForSkyBlocks(int lightmap, int x, int y, int z, int p_72802_4_){
|
||||
if (DynamicLights.isEnabled() && !getBlock(x, y, z).isOpaqueCube()){
|
||||
return DynamicLights.get().getLightmapWithDynamicLight(x, y, z, lightmap);
|
||||
}
|
||||
if (!DynamicLights.isEnabled()) return lightmap;
|
||||
final DynamicLights dl = DynamicLights.get();
|
||||
if (!dl.hasLightSources()) return lightmap;
|
||||
final double dynamicLightLevel = dl.getDynamicLightLevel(x, y, z);
|
||||
if (dynamicLightLevel > 0 && !getBlock(x, y, z).isOpaqueCube()) return dl.getLightmapWithDynamicLight(dynamicLightLevel, lightmap);
|
||||
return lightmap;
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -1,5 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.angelica.startup;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.DriverCompatabilityCheck;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import org.lwjgl.opengl.Display;
|
||||
@@ -15,5 +16,6 @@ public class MixinInitGLStateManager {
|
||||
GLStateManager.setDrawableGL(Display.getDrawable());
|
||||
GLStateManager.preInit();
|
||||
GLStateManager.init();
|
||||
DriverCompatabilityCheck.checkDriverCompatibility();
|
||||
}
|
||||
}
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.celeritas.terrain;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.IChunkTileEntityMapHolder;
|
||||
import com.gtnewhorizons.angelica.rendering.RenderThreadContext;
|
||||
import com.gtnewhorizons.angelica.utils.ConcurrentTileEntityMap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(Chunk.class)
|
||||
public abstract class MixinChunk implements IChunkTileEntityMapHolder {
|
||||
|
||||
@Shadow public Map<ChunkPosition, TileEntity> chunkTileEntityMap = new ConcurrentTileEntityMap();
|
||||
@Shadow public World worldObj;
|
||||
@Shadow private ExtendedBlockStorage[] storageArrays;
|
||||
@Final @Shadow public int xPosition;
|
||||
@Final @Shadow public int zPosition;
|
||||
|
||||
@Shadow public abstract void addTileEntity(TileEntity te);
|
||||
|
||||
@Override
|
||||
public ConcurrentTileEntityMap angelica$getConcurrentTEMap() {
|
||||
return (ConcurrentTileEntityMap) this.chunkTileEntityMap;
|
||||
}
|
||||
|
||||
@Redirect(method = "getTileEntityUnsafe", at = @At(value = "INVOKE", target = "Ljava/util/Map;get(Ljava/lang/Object;)Ljava/lang/Object;"), remap = false)
|
||||
private Object angelica$redirectGetTEUnsafe(Map<ChunkPosition, TileEntity> map, Object key) {
|
||||
if (RenderThreadContext.hasWorldSlice()) {
|
||||
final ChunkPosition pos = (ChunkPosition) key;
|
||||
final TileEntity te = RenderThreadContext.getSnapshotTE((this.xPosition << 4) + pos.chunkPosX, pos.chunkPosY, (this.zPosition << 4) + pos.chunkPosZ);
|
||||
if (te != null) return te;
|
||||
}
|
||||
return map.get(key);
|
||||
}
|
||||
|
||||
@Redirect(method = "func_150806_e", at = @At(value = "INVOKE", target = "Ljava/util/Map;get(Ljava/lang/Object;)Ljava/lang/Object;"))
|
||||
private Object angelica$redirectGetTEFunc(Map<ChunkPosition, TileEntity> map, Object key) {
|
||||
if (RenderThreadContext.hasWorldSlice()) {
|
||||
final ChunkPosition pos = (ChunkPosition) key;
|
||||
final TileEntity te = RenderThreadContext.getSnapshotTE((this.xPosition << 4) + pos.chunkPosX, pos.chunkPosY, (this.zPosition << 4) + pos.chunkPosZ);
|
||||
if (te != null) return te;
|
||||
}
|
||||
return map.get(key);
|
||||
}
|
||||
|
||||
@Redirect(method = "func_150806_e", at = @At(value = "INVOKE", target = "Ljava/util/Map;remove(Ljava/lang/Object;)Ljava/lang/Object;"))
|
||||
private Object angelica$deferRemoveFunc150806e(Map<ChunkPosition, TileEntity> map, Object key) {
|
||||
return angelica$deferRemoveImpl(map, key);
|
||||
}
|
||||
|
||||
@Redirect(method = "getTileEntityUnsafe", at = @At(value = "INVOKE", target = "Ljava/util/Map;remove(Ljava/lang/Object;)Ljava/lang/Object;"), remap = false)
|
||||
private Object angelica$deferRemoveGetTEUnsafe(Map<ChunkPosition, TileEntity> map, Object key) {
|
||||
return angelica$deferRemoveImpl(map, key);
|
||||
}
|
||||
|
||||
@Redirect(method = "removeInvalidTileEntity", at = @At(value = "INVOKE", target = "Ljava/util/Map;remove(Ljava/lang/Object;)Ljava/lang/Object;"), remap = false)
|
||||
private Object angelica$deferRemoveInvalidTE(Map<ChunkPosition, TileEntity> map, Object key) {
|
||||
return angelica$deferRemoveImpl(map, key);
|
||||
}
|
||||
|
||||
private Object angelica$deferRemoveImpl(Map<ChunkPosition, TileEntity> map, Object key) {
|
||||
if (!RenderThreadContext.hasWorldSlice()) return map.remove(key);
|
||||
((ConcurrentTileEntityMap) map).queueInvalidation((ChunkPosition) key);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Inject(method = "fillChunk", at = @At("RETURN"))
|
||||
private void angelica$createTileEntities(byte[] data, int primaryBitMask, int addBitMask, boolean groundUp, CallbackInfo ci) {
|
||||
((ConcurrentTileEntityMap) this.chunkTileEntityMap).withWriteLock(() -> {
|
||||
final boolean hasExistingTEs = !this.chunkTileEntityMap.isEmpty();
|
||||
|
||||
for (int sectionY = 0; sectionY < this.storageArrays.length; sectionY++) {
|
||||
if ((primaryBitMask & (1 << sectionY)) == 0) continue;
|
||||
|
||||
final ExtendedBlockStorage section = this.storageArrays[sectionY];
|
||||
if (section == null) continue;
|
||||
|
||||
final int baseY = sectionY << 4;
|
||||
for (int y = 0; y < 16; y++) {
|
||||
final int worldY = baseY + y;
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int x = 0; x < 16; x++) {
|
||||
final Block block = section.getBlockByExtId(x, y, z);
|
||||
if (block == null) continue;
|
||||
final int meta = section.getExtBlockMetadata(x, y, z);
|
||||
if (block.hasTileEntity(meta)) {
|
||||
if (hasExistingTEs) {
|
||||
final ChunkPosition pos = new ChunkPosition(x, worldY, z);
|
||||
final TileEntity existing = this.chunkTileEntityMap.get(pos);
|
||||
if (existing != null && !existing.isInvalid()) continue;
|
||||
}
|
||||
final TileEntity te = block.createTileEntity(this.worldObj, meta);
|
||||
if (te != null) {
|
||||
te.xCoord = (this.xPosition << 4) + x;
|
||||
te.yCoord = worldY;
|
||||
te.zCoord = (this.zPosition << 4) + z;
|
||||
this.addTileEntity(te);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -17,7 +17,6 @@ import net.coderbot.iris.pipeline.WorldRenderingPipeline;
|
||||
import net.coderbot.iris.shadows.ShadowRenderingState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
@@ -31,6 +30,7 @@ import org.embeddedt.embeddium.impl.render.chunk.shader.ChunkShaderFogComponent;
|
||||
import org.embeddedt.embeddium.impl.render.terrain.SimpleWorldRenderer;
|
||||
import org.embeddedt.embeddium.impl.render.viewport.ViewportProvider;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -144,7 +144,7 @@ public class MixinRenderGlobal implements IRenderGlobalExt {
|
||||
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
|
||||
GLStateManager.glActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
GLStateManager.glActiveTexture(GL13.GL_TEXTURE0);
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.getTextureMapBlocks().getGlTextureId());
|
||||
GLStateManager.glEnable(GL11.GL_TEXTURE_2D);
|
||||
|
||||
|
||||
+6
-5
@@ -1,7 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.mcpatcherforge.cit.client.renderer.entity;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RendererLivingEntity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -13,6 +13,7 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
@@ -224,9 +225,9 @@ public abstract class MixinRenderEntityLiving extends Render {
|
||||
this.renderEquippedItems(entity, p_76986_9_);
|
||||
float f14 = entity.getBrightness(p_76986_9_);
|
||||
j = this.getColorMultiplier(entity, f14, p_76986_9_);
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
GLStateManager.setActiveTexture(GL13.GL_TEXTURE1);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
GLStateManager.setActiveTexture(GL13.GL_TEXTURE0);
|
||||
|
||||
if ((j >> 24 & 255) > 0 || entity.hurtTime > 0 || entity.deathTime > 0) {
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
@@ -274,9 +275,9 @@ public abstract class MixinRenderEntityLiving extends Render {
|
||||
logger.error("Couldn't render entity", exception);
|
||||
}
|
||||
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
GLStateManager.setActiveTexture(GL13.GL_TEXTURE1);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
GLStateManager.setActiveTexture(GL13.GL_TEXTURE0);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glPopMatrix();
|
||||
this.passSpecialRender(entity, x, y, z);
|
||||
|
||||
+58
-4
@@ -1,20 +1,34 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.rendering;
|
||||
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ITileEntityBoundingBoxCache;
|
||||
import com.gtnewhorizons.angelica.rendering.TileEntityRenderBoundsRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@Mixin(TileEntity.class)
|
||||
public class MixinTileEntity {
|
||||
public abstract class MixinTileEntity implements ITileEntityBoundingBoxCache {
|
||||
@Shadow private Block blockType;
|
||||
@Shadow private int blockMetadata;
|
||||
@Shadow World worldObj;
|
||||
@Shadow int xCoord;
|
||||
@Shadow int yCoord;
|
||||
@Shadow int zCoord;
|
||||
@Shadow public int xCoord;
|
||||
@Shadow public int yCoord;
|
||||
@Shadow public int zCoord;
|
||||
|
||||
@Shadow public abstract AxisAlignedBB getRenderBoundingBox();
|
||||
|
||||
@Unique private int angelica$cachedBBX = Integer.MIN_VALUE;
|
||||
@Unique private int angelica$cachedBBY = Integer.MIN_VALUE;
|
||||
@Unique private int angelica$cachedBBZ = Integer.MIN_VALUE;
|
||||
@Unique private int angelica$cachedBBMetadata = -1;
|
||||
@Unique private Block angelica$cachedBBBlockType = null;
|
||||
@Unique private AxisAlignedBB angelica$cachedRenderBB = null;
|
||||
@Unique private byte angelica$infiniteExtentCached = 0; // 0 = unchecked, 1 = finite, 2 = infinite
|
||||
|
||||
/**
|
||||
* @author mitchej123
|
||||
@@ -43,4 +57,44 @@ public class MixinTileEntity {
|
||||
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB angelica$getCachedRenderBoundingBox() {
|
||||
if (angelica$cachedRenderBB != null && angelica$cachedBBX == this.xCoord && angelica$cachedBBY == this.yCoord && angelica$cachedBBZ == this.zCoord
|
||||
&& angelica$cachedBBMetadata == this.blockMetadata && angelica$cachedBBBlockType == this.blockType)
|
||||
{
|
||||
return angelica$cachedRenderBB;
|
||||
}
|
||||
|
||||
final AxisAlignedBB computed = this.getRenderBoundingBox();
|
||||
|
||||
this.angelica$cachedBBX = this.xCoord;
|
||||
this.angelica$cachedBBY = this.yCoord;
|
||||
this.angelica$cachedBBZ = this.zCoord;
|
||||
this.angelica$cachedBBMetadata = this.blockMetadata;
|
||||
this.angelica$cachedBBBlockType = this.blockType;
|
||||
|
||||
if (computed == TileEntity.INFINITE_EXTENT_AABB) {
|
||||
this.angelica$cachedRenderBB = computed;
|
||||
} else if (computed != null) {
|
||||
if (this.angelica$cachedRenderBB != null && this.angelica$cachedRenderBB != TileEntity.INFINITE_EXTENT_AABB) {
|
||||
this.angelica$cachedRenderBB.setBounds(computed.minX, computed.minY, computed.minZ, computed.maxX, computed.maxY, computed.maxZ);
|
||||
} else {
|
||||
this.angelica$cachedRenderBB = AxisAlignedBB.getBoundingBox(computed.minX, computed.minY, computed.minZ, computed.maxX, computed.maxY, computed.maxZ);
|
||||
}
|
||||
} else {
|
||||
this.angelica$cachedRenderBB = null;
|
||||
}
|
||||
|
||||
return this.angelica$cachedRenderBB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean angelica$isInfiniteExtent() {
|
||||
if (angelica$infiniteExtentCached == 0) {
|
||||
final boolean isInfinite = TileEntityRenderBoundsRegistry.isAlwaysInfiniteExtent((TileEntity) (Object) this);
|
||||
angelica$infiniteExtentCached = isInfinite ? (byte) 2 : (byte) 1;
|
||||
}
|
||||
return angelica$infiniteExtentCached == 2;
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.shaders;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import net.coderbot.iris.layer.GbufferPrograms;
|
||||
import net.minecraft.client.particle.EntityPickupFX;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
/**
|
||||
* Mixin to handle EntityPickupFX rendering items during pickup animation.
|
||||
* EntityPickupFX renders particles during the PARTICLES phase, but it renders
|
||||
* the actual EntityItem using RenderManager.renderEntityWithPosYaw. We need
|
||||
* to switch to ENTITIES phase during this render to apply proper materials.
|
||||
*/
|
||||
@Mixin(EntityPickupFX.class)
|
||||
public class MixinEntityPickupFX {
|
||||
|
||||
@WrapOperation(
|
||||
method = "renderParticle",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/RenderManager;func_147940_a(Lnet/minecraft/entity/Entity;DDDFF)Z")
|
||||
)
|
||||
private boolean iris$wrapPickupRender(RenderManager renderManager, Entity entity, double x, double y, double z, float yaw, float partialTicks, Operation<Boolean> original) {
|
||||
GbufferPrograms.beginEntities();
|
||||
try {
|
||||
return original.call(renderManager, entity, x, y, z, yaw, partialTicks);
|
||||
} finally {
|
||||
GbufferPrograms.endEntities();
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -40,7 +40,7 @@ public class MixinItemRenderer {
|
||||
ItemStack itemStack = mc.thePlayer.getCurrentEquippedItem();
|
||||
|
||||
if (itemStack == null || itemStack.getItem() == null) {
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(-1);
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -83,6 +83,6 @@ public class MixinItemRenderer {
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void iris$resetHeldItemId(float partialTicks, CallbackInfo ci) {
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(-1);
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(0);
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.shaders;
|
||||
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
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.callback.CallbackInfo;
|
||||
|
||||
@Mixin(OpenGlHelper.class)
|
||||
public class MixinOpenGlHelper {
|
||||
@Unique private static int iris$drawFramebuffer = 0;
|
||||
@Unique private static int iris$readFramebuffer = 0;
|
||||
|
||||
@Inject(method="func_153171_g", at=@At("HEAD"), cancellable=true)
|
||||
private static void iris$avoidRedundantBind(int target, int framebuffer, CallbackInfo ci) {
|
||||
if (target == GL30.GL_FRAMEBUFFER) {
|
||||
if (iris$drawFramebuffer == target && iris$readFramebuffer == target) {
|
||||
ci.cancel();
|
||||
} else {
|
||||
iris$drawFramebuffer = framebuffer;
|
||||
iris$readFramebuffer = framebuffer;
|
||||
}
|
||||
} else if (target == GL30.GL_DRAW_FRAMEBUFFER) {
|
||||
if (iris$drawFramebuffer == target) {
|
||||
ci.cancel();
|
||||
} else {
|
||||
iris$drawFramebuffer = framebuffer;
|
||||
}
|
||||
} else if (target == GL30.GL_READ_FRAMEBUFFER) {
|
||||
if (iris$readFramebuffer == target) {
|
||||
ci.cancel();
|
||||
} else {
|
||||
iris$readFramebuffer = framebuffer;
|
||||
}
|
||||
} else {
|
||||
throw new IllegalStateException("Invalid framebuffer target: " + target);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method="func_153174_h", at=@At("HEAD"))
|
||||
private static void iris$trackFramebufferDelete(int framebuffer, CallbackInfo ci) {
|
||||
if (iris$drawFramebuffer == framebuffer) {
|
||||
iris$drawFramebuffer = 0;
|
||||
}
|
||||
|
||||
if (iris$readFramebuffer == framebuffer) {
|
||||
iris$readFramebuffer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+4
-4
@@ -32,7 +32,7 @@ public class MixinRenderBiped {
|
||||
ItemStack itemStack = entity.func_130225_q(3 - armorSlot);
|
||||
|
||||
if (itemStack == null || itemStack.getItem() == null) {
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(-1);
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(0);
|
||||
original.call(instance, model);
|
||||
return;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class MixinRenderBiped {
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void iris$resetAtStart(EntityLiving entity, double x, double y, double z, float entityYaw, float partialTicks, org.spongepowered.asm.mixin.injection.callback.CallbackInfo ci) {
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(-1);
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,7 +66,7 @@ public class MixinRenderBiped {
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void iris$resetInEquippedItems(EntityLiving entity, float partialTicks, org.spongepowered.asm.mixin.injection.callback.CallbackInfo ci) {
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(-1);
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,6 +90,6 @@ public class MixinRenderBiped {
|
||||
original.call(itemRenderer, entity, itemStack, renderPass);
|
||||
|
||||
// Reset after rendering the held item
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(-1);
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(0);
|
||||
}
|
||||
}
|
||||
+38
-11
@@ -14,8 +14,10 @@ import net.coderbot.iris.pipeline.WorldRenderingPipeline;
|
||||
import net.coderbot.iris.shaderpack.materialmap.NamespacedId;
|
||||
import net.coderbot.iris.uniforms.CapturedRenderingState;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.client.renderer.culling.ICamera;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.effect.EntityLightningBolt;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -97,18 +99,43 @@ public class MixinRenderGlobal {
|
||||
angelica$cachedEntityIdMap = entityIdMap;
|
||||
}
|
||||
|
||||
if (entity instanceof EntityLightningBolt) {
|
||||
entityId = entityIdMap.applyAsInt(LIGHTNING_BOLT_ID);
|
||||
} else {
|
||||
String entityType = EntityList.getEntityString(entity);
|
||||
if (entityType != null) {
|
||||
int cached = angelica$entityIdCache.getInt(entityType);
|
||||
if (cached == Integer.MIN_VALUE) {
|
||||
cached = entityIdMap.applyAsInt(new NamespacedId(entityType));
|
||||
angelica$entityIdCache.put(entityType, cached);
|
||||
}
|
||||
entityId = cached;
|
||||
String entityType = EntityList.getEntityString(entity);
|
||||
String cacheKey;
|
||||
|
||||
if (entityType != null) {
|
||||
// Use registered entity name
|
||||
cacheKey = entityType;
|
||||
int cached = angelica$entityIdCache.getInt(cacheKey);
|
||||
if (cached == Integer.MIN_VALUE) {
|
||||
cached = entityIdMap.applyAsInt(new NamespacedId(entityType));
|
||||
angelica$entityIdCache.put(cacheKey, cached);
|
||||
}
|
||||
entityId = cached;
|
||||
} else {
|
||||
// Unregistered entity check
|
||||
Class<?> entityClass = entity.getClass();
|
||||
String className = entityClass.getName();
|
||||
cacheKey = className;
|
||||
|
||||
int cached = angelica$entityIdCache.getInt(cacheKey);
|
||||
if (cached == Integer.MIN_VALUE) {
|
||||
// Try simple class name first (e.g., "EntityLightningBolt")
|
||||
String simpleClassName = entityClass.getSimpleName();
|
||||
cached = entityIdMap.applyAsInt(new NamespacedId(simpleClassName));
|
||||
|
||||
// If not found, try FQN (e.g., "net.minecraft.entity.effect.EntityLightningBolt")
|
||||
if (cached == -1) {
|
||||
cached = entityIdMap.applyAsInt(new NamespacedId(className));
|
||||
}
|
||||
|
||||
// Special case: Shaderpacks have "minecraft:lightning_bolt" so we should continue to provide this
|
||||
if (cached == -1 && entity instanceof EntityLightningBolt) {
|
||||
cached = entityIdMap.applyAsInt(LIGHTNING_BOLT_ID);
|
||||
}
|
||||
|
||||
angelica$entityIdCache.put(cacheKey, cached);
|
||||
}
|
||||
entityId = cached;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ public abstract class MixinRenderHorse {
|
||||
|
||||
// Reset only if we set it
|
||||
if (hasArmor) {
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(-1);
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,6 +68,6 @@ public class MixinRenderItem {
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void iris$resetItemIdAfterRender(net.minecraft.entity.item.EntityItem entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci) {
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(-1);
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(0);
|
||||
}
|
||||
}
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.shaders;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntFunction;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.coderbot.iris.shaderpack.materialmap.NamespacedId;
|
||||
import net.coderbot.iris.uniforms.CapturedRenderingState;
|
||||
import net.coderbot.iris.uniforms.ItemMaterialHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
/**
|
||||
* Mixin to handle material ID setting for entities rendered through renderEntityWithPosYaw.
|
||||
* This is needed for EntityPickupFX which renders entities during pickup animation
|
||||
* Entity ID mapping is handled by MixinRenderGlobal for the normal rendering path.
|
||||
*/
|
||||
|
||||
// TODO: Find a way to de-duplicate this code.
|
||||
@Mixin(RenderManager.class)
|
||||
public class MixinRenderManager {
|
||||
@Unique private static final Object2IntOpenHashMap<String> angelica$entityIdCache = new Object2IntOpenHashMap<>();
|
||||
@Unique private static Object2IntFunction<NamespacedId> angelica$cachedEntityIdMap;
|
||||
|
||||
static {
|
||||
angelica$entityIdCache.defaultReturnValue(Integer.MIN_VALUE);
|
||||
}
|
||||
|
||||
@WrapOperation(
|
||||
method = "func_147939_a",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/Render;doRender(Lnet/minecraft/entity/Entity;DDDFF)V")
|
||||
)
|
||||
private void iris$wrapDoRender(net.minecraft.client.renderer.entity.Render render, Entity entity, double x, double y, double z, float entityYaw, float partialTicks, Operation<Void> original) {
|
||||
// Set appropriate material ID when entities are rendered through renderEntityWithPosYaw
|
||||
// (used by EntityPickupFX during pickup animation)
|
||||
// Note: Entity ID mapping is handled by MixinRenderGlobal for the normal path
|
||||
boolean setItemId = false;
|
||||
boolean setEntityId = false;
|
||||
|
||||
if (entity instanceof EntityItem) {
|
||||
EntityItem entityItem = (EntityItem) entity;
|
||||
ItemStack itemStack = entityItem.getEntityItem();
|
||||
int itemId = ItemMaterialHelper.getMaterialId(itemStack);
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(itemId);
|
||||
setItemId = true;
|
||||
} else {
|
||||
Object2IntFunction<NamespacedId> entityIdMap = BlockRenderingSettings.INSTANCE.getEntityIds();
|
||||
if (entityIdMap != null) {
|
||||
// Invalidate cache if the map changed (shader reload)
|
||||
if (entityIdMap != angelica$cachedEntityIdMap) {
|
||||
angelica$entityIdCache.clear();
|
||||
angelica$cachedEntityIdMap = entityIdMap;
|
||||
}
|
||||
|
||||
int entityId = entity.getEntityId();
|
||||
|
||||
String entityType = EntityList.getEntityString(entity);
|
||||
String cacheKey;
|
||||
|
||||
if (entityType != null) {
|
||||
// Use registered entity name
|
||||
cacheKey = entityType;
|
||||
int cached = angelica$entityIdCache.getInt(cacheKey);
|
||||
if (cached == Integer.MIN_VALUE) {
|
||||
cached = entityIdMap.applyAsInt(new NamespacedId(entityType));
|
||||
angelica$entityIdCache.put(cacheKey, cached);
|
||||
}
|
||||
entityId = cached;
|
||||
} else {
|
||||
// Unregistered entity - try class names
|
||||
Class<?> entityClass = entity.getClass();
|
||||
String className = entityClass.getName();
|
||||
cacheKey = className;
|
||||
|
||||
int cached = angelica$entityIdCache.getInt(cacheKey);
|
||||
if (cached == Integer.MIN_VALUE) {
|
||||
// Try simple class name first (e.g., "EntityLightningBolt")
|
||||
String simpleClassName = entityClass.getSimpleName();
|
||||
cached = entityIdMap.applyAsInt(new NamespacedId(simpleClassName));
|
||||
|
||||
// If not found, try FQN (e.g., "net.minecraft.entity.effect.EntityLightningBolt")
|
||||
if (cached == -1) {
|
||||
cached = entityIdMap.applyAsInt(new NamespacedId(className));
|
||||
}
|
||||
|
||||
angelica$entityIdCache.put(cacheKey, cached);
|
||||
}
|
||||
entityId = cached;
|
||||
}
|
||||
|
||||
CapturedRenderingState.INSTANCE.setCurrentEntity(entityId);
|
||||
setEntityId = true;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
original.call(render, entity, x, y, z, entityYaw, partialTicks);
|
||||
} finally {
|
||||
if (setItemId) {
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(0);
|
||||
}
|
||||
if (setEntityId) {
|
||||
CapturedRenderingState.INSTANCE.setCurrentEntity(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.shaders;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntFunction;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.coderbot.iris.shaderpack.materialmap.NamespacedId;
|
||||
import net.coderbot.iris.uniforms.CapturedRenderingState;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.entity.Entity;
|
||||
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.callback.CallbackInfo;
|
||||
|
||||
/**
|
||||
* Mixin to set the entity ID to "name_tag" when rendering entity name tags.
|
||||
* This allows shaders to apply materials to name tags separately from entities.
|
||||
* This is not an actual entity but from our perspective, it looks like it is.
|
||||
*/
|
||||
@Mixin(Render.class)
|
||||
public class MixinRenderNameTag {
|
||||
@Unique
|
||||
private static final NamespacedId NAME_TAG_ID = new NamespacedId("minecraft", "name_tag");
|
||||
|
||||
@Unique
|
||||
private int angelica$previousEntityId = -1;
|
||||
|
||||
/**
|
||||
* Inject at the HEAD of func_147906_a to set the special name_tag entity ID before rendering.
|
||||
* func_147906_a is the method that renders entity name tags.
|
||||
*/
|
||||
@Inject(
|
||||
method = "func_147906_a",
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void iris$setNameTagEntityId(Entity entity, String name, double x, double y, double z, int maxDistance, CallbackInfo ci) {
|
||||
Object2IntFunction<NamespacedId> entityIdMap = BlockRenderingSettings.INSTANCE.getEntityIds();
|
||||
if (entityIdMap != null) {
|
||||
angelica$previousEntityId = CapturedRenderingState.INSTANCE.getCurrentRenderedEntity();
|
||||
|
||||
// Set the special name_tag entity ID
|
||||
int nameTagId = entityIdMap.applyAsInt(NAME_TAG_ID);
|
||||
CapturedRenderingState.INSTANCE.setCurrentEntity(nameTagId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject at the RETURN of func_147906_a to restore the previous entity ID after rendering.
|
||||
*/
|
||||
@Inject(
|
||||
method = "func_147906_a",
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void iris$restoreEntityId(Entity entity, String name, double x, double y, double z, int maxDistance, CallbackInfo ci) {
|
||||
if (angelica$previousEntityId != -1) {
|
||||
CapturedRenderingState.INSTANCE.setCurrentEntity(angelica$previousEntityId);
|
||||
angelica$previousEntityId = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -32,7 +32,7 @@ public class MixinRenderPlayerArmor {
|
||||
ItemStack itemStack = player.getCurrentArmor(3 - armorSlot);
|
||||
|
||||
if (itemStack == null || itemStack.getItem() == null) {
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(-1);
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(0);
|
||||
original.call(instance, model);
|
||||
return;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class MixinRenderPlayerArmor {
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void iris$resetAtStart(AbstractClientPlayer player, double x, double y, double z, float entityYaw, float partialTicks, org.spongepowered.asm.mixin.injection.callback.CallbackInfo ci) {
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(-1);
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,7 +66,7 @@ public class MixinRenderPlayerArmor {
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void iris$resetInEquippedItems(AbstractClientPlayer player, float partialTicks, org.spongepowered.asm.mixin.injection.callback.CallbackInfo ci) {
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(-1);
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,6 +90,6 @@ public class MixinRenderPlayerArmor {
|
||||
original.call(itemRenderer, entity, itemStack, renderPass);
|
||||
|
||||
// Reset after rendering the held item
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(-1);
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(0);
|
||||
}
|
||||
}
|
||||
+11
@@ -20,6 +20,17 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(RendererLivingEntity.class)
|
||||
public class MixinRendererLivingEntity {
|
||||
/**
|
||||
* Reset currentRenderedItemId at the start of rendering each living entity, otherwise entity materials don't apply.
|
||||
*/
|
||||
@Inject(
|
||||
method = "doRender(Lnet/minecraft/entity/EntityLivingBase;DDDFF)V",
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void iris$resetItemIdAtStart(EntityLivingBase entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci) {
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(0);
|
||||
}
|
||||
|
||||
@WrapOperation(
|
||||
method="doRender",
|
||||
at=@At(value="INVOKE", target="Lnet/minecraft/client/renderer/entity/RendererLivingEntity;getColorMultiplier(Lnet/minecraft/entity/EntityLivingBase;FF)I")
|
||||
|
||||
+25
-5
@@ -30,10 +30,29 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@Mixin(value = SkyProviderCelestial.class, priority = 100)
|
||||
public class MixinSkyProviderCelestial_ShaderCompat {
|
||||
|
||||
/// Simple white 2x2 texture
|
||||
@Unique
|
||||
private static ResourceLocation GL_TEXTURE_2D_WORKAROUND = new ResourceLocation("angelica:textures/shaders_workaround.png"); /// Simple white 2x2 texture
|
||||
private static ResourceLocation GL_TEXTURE_2D_WORKAROUND = new ResourceLocation("angelica:textures/shaders_workaround.png");
|
||||
|
||||
/// Fixes
|
||||
// Fixes
|
||||
|
||||
/**
|
||||
* Disables {@link GL11#glDisable(int GL_TEXTURE_2D)} call
|
||||
* @see #iris$atmosphereBlend$renderInDefaultProgram(CallbackInfo, Minecraft, LocalIntRef)
|
||||
*/
|
||||
@WrapWithCondition(method = "renderSunset", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glDisable(I)V", ordinal = 0), remap = false)
|
||||
private boolean iris$sunset$revertTextureDisable(int i) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables {@link GL11#glEnable(int GL_TEXTURE_2D)} call
|
||||
* @see #iris$atmosphereBlend$renderInDefaultProgram(CallbackInfo, Minecraft, LocalIntRef)
|
||||
*/
|
||||
@WrapWithCondition(method = "renderSunset", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glEnable(I)V", ordinal = 0), remap = false)
|
||||
private boolean iris$sunsetBlend$revertTextureEnable(int i) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces sunset to render with the default program
|
||||
@@ -41,13 +60,14 @@ public class MixinSkyProviderCelestial_ShaderCompat {
|
||||
* 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) {
|
||||
public void iris$sunset$renderInDefaultProgram(CallbackInfo ci, @Local(argsOnly = true) Minecraft mc, @Share("sunset$previousProgram") LocalIntRef sunset$previousProgram) {
|
||||
sunset$previousProgram.set(GLStateManager.getActiveProgram());
|
||||
GLStateManager.glUseProgram(0);
|
||||
mc.getTextureManager().bindTexture(GL_TEXTURE_2D_WORKAROUND);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the program back before {@link #iris$sunset$renderInDefaultProgram(CallbackInfo, LocalIntRef)} call
|
||||
* Sets the program back before {@link #iris$sunset$renderInDefaultProgram(CallbackInfo, Minecraft, 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) {
|
||||
@@ -200,7 +220,7 @@ public class MixinSkyProviderCelestial_ShaderCompat {
|
||||
GLStateManager.glUseProgram(ringsFront$previousProgram.get());
|
||||
}
|
||||
|
||||
/// Pipeline setup
|
||||
// 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) {
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.gtnewhorizons.angelica.mixins.late.client.ntmSpace;
|
||||
|
||||
import com.hbm.dim.laythe.SkyProviderLaytheSunset;
|
||||
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
@Mixin(value = SkyProviderLaytheSunset.class, priority = 100)
|
||||
public class MixinSkyProviderLaytheSunset {
|
||||
|
||||
/**
|
||||
* Disables {@link GL11#glDisable(int GL_TEXTURE_2D)} call
|
||||
*/
|
||||
@WrapWithCondition(method = "renderSunset", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glDisable(I)V", ordinal = 0), remap = false)
|
||||
private boolean iris$sunset$revertTextureDisable(int i) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables {@link GL11#glEnable(int GL_TEXTURE_2D)} call
|
||||
*/
|
||||
@WrapWithCondition(method = "renderSunset", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glEnable(I)V", ordinal = 0), remap = false)
|
||||
private boolean iris$sunsetBlend$revertTextureEnable(int i) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user