Added recipes into named map

This commit is contained in:
paulevsGitch 2022-01-13 15:50:11 +03:00
parent 95284640e0
commit 8ebcf2352a
2 changed files with 5 additions and 2 deletions

View file

@ -21,6 +21,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import ru.bclib.BCLib;
import ru.bclib.api.dataexchange.DataExchangeAPI; import ru.bclib.api.dataexchange.DataExchangeAPI;
import ru.bclib.recipes.BCLRecipeManager; import ru.bclib.recipes.BCLRecipeManager;
@ -59,7 +60,9 @@ public class MinecraftServerMixin {
private void bclib_injectRecipes() { private void bclib_injectRecipes() {
RecipeManagerAccessor accessor = (RecipeManagerAccessor) resources.getRecipeManager(); RecipeManagerAccessor accessor = (RecipeManagerAccessor) resources.getRecipeManager();
if (!BCLib.isClient()) {
accessor.bclib_setRecipesByName(BCLRecipeManager.getMapByName(accessor.bclib_getRecipesByName()));
}
accessor.bclib_setRecipes(BCLRecipeManager.getMap(accessor.bclib_getRecipes())); accessor.bclib_setRecipes(BCLRecipeManager.getMap(accessor.bclib_getRecipes()));
accessor.bclib_setRecipesByName(BCLRecipeManager.getMapByName(accessor.bclib_getRecipesByName()));
} }
} }

View file

@ -63,7 +63,7 @@ public class BCLRecipeManager {
public static Map<ResourceLocation, Recipe<?>> getMapByName(Map<ResourceLocation, Recipe<?>> recipes) { public static Map<ResourceLocation, Recipe<?>> getMapByName(Map<ResourceLocation, Recipe<?>> recipes) {
Map<ResourceLocation, Recipe<?>> result = CollectionsUtil.getMutable(recipes); Map<ResourceLocation, Recipe<?>> result = CollectionsUtil.getMutable(recipes);
RECIPES.values().forEach(map -> map.forEach((location, recipe) -> { RECIPES.values().forEach(map -> map.forEach((location, recipe) -> {
if (!recipes.containsKey(location)) { if (!result.containsKey(location)) {
result.put(location, recipe); result.put(location, recipe);
} }
})); }));