mirror of
https://github.com/FabricMC/fabric.git
synced 2025-04-21 03:10:54 -04:00
Add methods for setting multiple objects' render layer with one call
This commit is contained in:
parent
06c939b35c
commit
616c2e29a4
2 changed files with 48 additions and 0 deletions
fabric-blockrenderlayer-v1/src/main/java/net/fabricmc/fabric
|
@ -47,6 +47,15 @@ public interface BlockRenderLayerMap {
|
|||
*/
|
||||
void putBlock(Block block, RenderLayer renderLayer);
|
||||
|
||||
/**
|
||||
* Map (or re-map) multiple block states with a render layer. Re-mapping is not recommended but if done, last one in wins.
|
||||
* Must be called from client thread prior to world load/rendering. Best practice will be to call from mod's client initializer.
|
||||
*
|
||||
* @param renderLayer Render layer. Should be one of the layers used for terrain rendering.
|
||||
* @param blocks Identifies blocks to be mapped.
|
||||
*/
|
||||
void putBlocks(RenderLayer renderLayer, Block... blocks);
|
||||
|
||||
/**
|
||||
* Map (or re-map) a item with a render layer. Re-mapping is not recommended but if done, last one in wins.
|
||||
* Must be called from client thread prior to world load/rendering. Best practice will be to call from mod's client initializer.
|
||||
|
@ -56,6 +65,15 @@ public interface BlockRenderLayerMap {
|
|||
*/
|
||||
void putItem(Item item, RenderLayer renderLayer);
|
||||
|
||||
/**
|
||||
* Map (or re-map) multiple items with a render layer. Re-mapping is not recommended but if done, last one in wins.
|
||||
* Must be called from client thread prior to world load/rendering. Best practice will be to call from mod's client initializer.
|
||||
*
|
||||
* @param renderLayer Render layer. Should be one of the layers used for entity rendering.
|
||||
* @param items Identifies items to be mapped.
|
||||
*/
|
||||
void putItems(RenderLayer renderLayer, Item... items);
|
||||
|
||||
/**
|
||||
* Map (or re-map) a fluid state with a render layer. Re-mapping is not recommended but if done, last one in wins.
|
||||
* Must be called from client thread prior to world load/rendering. Best practice will be to call from mod's client initializer.
|
||||
|
@ -64,4 +82,13 @@ public interface BlockRenderLayerMap {
|
|||
* @param renderLayer Render layer. Should be one of the layers used for terrain rendering.
|
||||
*/
|
||||
void putFluid(Fluid fluid, RenderLayer renderLayer);
|
||||
|
||||
/**
|
||||
* Map (or re-map) multiple fluid states with a render layer. Re-mapping is not recommended but if done, last one in wins.
|
||||
* Must be called from client thread prior to world load/rendering. Best practice will be to call from mod's client initializer.
|
||||
*
|
||||
* @param renderLayer Render layer. Should be one of the layers used for terrain rendering.
|
||||
* @param fluids Identifies fluids to be mapped.
|
||||
*/
|
||||
void putFluids(RenderLayer renderLayer, Fluid... fluids);
|
||||
}
|
||||
|
|
|
@ -38,6 +38,13 @@ public class BlockRenderLayerMapImpl implements BlockRenderLayerMap {
|
|||
blockHandler.accept(block, renderLayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putBlocks(RenderLayer renderLayer, Block... blocks) {
|
||||
for (Block block : blocks) {
|
||||
putBlock(block, renderLayer);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putItem(Item item, RenderLayer renderLayer) {
|
||||
if (item == null) throw new IllegalArgumentException("Request to map null item to BlockRenderLayer");
|
||||
|
@ -46,6 +53,13 @@ public class BlockRenderLayerMapImpl implements BlockRenderLayerMap {
|
|||
itemHandler.accept(item, renderLayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putItems(RenderLayer renderLayer, Item... items) {
|
||||
for (Item item : items) {
|
||||
putItem(item, renderLayer);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putFluid(Fluid fluid, RenderLayer renderLayer) {
|
||||
if (fluid == null) throw new IllegalArgumentException("Request to map null fluid to BlockRenderLayer");
|
||||
|
@ -54,6 +68,13 @@ public class BlockRenderLayerMapImpl implements BlockRenderLayerMap {
|
|||
fluidHandler.accept(fluid, renderLayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putFluids(RenderLayer renderLayer, Fluid... fluids) {
|
||||
for (Fluid fluid : fluids) {
|
||||
putFluid(fluid, renderLayer);
|
||||
}
|
||||
}
|
||||
|
||||
public static final BlockRenderLayerMap INSTANCE = new BlockRenderLayerMapImpl();
|
||||
|
||||
private static Map<Block, RenderLayer> blockRenderLayerMap = new HashMap<>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue