mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-26 07:03:02 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2836735922 |
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.api.shaders;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import net.coderbot.iris.block_rendering.BlockMaterialMapping;
|
||||
import net.coderbot.iris.uniforms.CapturedRenderingState;
|
||||
import net.coderbot.iris.uniforms.SystemTimeUniforms;
|
||||
import net.irisshaders.iris.api.v0.IrisApi;
|
||||
@@ -28,4 +29,13 @@ public final class ShaderPacks {
|
||||
if (!AngelicaConfig.enableIris) return;
|
||||
CapturedRenderingState.INSTANCE.popCurrentBlockEntity();
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes shaderpacks treat {@code alias} as {@code target} (same block.properties material IDs and render layer),
|
||||
* e.g. a modded water block aliased to {@code Blocks.water}. Packs that map {@code alias} explicitly take
|
||||
* precedence. Register during init, before the first shaderpack load.
|
||||
*/
|
||||
public static void registerBlockAlias(Block alias, Block target) {
|
||||
BlockMaterialMapping.registerAlias(alias, target);
|
||||
}
|
||||
}
|
||||
-4
@@ -283,10 +283,6 @@ public class DarkModeFontTransform {
|
||||
RecolorTarget.excludeMethodCall(
|
||||
new MethodInfo("gregtech.api.recipe.RecipeMapFrontend drawNEIOverlayText(Ljava/lang/String;Lcodechicken/nei/PositionedStack;IFZLcom/gtnewhorizons/modularui/api/math/Alignment;)V"),
|
||||
new MethodInfo("net.minecraft.client.gui.FontRenderer func_85187_a(Ljava/lang/String;IIIZ)I # drawString")
|
||||
),
|
||||
RecolorTarget.excludeMethodCall(
|
||||
new MethodInfo("gregtech.nei.GTNEIDefaultHandler$FixedPositionedStack draw(II)V"),
|
||||
new MethodInfo("net.minecraft.client.gui.FontRenderer func_85187_a(Ljava/lang/String;IIIZ)I # drawString")
|
||||
),
|
||||
// GT NEI Ore Plugin
|
||||
RecolorTarget.excludeMethodCall(
|
||||
|
||||
@@ -22,6 +22,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
public class BlockMaterialMapping {
|
||||
|
||||
@@ -34,6 +35,24 @@ public class BlockMaterialMapping {
|
||||
|
||||
public static final int WILDCARD_META_KEY = 1 << 30;
|
||||
|
||||
// alias -> target; alias blocks inherit the target's shader IDs and render layer
|
||||
private static final Map<Block, Block> BLOCK_ALIASES = new Reference2ReferenceOpenHashMap<>();
|
||||
|
||||
/**
|
||||
* Makes {@code alias} resolve to the same shader material IDs and render layer as {@code target}, unless the
|
||||
* shaderpack maps {@code alias} itself. Takes effect on the next shaderpack load.
|
||||
*/
|
||||
public static void registerAlias(Block alias, Block target) {
|
||||
BLOCK_ALIASES.put(alias, target);
|
||||
}
|
||||
|
||||
private static <V> void applyAliases(Map<Block, V> map, UnaryOperator<V> copy) {
|
||||
BLOCK_ALIASES.forEach((alias, target) -> {
|
||||
final V value = map.get(target);
|
||||
if (value != null && !map.containsKey(alias)) map.put(alias, copy.apply(value));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the standard block meta ID map, the TileEntity NBT-conditional map, and registers
|
||||
* snowy blocks on {@link BlockRenderingSettings}.
|
||||
@@ -53,6 +72,12 @@ public class BlockMaterialMapping {
|
||||
}
|
||||
});
|
||||
|
||||
applyAliases(blockMatches, metaMap -> {
|
||||
final Int2IntMap copy = new Int2IntOpenHashMap(metaMap);
|
||||
copy.defaultReturnValue(-1);
|
||||
return copy;
|
||||
});
|
||||
|
||||
BlockRenderingSettings.INSTANCE.setHasSnowyEntries(!snowyBlocks.isEmpty());
|
||||
BlockRenderingSettings.INSTANCE.setSnowyBlocks(snowyBlocks);
|
||||
return new BlockIdMaps(blockMatches, tileEntityMap);
|
||||
@@ -78,6 +103,8 @@ public class BlockMaterialMapping {
|
||||
if (layer != null) blockTypeIds.put(block, layer);
|
||||
});
|
||||
|
||||
applyAliases(blockTypeIds, UnaryOperator.identity());
|
||||
|
||||
return blockTypeIds;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user