mojira.dev
MC-269687

Most components of banners not saved when placed/broken

Almost all components of banner blocks are lost when the banner is placed down, and later broken. This leads to behavior such as the banner not being able to stack with other similar banners when picked back up.

Steps to Reproduce:

  1. Get the following item stack:

    /give @p white_banner[minecraft:max_stack_size=99] 99
  2. Place one banner down

  3. Break it
    → ❌ The max_stack_size component is lost, and will not stack with the other banners it used to stack with.

Expected Results:

✔ - The banner would stack with the other items and keep it's components when placed.

Screenshots/Videos:

[media]

Notes:

  1. Code Analysis in the pinned comment.

  2. Relates to MC-251509 MC-261369 MC-106043 MC-249067 MC-140069

Related issues

Attachments

Comments

migrated
[media]
[Mod] Jingy

Code Analysis:

(Class: BannerBlockEntity / Method saveAdditional() & load() / Mappings: Mojang using MCPReborn)

Here, the only data which is saved, is "CustomName" and "patterns".

protected void saveAdditional(CompoundTag compoundTag, HolderLookup.Provider provider) {
      super.saveAdditional(compoundTag, provider);
      if (!this.patterns.equals(BannerPatternLayers.EMPTY)) {
         compoundTag.put("patterns", Util.getOrThrow(BannerPatternLayers.CODEC.encodeStart(provider.createSerializationContext(NbtOps.INSTANCE), this.patterns), IllegalStateException::new));
      }
      if (this.name != null) {
         compoundTag.putString("CustomName", Component.Serializer.toJson(this.name, provider));
      }
   }

   public void load(CompoundTag compoundTag, HolderLookup.Provider provider) {
      super.load(compoundTag, provider);
      if (compoundTag.contains("CustomName", 8)) {
         this.name = Component.Serializer.fromJson(compoundTag.getString("CustomName"), provider);
      }
      if (compoundTag.contains("patterns")) {
         BannerPatternLayers.CODEC.parse(provider.createSerializationContext(NbtOps.INSTANCE), compoundTag.get("patterns")).resultOrPartial((p_329523_) -> {
            LOGGER.error("Failed to parse banner patterns: '{}'", (Object)p_329523_);
         }).ifPresent((p_330866_) -> {
            this.patterns = p_330866_;
         });
      }
   }
[Mod] turbo

Thank you for your report!
After consideration, the issue is being closed as Invalid.

You have posted a feature request or a suggestion. This site is for bug reports only.
For suggestions, please visit The official Minecraft feedback site or visit the Minecraft Feedback Discord server.

Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support (Technical Issues) – 📧 Microsoft Support (Account Issues)
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki

[Mod] Jingy

(Unassigned)

Confirmed

Platform

Important

Block states, Items, Save Data

banner, component, data-loss

24w12a

Retrieved