mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-12-23 08:57:39 +01:00
Replace DataItem constructor usages (#3893)
This commit is contained in:
parent
03e8eec12e
commit
5245a7ef2e
@ -320,11 +320,11 @@ public class EntityPacketRewriter1_14 extends EntityRewriter<ClientboundPackets1
|
|||||||
int armorType = meta.value();
|
int armorType = meta.value();
|
||||||
Item armorItem = null;
|
Item armorItem = null;
|
||||||
if (armorType == 1) { //iron armor
|
if (armorType == 1) { //iron armor
|
||||||
armorItem = new DataItem(protocol.getMappingData().getNewItemId(727), (byte) 1, (short) 0, null);
|
armorItem = new DataItem(protocol.getMappingData().getNewItemId(727), (byte) 1, null);
|
||||||
} else if (armorType == 2) { //gold armor
|
} else if (armorType == 2) { //gold armor
|
||||||
armorItem = new DataItem(protocol.getMappingData().getNewItemId(728), (byte) 1, (short) 0, null);
|
armorItem = new DataItem(protocol.getMappingData().getNewItemId(728), (byte) 1, null);
|
||||||
} else if (armorType == 3) { //diamond armor
|
} else if (armorType == 3) { //diamond armor
|
||||||
armorItem = new DataItem(protocol.getMappingData().getNewItemId(729), (byte) 1, (short) 0, null);
|
armorItem = new DataItem(protocol.getMappingData().getNewItemId(729), (byte) 1, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketWrapper equipmentPacket = PacketWrapper.create(ClientboundPackets1_14.SET_EQUIPPED_ITEM, null, event.user());
|
PacketWrapper equipmentPacket = PacketWrapper.create(ClientboundPackets1_14.SET_EQUIPPED_ITEM, null, event.user());
|
||||||
|
@ -222,7 +222,7 @@ public class ItemPacketRewriter1_14 extends ItemRewriter<ClientboundPackets1_13,
|
|||||||
resyncPacket.write(Types.VAR_INT, 5); // 4 - Mode - Drag
|
resyncPacket.write(Types.VAR_INT, 5); // 4 - Mode - Drag
|
||||||
CompoundTag tag = new CompoundTag();
|
CompoundTag tag = new CompoundTag();
|
||||||
tag.put("force_resync", new DoubleTag(Double.NaN)); // Tags with NaN are not equal
|
tag.put("force_resync", new DoubleTag(Double.NaN)); // Tags with NaN are not equal
|
||||||
resyncPacket.write(Types.ITEM1_13_2, new DataItem(1, (byte) 1, (short) 0, tag)); // 5 - Clicked Item
|
resyncPacket.write(Types.ITEM1_13_2, new DataItem(1, (byte) 1, tag)); // 5 - Clicked Item
|
||||||
resyncPacket.scheduleSendToServer(Protocol1_13_2To1_14.class);
|
resyncPacket.scheduleSendToServer(Protocol1_13_2To1_14.class);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ public final class Protocol1_17To1_17_1 extends AbstractProtocol<ClientboundPack
|
|||||||
|
|
||||||
registerServerbound(ServerboundPackets1_17.EDIT_BOOK, wrapper -> {
|
registerServerbound(ServerboundPackets1_17.EDIT_BOOK, wrapper -> {
|
||||||
CompoundTag tag = new CompoundTag();
|
CompoundTag tag = new CompoundTag();
|
||||||
Item item = new DataItem(942, (byte) 1, (short) 0, tag); // Magic value for writable books
|
Item item = new DataItem(942, (byte) 1, tag); // Magic value for writable books
|
||||||
|
|
||||||
// Write the item, edit the tag down the line
|
// Write the item, edit the tag down the line
|
||||||
wrapper.write(Types.ITEM1_13_2, item);
|
wrapper.write(Types.ITEM1_13_2, item);
|
||||||
|
@ -391,7 +391,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
|
|
||||||
final StructuredData<CompoundTag> customData = data.getNonEmpty(StructuredDataKey.CUSTOM_DATA);
|
final StructuredData<CompoundTag> customData = data.getNonEmpty(StructuredDataKey.CUSTOM_DATA);
|
||||||
final CompoundTag tag = customData != null ? customData.value() : new CompoundTag();
|
final CompoundTag tag = customData != null ? customData.value() : new CompoundTag();
|
||||||
final DataItem dataItem = new DataItem(item.identifier(), (byte) item.amount(), (short) 0, tag);
|
final DataItem dataItem = new DataItem(item.identifier(), (byte) item.amount(), tag);
|
||||||
if (customData != null && tag.remove(nbtTagName()) != null) {
|
if (customData != null && tag.remove(nbtTagName()) != null) {
|
||||||
return dataItem;
|
return dataItem;
|
||||||
}
|
}
|
||||||
@ -1204,7 +1204,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
|||||||
|
|
||||||
final byte count = item.getByte("Count", (byte) 1);
|
final byte count = item.getByte("Count", (byte) 1);
|
||||||
final CompoundTag tag = item.getCompoundTag("tag");
|
final CompoundTag tag = item.getCompoundTag("tag");
|
||||||
return handleItemToClient(connection, new DataItem(itemId, count, (short) 0, tag));
|
return handleItemToClient(connection, new DataItem(itemId, count, tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateEnchantments(final StructuredDataContainer data, final CompoundTag tag, final String key,
|
private void updateEnchantments(final StructuredDataContainer data, final CompoundTag tag, final String key,
|
||||||
|
Loading…
Reference in New Issue
Block a user