Added getOrDefault
@@ -8,6 +8,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.network.Packet;
import net.minecraft.util.math.Vec3d;
+import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
@@ -99,6 +100,10 @@ public class Utils implements Globals {
return value == null ? defaultTo : value;
}
+ public static <T> T getOrDefault(Collection<T> collection, int index, T defaultTo) {
+ return collection.stream().skip(index).findFirst().orElse(defaultTo);
+ }
+
@Deprecated
public static class Colors {
public final static int WHITE = Utils.toRGBA(255, 255, 255, 255);
