Search in sources :

Example 21 with ProtocolStorage

use of com.github.dirtpowered.dirtmv.data.user.ProtocolStorage 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);
}
Also used : ProtocolStorage(com.github.dirtpowered.dirtmv.data.user.ProtocolStorage) UserData(com.github.dirtpowered.dirtmv.data.user.UserData) DataItem(com.viaversion.viaversion.api.minecraft.item.DataItem) ItemStack(com.github.dirtpowered.dirtmv.data.protocol.objects.ItemStack) QuickBarTracker(com.github.dirtpowered.dirtmv.network.versions.Release47To5.inventory.QuickBarTracker)

Aggregations

ProtocolStorage (com.github.dirtpowered.dirtmv.data.user.ProtocolStorage)21 PacketData (com.github.dirtpowered.dirtmv.data.protocol.PacketData)9 TypeHolder (com.github.dirtpowered.dirtmv.data.protocol.TypeHolder)9 PacketTranslator (com.github.dirtpowered.dirtmv.data.translator.PacketTranslator)8 ServerSession (com.github.dirtpowered.dirtmv.network.server.ServerSession)8 ItemStack (com.github.dirtpowered.dirtmv.data.protocol.objects.ItemStack)6 BlockLocation (com.github.dirtpowered.dirtmv.data.protocol.objects.BlockLocation)5 BlockStorage (com.github.dirtpowered.dirtmv.network.versions.Beta17To14.storage.BlockStorage)5 ArrayList (java.util.ArrayList)5 Location (com.github.dirtpowered.dirtmv.data.protocol.objects.Location)4 V1_2MultiBlockArray (com.github.dirtpowered.dirtmv.data.protocol.objects.V1_2MultiBlockArray)4 IOException (java.io.IOException)4 List (java.util.List)4 V1_2Chunk (com.github.dirtpowered.dirtmv.data.protocol.objects.V1_2Chunk)3 QuickBarTracker (com.github.dirtpowered.dirtmv.network.versions.Release47To5.inventory.QuickBarTracker)3 DirtMultiVersion (com.github.dirtpowered.dirtmv.DirtMultiVersion)2 Configuration (com.github.dirtpowered.dirtmv.api.Configuration)2 MinecraftVersion (com.github.dirtpowered.dirtmv.data.MinecraftVersion)2 OldChunkData (com.github.dirtpowered.dirtmv.data.chunk.biome.OldChunkData)2 ExtendedBlockStorage (com.github.dirtpowered.dirtmv.data.chunk.storage.ExtendedBlockStorage)2