When creating a new schema, buildTypes() is called. In that method templates.stream().reduce(DSL::or).get();.reduce(DSL::or).get(); At this time templates only includes the entries in the RECURSIVE_TYPES map. The .get() method is troublesome, as if the .reduce() function didn't return anything, then the method reports a NoSuchElementException and breaks. If you don't add any recursive types, then .get() throws the error.
Error Log:
Exception in thread "main" java.util.NoSuchElementException: No value present at java.util.Optional.get(Optional.java:135) at com.mojang.datafixers.schemas.Schema.buildTypes(Schema.java:50) at com.mojang.datafixers.schemas.Schema.<init>(Schema.java:38) at DataFixerUpperExamples.schemas.Version1.<init>(Version1.java:16) at com.mojang.datafixers.DataFixerBuilder.addSchema(DataFixerBuilder.java:40) at com.mojang.datafixers.DataFixerBuilder.addSchema(DataFixerBuilder.java:34)
Details of how to reproduce
Create a new class that extends Schema with the regular override of functions registerEntities(), registerBlockEntities() and registerTypes(), but don't register a recursive type, (i.e. never schema.registerType(true, ...); ) For my schema class, see below:
public class Version1 extends Schema {
public Version1(int versionKey, Schema parent) {
super(versionKey, parent);
}
public Version1() {
super(1, null);
}
public void registerTypes(final Schema schema, final Map<String, Supplier<TypeTemplate>> entityTypes, final Map<String, Supplier<TypeTemplate>> blockEntityTypes) {
schema.registerType(false, TypeReferences.LEVEL, DSL::remainder);
}
public Map<String, Supplier<TypeTemplate>> registerEntities(final Schema schema) {
Map<String, Supplier<TypeTemplate>> map = Maps.newHashMap();
return map;
}
public Map<String, Supplier<TypeTemplate>> registerBlockEntities(final Schema schema) {
Map<String, Supplier<TypeTemplate>> map = Maps.newHashMap();
return map;
}
}
Description
When creating a new schema,
buildTypes()
is called. In that methodtemplates.stream().reduce(DSL::or).get();.reduce(DSL::or).get();
At this timetemplates
only includes the entries in the RECURSIVE_TYPES map. The.get()
method is troublesome, as if the.reduce()
function didn't return anything, then the method reports a NoSuchElementException and breaks. If you don't add any recursive types, then.get()
throws the error.Error Log:
Exception in thread "main" java.util.NoSuchElementException: No value present at java.util.Optional.get(Optional.java:135) at com.mojang.datafixers.schemas.Schema.buildTypes(Schema.java:50) at com.mojang.datafixers.schemas.Schema.<init>(Schema.java:38) at DataFixerUpperExamples.schemas.Version1.<init>(Version1.java:16) at com.mojang.datafixers.DataFixerBuilder.addSchema(DataFixerBuilder.java:40) at com.mojang.datafixers.DataFixerBuilder.addSchema(DataFixerBuilder.java:34)
Details of how to reproduce
Create a new class that extends Schema with the regular override of functions registerEntities(), registerBlockEntities() and registerTypes(), but don't register a recursive type, (i.e. never schema.registerType(true, ...); ) For my schema class, see below: