mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-23 21:59:44 +00:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b7015bf10e | ||
|
|
46602ab921 | ||
|
|
63e9fa0df1 | ||
|
|
dcea970a77 | ||
|
|
b29240d6da | ||
|
|
9d5a02ed21 | ||
|
|
b454483aae | ||
|
|
72b13543c6 |
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -188,6 +188,7 @@ public enum Mixins implements IMixins {
|
||||
, "celeritas.biome_blending.MixinBlockLeaves"
|
||||
, "celeritas.biome_blending.MixinBlockLiquid"
|
||||
, "celeritas.threading.MixinForgeHooksClient"
|
||||
, "celeritas.terrain.MixinChunk"
|
||||
)
|
||||
),
|
||||
|
||||
@@ -195,7 +196,8 @@ public enum Mixins implements IMixins {
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableIris)
|
||||
.addClientMixins(
|
||||
"shaders.MixinEntityRenderer"
|
||||
"shaders.MixinEntityPickupFX"
|
||||
, "shaders.MixinEntityRenderer"
|
||||
, "shaders.MixinGuiIngameForge"
|
||||
, "shaders.MixinFramebuffer"
|
||||
, "shaders.MixinItem"
|
||||
@@ -207,6 +209,8 @@ public enum Mixins implements IMixins {
|
||||
, "shaders.MixinRenderGlobal"
|
||||
, "shaders.MixinRenderHorse"
|
||||
, "shaders.MixinRenderItem"
|
||||
, "shaders.MixinRenderManager"
|
||||
, "shaders.MixinRenderNameTag"
|
||||
, "shaders.MixinRenderPlayerArmor"
|
||||
, "shaders.MixinTileEntityBeaconRenderer"
|
||||
)
|
||||
|
||||
+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();
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -56,6 +56,7 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
private final VertexArrayQuadView quadView;
|
||||
private boolean lightPipelineReady = false;
|
||||
private int originX, originY, originZ;
|
||||
private IBlockAccess blockAccess;
|
||||
|
||||
public AngelicaChunkBuildContext(RenderPassConfiguration<?> renderPassConfiguration, WorldClient world) {
|
||||
super(renderPassConfiguration);
|
||||
@@ -71,6 +72,7 @@ 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;
|
||||
@@ -138,7 +140,7 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
final int worldX = originX + blockX;
|
||||
final int worldY = originY + blockY;
|
||||
final int worldZ = originZ + blockZ;
|
||||
final boolean isEmissive = useAoCalculation && QuadLightingHelper.isBlockEmissive(worldSlice, worldX, worldY, worldZ);
|
||||
final boolean isEmissive = useAoCalculation && QuadLightingHelper.isBlockEmissive(blockAccess, worldX, worldY, worldZ);
|
||||
|
||||
for (int quadIdx = 0; quadIdx < numQuads; quadIdx++) {
|
||||
float uSum = 0, vSum = 0;
|
||||
|
||||
+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 (!TileEntityRenderBoundsRegistry.isInfiniteExtentsBox(aabb) && !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;
|
||||
}
|
||||
|
||||
|
||||
+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();
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
@@ -572,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());
|
||||
@@ -597,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;
|
||||
}
|
||||
@@ -643,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),
|
||||
@@ -660,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+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);
|
||||
}
|
||||
}
|
||||
+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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user