use of com.viaversion.viaversion.api.minecraft.item.DataItem in project ViaVersion by ViaVersion.
the class FlatItemType method read.
@Override
public Item read(ByteBuf buffer) throws Exception {
short id = buffer.readShort();
if (id < 0) {
return null;
} else {
Item item = new DataItem();
item.setIdentifier(id);
item.setAmount(buffer.readByte());
item.setTag(Type.NBT.read(buffer));
return item;
}
}
use of com.viaversion.viaversion.api.minecraft.item.DataItem in project ViaVersion by ViaVersion.
the class ItemType method read.
@Override
public Item read(ByteBuf buffer) throws Exception {
short id = buffer.readShort();
if (id < 0) {
return null;
} else {
Item item = new DataItem();
item.setIdentifier(id);
item.setAmount(buffer.readByte());
item.setData(buffer.readShort());
item.setTag(NBT.read(buffer));
return item;
}
}
use of com.viaversion.viaversion.api.minecraft.item.DataItem in project DirtMultiversion by DirtPowered.
the class ViaHandItemProvider method getHandItem.
@Override
public Item getHandItem(UserConnection userConnection) {
if (userConnection.getProtocolInfo() == null) {
return super.getHandItem(userConnection);
}
UserData userData = api.getUserDataFromUsername(userConnection.getProtocolInfo().getUsername());
if (userData != null) {
ProtocolStorage storage = userData.getProtocolStorage();
if (storage.hasObject(QuickBarTracker.class)) {
QuickBarTracker cache = storage.get(QuickBarTracker.class);
ItemStack item = cache.getItemInHand();
return new DataItem(item.getItemId(), (byte) item.getAmount(), (short) item.getData(), null);
}
}
return super.getHandItem(userConnection);
}
Aggregations