Search in sources :

Example 1 with MorphPacket

use of de.budschie.bmorph.network.MorphCapabilityFullSynchronizer.MorphPacket in project BudschieMorphMod by Budschie.

the class MorphCapabilityFullSynchronizer method decode.

@Override
public MorphPacket decode(PacketBuffer buffer) {
    UUID playerUUID = buffer.readUniqueId();
    // Hmmm yeah the floor is made out of floor
    MorphList morphList = new MorphList();
    morphList.deserializePacket(buffer);
    FavouriteList favouriteList = new FavouriteList(morphList);
    favouriteList.deserializePacket(buffer);
    Optional<MorphItem> toMorph = Optional.empty();
    Optional<Integer> entityIndex = Optional.empty();
    boolean hasMorph = buffer.readBoolean(), hasIndex = buffer.readBoolean();
    if (hasMorph)
        toMorph = Optional.of(MorphHandler.deserializeMorphItem(buffer.readCompoundTag()));
    if (hasIndex)
        entityIndex = Optional.of(buffer.readInt());
    int amountOfAbilities = buffer.readInt();
    ArrayList<String> abilities = new ArrayList<>(amountOfAbilities);
    for (int i = 0; i < amountOfAbilities; i++) abilities.add(buffer.readString());
    return new MorphPacket(toMorph, entityIndex, morphList, favouriteList, abilities, playerUUID);
}
Also used : MorphPacket(de.budschie.bmorph.network.MorphCapabilityFullSynchronizer.MorphPacket) FavouriteList(de.budschie.bmorph.morph.FavouriteList) MorphItem(de.budschie.bmorph.morph.MorphItem) ArrayList(java.util.ArrayList) UUID(java.util.UUID) MorphList(de.budschie.bmorph.morph.MorphList)

Aggregations

FavouriteList (de.budschie.bmorph.morph.FavouriteList)1 MorphItem (de.budschie.bmorph.morph.MorphItem)1 MorphList (de.budschie.bmorph.morph.MorphList)1 MorphPacket (de.budschie.bmorph.network.MorphCapabilityFullSynchronizer.MorphPacket)1 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1