Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-170128

Cannot build an EntityType without a datafixer due to an IllegalArgumentException

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Resolution: Fixed
    • 1.15.1, 1.15.2 Pre-release 2
    • 20w06a
    • None
    • Minecraft 1.15.2 Pre-release 2, Yarn v2 1.15.2-pre2+build.1 (Decompiled in IDEA with FernFlower)
    • Plausible
    • Crash
    • Normal

    Description

      The bug

      This bug report is based off of Minecraft 1.15.2 Pre-release 2 with Yarn names and decompiled with FernFlower.

      EntityType$Builder#build(String id) tries to get a datafixer for the entity before creating the type, and continue even if it is unable to get the fixer.
      The vanilla code looks like this:

      public EntityType<T> build(String id) {
          if (this.saveable) {
              try {
                  Schemas.getFixer().getSchema(DataFixUtils.makeKey(SharedConstants.getGameVersion().getWorldVersion())).getChoiceType(TypeReferences.ENTITY_TREE, id);
              } catch (IllegalStateException var3) {
                  if (SharedConstants.isDevelopment) {
                      throw var3;
                  }
      
                  EntityType.LOGGER.warn("No data fixer registered for entity {}", id);
              }
          }
      
          return new EntityType(this.factory, this.category, this.saveable, this.summonable, this.fireImmune, this.spawnableFarFromPlayer, this.size);
      }
      

      Vanilla catches an IllegalStateException, but the actual exception that is thrown by Schema#getChoiceType is IllegalArgumentException. This means that if an EntityType is built for an entity that doesn't have a type, the game will fail hard and crash.

      Recommended change:

      ...
      } catch (IllegalArgumentException var3) {
      ...
      

      Attachments

        Activity

          People

            slicedlime [Mojang] slicedlime
            glitchieplays Glitch
            Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              CHK: