Am I doing something wrong?

So I have a signed book and I am trying to unsign it by changing the ItemType to WRITTABLE_BOOK by creating a ItemStackSnapshot of a WRITTABLE_BOOK and then copying over the Keys and values over from the original signed book. However something odd happens

Signed book

Unsigned book with copied key+value from the signed book

Am I doing something wrong as the value is directly copied over?

here is my code

        Slot slot;
        ItemStack book = slot.peek().get();
        ItemStackSnapshot snapshot = ItemTypes.WRITABLE_BOOK.getTemplate();
        for(Key<? extends BaseValue<? extends Object>> key : book.getKeys()){
            snapshot = addTo(snapshot, book, key);
        return CommandResult.success();

    private <T extends Object> ItemStackSnapshot addTo(ItemStackSnapshot snapshot, ItemStack book, Key<? extends BaseValue<? extends Object>> key){
        Key<? extends BaseValue<T>> key2 = (Key<? extends BaseValue<T>>)key;
        Optional<T> opValue = book.get(key2);
            return snapshot;
        Optional<ItemStackSnapshot> opSnapshot = snapshot.with(key2, opValue.get());
            return opSnapshot.get();
        return snapshot;

Check what values you’re copying over would be my advice. Add a couple debug log lines in that loop, and see the exact values you’re inserting into the writable book.

I have since then. Checking the Text values from book as “toPlain()” results in the same text you see in the book.
Does that mean its a sponge issue?


1 Like