Automated nullability

- Remove most NotNull annotations
- Automatically generate missing package-info.java files which contain
annotations to establish that everything is not null by default
- Remove CurseForge integration from build script
- Fix some other formatting
This commit is contained in:
PepperCode1 2024-01-22 11:12:48 -08:00
parent 470f207189
commit f9e5d33296
46 changed files with 297 additions and 327 deletions

2
.gitignore vendored
View file

@ -43,4 +43,6 @@ local.properties
# PDT-specific # PDT-specific
.buildpath .buildpath
# Other
mcmodsrepo mcmodsrepo
src/*/generatedPackageInfos/

View file

@ -5,7 +5,6 @@ plugins {
id 'net.minecraftforge.gradle' version "${forgegradle_version}" id 'net.minecraftforge.gradle' version "${forgegradle_version}"
id 'org.parchmentmc.librarian.forgegradle' version "${librarian_version}" id 'org.parchmentmc.librarian.forgegradle' version "${librarian_version}"
id 'org.spongepowered.mixin' version "${mixingradle_version}" id 'org.spongepowered.mixin' version "${mixingradle_version}"
id 'com.matthewprenger.cursegradle' version "${cursegradle_version}"
} }
jarJar.enable() jarJar.enable()
@ -166,6 +165,8 @@ tasks.named('processResources', ProcessResources).configure {
} }
} }
apply from: rootProject.file('gradle/package-infos.gradle')
void addLicense(jarTask) { void addLicense(jarTask) {
jarTask.from('LICENSE.md') { jarTask.from('LICENSE.md') {
rename '(.*)\\.(.*)', '$1_' + archivesBaseName + '.$2' rename '(.*)\\.(.*)', '$1_' + archivesBaseName + '.$2'
@ -230,19 +231,3 @@ publishing {
} }
} }
} }
tasks.curseforge.enabled = !dev && project.hasProperty('jozu_curseforge_key')
curseforge {
if (project.hasProperty('jozu_curseforge_key')) {
apiKey = project.jozu_curseforge_key
}
project {
id = project.projectId
changelog = file('changelog.txt')
releaseType = project.curse_type
mainArtifact jar
addGameVersion '1.20.1'
}
}

View file

@ -7,7 +7,7 @@ artifact_minecraft_version = 1.20.1
minecraft_version = 1.20.1 minecraft_version = 1.20.1
forge_version = 47.2.19 forge_version = 47.2.19
# Version ranges for the mods.toml # Version ranges for the mods.toml
minecraft_version_range=[1.20.1,1.20.3) minecraft_version_range = [1.20.1,1.20.2)
forge_version_range = [47,) forge_version_range = [47,)
loader_version_range = [47,) loader_version_range = [47,)
@ -18,10 +18,3 @@ mixin_version = 0.8.5
librarian_version = 1.+ librarian_version = 1.+
cursegradle_version = 1.4.0 cursegradle_version = 1.4.0
parchment_version = 2023.09.03 parchment_version = 2023.09.03
# curseforge info
projectId = 486392
curse_type = release
# github info
github_project = Jozufozu/Flywheel

View file

@ -0,0 +1,70 @@
// Adapted from https://github.com/FabricMC/fabric/blob/31787236d242247e0b6c4ae806b1cfaa7042a62c/gradle/package-info.gradle, which is licensed under Apache 2.0.
import java.nio.file.Files
setupGeneratePackageInfos(sourceSets.main)
def setupGeneratePackageInfos(SourceSet sourceSet) {
// We have to capture the source set name for the lazy string literals,
// otherwise it'll just be whatever the last source set is in the list.
def sourceSetName = sourceSet.name
def taskName = sourceSet.getTaskName('generate', 'PackageInfos')
def task = tasks.register(taskName, GeneratePackageInfosTask) {
group = 'flywheel'
description = "Generates package-info files for $sourceSetName packages."
// Only apply to default source directory since we also add the generated
// sources to the source set.
sourceRoot = file("src/$sourceSetName/java")
outputDir = file("src/$sourceSetName/generatedPackageInfos")
}
sourceSet.java.srcDir task
def cleanTask = tasks.register(sourceSet.getTaskName('clean', 'PackageInfos'), Delete) {
group = 'flywheel'
delete file("src/$sourceSetName/generatedPackageInfos")
}
clean.dependsOn cleanTask
}
class GeneratePackageInfosTask extends DefaultTask {
@SkipWhenEmpty
@InputDirectory
final DirectoryProperty sourceRoot = project.objects.directoryProperty()
@OutputDirectory
final DirectoryProperty outputDir = project.objects.directoryProperty()
@TaskAction
def run() {
def output = outputDir.get().asFile.toPath()
output.deleteDir()
def root = sourceRoot.get().asFile.toPath()
root.eachDirRecurse {
def containsJava = Files.list(it).any {
Files.isRegularFile(it) && it.fileName.toString().endsWith('.java')
}
if (containsJava && Files.notExists(it.resolve('package-info.java'))) {
def relativePath = root.relativize(it)
def target = output.resolve(relativePath)
Files.createDirectories(target)
target.resolve('package-info.java').withWriter {
def packageName = relativePath.toString().replace(File.separator, '.')
it.write("""@ParametersAreNonnullByDefault
|@FieldsAreNonnullByDefault
|@MethodsReturnNonnullByDefault
|package $packageName;
|
|import javax.annotation.ParametersAreNonnullByDefault;
|
|import net.minecraft.FieldsAreNonnullByDefault;
|import net.minecraft.MethodsReturnNonnullByDefault;
|""".stripMargin())
}
}
}
}
}

View file

@ -2,8 +2,6 @@ package com.jozufozu.flywheel.api.backend;
import java.util.List; import java.util.List;
import org.jetbrains.annotations.NotNull;
import com.jozufozu.flywheel.api.event.RenderContext; import com.jozufozu.flywheel.api.event.RenderContext;
import com.jozufozu.flywheel.api.event.RenderStage; import com.jozufozu.flywheel.api.event.RenderStage;
import com.jozufozu.flywheel.api.instance.Instance; import com.jozufozu.flywheel.api.instance.Instance;
@ -67,6 +65,6 @@ public interface Engine extends InstancerProvider {
* @param pos The position of the block. * @param pos The position of the block.
* @param instances The instances associated with the BE at this position. * @param instances The instances associated with the BE at this position.
*/ */
record CrumblingBlock(int progress, BlockPos pos, List<@NotNull Instance> instances) { record CrumblingBlock(int progress, BlockPos pos, List<Instance> instances) {
} }
} }

View file

@ -1,7 +1,5 @@
package com.jozufozu.flywheel.api.context; package com.jozufozu.flywheel.api.context;
import org.jetbrains.annotations.NotNull;
import com.jozufozu.flywheel.api.registry.Registry; import com.jozufozu.flywheel.api.registry.Registry;
import com.jozufozu.flywheel.backend.gl.shader.GlProgram; import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
import com.jozufozu.flywheel.impl.RegistryImpl; import com.jozufozu.flywheel.impl.RegistryImpl;
@ -11,7 +9,7 @@ import net.minecraft.resources.ResourceLocation;
public interface Context { public interface Context {
static Registry<Context> REGISTRY = RegistryImpl.create(); static Registry<Context> REGISTRY = RegistryImpl.create();
void onProgramLink(@NotNull GlProgram program); void onProgramLink(GlProgram program);
ResourceLocation vertexShader(); ResourceLocation vertexShader();

View file

@ -6,8 +6,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.function.Function; import java.util.function.Function;
import org.jetbrains.annotations.NotNull;
import com.jozufozu.flywheel.Flywheel; import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.api.instance.InstanceType; import com.jozufozu.flywheel.api.instance.InstanceType;
import com.jozufozu.flywheel.api.layout.FloatRepr; import com.jozufozu.flywheel.api.layout.FloatRepr;
@ -126,152 +124,38 @@ public class IndirectComponent implements SourceComponent {
throw new IllegalArgumentException("Unknown type " + type); throw new IllegalArgumentException("Unknown type " + type);
} }
private static GlslExpr unpackMatrix(String name, GlslStruct packed, MatrixElementType matrix) {
var repr = matrix.repr();
int rows = matrix.rows();
int columns = matrix.columns();
List<GlslExpr> args = new ArrayList<>();
for (int i = 0; i < columns; i++) {
args.add(unpackFloatVector(name + "_" + i, repr, packed, rows));
}
return GlslExpr.call("mat" + columns + "x" + rows, args);
}
private static GlslExpr unpackScalar(String fieldName, GlslStruct packed, ScalarElementType scalar) { private static GlslExpr unpackScalar(String fieldName, GlslStruct packed, ScalarElementType scalar) {
var repr = scalar.repr(); var repr = scalar.repr();
if (repr instanceof FloatRepr floatRepr) { if (repr instanceof IntegerRepr intRepr) {
return unpackFloatScalar(fieldName, floatRepr, packed);
} else if (repr instanceof IntegerRepr intRepr) {
return unpackIntScalar(fieldName, intRepr, packed); return unpackIntScalar(fieldName, intRepr, packed);
} else if (repr instanceof UnsignedIntegerRepr unsignedIntegerRepr) { } else if (repr instanceof UnsignedIntegerRepr unsignedIntegerRepr) {
return unpackUnsignedScalar(fieldName, unsignedIntegerRepr, packed); return unpackUnsignedScalar(fieldName, unsignedIntegerRepr, packed);
} else if (repr instanceof FloatRepr floatRepr) {
return unpackFloatScalar(fieldName, floatRepr, packed);
} }
throw new IllegalArgumentException("Unknown repr " + repr); throw new IllegalArgumentException("Unknown repr " + repr);
} }
private static GlslExpr unpackVector(String fieldName, GlslStruct packed, VectorElementType vector) { private static GlslExpr unpackIntScalar(String fieldName, IntegerRepr intRepr, GlslStruct packed) {
var repr = vector.repr(); return switch (intRepr) {
case BYTE -> unpackScalar(fieldName, packed, "uint", e -> e.and(0xFF)
int size = vector.size(); .cast("int"));
case SHORT -> unpackScalar(fieldName, packed, "uint", e -> e.and(0xFFFF)
if (repr instanceof FloatRepr floatRepr) { .cast("int"));
return unpackFloatVector(fieldName, floatRepr, packed, size); case INT -> unpackScalar(fieldName, packed, "int");
} else if (repr instanceof IntegerRepr intRepr) {
return unpackIntVector(fieldName, intRepr, packed, size);
} else if (repr instanceof UnsignedIntegerRepr unsignedIntegerRepr) {
return unpackUnsignedVector(fieldName, unsignedIntegerRepr, packed, size);
}
throw new IllegalArgumentException("Unknown repr " + repr);
}
private static GlslExpr unpackFloatVector(String fieldName, FloatRepr floatRepr, GlslStruct packed, int size) {
return switch (floatRepr) {
case NORMALIZED_BYTE -> unpackBuiltin(fieldName, packed, size, "unpackSnorm4x8");
case NORMALIZED_UNSIGNED_BYTE -> unpackBuiltin(fieldName, packed, size, "unpackUnorm4x8");
case NORMALIZED_SHORT -> unpackBuiltin(fieldName, packed, size, "unpackSnorm2x16");
case NORMALIZED_UNSIGNED_SHORT -> unpackBuiltin(fieldName, packed, size, "unpackUnorm2x16");
case NORMALIZED_INT -> unpack(fieldName, packed, size, "int", "vec" + size, e -> e.div(2147483647f)
.clamp(-1, 1));
case NORMALIZED_UNSIGNED_INT ->
unpack(fieldName, packed, size, "uint", "vec" + size, e -> e.div(4294967295f));
case BYTE -> unpackByteBacked(fieldName, packed, size, "vec" + size, e -> e.cast("int")
.cast("float"));
case UNSIGNED_BYTE -> unpackByteBacked(fieldName, packed, size, "vec" + size, e -> e.cast("float"));
case SHORT -> unpackShortBacked(fieldName, packed, size, "vec" + size, e -> e.cast("int")
.cast("float"));
case UNSIGNED_SHORT -> unpackShortBacked(fieldName, packed, size, "vec" + size, e -> e.cast("float"));
case INT -> unpack(fieldName, packed, size, "int", "vec" + size, e -> e.cast("float"));
case UNSIGNED_INT -> unpack(fieldName, packed, size, "float", "vec" + size, e -> e.cast("float"));
case FLOAT -> unpack(fieldName, packed, size, "float", "vec" + size);
}; };
} }
private static GlslExpr unpackUnsignedVector(String fieldName, UnsignedIntegerRepr unsignedIntegerRepr, GlslStruct packed, int size) { private static GlslExpr unpackUnsignedScalar(String fieldName, UnsignedIntegerRepr repr, GlslStruct packed) {
return switch (unsignedIntegerRepr) {
case UNSIGNED_BYTE -> unpackByteBacked(fieldName, packed, size, "uvec" + size, e -> e.cast("uint"));
case UNSIGNED_SHORT -> unpackShortBacked(fieldName, packed, size, "uvec" + size, e -> e.cast("uint"));
case UNSIGNED_INT -> unpack(fieldName, packed, size, "uint", "uvec" + size);
};
}
private static GlslExpr unpackIntVector(String fieldName, IntegerRepr repr, GlslStruct packed, int size) {
return switch (repr) { return switch (repr) {
case BYTE -> unpackByteBacked(fieldName, packed, size, "ivec" + size, e -> e.cast("int")); case UNSIGNED_BYTE -> unpackScalar(fieldName, packed, "uint", e -> e.and(0xFF));
case SHORT -> unpackShortBacked(fieldName, packed, size, "ivec" + size, e -> e.cast("int")); case UNSIGNED_SHORT -> unpackScalar(fieldName, packed, "uint", e -> e.and(0xFFFF));
case INT -> unpack(fieldName, packed, size, "int", "ivec" + size); case UNSIGNED_INT -> unpackScalar(fieldName, packed, "uint");
}; };
} }
@NotNull
private static GlslExpr unpack(String fieldName, GlslStruct packed, int size, String backingType, String outType) {
return unpack(fieldName, packed, size, backingType, outType, Function.identity());
}
@NotNull
private static GlslExpr unpack(String fieldName, GlslStruct packed, int size, String backingType, String outType, Function<GlslExpr, GlslExpr> perElement) {
List<GlslExpr> args = new ArrayList<>();
for (int i = 0; i < size; i++) {
var name = fieldName + "_" + i;
packed.addField(backingType, name);
args.add(UNPACKING_VARIABLE.access(name)
.transform(perElement));
}
return GlslExpr.call(outType, args);
}
@NotNull
private static GlslExpr unpackBuiltin(String fieldName, GlslStruct packed, int size, String func) {
packed.addField("uint", fieldName);
GlslExpr expr = UNPACKING_VARIABLE.access(fieldName)
.callFunction(func);
return switch (size) {
case 2 -> expr.swizzle("xy");
case 3 -> expr.swizzle("xyz");
case 4 -> expr;
default -> throw new IllegalArgumentException("Invalid vector size " + size);
};
}
@NotNull
private static GlslExpr unpackByteBacked(String fieldName, GlslStruct packed, int size, String outType, Function<GlslExpr, GlslExpr> perElement) {
packed.addField("uint", fieldName);
List<GlslExpr> args = new ArrayList<>();
for (int i = 0; i < size; i++) {
int bitPos = i * 8;
var element = UNPACKING_VARIABLE.access(fieldName)
.and(0xFF << bitPos)
.rsh(bitPos);
args.add(perElement.apply(element));
}
return GlslExpr.call(outType + size, args);
}
@NotNull
private static GlslExpr unpackShortBacked(String fieldName, GlslStruct packed, int size, String outType, Function<GlslExpr, GlslExpr> perElement) {
List<GlslExpr> args = new ArrayList<>();
for (int i = 0; i < size; i++) {
int unpackField = i / 2;
int bitPos = (i % 2) * 16;
var name = fieldName + "_" + unpackField;
if (bitPos == 0) {
// First time we're seeing this field, add it to the struct.
packed.addField("uint", name);
}
var element = UNPACKING_VARIABLE.access(name)
.and(0xFFFF << bitPos)
.rsh(bitPos);
args.add(perElement.apply(element));
}
return GlslExpr.call(outType, args);
}
private static GlslExpr unpackFloatScalar(String fieldName, FloatRepr repr, GlslStruct packed) { private static GlslExpr unpackFloatScalar(String fieldName, FloatRepr repr, GlslStruct packed) {
return switch (repr) { return switch (repr) {
case BYTE -> unpackScalar(fieldName, packed, "uint", e -> e.and(0xFF) case BYTE -> unpackScalar(fieldName, packed, "uint", e -> e.and(0xFF)
@ -303,24 +187,6 @@ public class IndirectComponent implements SourceComponent {
}; };
} }
private static GlslExpr unpackUnsignedScalar(String fieldName, UnsignedIntegerRepr repr, GlslStruct packed) {
return switch (repr) {
case UNSIGNED_BYTE -> unpackScalar(fieldName, packed, "uint", e -> e.and(0xFF));
case UNSIGNED_SHORT -> unpackScalar(fieldName, packed, "uint", e -> e.and(0xFFFF));
case UNSIGNED_INT -> unpackScalar(fieldName, packed, "uint");
};
}
private static GlslExpr unpackIntScalar(String fieldName, IntegerRepr intRepr, GlslStruct packed) {
return switch (intRepr) {
case BYTE -> unpackScalar(fieldName, packed, "uint", e -> e.and(0xFF)
.cast("int"));
case SHORT -> unpackScalar(fieldName, packed, "uint", e -> e.and(0xFFFF)
.cast("int"));
case INT -> unpackScalar(fieldName, packed, "int");
};
}
private static GlslExpr unpackScalar(String fieldName, GlslStruct packed, String packedType) { private static GlslExpr unpackScalar(String fieldName, GlslStruct packed, String packedType) {
return unpackScalar(fieldName, packed, packedType, Function.identity()); return unpackScalar(fieldName, packed, packedType, Function.identity());
} }
@ -329,4 +195,131 @@ public class IndirectComponent implements SourceComponent {
packed.addField(packedType, fieldName); packed.addField(packedType, fieldName);
return perElement.apply(UNPACKING_VARIABLE.access(fieldName)); return perElement.apply(UNPACKING_VARIABLE.access(fieldName));
} }
private static GlslExpr unpackVector(String fieldName, GlslStruct packed, VectorElementType vector) {
var repr = vector.repr();
int size = vector.size();
if (repr instanceof IntegerRepr intRepr) {
return unpackIntVector(fieldName, intRepr, packed, size);
} else if (repr instanceof UnsignedIntegerRepr unsignedIntegerRepr) {
return unpackUnsignedVector(fieldName, unsignedIntegerRepr, packed, size);
} else if (repr instanceof FloatRepr floatRepr) {
return unpackFloatVector(fieldName, floatRepr, packed, size);
}
throw new IllegalArgumentException("Unknown repr " + repr);
}
private static GlslExpr unpackIntVector(String fieldName, IntegerRepr repr, GlslStruct packed, int size) {
return switch (repr) {
case BYTE -> unpackByteBacked(fieldName, packed, size, "ivec" + size, e -> e.cast("int"));
case SHORT -> unpackShortBacked(fieldName, packed, size, "ivec" + size, e -> e.cast("int"));
case INT -> unpack(fieldName, packed, size, "int", "ivec" + size);
};
}
private static GlslExpr unpackUnsignedVector(String fieldName, UnsignedIntegerRepr unsignedIntegerRepr, GlslStruct packed, int size) {
return switch (unsignedIntegerRepr) {
case UNSIGNED_BYTE -> unpackByteBacked(fieldName, packed, size, "uvec" + size, e -> e.cast("uint"));
case UNSIGNED_SHORT -> unpackShortBacked(fieldName, packed, size, "uvec" + size, e -> e.cast("uint"));
case UNSIGNED_INT -> unpack(fieldName, packed, size, "uint", "uvec" + size);
};
}
private static GlslExpr unpackFloatVector(String fieldName, FloatRepr floatRepr, GlslStruct packed, int size) {
return switch (floatRepr) {
case NORMALIZED_BYTE -> unpackBuiltin(fieldName, packed, size, "unpackSnorm4x8");
case NORMALIZED_UNSIGNED_BYTE -> unpackBuiltin(fieldName, packed, size, "unpackUnorm4x8");
case NORMALIZED_SHORT -> unpackBuiltin(fieldName, packed, size, "unpackSnorm2x16");
case NORMALIZED_UNSIGNED_SHORT -> unpackBuiltin(fieldName, packed, size, "unpackUnorm2x16");
case NORMALIZED_INT -> unpack(fieldName, packed, size, "int", "vec" + size, e -> e.div(2147483647f)
.clamp(-1, 1));
case NORMALIZED_UNSIGNED_INT ->
unpack(fieldName, packed, size, "uint", "vec" + size, e -> e.div(4294967295f));
case BYTE -> unpackByteBacked(fieldName, packed, size, "vec" + size, e -> e.cast("int")
.cast("float"));
case UNSIGNED_BYTE -> unpackByteBacked(fieldName, packed, size, "vec" + size, e -> e.cast("float"));
case SHORT -> unpackShortBacked(fieldName, packed, size, "vec" + size, e -> e.cast("int")
.cast("float"));
case UNSIGNED_SHORT -> unpackShortBacked(fieldName, packed, size, "vec" + size, e -> e.cast("float"));
case INT -> unpack(fieldName, packed, size, "int", "vec" + size, e -> e.cast("float"));
case UNSIGNED_INT -> unpack(fieldName, packed, size, "float", "vec" + size, e -> e.cast("float"));
case FLOAT -> unpack(fieldName, packed, size, "float", "vec" + size);
};
}
private static GlslExpr unpackByteBacked(String fieldName, GlslStruct packed, int size, String outType, Function<GlslExpr, GlslExpr> perElement) {
packed.addField("uint", fieldName);
List<GlslExpr> args = new ArrayList<>();
for (int i = 0; i < size; i++) {
int bitPos = i * 8;
var element = UNPACKING_VARIABLE.access(fieldName)
.and(0xFF << bitPos)
.rsh(bitPos);
args.add(perElement.apply(element));
}
return GlslExpr.call(outType + size, args);
}
private static GlslExpr unpackShortBacked(String fieldName, GlslStruct packed, int size, String outType, Function<GlslExpr, GlslExpr> perElement) {
List<GlslExpr> args = new ArrayList<>();
for (int i = 0; i < size; i++) {
int unpackField = i / 2;
int bitPos = (i % 2) * 16;
var name = fieldName + "_" + unpackField;
if (bitPos == 0) {
// First time we're seeing this field, add it to the struct.
packed.addField("uint", name);
}
var element = UNPACKING_VARIABLE.access(name)
.and(0xFFFF << bitPos)
.rsh(bitPos);
args.add(perElement.apply(element));
}
return GlslExpr.call(outType, args);
}
private static GlslExpr unpack(String fieldName, GlslStruct packed, int size, String backingType, String outType) {
return unpack(fieldName, packed, size, backingType, outType, Function.identity());
}
private static GlslExpr unpack(String fieldName, GlslStruct packed, int size, String backingType, String outType, Function<GlslExpr, GlslExpr> perElement) {
List<GlslExpr> args = new ArrayList<>();
for (int i = 0; i < size; i++) {
var name = fieldName + "_" + i;
packed.addField(backingType, name);
args.add(UNPACKING_VARIABLE.access(name)
.transform(perElement));
}
return GlslExpr.call(outType, args);
}
private static GlslExpr unpackBuiltin(String fieldName, GlslStruct packed, int size, String func) {
packed.addField("uint", fieldName);
GlslExpr expr = UNPACKING_VARIABLE.access(fieldName)
.callFunction(func);
return switch (size) {
case 2 -> expr.swizzle("xy");
case 3 -> expr.swizzle("xyz");
case 4 -> expr;
default -> throw new IllegalArgumentException("Invalid vector size " + size);
};
}
private static GlslExpr unpackMatrix(String name, GlslStruct packed, MatrixElementType matrix) {
var repr = matrix.repr();
int rows = matrix.rows();
int columns = matrix.columns();
List<GlslExpr> args = new ArrayList<>();
for (int i = 0; i < columns; i++) {
args.add(unpackFloatVector(name + "_" + i, repr, packed, rows));
}
return GlslExpr.call("mat" + columns + "x" + rows, args);
}
} }

View file

@ -5,7 +5,6 @@ import java.io.FileWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.jetbrains.annotations.NotNull;
import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GL20;
import com.jozufozu.flywheel.backend.compile.FlwPrograms; import com.jozufozu.flywheel.backend.compile.FlwPrograms;
@ -33,7 +32,6 @@ public class Compilation {
private final StringBuilder fullSource = new StringBuilder(); private final StringBuilder fullSource = new StringBuilder();
private int generatedLines = 0; private int generatedLines = 0;
@NotNull
public ShaderResult compile(ShaderType shaderType, String name) { public ShaderResult compile(ShaderType shaderType, String name) {
int handle = GL20.glCreateShader(shaderType.glEnum); int handle = GL20.glCreateShader(shaderType.glEnum);
var source = fullSource.toString(); var source = fullSource.toString();

View file

@ -10,7 +10,6 @@ import java.util.function.BiFunction;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Function; import java.util.function.Function;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import com.jozufozu.flywheel.backend.gl.shader.GlProgram; import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
@ -98,7 +97,7 @@ public class Compile<K> {
public static class ShaderCompiler<K> { public static class ShaderCompiler<K> {
private final GlslVersion glslVersion; private final GlslVersion glslVersion;
private final ShaderType shaderType; private final ShaderType shaderType;
private final List<BiFunction<K, SourceLoader, SourceComponent>> fetchers = new ArrayList<>(); private final List<BiFunction<K, SourceLoader, @Nullable SourceComponent>> fetchers = new ArrayList<>();
private Consumer<Compilation> compilationCallbacks = $ -> { private Consumer<Compilation> compilationCallbacks = $ -> {
}; };
private Function<K, String> nameMapper = Object::toString; private Function<K, String> nameMapper = Object::toString;
@ -113,25 +112,25 @@ public class Compile<K> {
return this; return this;
} }
public ShaderCompiler<K> with(BiFunction<K, SourceLoader, SourceComponent> fetch) { public ShaderCompiler<K> with(BiFunction<K, SourceLoader, @Nullable SourceComponent> fetch) {
fetchers.add(fetch); fetchers.add(fetch);
return this; return this;
} }
public ShaderCompiler<K> withComponents(Collection<SourceComponent> components) { public ShaderCompiler<K> withComponents(Collection<@Nullable SourceComponent> components) {
components.forEach(this::withComponent); components.forEach(this::withComponent);
return this; return this;
} }
public ShaderCompiler<K> withComponent(SourceComponent component) { public ShaderCompiler<K> withComponent(@Nullable SourceComponent component) {
return withComponent($ -> component); return withComponent($ -> component);
} }
public ShaderCompiler<K> withComponent(Function<K, @NotNull SourceComponent> sourceFetcher) { public ShaderCompiler<K> withComponent(Function<K, @Nullable SourceComponent> sourceFetcher) {
return with((key, $) -> sourceFetcher.apply(key)); return with((key, $) -> sourceFetcher.apply(key));
} }
public ShaderCompiler<K> withResource(Function<K, @NotNull ResourceLocation> sourceFetcher) { public ShaderCompiler<K> withResource(Function<K, ResourceLocation> sourceFetcher) {
return with((key, loader) -> loader.find(sourceFetcher.apply(key))); return with((key, loader) -> loader.find(sourceFetcher.apply(key)));
} }

View file

@ -6,7 +6,6 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Marker; import org.slf4j.Marker;
import org.slf4j.MarkerFactory; import org.slf4j.MarkerFactory;
@ -71,7 +70,6 @@ public class CompilerStats {
.collect(Collectors.joining("\n")); .collect(Collectors.joining("\n"));
} }
@NotNull
private String linkErrors() { private String linkErrors() {
return String.join("\n", programErrors); return String.join("\n", programErrors);
} }

View file

@ -8,8 +8,6 @@ import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.jetbrains.annotations.NotNull;
import com.jozufozu.flywheel.Flywheel; import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.backend.glsl.SourceFile; import com.jozufozu.flywheel.backend.glsl.SourceFile;
import com.jozufozu.flywheel.backend.glsl.SourceLines; import com.jozufozu.flywheel.backend.glsl.SourceLines;
@ -49,7 +47,6 @@ public class FailedCompilation {
.collect(Collectors.joining("\n")); .collect(Collectors.joining("\n"));
} }
@NotNull
private Stream<ErrorBuilder> errorStream() { private Stream<ErrorBuilder> errorStream() {
return errorLog.lines() return errorLog.lines()
.mapMulti(this::interpretLine); .mapMulti(this::interpretLine);
@ -142,7 +139,6 @@ public class FailedCompilation {
.note("This generally indicates a bug in Flywheel, not your shader code."); .note("This generally indicates a bug in Flywheel, not your shader code.");
} }
@NotNull
private static ErrorLevel parseErrorLevel(String level) { private static ErrorLevel parseErrorLevel(String level) {
return switch (level.toLowerCase(Locale.ROOT)) { return switch (level.toLowerCase(Locale.ROOT)) {
case "error" -> ErrorLevel.ERROR; case "error" -> ErrorLevel.ERROR;

View file

@ -1,6 +0,0 @@
@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault
package com.jozufozu.flywheel.backend.compile;
import javax.annotation.ParametersAreNonnullByDefault;
import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -11,8 +11,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.jetbrains.annotations.NotNull;
import com.jozufozu.flywheel.api.backend.Engine; import com.jozufozu.flywheel.api.backend.Engine;
import com.jozufozu.flywheel.api.event.RenderStage; import com.jozufozu.flywheel.api.event.RenderStage;
import com.jozufozu.flywheel.api.instance.Instance; import com.jozufozu.flywheel.api.instance.Instance;
@ -158,7 +156,6 @@ public class IndirectDrawManager extends InstancerStorage<IndirectInstancer<?>>
block.free(); block.free();
} }
@NotNull
private static Map<InstanceType<?>, Int2ObjectMap<List<Pair<IndirectInstancer<?>, InstanceHandleImpl>>>> doCrumblingSort(List<Engine.CrumblingBlock> crumblingBlocks) { private static Map<InstanceType<?>, Int2ObjectMap<List<Pair<IndirectInstancer<?>, InstanceHandleImpl>>>> doCrumblingSort(List<Engine.CrumblingBlock> crumblingBlocks) {
Map<InstanceType<?>, Int2ObjectMap<List<Pair<IndirectInstancer<?>, InstanceHandleImpl>>>> byType = new HashMap<>(); Map<InstanceType<?>, Int2ObjectMap<List<Pair<IndirectInstancer<?>, InstanceHandleImpl>>>> byType = new HashMap<>();
for (Engine.CrumblingBlock block : crumblingBlocks) { for (Engine.CrumblingBlock block : crumblingBlocks) {

View file

@ -2,7 +2,6 @@ package com.jozufozu.flywheel.backend.engine.indirect;
import java.util.function.LongConsumer; import java.util.function.LongConsumer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.lwjgl.opengl.GL45; import org.lwjgl.opengl.GL45;
import org.lwjgl.opengl.GL45C; import org.lwjgl.opengl.GL45C;
@ -227,7 +226,6 @@ public class StagingBuffer {
FlwMemoryTracker._freeCPUMemory(capacity); FlwMemoryTracker._freeCPUMemory(capacity);
} }
@NotNull
private MemoryBlock getScratch(long size) { private MemoryBlock getScratch(long size) {
if (scratch == null) { if (scratch == null) {
scratch = MemoryBlock.malloc(size); scratch = MemoryBlock.malloc(size);

View file

@ -3,7 +3,6 @@ package com.jozufozu.flywheel.backend.engine.instancing;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.jetbrains.annotations.NotNull;
import org.lwjgl.system.MemoryUtil; import org.lwjgl.system.MemoryUtil;
import com.jozufozu.flywheel.api.model.IndexSequence; import com.jozufozu.flywheel.api.model.IndexSequence;
@ -55,7 +54,6 @@ public class EboCache {
} }
private record Entry(int ebo, int gpuSize) { private record Entry(int ebo, int gpuSize) {
@NotNull
private static Entry create(IndexSequence provider, int indexCount) { private static Entry create(IndexSequence provider, int indexCount) {
int byteSize = indexCount * GlNumericType.UINT.byteWidth(); int byteSize = indexCount * GlNumericType.UINT.byteWidth();
var ebo = Buffer.IMPL.create(); var ebo = Buffer.IMPL.create();

View file

@ -5,8 +5,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.jetbrains.annotations.NotNull;
import com.jozufozu.flywheel.api.backend.Engine; import com.jozufozu.flywheel.api.backend.Engine;
import com.jozufozu.flywheel.api.instance.Instance; import com.jozufozu.flywheel.api.instance.Instance;
import com.jozufozu.flywheel.backend.compile.InstancingPrograms; import com.jozufozu.flywheel.backend.compile.InstancingPrograms;
@ -74,7 +72,6 @@ public class InstancedCrumbling {
} }
} }
@NotNull
private static Map<ShaderState, Int2ObjectMap<List<Runnable>>> doCrumblingSort(List<Engine.CrumblingBlock> instances) { private static Map<ShaderState, Int2ObjectMap<List<Runnable>>> doCrumblingSort(List<Engine.CrumblingBlock> instances) {
Map<ShaderState, Int2ObjectMap<List<Runnable>>> out = new HashMap<>(); Map<ShaderState, Int2ObjectMap<List<Runnable>>> out = new HashMap<>();

View file

@ -5,8 +5,6 @@ import java.util.EnumMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import org.jetbrains.annotations.NotNull;
import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ListMultimap; import com.google.common.collect.ListMultimap;
@ -108,7 +106,6 @@ public class InstancedDrawManager extends InstancerStorage<InstancedInstancer<?>
return drawCalls.isEmpty(); return drawCalls.isEmpty();
} }
@NotNull
@Override @Override
public Iterator<Map.Entry<ShaderState, Collection<DrawCall>>> iterator() { public Iterator<Map.Entry<ShaderState, Collection<DrawCall>>> iterator() {
return drawCalls.asMap() return drawCalls.asMap()

View file

@ -9,7 +9,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.VisibleForTesting; import org.jetbrains.annotations.VisibleForTesting;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
@ -40,7 +39,6 @@ public class ShaderSources {
cache.putAll(preloadCache); cache.putAll(preloadCache);
} }
@NotNull
public LoadResult find(ResourceLocation location) { public LoadResult find(ResourceLocation location) {
if (findStack.contains(location)) { if (findStack.contains(location)) {
// Make a copy of the find stack with the offending location added on top to show the full path. // Make a copy of the find stack with the offending location added on top to show the full path.
@ -57,7 +55,6 @@ public class ShaderSources {
return out; return out;
} }
@NotNull
private LoadResult _find(ResourceLocation location) { private LoadResult _find(ResourceLocation location) {
// Can't use computeIfAbsent because mutual recursion causes ConcurrentModificationExceptions // Can't use computeIfAbsent because mutual recursion causes ConcurrentModificationExceptions
var out = cache.get(location); var out = cache.get(location);
@ -68,7 +65,7 @@ public class ShaderSources {
return out; return out;
} }
@NotNull @VisibleForTesting
protected LoadResult load(ResourceLocation loc) { protected LoadResult load(ResourceLocation loc) {
return manager.getResource(loc.withPrefix(SHADER_DIR)) return manager.getResource(loc.withPrefix(SHADER_DIR))
.map(resource -> { .map(resource -> {

View file

@ -7,7 +7,6 @@ import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -229,7 +228,6 @@ public class SourceFile implements SourceComponent {
return System.identityHashCode(this); return System.identityHashCode(this);
} }
@NotNull
private static String generateFinalSource(ImmutableList<Import> imports, SourceLines source) { private static String generateFinalSource(ImmutableList<Import> imports, SourceLines source) {
var out = new StringBuilder(); var out = new StringBuilder();

View file

@ -3,8 +3,6 @@ package com.jozufozu.flywheel.backend.glsl;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.jetbrains.annotations.NotNull;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.jozufozu.flywheel.backend.glsl.span.CharPos; import com.jozufozu.flywheel.backend.glsl.span.CharPos;
@ -14,8 +12,7 @@ import it.unimi.dsi.fastutil.ints.IntLists;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
public class SourceLines implements CharSequence { public class SourceLines implements CharSequence {
private static final Pattern NEW_LINE = Pattern.compile("(\\r\\n|\\r|\\n)");
private static final Pattern newLine = Pattern.compile("(\\r\\n|\\r|\\n)");
public final ResourceLocation name; public final ResourceLocation name;
/** /**
@ -88,7 +85,7 @@ public class SourceLines implements CharSequence {
IntList l = new IntArrayList(); IntList l = new IntArrayList();
l.add(0); // first line is always at position 0 l.add(0); // first line is always at position 0
Matcher matcher = newLine.matcher(source); Matcher matcher = NEW_LINE.matcher(source);
while (matcher.find()) { while (matcher.find()) {
l.add(matcher.end()); l.add(matcher.end());
@ -116,16 +113,17 @@ public class SourceLines implements CharSequence {
return raw; return raw;
} }
@NotNull
@Override @Override
public CharSequence subSequence(int start, int end) { public CharSequence subSequence(int start, int end) {
return raw.subSequence(start, end); return raw.subSequence(start, end);
} }
@Override
public char charAt(int i) { public char charAt(int i) {
return raw.charAt(i); return raw.charAt(i);
} }
@Override
public int length() { public int length() {
return raw.length(); return raw.length();
} }

View file

@ -5,7 +5,6 @@ import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.VisibleForTesting; import org.jetbrains.annotations.VisibleForTesting;
@ -148,7 +147,6 @@ public class ErrorBuilder {
return lineStream.collect(Collectors.joining("\n")); return lineStream.collect(Collectors.joining("\n"));
} }
@NotNull
private Stream<String> getLineStream() { private Stream<String> getLineStream() {
int maxMargin = calculateMargin(); int maxMargin = calculateMargin();

View file

@ -4,13 +4,10 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.jetbrains.annotations.NotNull;
import com.jozufozu.flywheel.lib.util.Pair; import com.jozufozu.flywheel.lib.util.Pair;
import com.jozufozu.flywheel.lib.util.StringUtil; import com.jozufozu.flywheel.lib.util.StringUtil;
public class GlslSwitch implements GlslStmt { public class GlslSwitch implements GlslStmt {
private final GlslExpr on; private final GlslExpr on;
private final List<Pair<GlslExpr, GlslBlock>> cases = new ArrayList<>(); private final List<Pair<GlslExpr, GlslBlock>> cases = new ArrayList<>();
@ -44,7 +41,6 @@ public class GlslSwitch implements GlslStmt {
}""".formatted(on.prettyPrint(), formatCases()); }""".formatted(on.prettyPrint(), formatCases());
} }
@NotNull
private String formatCases() { private String formatCases() {
var cases = this.cases.stream() var cases = this.cases.stream()
.map(GlslSwitch::prettyPrintCase) .map(GlslSwitch::prettyPrintCase)
@ -64,5 +60,4 @@ public class GlslSwitch implements GlslStmt {
case %s: case %s:
%s""".formatted(variant, StringUtil.indent(block, 4)); %s""".formatted(variant, StringUtil.indent(block, 4));
} }
} }

View file

@ -1,6 +0,0 @@
@MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault
package com.jozufozu.flywheel.backend.glsl;
import javax.annotation.ParametersAreNonnullByDefault;
import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -9,7 +9,6 @@ import com.jozufozu.flywheel.backend.glsl.SourceLines;
import com.jozufozu.flywheel.backend.glsl.span.Span; import com.jozufozu.flywheel.backend.glsl.span.Span;
public class ShaderStruct { public class ShaderStruct {
// https://regexr.com/61rpe // https://regexr.com/61rpe
public static final Pattern PATTERN = Pattern.compile("struct\\s+([\\w_]*)\\s*\\{(.*?)}\\s*([\\w_]*)?\\s*;\\s", Pattern.DOTALL); public static final Pattern PATTERN = Pattern.compile("struct\\s+([\\w_]*)\\s*\\{(.*?)}\\s*([\\w_]*)?\\s*;\\s", Pattern.DOTALL);

View file

@ -2,8 +2,6 @@ package com.jozufozu.flywheel.backend.glsl.span;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import org.jetbrains.annotations.NotNull;
import com.jozufozu.flywheel.backend.glsl.SourceFile; import com.jozufozu.flywheel.backend.glsl.SourceFile;
import com.jozufozu.flywheel.backend.glsl.SourceLines; import com.jozufozu.flywheel.backend.glsl.SourceLines;
@ -125,7 +123,7 @@ public abstract class Span implements CharSequence, Comparable<Span> {
} }
@Override @Override
public int compareTo(@NotNull Span o) { public int compareTo(Span o) {
return Integer.compareUnsigned(startIndex(), o.startIndex()); return Integer.compareUnsigned(startIndex(), o.startIndex());
} }
} }

View file

@ -9,7 +9,6 @@ import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.BooleanSupplier; import java.util.function.BooleanSupplier;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import com.jozufozu.flywheel.Flywheel; import com.jozufozu.flywheel.Flywheel;
@ -106,7 +105,7 @@ public class ParallelTaskExecutor implements TaskExecutor {
} }
@Override @Override
public void execute(@NotNull Runnable task) { public void execute(Runnable task) {
if (!running.get()) { if (!running.get()) {
throw new IllegalStateException("Executor is stopped"); throw new IllegalStateException("Executor is stopped");
} }

View file

@ -1,6 +1,5 @@
package com.jozufozu.flywheel.impl.visualization; package com.jozufozu.flywheel.impl.visualization;
import org.jetbrains.annotations.NotNull;
import org.joml.FrustumIntersection; import org.joml.FrustumIntersection;
import org.joml.Matrix4f; import org.joml.Matrix4f;
@ -9,7 +8,6 @@ import com.jozufozu.flywheel.api.event.RenderContext;
import net.minecraft.core.Vec3i; import net.minecraft.core.Vec3i;
public record FrameContext(double cameraX, double cameraY, double cameraZ, FrustumIntersection frustum, float partialTick) { public record FrameContext(double cameraX, double cameraY, double cameraZ, FrustumIntersection frustum, float partialTick) {
@NotNull
public static FrameContext create(RenderContext context, Vec3i renderOrigin) { public static FrameContext create(RenderContext context, Vec3i renderOrigin) {
var cameraPos = context.camera() var cameraPos = context.camera()
.getPosition(); .getPosition();

View file

@ -3,8 +3,6 @@ package com.jozufozu.flywheel.impl.visualization.storage;
import java.util.List; import java.util.List;
import java.util.function.Supplier; import java.util.function.Supplier;
import org.jetbrains.annotations.NotNull;
import com.jozufozu.flywheel.api.task.Plan; import com.jozufozu.flywheel.api.task.Plan;
import com.jozufozu.flywheel.api.task.TaskExecutor; import com.jozufozu.flywheel.api.task.TaskExecutor;
import com.jozufozu.flywheel.lib.task.NestedPlan; import com.jozufozu.flywheel.lib.task.NestedPlan;
@ -13,7 +11,6 @@ import com.jozufozu.flywheel.lib.task.UnitPlan;
public class VisualUpdatePlan<C> implements SimplyComposedPlan<C> { public class VisualUpdatePlan<C> implements SimplyComposedPlan<C> {
private final Supplier<List<Plan<C>>> initializer; private final Supplier<List<Plan<C>>> initializer;
@NotNull
private Plan<C> plan = UnitPlan.of(); private Plan<C> plan = UnitPlan.of();
private boolean initialized = false; private boolean initialized = false;
private boolean needsSimplify = true; private boolean needsSimplify = true;

View file

@ -12,8 +12,8 @@ import com.dreizak.miniball.highdim.Miniball;
import com.dreizak.miniball.model.PointSet; import com.dreizak.miniball.model.PointSet;
import com.jozufozu.flywheel.api.material.Material; import com.jozufozu.flywheel.api.material.Material;
import com.jozufozu.flywheel.api.model.Mesh; import com.jozufozu.flywheel.api.model.Mesh;
import com.jozufozu.flywheel.api.vertex.VertexView;
import com.jozufozu.flywheel.api.vertex.VertexList; import com.jozufozu.flywheel.api.vertex.VertexList;
import com.jozufozu.flywheel.api.vertex.VertexView;
import com.jozufozu.flywheel.api.vertex.VertexViewProviderRegistry; import com.jozufozu.flywheel.api.vertex.VertexViewProviderRegistry;
import com.jozufozu.flywheel.lib.material.Materials; import com.jozufozu.flywheel.lib.material.Materials;
import com.jozufozu.flywheel.lib.memory.MemoryBlock; import com.jozufozu.flywheel.lib.memory.MemoryBlock;

View file

@ -3,8 +3,6 @@ package com.jozufozu.flywheel.lib.model.baked;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.jetbrains.annotations.NotNull;
import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.client.event.ModelEvent; import net.minecraftforge.client.event.ModelEvent;
@ -51,7 +49,6 @@ public class PartialModel {
} }
} }
@NotNull
public String getName() { public String getName() {
return getLocation() return getLocation()
.toString(); .toString();

View file

@ -5,4 +5,12 @@
* interface, but do not need to create additional closure objects to translate when the consumer wishes to ignore * interface, but do not need to create additional closure objects to translate when the consumer wishes to ignore
* the context object. * the context object.
*/ */
@ParametersAreNonnullByDefault
@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
package com.jozufozu.flywheel.lib.task.functional; package com.jozufozu.flywheel.lib.task.functional;
import javax.annotation.ParametersAreNonnullByDefault;
import net.minecraft.FieldsAreNonnullByDefault;
import net.minecraft.MethodsReturnNonnullByDefault;

View file

@ -1,7 +1,5 @@
package com.jozufozu.flywheel.lib.util; package com.jozufozu.flywheel.lib.util;
import org.jetbrains.annotations.NotNull;
import com.jozufozu.flywheel.Flywheel; import com.jozufozu.flywheel.Flywheel;
import com.mojang.brigadier.StringReader; import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.CommandSyntaxException;
@ -55,7 +53,6 @@ public final class ResourceUtil {
} }
} }
@NotNull
public static String toDebugFileNameNoExtension(ResourceLocation resourceLocation) { public static String toDebugFileNameNoExtension(ResourceLocation resourceLocation) {
var stringLoc = resourceLocation.toString(); var stringLoc = resourceLocation.toString();
return stringLoc.substring(0, stringLoc.lastIndexOf('.')) return stringLoc.substring(0, stringLoc.lastIndexOf('.'))

View file

@ -3,8 +3,6 @@ package com.jozufozu.flywheel.lib.visual;
import java.util.Objects; import java.util.Objects;
import java.util.function.Predicate; import java.util.function.Predicate;
import org.jetbrains.annotations.NotNull;
import com.jozufozu.flywheel.api.visual.BlockEntityVisual; import com.jozufozu.flywheel.api.visual.BlockEntityVisual;
import com.jozufozu.flywheel.api.visualization.BlockEntityVisualizer; import com.jozufozu.flywheel.api.visualization.BlockEntityVisualizer;
import com.jozufozu.flywheel.api.visualization.VisualizationContext; import com.jozufozu.flywheel.api.visualization.VisualizationContext;
@ -45,7 +43,7 @@ public class SimpleBlockEntityVisualizer<T extends BlockEntity> implements Block
@FunctionalInterface @FunctionalInterface
public interface Factory<T extends BlockEntity> { public interface Factory<T extends BlockEntity> {
@NotNull BlockEntityVisual<? super T> create(VisualizationContext ctx, T blockEntity); BlockEntityVisual<? super T> create(VisualizationContext ctx, T blockEntity);
} }
/** /**

View file

@ -3,8 +3,6 @@ package com.jozufozu.flywheel.lib.visual;
import java.util.Objects; import java.util.Objects;
import java.util.function.Predicate; import java.util.function.Predicate;
import org.jetbrains.annotations.NotNull;
import com.jozufozu.flywheel.api.visual.EntityVisual; import com.jozufozu.flywheel.api.visual.EntityVisual;
import com.jozufozu.flywheel.api.visualization.EntityVisualizer; import com.jozufozu.flywheel.api.visualization.EntityVisualizer;
import com.jozufozu.flywheel.api.visualization.VisualizationContext; import com.jozufozu.flywheel.api.visualization.VisualizationContext;
@ -45,7 +43,7 @@ public class SimpleEntityVisualizer<T extends Entity> implements EntityVisualize
@FunctionalInterface @FunctionalInterface
public interface Factory<T extends Entity> { public interface Factory<T extends Entity> {
@NotNull EntityVisual<? super T> create(VisualizationContext ctx, T entity); EntityVisual<? super T> create(VisualizationContext ctx, T entity);
} }
/** /**

View file

@ -5,7 +5,6 @@ license = "MIT"
[[mods]] [[mods]]
modId = "flywheel" modId = "flywheel"
# The Implementation-Version property in the jar's MANIFEST.MF file will be used as the mod version at runtime
version = "${mod_version}" version = "${mod_version}"
displayName = "Flywheel" displayName = "Flywheel"
logoFile = "logo.png" logoFile = "logo.png"

View file

@ -4,7 +4,6 @@ import java.io.FileNotFoundException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
@ -21,7 +20,6 @@ public class MockShaderSources extends ShaderSources {
sources.put(loc, source); sources.put(loc, source);
} }
@NotNull
@Override @Override
protected LoadResult load(ResourceLocation loc) { protected LoadResult load(ResourceLocation loc) {
var maybeFound = sources.get(loc); var maybeFound = sources.get(loc);

View file

@ -6,8 +6,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.List; import java.util.List;
import org.jetbrains.annotations.NotNull;
import com.jozufozu.flywheel.Flywheel; import com.jozufozu.flywheel.Flywheel;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
@ -22,7 +20,6 @@ public class TestBase {
return list.get(0); return list.get(0);
} }
@NotNull
public static <E extends LoadError> E findAndAssertError(Class<E> clazz, MockShaderSources sources, ResourceLocation loc) { public static <E extends LoadError> E findAndAssertError(Class<E> clazz, MockShaderSources sources, ResourceLocation loc) {
var result = sources.find(loc); var result = sources.find(loc);
var failure = assertInstanceOf(LoadResult.Failure.class, result); var failure = assertInstanceOf(LoadResult.Failure.class, result);
@ -40,13 +37,11 @@ public class TestBase {
return assertInstanceOf(finalErrType, pair.second()); return assertInstanceOf(finalErrType, pair.second());
} }
@NotNull
public static SourceFile findAndAssertSuccess(MockShaderSources sources, ResourceLocation loc) { public static SourceFile findAndAssertSuccess(MockShaderSources sources, ResourceLocation loc) {
var result = sources.find(loc); var result = sources.find(loc);
return assertSuccessAndUnwrap(loc, result); return assertSuccessAndUnwrap(loc, result);
} }
@NotNull
public static SourceFile assertSuccessAndUnwrap(ResourceLocation expectedName, LoadResult result) { public static SourceFile assertSuccessAndUnwrap(ResourceLocation expectedName, LoadResult result) {
assertInstanceOf(LoadResult.Success.class, result); assertInstanceOf(LoadResult.Success.class, result);

View file

@ -3,7 +3,6 @@ package com.jozufozu.flywheel.backend.glsl;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -62,7 +61,6 @@ public class TestErrorMessages extends TestBase {
assertEquals(expected.trim(), message.trim()); assertEquals(expected.trim(), message.trim());
} }
@NotNull
public static ErrorBuilder assertErrorAndGetMessage(MockShaderSources sources, ResourceLocation loc) { public static ErrorBuilder assertErrorAndGetMessage(MockShaderSources sources, ResourceLocation loc) {
var result = sources.find(loc); var result = sources.find(loc);
var failure = assertInstanceOf(LoadResult.Failure.class, result); var failure = assertInstanceOf(LoadResult.Failure.class, result);