mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-21 21:02:15 +00:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d60477b93 | ||
|
|
362724610c | ||
|
|
ea4a3cdf0b | ||
|
|
65959268d0 | ||
|
|
58d820cd7e | ||
|
|
685d68bd9c |
No files matched your search
+2
-2
@@ -80,8 +80,8 @@ dependencies {
|
||||
compileOnly "org.apache.ant:ant:1.8.2"
|
||||
|
||||
// Celeritas (transitive=false: deps provided by GTNHLib/runtime)
|
||||
embedOnly("org.embeddedt.celeritas:celeritas-common:2.5.1-GTNH") { transitive = false }
|
||||
embedOnly("org.embeddedt.celeritas:celeritas-lwjgl2-service:2.5.1-GTNH") { transitive = false }
|
||||
embedOnly("org.embeddedt.celeritas:celeritas-common:2.5.2-GTNH") { transitive = false }
|
||||
embedOnly("org.embeddedt.celeritas:celeritas-lwjgl2-service:2.5.2-GTNH") { transitive = false }
|
||||
|
||||
// Because who doesn't want NEI
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.8.35-GTNH:dev')
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.gtnewhorizon.gtnhlib.util.font.GlyphReplacements;
|
||||
import com.gtnewhorizons.angelica.config.FontConfig;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.FontRendererAccessor;
|
||||
import cpw.mods.fml.client.SplashProgress;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import net.coderbot.iris.gl.program.Program;
|
||||
import net.coderbot.iris.gl.program.ProgramBuilder;
|
||||
@@ -508,10 +507,16 @@ public class BatchingFontRenderer {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (FontConfig.enableCustomFont) {
|
||||
if (FontConfig.enableCustomFont && FontConfig.enableGlyphReplacements) {
|
||||
String chrReplacement = GlyphReplacements.customGlyphs.get(String.valueOf(chr));
|
||||
if (chrReplacement != null) {
|
||||
chr = chrReplacement.charAt(0);
|
||||
char replacement = chrReplacement.charAt(0);
|
||||
boolean isReplacementCharAvailable =
|
||||
FontProviderCustom.getPrimary().isGlyphAvailable(replacement)
|
||||
|| FontProviderCustom.getFallback().isGlyphAvailable(replacement);
|
||||
if (isReplacementCharAvailable) {
|
||||
chr = replacement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,4 +70,11 @@ public class FontConfig {
|
||||
@Config.DefaultFloat(1.5F)
|
||||
@Config.RangeFloat(min = 0.1F, max = 3F)
|
||||
public static float customFontScale;
|
||||
|
||||
@Config.Comment({"Mods can provide Angelica with a mapping of special characters to either get replaced with " +
|
||||
"different characters or rendered using the default Unicode font. Setting this to false disables the " +
|
||||
"replacement, which is useful in cases where custom fonts have direct support for these special characters. ",
|
||||
"See for additional details: https://github.com/GTNewHorizons/Angelica/issues/1239#issuecomment-3729877936"})
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean enableGlyphReplacements;
|
||||
}
|
||||
@@ -328,6 +328,7 @@ public class GLStateManager {
|
||||
@Getter protected static final ViewPortStateStack viewportState = new ViewPortStateStack();
|
||||
|
||||
@Getter protected static int activeProgram = 0;
|
||||
@Getter protected static int listBase = 0;
|
||||
|
||||
public static void reset() {
|
||||
runningSplash = true;
|
||||
@@ -804,6 +805,7 @@ public class GLStateManager {
|
||||
return switch (pname) {
|
||||
case GL11.GL_ALPHA_TEST_FUNC -> alphaState.getFunction();
|
||||
case GL11.GL_DEPTH_FUNC -> depthState.getFunc();
|
||||
case GL11.GL_LIST_BASE -> listBase;
|
||||
case GL11.GL_LIST_MODE -> DisplayListManager.getListMode();
|
||||
case GL11.GL_MATRIX_MODE -> matrixMode.getMode();
|
||||
case GL11.GL_SHADE_MODEL -> shadeModelState.getValue();
|
||||
@@ -2137,7 +2139,7 @@ public class GLStateManager {
|
||||
// TODO: Iris Notifier
|
||||
if (HAS_MULTIPLE_SET.contains(pname)) {
|
||||
GL11.glFog(pname, param);
|
||||
|
||||
|
||||
if (pname == GL11.GL_FOG_COLOR && isCachingEnabled()) {
|
||||
final float red = param.get(0);
|
||||
final float green = param.get(1);
|
||||
@@ -2459,7 +2461,7 @@ public class GLStateManager {
|
||||
// Reset relative transform - subsequent transforms are relative to loaded matrix
|
||||
DisplayListManager.resetRelativeTransform();
|
||||
if (mode == RecordMode.COMPILE) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (isCachingEnabled()) {
|
||||
@@ -3584,24 +3586,28 @@ public class GLStateManager {
|
||||
|
||||
// Display List Commands
|
||||
public static void glCallLists(IntBuffer lists) {
|
||||
if (DisplayListManager.isRecording()) {
|
||||
throw new UnsupportedOperationException("glCallLists in display lists not yet implemented - if you see this, please report!");
|
||||
while (lists.hasRemaining()) {
|
||||
final int listId = lists.get() + listBase;
|
||||
glCallList(listId);
|
||||
}
|
||||
}
|
||||
|
||||
public static void glCallLists(ShortBuffer lists) {
|
||||
while (lists.hasRemaining()) {
|
||||
final int listId = (lists.get() & 0xFFFF) + listBase;
|
||||
glCallList(listId);
|
||||
}
|
||||
GL11.glCallLists(lists);
|
||||
}
|
||||
|
||||
public static void glCallLists(ByteBuffer lists) {
|
||||
if (DisplayListManager.isRecording()) {
|
||||
throw new UnsupportedOperationException("glCallLists in display lists not yet implemented - if you see this, please report!");
|
||||
while (lists.hasRemaining()) {
|
||||
final int listId = (lists.get() & 0xFF) + listBase;
|
||||
glCallList(listId);
|
||||
}
|
||||
GL11.glCallLists(lists);
|
||||
}
|
||||
|
||||
public static void glListBase(int base) {
|
||||
if (DisplayListManager.isRecording()) {
|
||||
throw new UnsupportedOperationException("glListBase in display lists not yet implemented - if you see this, please report!");
|
||||
}
|
||||
GL11.glListBase(base);
|
||||
listBase = base;
|
||||
}
|
||||
|
||||
// Clip Plane Commands
|
||||
|
||||
@@ -202,9 +202,13 @@ public enum Mixins implements IMixins {
|
||||
, "shaders.MixinLocale"
|
||||
, "shaders.MixinOpenGlHelper"
|
||||
, "shaders.MixinRender"
|
||||
, "shaders.MixinRenderBiped"
|
||||
, "shaders.MixinRenderEntityFlame"
|
||||
, "shaders.MixinRendererLivingEntity"
|
||||
, "shaders.MixinRenderGlobal"
|
||||
, "shaders.MixinRenderHorse"
|
||||
, "shaders.MixinRenderItem"
|
||||
, "shaders.MixinRenderPlayerArmor"
|
||||
, "shaders.MixinTileEntityBeaconRenderer"
|
||||
)
|
||||
),
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.gtnewhorizons.angelica.mixins.interfaces.IGameSettingsExt;
|
||||
import com.gtnewhorizons.angelica.render.CloudRenderer;
|
||||
import com.gtnewhorizons.angelica.rendering.AngelicaBlockSafetyRegistry;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.CeleritasDebugScreenHandler;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.CeleritasSetup;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.threading.ChunkTaskRegistry;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.threading.DefaultChunkTaskProvider;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.threading.ThreadedChunkTaskProvider;
|
||||
@@ -66,9 +67,7 @@ import net.minecraftforge.client.event.GuiOpenEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import org.embeddedt.embeddium.impl.gl.device.GLRenderDevice;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
|
||||
@@ -116,8 +115,10 @@ public class ClientProxy extends CommonProxy {
|
||||
HUDCaching.init();
|
||||
}
|
||||
if (AngelicaConfig.enableCeleritas) {
|
||||
GLRenderDevice.VANILLA_STATE_RESETTER = () -> GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
|
||||
CeleritasSetup.ensureInitialized();
|
||||
MinecraftForge.EVENT_BUS.register(CeleritasDebugScreenHandler.INSTANCE);
|
||||
} else {
|
||||
LOGGER.info("Celeritas is disabled, skipping initialization from init()");
|
||||
}
|
||||
if (AngelicaConfig.enableIris) {
|
||||
MinecraftForge.EVENT_BUS.register(IrisDebugScreenHandler.INSTANCE);
|
||||
|
||||
+4
-4
@@ -163,7 +163,7 @@ public abstract class AngelicaChunkBuilderMeshingTask extends ChunkBuilderTask<C
|
||||
continue;
|
||||
}
|
||||
|
||||
renderBlock(block, x, y, z, pass, tessellator, renderBlocks,
|
||||
renderBlock(block, meta, x, y, z, pass, tessellator, renderBlocks,
|
||||
buffers, buildContext, blockRenderContext, minX, minY, minZ);
|
||||
}
|
||||
}
|
||||
@@ -207,7 +207,7 @@ public abstract class AngelicaChunkBuilderMeshingTask extends ChunkBuilderTask<C
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderBlock(Block block, int x, int y, int z, int pass, Tessellator tessellator, RenderBlocks renderBlocks, ChunkBuildBuffers buffers, AngelicaChunkBuildContext buildContext, BlockRenderContext blockRenderContext, int originX, int originY, int originZ) {
|
||||
protected void renderBlock(Block block, int metadata, int x, int y, int z, int pass, Tessellator tessellator, RenderBlocks renderBlocks, ChunkBuildBuffers buffers, AngelicaChunkBuildContext buildContext, BlockRenderContext blockRenderContext, int originX, int originY, int originZ) {
|
||||
|
||||
final Material blockMaterial = block.getMaterial();
|
||||
final boolean isFluid = blockMaterial == Material.water || blockMaterial == Material.lava;
|
||||
@@ -226,7 +226,7 @@ public abstract class AngelicaChunkBuilderMeshingTask extends ChunkBuilderTask<C
|
||||
if (isFluid) {
|
||||
contextEncoder.prepareToRenderFluid(blockRenderContext, block, lightValue);
|
||||
} else {
|
||||
contextEncoder.prepareToRenderBlock(blockRenderContext, block,
|
||||
contextEncoder.prepareToRenderBlock(blockRenderContext, block, metadata,
|
||||
ExtendedDataHelper.BLOCK_RENDER_TYPE, lightValue);
|
||||
}
|
||||
}
|
||||
@@ -255,7 +255,7 @@ public abstract class AngelicaChunkBuilderMeshingTask extends ChunkBuilderTask<C
|
||||
mainTessellator.setTranslation(-minX, -minY, -minZ);
|
||||
|
||||
for (DeferredBlock deferred : deferredBlocks) {
|
||||
renderBlock(deferred.block(), deferred.x(), deferred.y(), deferred.z(), deferred.pass(),
|
||||
renderBlock(deferred.block(), deferred.meta(), deferred.x(), deferred.y(), deferred.z(), deferred.pass(),
|
||||
mainTessellator, mainThreadRenderBlocks, buffers, buildContext,
|
||||
blockRenderContext, minX, minY, minZ);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.gtnewhorizons.angelica.rendering.celeritas;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import org.embeddedt.embeddium.impl.gl.device.GLRenderDevice;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
import static com.gtnewhorizons.angelica.loading.AngelicaTweaker.LOGGER;
|
||||
|
||||
public class CeleritasSetup {
|
||||
private static boolean initialized = false;
|
||||
|
||||
public static void ensureInitialized() {
|
||||
if (!initialized && AngelicaConfig.enableCeleritas) {
|
||||
GLRenderDevice.VANILLA_STATE_RESETTER = () -> GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
|
||||
LOGGER.debug("Celeritas init");
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
-4
@@ -1,6 +1,5 @@
|
||||
package com.gtnewhorizons.angelica.rendering.celeritas.api;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import net.minecraft.block.Block;
|
||||
import org.embeddedt.embeddium.impl.gl.shader.GlProgram;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.RenderPassConfiguration;
|
||||
@@ -28,7 +27,4 @@ public interface IrisShaderProvider {
|
||||
|
||||
/** Block render layer overrides from shader pack */
|
||||
@Nullable Map<Block, RenderLayer> getBlockTypeIds();
|
||||
|
||||
/** Block ID matches for extended vertex data */
|
||||
@Nullable Object2IntMap<Block> getBlockMatches();
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@ import org.embeddedt.embeddium.impl.render.chunk.vertex.format.ChunkVertexEncode
|
||||
|
||||
public interface ContextAwareChunkVertexEncoder extends ChunkVertexEncoder {
|
||||
|
||||
void prepareToRenderBlock(BlockRenderContext ctx, Block block, short renderType, byte lightValue);
|
||||
void prepareToRenderBlock(BlockRenderContext ctx, Block block, int metadata, short renderType, byte lightValue);
|
||||
|
||||
void prepareToRenderFluid(BlockRenderContext ctx, Block block, byte lightValue);
|
||||
|
||||
|
||||
+10
-9
@@ -4,10 +4,10 @@ import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
|
||||
import static com.gtnewhorizons.angelica.rendering.celeritas.iris.IrisExtendedChunkVertexType.STRIDE;
|
||||
import static com.gtnewhorizons.angelica.rendering.celeritas.iris.IrisExtendedChunkVertexType.encodeMidTexture;
|
||||
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.api.IrisShaderProvider;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.api.IrisShaderProviderHolder;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
|
||||
import lombok.Setter;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.coderbot.iris.vertices.ExtendedDataHelper;
|
||||
import net.coderbot.iris.vertices.NormalHelper;
|
||||
import net.coderbot.iris.vertices.NormI8;
|
||||
@@ -30,11 +30,10 @@ public class IrisExtendedChunkVertexEncoder implements ContextAwareChunkVertexEn
|
||||
private final ChunkVertexEncoder baseEncoder = IrisExtendedChunkVertexType.BASE_TYPE.createEncoder();
|
||||
private final CeleritasQuadView quad = new CeleritasQuadView();
|
||||
private final Vector3f normal = new Vector3f();
|
||||
private final Object2IntMap<Block> blockMatches;
|
||||
private final Reference2ObjectMap<Block, Int2IntMap> blockMetaMatches;
|
||||
|
||||
public IrisExtendedChunkVertexEncoder() {
|
||||
final IrisShaderProvider provider = IrisShaderProviderHolder.getProvider();
|
||||
this.blockMatches = provider != null ? provider.getBlockMatches() : null;
|
||||
this.blockMetaMatches = BlockRenderingSettings.INSTANCE.getBlockMetaMatches();
|
||||
}
|
||||
|
||||
// Per-quad accumulators
|
||||
@@ -46,9 +45,10 @@ public class IrisExtendedChunkVertexEncoder implements ContextAwareChunkVertexEn
|
||||
private BlockRenderContext context;
|
||||
|
||||
@Override
|
||||
public void prepareToRenderBlock(BlockRenderContext ctx, Block block, short renderType, byte lightValue) {
|
||||
public void prepareToRenderBlock(BlockRenderContext ctx, Block block, int metadata, short renderType, byte lightValue) {
|
||||
this.context = ctx;
|
||||
ctx.blockId = (short) (blockMatches != null ? blockMatches.getOrDefault(block, -1) : -1);
|
||||
Int2IntMap metaMap = blockMetaMatches != null ? blockMetaMatches.get(block) : null;
|
||||
ctx.blockId = (short) (metaMap != null ? metaMap.get(metadata) : -1);
|
||||
ctx.renderType = renderType;
|
||||
ctx.lightValue = lightValue;
|
||||
}
|
||||
@@ -56,7 +56,8 @@ public class IrisExtendedChunkVertexEncoder implements ContextAwareChunkVertexEn
|
||||
@Override
|
||||
public void prepareToRenderFluid(BlockRenderContext ctx, Block block, byte lightValue) {
|
||||
this.context = ctx;
|
||||
ctx.blockId = (short) (blockMatches != null ? blockMatches.getOrDefault(block, -1) : -1);
|
||||
Int2IntMap metaMap = blockMetaMatches != null ? blockMetaMatches.get(block) : null;
|
||||
ctx.blockId = (short) (metaMap != null ? metaMap.get(0) : -1);
|
||||
ctx.renderType = ExtendedDataHelper.FLUID_RENDER_TYPE;
|
||||
ctx.lightValue = lightValue;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,9 @@ import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.InputEvent;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
|
||||
import lombok.Getter;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
@@ -860,14 +862,14 @@ public class Iris {
|
||||
|
||||
private static int getShaderMaterialOverrideId(Block block, int meta) {
|
||||
if (contextHolder == null) {
|
||||
final Object2IntMap<Block> blockMatches = BlockRenderingSettings.INSTANCE.getBlockMatches();
|
||||
if (blockMatches == null) {
|
||||
final Reference2ObjectMap<Block, Int2IntMap> blockMetaMatches = BlockRenderingSettings.INSTANCE.getBlockMetaMatches();
|
||||
if (blockMetaMatches == null) {
|
||||
return -1;
|
||||
}
|
||||
contextHolder = new BlockContextHolder(blockMatches);
|
||||
contextHolder = new BlockContextHolder(blockMetaMatches);
|
||||
|
||||
}
|
||||
contextHolder.set(block, (short) block.getRenderType());
|
||||
contextHolder.set(block, meta, (short) block.getRenderType());
|
||||
return contextHolder.blockId;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,39 @@
|
||||
package net.coderbot.iris.block_context;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
/**
|
||||
* Holds block context for shader material ID lookups.
|
||||
*/
|
||||
public class BlockContextHolder {
|
||||
private final Object2IntMap<Block> blockMatches;
|
||||
private final Reference2ObjectMap<Block, Int2IntMap> blockMetaMatches;
|
||||
public int blockId;
|
||||
public short renderType;
|
||||
|
||||
public BlockContextHolder(Object2IntMap<Block> blockMatches) {
|
||||
this.blockMatches = blockMatches;
|
||||
public BlockContextHolder(Reference2ObjectMap<Block, Int2IntMap> blockMetaMatches) {
|
||||
this.blockMetaMatches = blockMetaMatches;
|
||||
this.blockId = -1;
|
||||
this.renderType = -1;
|
||||
}
|
||||
|
||||
public void set(Block block, short renderType) {
|
||||
/**
|
||||
* Set the material ID for a block.
|
||||
* @param block The block
|
||||
* @param meta The block metadata
|
||||
* @param renderType The render type
|
||||
*/
|
||||
public void set(Block block, int meta, short renderType) {
|
||||
Int2IntMap metaMap = this.blockMetaMatches != null ? this.blockMetaMatches.get(block) : null;
|
||||
int id = metaMap != null ? metaMap.get(meta) : -1;
|
||||
|
||||
this.blockId = id;
|
||||
this.renderType = renderType;
|
||||
this.blockId = blockMatches.getOrDefault(block, -1);
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
this.blockId = -1;
|
||||
this.renderType = -1;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
package net.coderbot.iris.block_rendering;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap;
|
||||
import net.coderbot.iris.shaderpack.materialmap.BlockEntry;
|
||||
import net.coderbot.iris.shaderpack.materialmap.BlockRenderType;
|
||||
@@ -14,14 +17,19 @@ import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class BlockMaterialMapping {
|
||||
public static Object2IntMap<Block> createBlockStateIdMap(Int2ObjectMap<List<BlockEntry>> blockPropertiesMap) {
|
||||
Object2IntMap<Block> blockMatches = new Object2IntOpenHashMap<>();
|
||||
/**
|
||||
* Creates a two-level map structure for block material IDs.
|
||||
* Based on Iris's BlockState mapping approach adapted for 1.7.10's metadata system.
|
||||
*/
|
||||
public static Reference2ObjectMap<Block, Int2IntMap> createBlockMetaIdMap(Int2ObjectMap<List<BlockEntry>> blockPropertiesMap) {
|
||||
Reference2ObjectMap<Block, Int2IntMap> blockMatches = new Reference2ObjectOpenHashMap<>();
|
||||
|
||||
blockPropertiesMap.forEach((intId, entries) -> {
|
||||
for (BlockEntry entry : entries) {
|
||||
addBlock(entry, blockMatches, intId);
|
||||
addBlockMetas(entry, blockMatches, intId);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -57,7 +65,11 @@ public class BlockMaterialMapping {
|
||||
};
|
||||
}
|
||||
|
||||
private static void addBlock(BlockEntry entry, Object2IntMap<Block> idMap, int intId) {
|
||||
/**
|
||||
* Adds block+metadata combinations to the material ID map.
|
||||
* Based on Iris's addBlockStates method, adapted for 1.7.10 metadata system.
|
||||
*/
|
||||
private static void addBlockMetas(BlockEntry entry, Reference2ObjectMap<Block, Int2IntMap> idMap, int intId) {
|
||||
final NamespacedId id = entry.getId();
|
||||
final ResourceLocation resourceLocation = new ResourceLocation(id.getNamespace(), id.getName());
|
||||
|
||||
@@ -69,40 +81,25 @@ public class BlockMaterialMapping {
|
||||
return;
|
||||
}
|
||||
|
||||
idMap.put(block, intId);
|
||||
Set<Integer> metas = entry.getMetas();
|
||||
|
||||
// Set<Integer> metas = entry.getMetas();
|
||||
// // All metas match
|
||||
// if (metas.isEmpty()) {
|
||||
// idMap.putIfAbsent(new BlockMatch(block, null), intId);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// // A subset of metas match
|
||||
// for(int meta : metas) {
|
||||
// idMap.putIfAbsent(new BlockMatch(block, meta), intId);
|
||||
// }
|
||||
Int2IntMap metaMap = idMap.get(block);
|
||||
if (metaMap == null) {
|
||||
metaMap = new Int2IntOpenHashMap();
|
||||
metaMap.defaultReturnValue(-1);
|
||||
idMap.put(block, metaMap);
|
||||
}
|
||||
|
||||
if (metas.isEmpty()) {
|
||||
// Add all metadata values (0-15) if there aren't any specific ones
|
||||
for (int meta = 0; meta < 16; meta++) {
|
||||
metaMap.putIfAbsent(meta, intId);
|
||||
}
|
||||
} else {
|
||||
// Add only specific metadata values
|
||||
for (int meta : metas) {
|
||||
metaMap.putIfAbsent(meta, intId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We ignore generics here, the actual types don't matter because we just convert
|
||||
// them to strings anyways, and the compiler checks just get in the way.
|
||||
//
|
||||
// If you're able to rewrite this function without SuppressWarnings, feel free.
|
||||
// But otherwise it works fine.
|
||||
// TODO: BlockStateIdMap
|
||||
// @SuppressWarnings({"rawtypes", "unchecked"})
|
||||
// private static boolean checkState(BlockState state, Map<Property<?>, String> expectedValues) {
|
||||
// for (Map.Entry<Property<?>, String> condition : expectedValues.entrySet()) {
|
||||
// Property property = condition.getKey();
|
||||
// String expectedValue = condition.getValue();
|
||||
//
|
||||
// String actualValue = property.getName(state.getValue(property));
|
||||
//
|
||||
// if (!expectedValue.equals(actualValue)) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
package net.coderbot.iris.block_rendering;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntFunction;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
|
||||
import lombok.Getter;
|
||||
import net.coderbot.iris.shaderpack.materialmap.NamespacedId;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -16,9 +17,10 @@ public class BlockRenderingSettings {
|
||||
|
||||
@Getter
|
||||
private boolean reloadRequired;
|
||||
private Object2IntMap<Block> blockMatches;
|
||||
private Reference2ObjectMap<Block, Int2IntMap> blockMetaMatches;
|
||||
private Map<Block, RenderLayer> blockTypeIds;
|
||||
private Object2IntFunction<NamespacedId> entityIds;
|
||||
private Object2IntFunction<NamespacedId> itemIds;
|
||||
private float ambientOcclusionLevel;
|
||||
private boolean disableDirectionalShading;
|
||||
private boolean useSeparateAo;
|
||||
@@ -26,7 +28,7 @@ public class BlockRenderingSettings {
|
||||
|
||||
public BlockRenderingSettings() {
|
||||
reloadRequired = false;
|
||||
blockMatches = null;
|
||||
blockMetaMatches = null;
|
||||
blockTypeIds = null;
|
||||
ambientOcclusionLevel = 1.0F;
|
||||
disableDirectionalShading = false;
|
||||
@@ -48,8 +50,8 @@ public class BlockRenderingSettings {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Object2IntMap<Block> getBlockMatches() {
|
||||
return blockMatches;
|
||||
public Reference2ObjectMap<Block, Int2IntMap> getBlockMetaMatches() {
|
||||
return blockMetaMatches;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -62,13 +64,14 @@ public class BlockRenderingSettings {
|
||||
return entityIds;
|
||||
}
|
||||
|
||||
public void setBlockMatches(Object2IntMap<Block> blockIds) {
|
||||
if (this.blockMatches != null && this.blockMatches.equals(blockIds)) {
|
||||
return;
|
||||
}
|
||||
@Nullable
|
||||
public Object2IntFunction<NamespacedId> getItemIds() {
|
||||
return itemIds;
|
||||
}
|
||||
|
||||
public void setBlockMetaMatches(Reference2ObjectMap<Block, Int2IntMap> blockMetaIds) {
|
||||
this.reloadRequired = true;
|
||||
this.blockMatches = blockIds;
|
||||
this.blockMetaMatches = blockMetaIds;
|
||||
}
|
||||
|
||||
public void setBlockTypeIds(Map<Block, RenderLayer> blockTypeIds) {
|
||||
@@ -85,6 +88,11 @@ public class BlockRenderingSettings {
|
||||
this.entityIds = entityIds;
|
||||
}
|
||||
|
||||
public void setItemIds(Object2IntFunction<NamespacedId> itemIds) {
|
||||
// note: no reload needed, items are rendered every frame.
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
|
||||
public float getAmbientOcclusionLevel() {
|
||||
return ambientOcclusionLevel;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package net.coderbot.iris.celeritas;
|
||||
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.api.IrisShaderProvider;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.iris.IrisExtendedChunkVertexType;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.coderbot.iris.shadows.ShadowRenderingState;
|
||||
@@ -66,12 +65,6 @@ public class IrisCeleritasShaderProvider implements IrisShaderProvider {
|
||||
return BlockRenderingSettings.INSTANCE.getBlockTypeIds();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object2IntMap<Block> getBlockMatches() {
|
||||
return BlockRenderingSettings.INSTANCE.getBlockMatches();
|
||||
}
|
||||
|
||||
public void deleteShaders() {
|
||||
overrides.deleteShaders();
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ import net.coderbot.iris.texture.pbr.PBRTextureManager;
|
||||
import net.coderbot.iris.texture.pbr.PBRType;
|
||||
import net.coderbot.iris.uniforms.CommonUniforms;
|
||||
import net.coderbot.iris.uniforms.FrameUpdateNotifier;
|
||||
import net.coderbot.iris.uniforms.ItemMaterialHelper;
|
||||
import net.coderbot.iris.uniforms.custom.CustomUniforms;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
@@ -230,11 +231,13 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
holder -> CommonUniforms.addNonDynamicUniforms(holder, programs.getPack().getIdMap(), programs.getPackDirectives(), this.updateNotifier)
|
||||
);
|
||||
|
||||
// TODO: BlockStateIdMap
|
||||
BlockRenderingSettings.INSTANCE.setBlockMatches(BlockMaterialMapping.createBlockStateIdMap(programs.getPack().getIdMap().getBlockProperties()));
|
||||
BlockRenderingSettings.INSTANCE.setBlockMetaMatches(BlockMaterialMapping.createBlockMetaIdMap(programs.getPack().getIdMap().getBlockProperties()));
|
||||
BlockRenderingSettings.INSTANCE.setBlockTypeIds(BlockMaterialMapping.createBlockTypeMap(programs.getPack().getIdMap().getBlockRenderTypeMap()));
|
||||
|
||||
BlockRenderingSettings.INSTANCE.setEntityIds(programs.getPack().getIdMap().getEntityIdMap());
|
||||
|
||||
ItemMaterialHelper.clearCache();
|
||||
BlockRenderingSettings.INSTANCE.setItemIds(programs.getPack().getIdMap().getItemIdMap());
|
||||
BlockRenderingSettings.INSTANCE.setAmbientOcclusionLevel(programs.getPackDirectives().getAmbientOcclusionLevel());
|
||||
BlockRenderingSettings.INSTANCE.setDisableDirectionalShading(shouldDisableDirectionalShading());
|
||||
BlockRenderingSettings.INSTANCE.setUseSeparateAo(programs.getPackDirectives().shouldUseSeparateAo());
|
||||
|
||||
@@ -132,6 +132,82 @@ public class IdMap {
|
||||
return parseIdMap(properties, "entity.", "entity.properties");
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a space-delimited list of identifiers.
|
||||
* Identifiers with spaces or special characters can be enclosed in double quotes.
|
||||
* Use backslash to escape quotes or backslashes within quoted strings.
|
||||
*
|
||||
* Examples (input -> parsed result):
|
||||
* minecraft:stone natura:berry
|
||||
* -> minecraft:stone, natura:berry
|
||||
*
|
||||
* minecraft:stone "Natura:N Crops"
|
||||
* -> minecraft:stone, Natura:N Crops
|
||||
*
|
||||
* "SomeDumbMod:Foo\\ \"Bar\":3"
|
||||
* -> SomeDumbMod:Foo\ "Bar":3
|
||||
*
|
||||
* @param value The space-delimited string to parse
|
||||
* @param fileName The name of the properties file (for error messages)
|
||||
* @param key The property key being parsed (for error messages)
|
||||
* @return List of parsed identifiers
|
||||
*/
|
||||
private static List<String> parseIdentifierList(String value, String fileName, String key) {
|
||||
if (value.indexOf('"') == -1) {
|
||||
String[] parts = value.split("\\s+");
|
||||
List<String> result = new ArrayList<>(parts.length);
|
||||
for (String part : parts) {
|
||||
if (!part.isEmpty()) {
|
||||
result.add(part);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Found quote, start of a dumb block ID
|
||||
List<String> result = new ArrayList<>();
|
||||
StringBuilder current = new StringBuilder();
|
||||
boolean inQuotes = false;
|
||||
boolean escaped = false;
|
||||
|
||||
for (int i = 0; i < value.length(); i++) {
|
||||
char c = value.charAt(i);
|
||||
|
||||
if (escaped) {
|
||||
current.append(c);
|
||||
escaped = false;
|
||||
} else if (c == '\\') {
|
||||
escaped = true;
|
||||
} else if (c == '"') {
|
||||
inQuotes = !inQuotes;
|
||||
} else if (Character.isWhitespace(c) && !inQuotes) {
|
||||
if (current.length() > 0) {
|
||||
result.add(current.toString());
|
||||
current.setLength(0);
|
||||
}
|
||||
} else {
|
||||
current.append(c);
|
||||
}
|
||||
}
|
||||
|
||||
// Didn't close a quote, warn
|
||||
if (inQuotes) {
|
||||
Iris.logger.warn(fileName + " [" + key + "]: Unclosed quote");
|
||||
}
|
||||
|
||||
// Trailing backslash, warn
|
||||
if (escaped) {
|
||||
Iris.logger.warn(fileName + " [" + key + "]: Trailing backslash");
|
||||
}
|
||||
|
||||
// Add final token
|
||||
if (current.length() > 0) {
|
||||
result.add(current.toString());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a NamespacedId map in OptiFine format
|
||||
*/
|
||||
@@ -158,8 +234,8 @@ public class IdMap {
|
||||
return;
|
||||
}
|
||||
|
||||
// Split on any whitespace
|
||||
for (String part : value.split("\\s+")) {
|
||||
// Parse identifiers
|
||||
for (String part : parseIdentifierList(value, fileName, key)) {
|
||||
if (part.contains("=")) {
|
||||
// Avoid tons of logspam for now
|
||||
Iris.logger.warn("Failed to parse an ResourceLocation in " + fileName + " for the key " + key + ": state properties are currently not supported: " + part);
|
||||
@@ -209,8 +285,8 @@ public class IdMap {
|
||||
}
|
||||
}
|
||||
|
||||
// Split on whitespace groups, not just single spaces
|
||||
for (String part : value.toString().split("\\s+")) {
|
||||
// Parse identifiers
|
||||
for (String part : parseIdentifierList(value.toString(), fileName, key)) {
|
||||
if (part.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
@@ -255,7 +331,7 @@ public class IdMap {
|
||||
return;
|
||||
}
|
||||
|
||||
for (String part : value.split("\\s+")) {
|
||||
for (String part : parseIdentifierList(value, fileName, key)) {
|
||||
// Note: NamespacedId performs no validation on the content. That will need to be done by whatever is
|
||||
// converting these things to ResourceLocations.
|
||||
overrides.put(new NamespacedId(part), renderType);
|
||||
|
||||
@@ -34,7 +34,9 @@ public enum ProgramId {
|
||||
Entities(ProgramGroup.Gbuffers, "entities", TexturedLit),
|
||||
EntitiesTrans(ProgramGroup.Gbuffers, "entities_translucent", Entities),
|
||||
EntitiesGlowing(ProgramGroup.Gbuffers, "entities_glowing", Entities),
|
||||
ArmorGlint(ProgramGroup.Gbuffers, "armor_glint", Textured),
|
||||
ArmorGlint(ProgramGroup.Gbuffers, "armor_glint", Textured,
|
||||
new BlendModeOverride(new BlendState(BlendModeFunction.SRC_COLOR.getGlId(), BlendModeFunction.ONE.getGlId(), BlendModeFunction.ONE.getGlId(), BlendModeFunction.ZERO.getGlId()))),
|
||||
// TODO: Figure out why this is needed in 2.x, this worked properly before without needing an override
|
||||
SpiderEyes(ProgramGroup.Gbuffers, "spidereyes", Textured,
|
||||
new BlendModeOverride(new BlendState(BlendModeFunction.SRC_ALPHA.getGlId(), BlendModeFunction.ONE.getGlId(), BlendModeFunction.ZERO.getGlId(), BlendModeFunction.ONE.getGlId()))),
|
||||
|
||||
|
||||
@@ -18,6 +18,10 @@ public class CapturedRenderingState {
|
||||
private int currentRenderedEntity = -1;
|
||||
private Runnable entityIdListener = null;
|
||||
|
||||
@Getter
|
||||
private int currentRenderedItem = -1;
|
||||
private Runnable itemIdListener = null;
|
||||
|
||||
@Getter
|
||||
private final Vector4f currentEntityColor = new Vector4f();
|
||||
private Runnable entityColorListener = null;
|
||||
@@ -53,6 +57,18 @@ public class CapturedRenderingState {
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentRenderedItem(int item) {
|
||||
if (this.currentRenderedItem == item) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.currentRenderedItem = item;
|
||||
|
||||
if (this.itemIdListener != null) {
|
||||
this.itemIdListener.run();
|
||||
}
|
||||
}
|
||||
|
||||
public ValueUpdateNotifier getEntityIdNotifier() {
|
||||
return listener -> this.entityIdListener = listener;
|
||||
}
|
||||
@@ -61,5 +77,9 @@ public class CapturedRenderingState {
|
||||
return listener -> this.blockEntityIdListener = listener;
|
||||
}
|
||||
|
||||
public ValueUpdateNotifier getItemIdNotifier() {
|
||||
return listener -> this.itemIdListener = listener;
|
||||
}
|
||||
|
||||
public ValueUpdateNotifier getEntityColorNotifier() { return listener -> this.entityColorListener = listener; }
|
||||
}
|
||||
@@ -44,6 +44,9 @@ public final class IdMapUniforms {
|
||||
|
||||
uniforms.uniform1i("blockEntityId", CapturedRenderingState.INSTANCE::getCurrentRenderedBlockEntity,
|
||||
CapturedRenderingState.INSTANCE.getBlockEntityIdNotifier());
|
||||
|
||||
uniforms.uniform1i("currentRenderedItemId", CapturedRenderingState.INSTANCE::getCurrentRenderedItem,
|
||||
CapturedRenderingState.INSTANCE.getItemIdNotifier());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
package net.coderbot.iris.uniforms;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntFunction;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.coderbot.iris.shaderpack.materialmap.NamespacedId;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
/**
|
||||
* Helper class for resolving material IDs for items.
|
||||
* Checks both item.properties and block.properties.
|
||||
*/
|
||||
public class ItemMaterialHelper {
|
||||
private static final Reference2ObjectMap<Item, Int2IntMap> MATERIAL_CACHE = new Reference2ObjectOpenHashMap<>();
|
||||
private static final int CACHE_MISS_SENTINEL = Integer.MIN_VALUE;
|
||||
public static final IntSet WARNED_UNKNOWN_ARMOR_INDICES = new IntOpenHashSet();
|
||||
|
||||
/**
|
||||
* Get the material ID for an ItemStack.
|
||||
* Checks item.properties first, then block.properties if the item is an ItemBlock.
|
||||
*
|
||||
* @param itemStack The item stack to get material ID for
|
||||
* @return The material ID, or -1 if not found in either map
|
||||
*/
|
||||
public static int getMaterialId(ItemStack itemStack) {
|
||||
if (itemStack == null || itemStack.getItem() == null) {
|
||||
return -1;
|
||||
}
|
||||
return getMaterialId(itemStack.getItem(), itemStack.getItemDamage());
|
||||
}
|
||||
|
||||
|
||||
public static int getMaterialId(Item item, int metadata) {
|
||||
if (item == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Check cache first
|
||||
Int2IntMap metadataCache = MATERIAL_CACHE.get(item);
|
||||
if (metadataCache != null) {
|
||||
int cached = metadataCache.getOrDefault(metadata, CACHE_MISS_SENTINEL);
|
||||
if (cached != CACHE_MISS_SENTINEL) {
|
||||
return cached;
|
||||
}
|
||||
}
|
||||
|
||||
// Cache miss
|
||||
int materialId = lookupMaterialId(item, metadata);
|
||||
|
||||
if (metadataCache == null) {
|
||||
metadataCache = new Int2IntOpenHashMap();
|
||||
metadataCache.defaultReturnValue(CACHE_MISS_SENTINEL);
|
||||
MATERIAL_CACHE.put(item, metadataCache);
|
||||
}
|
||||
metadataCache.put(metadata, materialId);
|
||||
|
||||
return materialId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the actual material ID lookup without caching.
|
||||
*/
|
||||
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
|
||||
if (item instanceof ItemBlock) {
|
||||
ItemBlock itemBlock = (ItemBlock) item;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Not found in either map
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the material ID cache.
|
||||
* Should be called when shader packs are reloaded
|
||||
*/
|
||||
public static void clearCache() {
|
||||
MATERIAL_CACHE.clear();
|
||||
WARNED_UNKNOWN_ARMOR_INDICES.clear();
|
||||
}
|
||||
}
|
||||
+6
-3
@@ -7,6 +7,7 @@ import com.gtnewhorizons.angelica.mixins.interfaces.IRenderGlobalExt;
|
||||
import com.gtnewhorizons.angelica.rendering.AngelicaRenderQueue;
|
||||
import com.gtnewhorizons.angelica.rendering.RenderingState;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.BlockRenderLayer;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.CeleritasSetup;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.CeleritasWorldRenderer;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.layer.GbufferPrograms;
|
||||
@@ -17,6 +18,7 @@ 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;
|
||||
import net.minecraft.client.renderer.culling.ICamera;
|
||||
@@ -63,9 +65,9 @@ public class MixinRenderGlobal implements IRenderGlobalExt {
|
||||
}
|
||||
|
||||
@Redirect(method = "<init>(Lnet/minecraft/client/Minecraft;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GLAllocation;generateDisplayLists(I)I", ordinal = 0))
|
||||
private int celeritas$skipDisplayListAllocation(int count) {
|
||||
// Skip allocation - celeritas replaces WorldRenderer with its own rendering system
|
||||
return 0;
|
||||
private int celeritas$minimizeDisplayListAllocation(int count) {
|
||||
// Minimize allocation - celeritas replaces WorldRenderer with its own rendering system
|
||||
return GLAllocation.generateDisplayLists(3);
|
||||
}
|
||||
|
||||
@Redirect(method = "loadRenderers", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/RenderGlobal;renderDistanceChunks:I", opcode = Opcodes.GETFIELD, ordinal = 0))
|
||||
@@ -212,6 +214,7 @@ public class MixinRenderGlobal implements IRenderGlobalExt {
|
||||
|
||||
@Unique
|
||||
public void angelica$reload() {
|
||||
CeleritasSetup.ensureInitialized();
|
||||
RenderDevice.enterManagedCode();
|
||||
try {
|
||||
this.celeritas$renderer.reload();
|
||||
|
||||
+67
-4
@@ -1,25 +1,88 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.shaders;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.InteractionHand;
|
||||
import net.coderbot.iris.gbuffer_overrides.matching.SpecialCondition;
|
||||
import net.coderbot.iris.layer.GbufferPrograms;
|
||||
import net.coderbot.iris.pipeline.HandRenderer;
|
||||
import net.coderbot.iris.uniforms.CapturedRenderingState;
|
||||
import net.coderbot.iris.uniforms.ItemMaterialHelper;
|
||||
import net.irisshaders.iris.api.v0.IrisApi;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
/**
|
||||
* Mixin to handle hand rendering and item ID tracking.
|
||||
*/
|
||||
@Mixin(ItemRenderer.class)
|
||||
public class MixinItemRenderer {
|
||||
@Inject(method = "renderItemInFirstPerson", at = @At("HEAD"), cancellable = true)
|
||||
private void iris$skipTranslucentHands(float partialTicks, CallbackInfo ci) {
|
||||
private void iris$handleFirstPersonRender(float partialTicks, CallbackInfo ci) {
|
||||
if (IrisApi.getInstance().isShaderPackInUse()) {
|
||||
boolean isHandTranslucent = HandRenderer.INSTANCE.isHandTranslucent(InteractionHand.MAIN_HAND);
|
||||
if (HandRenderer.INSTANCE.isRenderingSolid() && isHandTranslucent) {
|
||||
ci.cancel();
|
||||
} else if (!HandRenderer.INSTANCE.isRenderingSolid() && !isHandTranslucent) {
|
||||
boolean isRenderingSolid = HandRenderer.INSTANCE.isRenderingSolid();
|
||||
|
||||
if (isRenderingSolid == isHandTranslucent) {
|
||||
ci.cancel();
|
||||
return; // Don't set item ID since we're cancelling
|
||||
}
|
||||
}
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if (mc.thePlayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack itemStack = mc.thePlayer.getCurrentEquippedItem();
|
||||
|
||||
if (itemStack == null || itemStack.getItem() == null) {
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get material ID from item.properties or block.properties
|
||||
int id = ItemMaterialHelper.getMaterialId(itemStack);
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate GLINT shader before rendering enchantment glint on held items.
|
||||
* Injects at the first glDepthFunc inside the if(hasEffect) block.
|
||||
*/
|
||||
@Inject(
|
||||
method = "renderItem(Lnet/minecraft/entity/EntityLivingBase;Lnet/minecraft/item/ItemStack;ILnet/minecraftforge/client/IItemRenderer$ItemRenderType;)V",
|
||||
at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glDepthFunc(I)V", ordinal = 0),
|
||||
remap = false
|
||||
)
|
||||
private void iris$activateGlintShaderHeldItem(net.minecraft.entity.EntityLivingBase entity, ItemStack itemStack, int renderPass, net.minecraftforge.client.IItemRenderer.ItemRenderType type, CallbackInfo ci) {
|
||||
GbufferPrograms.setupSpecialRenderCondition(SpecialCondition.GLINT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deactivate GLINT shader after rendering enchantment glint on held items.
|
||||
* Injects at the last glDepthFunc inside the if(hasEffect) block.
|
||||
*/
|
||||
@Inject(
|
||||
method = "renderItem(Lnet/minecraft/entity/EntityLivingBase;Lnet/minecraft/item/ItemStack;ILnet/minecraftforge/client/IItemRenderer$ItemRenderType;)V",
|
||||
at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glDepthFunc(I)V", ordinal = 1, shift = At.Shift.AFTER),
|
||||
remap = false
|
||||
)
|
||||
private void iris$deactivateGlintShaderHeldItem(net.minecraft.entity.EntityLivingBase entity, ItemStack itemStack, int renderPass, net.minecraftforge.client.IItemRenderer.ItemRenderType type, CallbackInfo ci) {
|
||||
GbufferPrograms.teardownSpecialRenderCondition();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the item ID after rendering first-person items.
|
||||
*/
|
||||
@Inject(
|
||||
method = "renderItemInFirstPerson",
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void iris$resetHeldItemId(float partialTicks, CallbackInfo ci) {
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(-1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
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.uniforms.CapturedRenderingState;
|
||||
import net.coderbot.iris.uniforms.ItemMaterialHelper;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.renderer.entity.RenderBiped;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
|
||||
/**
|
||||
* Mixin to set the currentRenderedItem ID when rendering armor on entities.
|
||||
* This allows shaders to identify and apply different materials to armor pieces.
|
||||
*/
|
||||
@Mixin(RenderBiped.class)
|
||||
public class MixinRenderBiped {
|
||||
|
||||
/**
|
||||
* Set the item ID when rendering armor.
|
||||
* Wraps the setRenderPassModel call to inject our ID setting logic.
|
||||
*/
|
||||
@WrapOperation(
|
||||
method = "shouldRenderPass(Lnet/minecraft/entity/EntityLiving;IF)I",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/RenderBiped;setRenderPassModel(Lnet/minecraft/client/model/ModelBase;)V")
|
||||
)
|
||||
private void iris$setArmorItemId(RenderBiped instance, ModelBase model, Operation<Void> original, EntityLiving entity, int armorSlot, float partialTicks) {
|
||||
// Get the armor item stack for this slot
|
||||
ItemStack itemStack = entity.func_130225_q(3 - armorSlot);
|
||||
|
||||
if (itemStack == null || itemStack.getItem() == null) {
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(-1);
|
||||
original.call(instance, model);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get material ID from item.properties or block.properties
|
||||
int id = ItemMaterialHelper.getMaterialId(itemStack);
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(id);
|
||||
|
||||
// Call original method
|
||||
original.call(instance, model);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the item ID at the start of rendering each entity.
|
||||
* This ensures a clean slate and prevents ID bleed between entities.
|
||||
*/
|
||||
@Inject(
|
||||
method = "doRender(Lnet/minecraft/entity/EntityLiving;DDDFF)V",
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the item ID at the start of renderEquippedItems.
|
||||
* This prevents armor IDs from bleeding into held item rendering.
|
||||
*/
|
||||
@Inject(
|
||||
method = "renderEquippedItems(Lnet/minecraft/entity/EntityLiving;F)V",
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void iris$resetInEquippedItems(EntityLiving entity, float partialTicks, org.spongepowered.asm.mixin.injection.callback.CallbackInfo ci) {
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(-1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the item ID when rendering held items in third person.
|
||||
* Wraps renderItem calls to set the ID based on the held item.
|
||||
*/
|
||||
@WrapOperation(
|
||||
method = "renderEquippedItems(Lnet/minecraft/entity/EntityLiving;F)V",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/ItemRenderer;renderItem(Lnet/minecraft/entity/EntityLivingBase;Lnet/minecraft/item/ItemStack;I)V")
|
||||
)
|
||||
private void iris$setHeldItemId(net.minecraft.client.renderer.ItemRenderer itemRenderer, net.minecraft.entity.EntityLivingBase entity, ItemStack itemStack, int renderPass, Operation<Void> original) {
|
||||
if (itemStack == null || itemStack.getItem() == null) {
|
||||
original.call(itemRenderer, entity, itemStack, renderPass);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get material ID from item.properties or block.properties
|
||||
int id = ItemMaterialHelper.getMaterialId(itemStack);
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(id);
|
||||
|
||||
original.call(itemRenderer, entity, itemStack, renderPass);
|
||||
|
||||
// Reset after rendering the held item
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(-1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
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.uniforms.CapturedRenderingState;
|
||||
import net.coderbot.iris.uniforms.ItemMaterialHelper;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.renderer.entity.RenderHorse;
|
||||
import net.minecraft.entity.passive.EntityHorse;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
/**
|
||||
* Mixin to set the currentRenderedItem ID when rendering horse armor.
|
||||
* This allows shaders to identify and apply different materials to horse armor.
|
||||
*/
|
||||
@Mixin(RenderHorse.class)
|
||||
public abstract class MixinRenderHorse {
|
||||
private static final Logger LOGGER = LogManager.getLogger("Angelica");
|
||||
|
||||
/**
|
||||
* Set the item ID when rendering the horse model if it has armor.
|
||||
* Wraps the mainModel.render() call to set the material ID only around the actual render.
|
||||
*/
|
||||
@WrapOperation(
|
||||
method = "renderModel(Lnet/minecraft/entity/passive/EntityHorse;FFFFFF)V",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/model/ModelBase;render(Lnet/minecraft/entity/Entity;FFFFFF)V")
|
||||
)
|
||||
private void iris$setHorseArmorItemId(ModelBase model, net.minecraft.entity.Entity entity, float p1, float p2, float p3, float p4, float p5, float p6, Operation<Void> original, EntityHorse horse) {
|
||||
// Only set ID if horse has armor equipped
|
||||
boolean hasArmor = false;
|
||||
|
||||
// Check if horse type == 0 (regular horse)
|
||||
if (horse.func_110259_cr()) {
|
||||
// Get armor index from DataWatcher (synced from server)
|
||||
int armorIndex = horse.func_110241_cb();
|
||||
|
||||
if (armorIndex > 0) {
|
||||
// Map armor index to vanilla items
|
||||
Item armorItem = null;
|
||||
switch (armorIndex) {
|
||||
case 1:
|
||||
armorItem = Items.iron_horse_armor;
|
||||
break;
|
||||
case 2:
|
||||
armorItem = Items.golden_horse_armor;
|
||||
break;
|
||||
case 3:
|
||||
armorItem = Items.diamond_horse_armor;
|
||||
break;
|
||||
default:
|
||||
// Unknown armor index - likely from a mod
|
||||
// Warn once per unique index to avoid spam
|
||||
if (!ItemMaterialHelper.WARNED_UNKNOWN_ARMOR_INDICES.contains(armorIndex)) {
|
||||
ItemMaterialHelper.WARNED_UNKNOWN_ARMOR_INDICES.add(armorIndex);
|
||||
LOGGER.warn("Unknown horse armor index detected: {}. " +
|
||||
"This is likely from a mod. Vanilla horse armor uses indices 1-3 (iron/gold/diamond). " +
|
||||
"Modded horse armor material IDs are not currently supported.", armorIndex);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (armorItem != null) {
|
||||
// Get material ID from item.properties
|
||||
int id = ItemMaterialHelper.getMaterialId(armorItem, 0);
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(id);
|
||||
hasArmor = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Call original render
|
||||
original.call(model, entity, p1, p2, p3, p4, p5, p6);
|
||||
|
||||
// Reset only if we set it
|
||||
if (hasArmor) {
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.shaders;
|
||||
|
||||
import net.coderbot.iris.gbuffer_overrides.matching.SpecialCondition;
|
||||
import net.coderbot.iris.layer.GbufferPrograms;
|
||||
import net.coderbot.iris.uniforms.CapturedRenderingState;
|
||||
import net.coderbot.iris.uniforms.ItemMaterialHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
/**
|
||||
* Mixin to set the currentRenderedItem ID when rendering dropped items (EntityItem).
|
||||
* This allows shaders to identify and apply different materials to items on the ground.
|
||||
*/
|
||||
@Mixin(RenderItem.class)
|
||||
public class MixinRenderItem {
|
||||
|
||||
/**
|
||||
* Set the item ID before rendering dropped items.
|
||||
* Checks both item.properties and block.properties.
|
||||
*/
|
||||
@Inject(
|
||||
method = "doRender(Lnet/minecraft/entity/item/EntityItem;DDDFF)V",
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void iris$setItemIdBeforeRender(net.minecraft.entity.item.EntityItem entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci) {
|
||||
ItemStack itemStack = entity.getEntityItem();
|
||||
|
||||
// Get material ID from item.properties or block.properties
|
||||
int id = ItemMaterialHelper.getMaterialId(itemStack);
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate GLINT shader before rendering enchantment glint.
|
||||
* Injects at the first glDepthFunc inside the if(hasEffect) block.
|
||||
*/
|
||||
@Inject(
|
||||
method = "renderDroppedItem(Lnet/minecraft/entity/item/EntityItem;Lnet/minecraft/util/IIcon;IFFFFI)V",
|
||||
at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glDepthFunc(I)V", ordinal = 0),
|
||||
remap = false
|
||||
)
|
||||
private void iris$activateGlintShader(net.minecraft.entity.item.EntityItem entity, net.minecraft.util.IIcon icon, int count, float partialTicks, float r, float g, float b, int pass, CallbackInfo ci) {
|
||||
GbufferPrograms.setupSpecialRenderCondition(SpecialCondition.GLINT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deactivate GLINT shader after rendering enchantment glint.
|
||||
* Injects at the last glDepthFunc inside the if(hasEffect) block.
|
||||
*/
|
||||
@Inject(
|
||||
method = "renderDroppedItem(Lnet/minecraft/entity/item/EntityItem;Lnet/minecraft/util/IIcon;IFFFFI)V",
|
||||
at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glDepthFunc(I)V", ordinal = 1, shift = At.Shift.AFTER),
|
||||
remap = false
|
||||
)
|
||||
private void iris$deactivateGlintShader(net.minecraft.entity.item.EntityItem entity, net.minecraft.util.IIcon icon, int count, float partialTicks, float r, float g, float b, int pass, CallbackInfo ci) {
|
||||
GbufferPrograms.teardownSpecialRenderCondition();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the item ID after rendering dropped items.
|
||||
*/
|
||||
@Inject(
|
||||
method = "doRender(Lnet/minecraft/entity/item/EntityItem;DDDFF)V",
|
||||
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);
|
||||
}
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
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.uniforms.CapturedRenderingState;
|
||||
import net.coderbot.iris.uniforms.ItemMaterialHelper;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
|
||||
/**
|
||||
* Mixin to set the currentRenderedItem ID when rendering armor on the player.
|
||||
* This allows shaders to identify and apply different materials to player armor pieces.
|
||||
*/
|
||||
@Mixin(RenderPlayer.class)
|
||||
public class MixinRenderPlayerArmor {
|
||||
|
||||
/**
|
||||
* Set the item ID when rendering player armor.
|
||||
* Wraps the setRenderPassModel call to inject our ID setting logic.
|
||||
*/
|
||||
@WrapOperation(
|
||||
method = "shouldRenderPass(Lnet/minecraft/client/entity/AbstractClientPlayer;IF)I",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/RenderPlayer;setRenderPassModel(Lnet/minecraft/client/model/ModelBase;)V")
|
||||
)
|
||||
private void iris$setArmorItemId(RenderPlayer instance, ModelBase model, Operation<Void> original, AbstractClientPlayer player, int armorSlot, float partialTicks) {
|
||||
// Get the armor item stack for this slot
|
||||
ItemStack itemStack = player.getCurrentArmor(3 - armorSlot);
|
||||
|
||||
if (itemStack == null || itemStack.getItem() == null) {
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(-1);
|
||||
original.call(instance, model);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get material ID from item.properties or block.properties
|
||||
int id = ItemMaterialHelper.getMaterialId(itemStack);
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(id);
|
||||
|
||||
// Call original method
|
||||
original.call(instance, model);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the item ID at the start of rendering each player.
|
||||
* This ensures a clean slate and prevents ID bleed between entities.
|
||||
*/
|
||||
@Inject(
|
||||
method = "doRender(Lnet/minecraft/client/entity/AbstractClientPlayer;DDDFF)V",
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the item ID at the start of renderEquippedItems.
|
||||
* This prevents armor IDs from bleeding into cape/held items rendering.
|
||||
*/
|
||||
@Inject(
|
||||
method = "renderEquippedItems(Lnet/minecraft/client/entity/AbstractClientPlayer;F)V",
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void iris$resetInEquippedItems(AbstractClientPlayer player, float partialTicks, org.spongepowered.asm.mixin.injection.callback.CallbackInfo ci) {
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(-1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the item ID when rendering held items in third person.
|
||||
* Wraps renderItem calls to set the ID based on the held item.
|
||||
*/
|
||||
@WrapOperation(
|
||||
method = "renderEquippedItems(Lnet/minecraft/client/entity/AbstractClientPlayer;F)V",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/ItemRenderer;renderItem(Lnet/minecraft/entity/EntityLivingBase;Lnet/minecraft/item/ItemStack;I)V")
|
||||
)
|
||||
private void iris$setHeldItemId(net.minecraft.client.renderer.ItemRenderer itemRenderer, net.minecraft.entity.EntityLivingBase entity, ItemStack itemStack, int renderPass, Operation<Void> original) {
|
||||
if (itemStack == null || itemStack.getItem() == null) {
|
||||
original.call(itemRenderer, entity, itemStack, renderPass);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get material ID from item.properties or block.properties
|
||||
int id = ItemMaterialHelper.getMaterialId(itemStack);
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(id);
|
||||
|
||||
original.call(itemRenderer, entity, itemStack, renderPass);
|
||||
|
||||
// Reset after rendering the held item
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(-1);
|
||||
}
|
||||
}
|
||||
+28
@@ -14,7 +14,9 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Slice;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(RendererLivingEntity.class)
|
||||
public class MixinRendererLivingEntity {
|
||||
@@ -49,4 +51,30 @@ public class MixinRendererLivingEntity {
|
||||
original.call(instance, entity, p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, p_78088_7_);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate GLINT shader before rendering armor enchantment glint.
|
||||
* Injects at the first glDepthFunc inside the armor glint rendering block.
|
||||
*/
|
||||
@Inject(
|
||||
method = "doRender(Lnet/minecraft/entity/EntityLivingBase;DDDFF)V",
|
||||
at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glDepthFunc(I)V", ordinal = 0),
|
||||
remap = false
|
||||
)
|
||||
private void iris$activateArmorGlintShader(EntityLivingBase entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci) {
|
||||
GbufferPrograms.setupSpecialRenderCondition(SpecialCondition.GLINT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deactivate GLINT shader after rendering armor enchantment glint.
|
||||
* Injects at the last glDepthFunc inside the armor glint rendering block.
|
||||
*/
|
||||
@Inject(
|
||||
method = "doRender(Lnet/minecraft/entity/EntityLivingBase;DDDFF)V",
|
||||
at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glDepthFunc(I)V", ordinal = 1, shift = At.Shift.AFTER),
|
||||
remap = false
|
||||
)
|
||||
private void iris$deactivateArmorGlintShader(EntityLivingBase entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci) {
|
||||
GbufferPrograms.teardownSpecialRenderCondition();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user