use of com.minecolonies.api.crafting.registry.CraftingType in project minecolonies by Minecolonies.
the class AbstractCraftingBuildingModule method serializeToView.
@Override
public void serializeToView(@NotNull final PacketBuffer buf) {
if (jobEntry != null) {
buf.writeBoolean(true);
buf.writeRegistryId(jobEntry);
} else {
buf.writeBoolean(false);
}
final Set<CraftingType> craftingTypes = this.getSupportedCraftingTypes();
buf.writeVarInt(craftingTypes.size());
for (final CraftingType type : craftingTypes) {
buf.writeRegistryIdUnsafe(MinecoloniesAPIProxy.getInstance().getCraftingTypeRegistry(), type);
}
final List<IRecipeStorage> storages = new ArrayList<>();
final List<IRecipeStorage> disabledStorages = new ArrayList<>();
final Map<ResourceLocation, CustomRecipe> crafterRecipes = CustomRecipeManager.getInstance().getAllRecipes().getOrDefault(getCustomRecipeKey(), Collections.emptyMap());
for (final IToken<?> token : new ArrayList<>(recipes)) {
final IRecipeStorage storage = IColonyManager.getInstance().getRecipeManager().getRecipes().get(token);
if (storage == null || (storage.getRecipeSource() != null && !crafterRecipes.containsKey(storage.getRecipeSource())) || (!isRecipeCompatibleWithCraftingModule(token) && !isPreTaughtRecipe(storage, crafterRecipes))) {
removeRecipe(token);
} else {
storages.add(storage);
if (disabledRecipes.contains(token)) {
disabledStorages.add(storage);
}
}
}
buf.writeInt(storages.size());
for (final IRecipeStorage storage : storages) {
buf.writeNbt(StandardFactoryController.getInstance().serialize(storage));
}
buf.writeInt(disabledStorages.size());
for (final IRecipeStorage storage : disabledStorages) {
buf.writeNbt(StandardFactoryController.getInstance().serialize(storage));
}
buf.writeInt(getMaxRecipes());
buf.writeUtf(getId());
buf.writeBoolean(isVisible());
}
use of com.minecolonies.api.crafting.registry.CraftingType in project minecolonies by Minecolonies.
the class CraftingTagAuditor method doRecipeAudit.
private static void doRecipeAudit(@NotNull final BufferedWriter writer, @NotNull final MinecraftServer server, @NotNull final CustomRecipeManager customRecipeManager) throws IOException {
final Map<CraftingType, List<IGenericRecipe>> vanillaRecipesMap = RecipeAnalyzer.buildVanillaRecipesMap(server.getRecipeManager(), server.overworld());
final List<ICraftingBuildingModule> crafters = getCraftingModules().stream().sorted(Comparator.comparing(m -> m instanceof SimpleCraftingModule).reversed()).collect(// sort the simple modules first (2x2 crafting, personal only)
Collectors.toList());
final Map<ItemStorage, Map<ICraftingBuildingModule, List<IGenericRecipe>>> craftingMap = new HashMap<>();
// initially map every vanilla craftable
for (final List<IGenericRecipe> recipeList : vanillaRecipesMap.values()) {
for (final IGenericRecipe recipe : recipeList) {
add(customRecipeManager, craftingMap, null, recipe);
}
}
writeItemHeaders(writer);
writer.write(",player");
for (final ICraftingBuildingModule crafter : crafters) {
writer.write(',');
writer.write(crafter.getCustomRecipeKey());
final List<IGenericRecipe> recipes = RecipeAnalyzer.findRecipes(vanillaRecipesMap, crafter);
for (final IGenericRecipe recipe : recipes) {
add(customRecipeManager, craftingMap, crafter, recipe);
}
}
writer.newLine();
for (final ItemStack item : getAllItems()) {
writeItemData(writer, item);
final Map<ICraftingBuildingModule, List<IGenericRecipe>> crafterMap = craftingMap.getOrDefault(new ItemStorage(item, true, false), Collections.emptyMap());
writeCrafterValue(writer, crafterMap, null);
for (final ICraftingBuildingModule crafter : crafters) {
writeCrafterValue(writer, crafterMap, crafter);
}
writer.newLine();
}
}
Aggregations