Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.16.3] Getting rid of data fixer error spam


felinoid
 Share

Recommended Posts

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?

Link to comment
Share on other sites

Data fixers are based on a global, ever increasing, "world file format version". This version is a single int for the whole world. As such, this is entirely incompatible with modding, as of course every mod needs their own world file format version.

 

I believe there was an attempt at some point to have every mod have their own version number, but it has not been done.

 

As such the best option currently is to just leave the error message be.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.