felinoid Posted December 7, 2020 Share Posted December 7, 2020 I have a mod that registers entities. Like every other 1.16 mod I have seen that registers entities, it prints the error "No data fixer registered for [entity]" every time it starts up. As far as I can tell, the lack of a data fixer is not causing any actual problems except for the error message. Loading from an older Minecraft version works fine. I do change the entity's save format occasionally, but that does not align neatly with Minecraft's version numbers so I write my own code logic to handle it. Mainly I just want it to not print an error. The message is coming from net.minecraft.util.Util: @Nullable public static Type<?> attemptDataFix(TypeReference type, String choiceName) { return !SharedConstants.useDatafixers ? null : attemptDataFixInternal(type, choiceName); } @Nullable private static Type<?> attemptDataFixInternal(TypeReference typeIn, String choiceName) { Type<?> type = null; try { type = DataFixesManager.getDataFixer().getSchema(DataFixUtils.makeKey(SharedConstants.getVersion().getWorldVersion())).getChoiceType(typeIn, choiceName); } catch (IllegalArgumentException illegalargumentexception) { LOGGER.error("No data fixer registered for {}", (Object)choiceName); if (SharedConstants.developmentMode) { throw illegalargumentexception; } } return type; } which is being called from net.minecraft.entity.EntityType.Builder.build: public EntityType<T> build(String id) { if (this.serializable) { Util.attemptDataFix(TypeReferences.ENTITY_TYPE, id); } return new EntityType<>(this.factory, this.classification, this.serializable, this.summonable, this.immuneToFire, this.field_225436_f, this.field_233603_c_, this.size, this.field_233604_h_, this.field_233605_i_, velocityUpdateSupplier, trackingRangeSupplier, updateIntervalSupplier, customClientFactory); } The most straightforward approach would probably be to register my own data fixer. I'm not sure how I would go about that or if it's even possible, as I can't find documentation for com.mojang.datafixers anywhere. I see a mention of it here, which doesn't look like it got resolved. Another possibility would be to pass the wrong argument in to the build method. For instance, if I passed it "minecraft:donkey" instead of my own donkey's ID, presumably that would get any data fixers registered for the donkey. This seems super sketchy. I know I don't need the HorseSaddle or HorseSplit fixes, what I don't know is whether it might also do something unexpected that could create a bug. This doesn't seem worth it. Oddly enough, SharedConstants.useDataFixers isn't final, which means in my entity registration method I could set it to false and then back to its previous value again. But if a lot of people do that, someday someone will forget to set it back to the previous value. That could potentially cause exactly the sort of corruption issues data fixers are supposed to prevent, all while being near impossible for a user to debug. The last option I see is to pass the build method a nonsense string such as "ignore this error". This is ugly, but at least it indicates to users that they should look elsewhere to find why they crashed. I don't like any of these, nor do I like leaving it be. Anyone have opinions on which is the least bad? Quote Link to comment Share on other sites More sharing options...
Chumbanotz Posted December 7, 2020 Share Posted December 7, 2020 I think I've found a viable way to prevent this error message. Copy the EntityType.Builder class, delete the check in EntityType#build, and use this class instead of the normal EntityType.Builder to create your entity types. I would place this class where your entity types are stored. You'll have to provide the Forge-added fields with the default value, as the fields from EntityType are private. Quote Link to comment Share on other sites More sharing options...
felinoid Posted December 7, 2020 Author Share Posted December 7, 2020 Yeaahh... looks like the only way to have pretty code is to leave it be. I just wish users wouldn't assume that because it says "ERROR" it's responsible for whatever problem they're having. I'll leave it for now, but if it shows up in too many more bug reports I might try passing the builder an empty/nonsense string. Thank you Diesieben, good to have it confirmed that at least I don't need to register a data fixer. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.