Search in sources :

Example 1 with MorphChangedPacket

use of de.budschie.bmorph.network.MorphChangedSynchronizer.MorphChangedPacket in project BudschieMorphMod by Budschie.

the class MorphChangedSynchronizer method decode.

@Override
public MorphChangedPacket decode(PacketBuffer buffer) {
    UUID playerUUID = buffer.readUniqueId();
    boolean hasIndex = buffer.readBoolean(), hasItem = buffer.readBoolean();
    Optional<Integer> morphIndex = Optional.empty();
    Optional<MorphItem> morphItem = Optional.empty();
    if (hasIndex)
        morphIndex = Optional.of(buffer.readInt());
    if (hasItem)
        morphItem = Optional.of(MorphHandler.deserializeMorphItem(buffer.readCompoundTag()));
    int amountOfAbilities = buffer.readInt();
    ArrayList<String> abilities = new ArrayList<>(amountOfAbilities);
    for (int i = 0; i < amountOfAbilities; i++) abilities.add(buffer.readString());
    return new MorphChangedPacket(playerUUID, morphIndex, morphItem, abilities);
}
Also used : MorphItem(de.budschie.bmorph.morph.MorphItem) ArrayList(java.util.ArrayList) UUID(java.util.UUID) MorphChangedPacket(de.budschie.bmorph.network.MorphChangedSynchronizer.MorphChangedPacket)

Aggregations

MorphItem (de.budschie.bmorph.morph.MorphItem)1 MorphChangedPacket (de.budschie.bmorph.network.MorphChangedSynchronizer.MorphChangedPacket)1 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1