ItemStack.getData() and ItemStack.setData(...) cause legacy material init

    • Type: Bug
    • Resolution: Won't Fix
    • Priority: Minor
    • None
    • Affects Version/s: None
    • Environment:

      Affects Minecraft versions 1.13+

    • git-Paper-135 (MC: 1.16.1)
    • Yes

      Calling ItemStack.getData() or ItemStack.setData(...) causes legacy material support initialization{{}}:

      Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!

      The server freezes for a second while it does some legacy material magic before returning a legacy material (e.g. LEGACY_DIRT, instead of{{ DIRT}}).

      The documentation does not mention this behavior.

      As I feel we all would prefer to work with new, better DIRT over old, horrible LEGACY_DIRT, I think the method should be annotated as deprecated and/or the documentation should be updated to make users aware of this (misleading) behavior.

      One of the methods in question looks like so:

      /**
      {{ * Gets the MaterialData for this stack of items}}
      {{ *}}
      {{ * @return MaterialData for this item}}
      {{ */}}
      @Nullable
      public MaterialData getData() {
          Material mat = Bukkit.getUnsafe().toLegacy(getType());
          if (data == null && mat != null && mat.getData() != null) {
              data = mat.getNewData((byte) this.getDurability());
      {{    }}}

          return data;
      }

       

            Assignee:
            Unassigned
            Reporter:
            Oscar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: