use of de.budschie.bmorph.network.MorphRequestFavouriteChange.MorphRequestFavouriteChangePacket in project BudschieMorphMod by Budschie.
the class FavouriteNetworkingHelper method internalAddFavouriteMorph.
// DRY CODE
private static void internalAddFavouriteMorph(boolean add, int indexInMorphArray) {
PlayerEntity player = Minecraft.getInstance().player;
LazyOptional<IMorphCapability> cap = player.getCapability(MorphCapabilityAttacher.MORPH_CAP);
if (cap.isPresent()) {
IMorphCapability resolved = cap.resolve().get();
if (add)
resolved.getFavouriteList().addFavourite(indexInMorphArray);
else
resolved.getFavouriteList().removeFavourite(indexInMorphArray);
MorphRequestFavouriteChangePacket favouritePacket = new MorphRequestFavouriteChangePacket(add, indexInMorphArray);
MainNetworkChannel.INSTANCE.sendToServer(favouritePacket);
} else {
LOGGER.warn("Can't " + (add ? "add" : "remove") + "morph " + indexInMorphArray + " as a favourite, as the capability for morphs is not loaded yet.");
}
}
Aggregations