Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import com.viaversion.nbt.tag.ByteTag;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.IntTag;
import com.viaversion.nbt.tag.ListTag;
import com.viaversion.nbt.tag.StringTag;
import com.viaversion.nbt.tag.Tag;
Expand Down Expand Up @@ -194,6 +195,7 @@ protected void registerRewrites() {
@Override
public Item handleItemToClient(UserConnection connection, Item item) {
if (item == null) return null;
final int originalId = item.identifier();
super.handleItemToClient(connection, item);

CompoundTag tag = item.tag();
Expand Down Expand Up @@ -280,6 +282,32 @@ public Item handleItemToClient(UserConnection connection, Item item) {
});
}

// Colors the fake leather armor for an elytra gray
if (originalId == 443) {
if (tag == null) {
item.setTag(tag = new CompoundTag());
}
CompoundTag display = tag.getCompoundTag("display");
if (display == null) {
tag.put("display", display = new CompoundTag());
}
display.put("color", new IntTag(0x737373)); // Gray
tag.put(nbtTagName() + "|elytra_color", new ByteTag(true));
}

// Makes the fake banner for a shield brown if it has no banner patterns
if (originalId == 442) {
final CompoundTag blockEntityTag = tag == null ? null : tag.getCompoundTag("BlockEntityTag");
final ListTag<CompoundTag> patterns = blockEntityTag == null ? null : blockEntityTag.getListTag("Patterns", CompoundTag.class);
if (patterns == null || patterns.isEmpty()) {
item.setData((short) 3); // Brown
if (tag == null) {
item.setTag(tag = new CompoundTag());
}
tag.put(nbtTagName() + "|shield_color", new ByteTag(true));
}
}

return item;
}

Expand All @@ -290,6 +318,19 @@ public Item handleItemToServer(UserConnection connection, Item item) {

CompoundTag tag = item.tag();

// Removes the gray color code from the fake leather armor for an elytra
if (tag != null && tag.remove(nbtTagName() + "|elytra_color") != null) {
final CompoundTag display = tag.getCompoundTag("display");
if (display != null) {
display.remove("color");
}
}

// Restores the original data of a shield whose banner color was changed to brown
if (tag != null && tag.remove(nbtTagName() + "|shield_color") != null) {
item.setData((short) 0);
}

enchantmentRewriter.handleToServer(item);

if (item.identifier() == 383 && item.data() != 0) { // Spawn eggs
Expand Down