Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type Building Assumes that you have recursive types #45

Open
lochnessdragon opened this issue Feb 14, 2020 · 0 comments
Open

Type Building Assumes that you have recursive types #45

lochnessdragon opened this issue Feb 14, 2020 · 0 comments

Comments

@lochnessdragon
Copy link

lochnessdragon commented Feb 14, 2020

Description

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;
}

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant