mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-27 15:43: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;
|
package com.gtnewhorizons.angelica.api.shaders;
|
||||||
|
|
||||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||||
|
import net.coderbot.iris.block_rendering.BlockMaterialMapping;
|
||||||
import net.coderbot.iris.uniforms.CapturedRenderingState;
|
import net.coderbot.iris.uniforms.CapturedRenderingState;
|
||||||
import net.coderbot.iris.uniforms.SystemTimeUniforms;
|
import net.coderbot.iris.uniforms.SystemTimeUniforms;
|
||||||
import net.irisshaders.iris.api.v0.IrisApi;
|
import net.irisshaders.iris.api.v0.IrisApi;
|
||||||
@@ -28,4 +29,13 @@ public final class ShaderPacks {
|
|||||||
if (!AngelicaConfig.enableIris) return;
|
if (!AngelicaConfig.enableIris) return;
|
||||||
CapturedRenderingState.INSTANCE.popCurrentBlockEntity();
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -22,6 +22,7 @@ import net.minecraft.util.ResourceLocation;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.function.UnaryOperator;
|
||||||
|
|
||||||
public class BlockMaterialMapping {
|
public class BlockMaterialMapping {
|
||||||
|
|
||||||
@@ -34,6 +35,24 @@ public class BlockMaterialMapping {
|
|||||||
|
|
||||||
public static final int WILDCARD_META_KEY = 1 << 30;
|
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
|
* Creates the standard block meta ID map, the TileEntity NBT-conditional map, and registers
|
||||||
* snowy blocks on {@link BlockRenderingSettings}.
|
* 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.setHasSnowyEntries(!snowyBlocks.isEmpty());
|
||||||
BlockRenderingSettings.INSTANCE.setSnowyBlocks(snowyBlocks);
|
BlockRenderingSettings.INSTANCE.setSnowyBlocks(snowyBlocks);
|
||||||
return new BlockIdMaps(blockMatches, tileEntityMap);
|
return new BlockIdMaps(blockMatches, tileEntityMap);
|
||||||
@@ -78,6 +103,8 @@ public class BlockMaterialMapping {
|
|||||||
if (layer != null) blockTypeIds.put(block, layer);
|
if (layer != null) blockTypeIds.put(block, layer);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
applyAliases(blockTypeIds, UnaryOperator.identity());
|
||||||
|
|
||||||
return blockTypeIds;
|
return blockTypeIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user