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);
}
Aggregations