mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2024-11-21 12:07:38 +01:00
Update VV API usage (#906)
Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
This commit is contained in:
parent
d6c27add17
commit
2c3c62d246
@ -114,6 +114,7 @@ public class BackwardsStructuredItemRewriter<C extends ClientboundPacketType, S
|
|||||||
if (customData != null) {
|
if (customData != null) {
|
||||||
if (customData.remove(nbtTagName("id")) instanceof final IntTag originalTag) {
|
if (customData.remove(nbtTagName("id")) instanceof final IntTag originalTag) {
|
||||||
item.setIdentifier(originalTag.asInt());
|
item.setIdentifier(originalTag.asInt());
|
||||||
|
removeCustomTag(dataContainer, customData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
package com.viaversion.viabackwards.protocol.v1_21to1_20_5.rewriter;
|
package com.viaversion.viabackwards.protocol.v1_21to1_20_5.rewriter;
|
||||||
|
|
||||||
import com.viaversion.nbt.tag.ByteTag;
|
import com.viaversion.nbt.tag.ByteTag;
|
||||||
|
import com.viaversion.nbt.tag.CompoundTag;
|
||||||
import com.viaversion.nbt.tag.StringTag;
|
import com.viaversion.nbt.tag.StringTag;
|
||||||
import com.viaversion.nbt.tag.Tag;
|
import com.viaversion.nbt.tag.Tag;
|
||||||
import com.viaversion.viabackwards.api.rewriters.BackwardsStructuredItemRewriter;
|
import com.viaversion.viabackwards.api.rewriters.BackwardsStructuredItemRewriter;
|
||||||
@ -53,7 +54,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter.BlockItemPacketRewriter1_21.downgradeItemData;
|
import static com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter.BlockItemPacketRewriter1_21.downgradeItemData;
|
||||||
import static com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter.BlockItemPacketRewriter1_21.resetRarityValues;
|
|
||||||
import static com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter.BlockItemPacketRewriter1_21.updateItemData;
|
import static com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter.BlockItemPacketRewriter1_21.updateItemData;
|
||||||
|
|
||||||
public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRewriter<ClientboundPacket1_21, ServerboundPacket1_20_5, Protocol1_21To1_20_5> {
|
public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRewriter<ClientboundPacket1_21, ServerboundPacket1_20_5, Protocol1_21To1_20_5> {
|
||||||
@ -190,15 +190,13 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe
|
|||||||
super.handleItemToClient(connection, item);
|
super.handleItemToClient(connection, item);
|
||||||
downgradeItemData(item);
|
downgradeItemData(item);
|
||||||
|
|
||||||
final StructuredDataContainer dataContainer = item.dataContainer();
|
if (data.has(StructuredDataKey.RARITY)) {
|
||||||
if (dataContainer.has(StructuredDataKey.RARITY)) {
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change rarity of trident and piglin banner pattern
|
// Change rarity of trident and piglin banner pattern
|
||||||
final boolean trident = identifier == 1188;
|
final boolean trident = identifier == 1188;
|
||||||
if (trident || identifier == 1200) {
|
if (trident || identifier == 1200) {
|
||||||
dataContainer.set(StructuredDataKey.RARITY, trident ? 3 : 1); // Epic or Uncommon
|
data.set(StructuredDataKey.RARITY, trident ? 3 : 1); // Epic or Uncommon
|
||||||
saveTag(createCustomTag(item), new ByteTag(true), "rarity");
|
saveTag(createCustomTag(item), new ByteTag(true), "rarity");
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
@ -210,8 +208,8 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
final StructuredDataContainer dataContainer = item.dataContainer();
|
final StructuredDataContainer data = item.dataContainer();
|
||||||
dataContainer.setIdLookup(protocol, false);
|
data.setIdLookup(protocol, false);
|
||||||
|
|
||||||
// Rewrite enchantments
|
// Rewrite enchantments
|
||||||
final EnchantmentsPaintingsStorage storage = connection.get(EnchantmentsPaintingsStorage.class);
|
final EnchantmentsPaintingsStorage storage = connection.get(EnchantmentsPaintingsStorage.class);
|
||||||
@ -224,7 +222,15 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe
|
|||||||
// Order is important
|
// Order is important
|
||||||
super.handleItemToServer(connection, item);
|
super.handleItemToServer(connection, item);
|
||||||
updateItemData(item);
|
updateItemData(item);
|
||||||
resetRarityValues(item, nbtTagName("rarity"));
|
|
||||||
|
final CompoundTag customData = data.get(StructuredDataKey.CUSTOM_DATA);
|
||||||
|
if (customData == null) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
if (customData.remove(nbtTagName("rarity")) != null) {
|
||||||
|
data.remove(StructuredDataKey.RARITY);
|
||||||
|
removeCustomTag(data, customData);
|
||||||
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user