use of de.siphalor.nbtcrafting.ingredient.IIngredient in project nbt-crafting by Siphalor.
the class NbtCrafting method createAdvancedRecipeSyncPacket.
public static PacketByteBuf createAdvancedRecipeSyncPacket(RecipeManager recipeManager) {
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
advancedIngredientSerializationEnabled.set(true);
List<Recipe<?>> recipes = recipeManager.values().stream().filter(recipe -> {
for (Ingredient ingredient : recipe.getPreviewInputs()) {
if (((IIngredient) (Object) ingredient).nbtCrafting$isAdvanced()) {
return true;
}
}
return false;
}).collect(Collectors.toList());
buf.writeVarInt(recipes.size());
for (Recipe<?> recipe : recipes) {
@SuppressWarnings("rawtypes") RecipeSerializer serializer = recipe.getSerializer();
buf.writeIdentifier(Registry.RECIPE_SERIALIZER.getId(serializer));
buf.writeIdentifier(recipe.getId());
// noinspection unchecked
serializer.write(buf, recipe);
}
advancedIngredientSerializationEnabled.set(false);
return buf;
}
Aggregations