Made default CacheLayer add method insert before 'normal'

This commit is contained in:
Anuken
2023-05-15 22:54:10 -04:00
parent 1289e20990
commit 8b35b44489
5 changed files with 30 additions and 2 deletions

View File

@@ -18,8 +18,16 @@ public class CacheLayer{
public int id;
/** Register a new CacheLayer. */
/** Registers cache layers that will render before the 'normal' layer. */
public static void add(CacheLayer... layers){
for(var layer : layers){
//7 = 'normal' index
add(7, layer);
}
}
/** Register CacheLayers at the end of the array. This will render over "normal" tiles. This is likely not the method you want to use. */
public static void addLast(CacheLayer... layers){
int newSize = all.length + layers.length;
var prev = all;
//reallocate the array and copy everything over; performance matters very little here anyway
@@ -43,11 +51,15 @@ public class CacheLayer{
System.arraycopy(prev, index, all, index + 1, prev.length - index);
all[index] = layer;
for(int i = 0; i < all.length; i++){
all[i].id = i;
}
}
/** Loads default cache layers. */
public static void init(){
add(
addLast(
water = new ShaderLayer(Shaders.water),
mud = new ShaderLayer(Shaders.mud),
tar = new ShaderLayer(Shaders.tar),