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

@@ -173,6 +173,7 @@ public interface Platform{
String result = OS.exec(args.toArray(String.class));
//cancelled selection, ignore result
if(result.isEmpty() || result.equals("\n")) return;
if(result.endsWith("\n")) result = result.substring(0, result.length() - 1);

View File

@@ -44,6 +44,11 @@ public abstract class Content implements Comparable<Content>{
return minfo.mod == null;
}
/** @return whether this content is from a mod. */
public boolean isModded(){
return !isVanilla();
}
@Override
public int compareTo(Content c){
return Integer.compare(id, c.id);

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),

View File

@@ -116,6 +116,11 @@ public class Stat implements Comparable<Stat>{
return Core.bundle.get("stat." + name.toLowerCase(Locale.ROOT));
}
@Override
public String toString(){
return name;
}
@Override
public int compareTo(Stat o){
return id - o.id;

View File

@@ -30,6 +30,11 @@ public class StatCat implements Comparable<StatCat>{
return Core.bundle.get("category." + name);
}
@Override
public String toString(){
return name;
}
@Override
public int compareTo(StatCat o){
return id - o.id;