use of top.theillusivec4.polymorph.api.client.base.RecipesWidget in project Polymorph by TheIllusiveC4.
the class PolymorphClientNetwork method sendRecipesList.
private static void sendRecipesList(MinecraftClient pClient, ClientPlayNetworkHandler pHandler, PacketByteBuf pBuf, PacketSender pSender) {
SortedSet<RecipePair> recipeDataset = new TreeSet<>();
Identifier selected = null;
if (pBuf.isReadable()) {
int size = pBuf.readInt();
for (int i = 0; i < size; i++) {
recipeDataset.add(new RecipePairImpl(pBuf.readIdentifier(), pBuf.readItemStack()));
}
if (pBuf.isReadable()) {
selected = pBuf.readIdentifier();
}
}
Identifier finalSelected = selected;
pClient.execute(() -> {
ClientPlayerEntity player = pClient.player;
if (player != null) {
Optional<RecipesWidget> maybeWidget = RecipesWidgetControl.get();
maybeWidget.ifPresent(widget -> widget.setRecipesList(recipeDataset, finalSelected));
if (!maybeWidget.isPresent()) {
RecipesWidgetControl.enqueueRecipesList(recipeDataset, finalSelected);
}
}
});
}
Aggregations