Skip to content

Commit

Permalink
Fix Lapis Lazuli not working in Translating tables
Browse files Browse the repository at this point in the history
We now look for the best match when translating an item which allows the more specific lapis to have priority over the generic dye

Reference: bundabrg/GeyserReversion#21
  • Loading branch information
bundabrg committed Dec 7, 2020
1 parent 2db658d commit fa8df03
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,21 @@ public ItemData mapItemDataToDownstream(ItemData item) {
return null;
}

RuntimeItemMapperEntry best = null;
for (RuntimeItemMapperEntry itemMapperEntry : itemToDownstreamMap.getOrDefault(item.getId(), new ArrayList<>())) {
VariableStore variableStore = new VariableStore();

if (!variableStore.compare(item.getDamage(), itemMapperEntry.getUpstream().getData())) {
continue;
}

if (best == null || best.getUpstream().getData() == null) {
best = itemMapperEntry;
}
}

if (best != null) {
VariableStore variableStore = new VariableStore();
NbtMap tag = item.getTag(); //enchantmentMapper.mapEnchantmentNbtToUpstream(item.getTag());
// TODO
// if (mapConfig.getDownstream().getName() != null) {
Expand All @@ -413,8 +421,8 @@ public ItemData mapItemDataToDownstream(ItemData item) {
// tagBuilder.putCompound("display", NbtMap.builder().putString("Name", mapConfig.getUpstream().getName()).build());
// tag = tagBuilder.build();
// }
return ItemData.fromNet(item.getNetId(), itemMapperEntry.getDownstream().getId(),
variableStore.getInt(itemMapperEntry.getDownstream().getData(), 0).shortValue(), item.getCount(),
return ItemData.fromNet(item.getNetId(), best.getDownstream().getId(),
variableStore.getInt(best.getDownstream().getData(), 0).shortValue(), item.getCount(),
tag, item.getCanPlace(), item.getCanBreak(), item.getBlockingTicks());
}
return item;
Expand Down

0 comments on commit fa8df03

Please sign in to comment.