From 822568ecaa1269bc6936a0a56ba35f909bbfe7c5 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Sat, 3 Jun 2023 00:21:09 -0400 Subject: [PATCH] Banners on shields support --- .../geysermc/geyser/item/type/ShieldItem.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/core/src/main/java/org/geysermc/geyser/item/type/ShieldItem.java b/core/src/main/java/org/geysermc/geyser/item/type/ShieldItem.java index fc28e1f50..c13dd4fcf 100644 --- a/core/src/main/java/org/geysermc/geyser/item/type/ShieldItem.java +++ b/core/src/main/java/org/geysermc/geyser/item/type/ShieldItem.java @@ -25,13 +25,40 @@ package org.geysermc.geyser.item.type; +import com.github.steveice10.opennbt.tag.builtin.CompoundTag; +import com.github.steveice10.opennbt.tag.builtin.IntTag; +import com.github.steveice10.opennbt.tag.builtin.ListTag; +import com.github.steveice10.opennbt.tag.builtin.Tag; +import org.checkerframework.checker.nullness.qual.NonNull; import org.geysermc.geyser.item.components.ToolTier; +import org.geysermc.geyser.session.GeyserSession; public class ShieldItem extends Item { public ShieldItem(String javaIdentifier, Builder builder) { super(javaIdentifier, builder); } + @Override + public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) { + super.translateNbtToBedrock(session, tag); + + if (tag.remove("BlockEntityTag") instanceof CompoundTag blockEntityTag) { + if (blockEntityTag.get("Patterns") instanceof ListTag patterns) { + for (Tag pattern : patterns) { + if (((CompoundTag) pattern).get("Color") instanceof IntTag color) { + color.setValue(15 - color.getValue()); + } + } + // Bedrock looks for patterns at the root + tag.put(patterns); + } + if (blockEntityTag.get("Base") instanceof IntTag base) { + base.setValue(15 - base.getValue()); + tag.put(base); + } + } + } + @Override public boolean isValidRepairItem(Item other) { // Java Edition 1.19.3 checks the tag, but TODO check to see if we want it or are simulating what Bedrock is doing