Made lots of things use java 8 and added access wideners for different versions

This commit is contained in:
coolGi2007
2022-04-02 19:29:01 +10:30
parent 6d12acc30a
commit a12f2e9e01
5 changed files with 62 additions and 55 deletions
@@ -7,18 +7,22 @@ public enum RendererType {
;
public static RendererType next(RendererType type) {
return switch (type) {
case DEFAULT -> DEBUG;
case DEBUG -> DISABLED;
default -> DEFAULT;
RendererType rendererType;
switch (type) {
case DEFAULT: rendererType = DEBUG;
case DEBUG: rendererType = DISABLED;
default: rendererType = DEFAULT;
};
return rendererType;
}
public static RendererType previous(RendererType type) {
return switch (type) {
case DEFAULT -> DISABLED;
case DEBUG -> DEFAULT;
default -> DEBUG;
RendererType rendererType;
switch (type) {
case DEFAULT: rendererType = DISABLED;
case DEBUG: rendererType = DEFAULT;
default: rendererType = DEBUG;
};
return rendererType;
}
}
@@ -118,18 +118,18 @@ public class LodFogConfig
str.append("// =======RUNTIME GENERATED DEFINE SECTION========\n#version 150 core\n");
if (farFogSetting == null) {
str.append("""
#define farFogStart 0.0
#define farFogLength 0.0
#define farFogMin 0.0
#define farFogRange 0.0
#define farFogDensity 0.0
#define heightFogStart 0.0
#define heightFogLength 0.0
#define heightFogMin 0.0
#define heightFogRange 0.0
#define heightFogDensity 0.0
""");
str.append(""+
"#define farFogStart 0.0"+
"#define farFogLength 0.0"+
"#define farFogMin 0.0"+
"#define farFogRange 0.0"+
"#define farFogDensity 0.0"+
"#define heightFogStart 0.0"+
"#define heightFogLength 0.0"+
"#define heightFogMin 0.0"+
"#define heightFogRange 0.0"+
"#define heightFogDensity 0.0"+
"");
} else {
str.append("\n#define farFogStart ");
str.append(farFogSetting.start);
@@ -144,13 +144,13 @@ public class LodFogConfig
str.append("\n");
if (heightFogSetting == null) {
str.append("""
#define heightFogStart 0.0
#define heightFogLength 0.0
#define heightFogMin 0.0
#define heightFogRange 0.0
#define heightFogDensity 0.0
""");
str.append(""+
"#define heightFogStart 0.0"+
"#define heightFogLength 0.0"+
"#define heightFogMin 0.0"+
"#define heightFogRange 0.0"+
"#define heightFogDensity 0.0"+
"");
} else {
str.append("\n#define heightFogStart ");
str.append(heightFogSetting.start);
@@ -238,25 +238,25 @@ public class LodFogConfig
// Generate method: float getNearFogThickness(float dist);
if (drawNearFog) {
str.append("""
float getNearFogThickness(float dist) {
return linearFog(dist, nearFogStart, nearFogLength, 1.0, -1.0);
}
""");
str.append(""+
"float getNearFogThickness(float dist) {"+
" return linearFog(dist, nearFogStart, nearFogLength, 1.0, -1.0);"+
"}"+
"");
} else {
str.append("""
float getNearFogThickness(float dist) {return 0.0;}
""");
str.append(""+
"float getNearFogThickness(float dist) {return 0.0;}"+
"");
}
if (farFogSetting == null) {
str.append("""
float getFarFogThickness(float dist) { return 0.0; }
float getHeightFogThickness(float dist) { return 0.0; }
float calculateFarFogDepth(float horizontal, float dist) { return 0.0; }
float calculateHeightFogDepth(float vertical, float realY) { return 0.0; }
float mixFogThickness(float near, float far, float height) { return near; }
""");
str.append(""+
"float getFarFogThickness(float dist) { return 0.0; }"+
"float getHeightFogThickness(float dist) { return 0.0; }"+
"float calculateFarFogDepth(float horizontal, float dist) { return 0.0; }"+
"float calculateHeightFogDepth(float vertical, float realY) { return 0.0; }"+
"float mixFogThickness(float near, float far, float height) { return near; }"+
"");
} else {
// Generate method: float getFarFogThickness(float dist);
str.append("float getFarFogThickness(float dist) {\n");
@@ -265,10 +265,10 @@ float mixFogThickness(float near, float far, float height) { return near; }
// Generate method: float getHeightFogThickness(float dist);
if (heightFogSetting == null) {
str.append("""
float getHeightFogThickness(float dist) { return 0.0; }
float calculateHeightFogDepth(float vertical, float realY) { return 0.0; }
""");
str.append(""+
"float getHeightFogThickness(float dist) { return 0.0; }"+
"float calculateHeightFogDepth(float vertical, float realY) { return 0.0; }"+
"");
} else {
str.append("float getHeightFogThickness(float dist) {\n");
str.append(getHeightFogMethod(heightFogSetting.fogType));
@@ -156,14 +156,17 @@ public class ColorUtil
float p = v * ( 1f - s );
float q = v * ( 1f - s * f );
float t = v * ( 1f - s * ( 1f - f ) );
return switch (i) {
case 0 -> ColorUtil.rgbToInt(a, v, t, p);
case 1 -> ColorUtil.rgbToInt(a, q, v, p);
case 2 -> ColorUtil.rgbToInt(a, p, v, t);
case 3 -> ColorUtil.rgbToInt(a, p, q, v);
case 4 -> ColorUtil.rgbToInt(a, t, p, v);
default -> ColorUtil.rgbToInt(a, v, p, q); // case 5
int color;
switch (i) {
case 0: color = ColorUtil.rgbToInt(a, v, t, p);
case 1: color = ColorUtil.rgbToInt(a, q, v, p);
case 2: color = ColorUtil.rgbToInt(a, p, v, t);
case 3: color = ColorUtil.rgbToInt(a, p, q, v);
case 4: color = ColorUtil.rgbToInt(a, t, p, v);
default: color = ColorUtil.rgbToInt(a, v, p, q); // case 5
};
return color;
}
public static String toString(int color)
@@ -364,7 +364,7 @@ public class LodUtil
Iterator<AbstractChunkPosWrapper> posIter = MC_RENDER.getVanillaRenderedChunks().iterator();
return new EdgeDistanceBooleanGrid(new Iterator<>() {
return new EdgeDistanceBooleanGrid(new Iterator<Pos2D>() {
@Override
public boolean hasNext() {
return posIter.hasNext();
@@ -89,7 +89,7 @@ public interface IMinecraftRenderWrapper extends IBindable
return sodium==null ? getMaximumRenderedChunks() : sodium.getNormalRenderedChunks();
}
private static boolean correctedCheckRadius(int dx, int dz, int radius2Mul4) {
static boolean correctedCheckRadius(int dx, int dz, int radius2Mul4) {
dx = dx*2;// + (dx < 0 ? -1 : 1);
dz = dz*2;// + (dz < 0 ? -1 : 1);
return (dx*dx + dz*dz <= radius2Mul4);