Removed deprecated Recipe Code
This commit is contained in:
parent
b0a275337d
commit
c5a8086eb4
8 changed files with 32 additions and 174 deletions
|
@ -3,7 +3,6 @@ package org.betterx.bclib.complexmaterials;
|
|||
import org.betterx.bclib.complexmaterials.entry.BlockEntry;
|
||||
import org.betterx.bclib.complexmaterials.entry.ItemEntry;
|
||||
import org.betterx.bclib.complexmaterials.entry.RecipeEntry;
|
||||
import org.betterx.bclib.config.PathConfig;
|
||||
import org.betterx.bclib.registry.BlockRegistry;
|
||||
import org.betterx.bclib.registry.ItemRegistry;
|
||||
import org.betterx.worlds.together.tag.v3.TagManager;
|
||||
|
@ -14,7 +13,6 @@ import net.minecraft.world.item.Item;
|
|||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
|
||||
|
||||
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
@ -56,10 +54,9 @@ public abstract class ComplexMaterial {
|
|||
*
|
||||
* @param blocksRegistry {@link BlockRegistry} instance to add blocks in;
|
||||
* @param itemsRegistry {@link ItemRegistry} instance to add items in;
|
||||
* @param recipeConfig {@link PathConfig} for recipes check.
|
||||
* @return {@link ComplexMaterial}.
|
||||
*/
|
||||
public ComplexMaterial init(BlockRegistry blocksRegistry, ItemRegistry itemsRegistry, PathConfig recipeConfig) {
|
||||
public ComplexMaterial init(BlockRegistry blocksRegistry, ItemRegistry itemsRegistry) {
|
||||
initTags();
|
||||
|
||||
final BlockBehaviour.Properties blockSettings = getBlockSettings();
|
||||
|
@ -78,7 +75,7 @@ public abstract class ComplexMaterial {
|
|||
|
||||
initDefaultRecipes();
|
||||
getRecipeEntries().forEach(entry -> {
|
||||
entry.init(this, recipeConfig);
|
||||
entry.init(this);
|
||||
});
|
||||
|
||||
initFlammable(FlammableBlockRegistry.getDefaultInstance());
|
||||
|
@ -182,6 +179,7 @@ public abstract class ComplexMaterial {
|
|||
* @return {@link BlockBehaviour.Properties}
|
||||
*/
|
||||
protected abstract BlockBehaviour.Properties getBlockSettings();
|
||||
|
||||
/**
|
||||
* Get default item settings for this material.
|
||||
*
|
||||
|
|
|
@ -263,7 +263,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
|
|||
@Override
|
||||
public void initDefaultRecipes() {
|
||||
Block planks = getBlock(BLOCK_PLANKS);
|
||||
addRecipeEntry(new RecipeEntry("planks", (material, config, id) -> {
|
||||
addRecipeEntry(new RecipeEntry("planks", (material, id) -> {
|
||||
Block log_stripped = getBlock(BLOCK_STRIPPED_LOG);
|
||||
Block bark_stripped = getBlock(BLOCK_STRIPPED_BARK);
|
||||
Block log = getBlock(BLOCK_LOG);
|
||||
|
@ -276,7 +276,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
|
|||
.setCategory(RecipeCategory.BUILDING_BLOCKS)
|
||||
.build();
|
||||
}));
|
||||
addRecipeEntry(new RecipeEntry("stairs", (material, config, id) -> {
|
||||
addRecipeEntry(new RecipeEntry("stairs", (material, id) -> {
|
||||
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_STAIRS))
|
||||
.setOutputCount(4)
|
||||
.setShape("# ", "## ", "###")
|
||||
|
@ -285,7 +285,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
|
|||
.setCategory(RecipeCategory.BUILDING_BLOCKS)
|
||||
.build();
|
||||
}));
|
||||
addRecipeEntry(new RecipeEntry("slab", (material, config, id) -> {
|
||||
addRecipeEntry(new RecipeEntry("slab", (material, id) -> {
|
||||
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_SLAB))
|
||||
.setOutputCount(6)
|
||||
.setShape("###")
|
||||
|
@ -294,7 +294,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
|
|||
.setCategory(RecipeCategory.BUILDING_BLOCKS)
|
||||
.build();
|
||||
}));
|
||||
addRecipeEntry(new RecipeEntry("fence", (material, config, id) -> {
|
||||
addRecipeEntry(new RecipeEntry("fence", (material, id) -> {
|
||||
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_FENCE))
|
||||
.setOutputCount(3)
|
||||
.setShape("#I#", "#I#")
|
||||
|
@ -304,7 +304,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
|
|||
.setCategory(RecipeCategory.DECORATIONS)
|
||||
.build();
|
||||
}));
|
||||
addRecipeEntry(new RecipeEntry("gate", (material, config, id) -> {
|
||||
addRecipeEntry(new RecipeEntry("gate", (material, id) -> {
|
||||
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_GATE))
|
||||
.setShape("I#I", "I#I")
|
||||
.addMaterial('#', planks)
|
||||
|
@ -313,7 +313,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
|
|||
.setCategory(RecipeCategory.REDSTONE)
|
||||
.build();
|
||||
}));
|
||||
addRecipeEntry(new RecipeEntry("button", (material, config, id) -> {
|
||||
addRecipeEntry(new RecipeEntry("button", (material, id) -> {
|
||||
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_BUTTON))
|
||||
.shapeless()
|
||||
.addMaterial('#', planks)
|
||||
|
@ -321,7 +321,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
|
|||
.setCategory(RecipeCategory.REDSTONE)
|
||||
.build();
|
||||
}));
|
||||
addRecipeEntry(new RecipeEntry("pressure_plate", (material, config, id) -> {
|
||||
addRecipeEntry(new RecipeEntry("pressure_plate", (material, id) -> {
|
||||
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_PRESSURE_PLATE))
|
||||
.setShape("##")
|
||||
.addMaterial('#', planks)
|
||||
|
@ -329,7 +329,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
|
|||
.setCategory(RecipeCategory.REDSTONE)
|
||||
.build();
|
||||
}));
|
||||
addRecipeEntry(new RecipeEntry("trapdoor", (material, config, id) -> {
|
||||
addRecipeEntry(new RecipeEntry("trapdoor", (material, id) -> {
|
||||
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_TRAPDOOR))
|
||||
.setOutputCount(2)
|
||||
.setShape("###", "###")
|
||||
|
@ -338,7 +338,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
|
|||
.setCategory(RecipeCategory.REDSTONE)
|
||||
.build();
|
||||
}));
|
||||
addRecipeEntry(new RecipeEntry("door", (material, config, id) -> {
|
||||
addRecipeEntry(new RecipeEntry("door", (material, id) -> {
|
||||
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_DOOR))
|
||||
.setOutputCount(3)
|
||||
.setShape("##", "##", "##")
|
||||
|
@ -347,7 +347,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
|
|||
.setCategory(RecipeCategory.REDSTONE)
|
||||
.build();
|
||||
}));
|
||||
addRecipeEntry(new RecipeEntry("crafting_table", (material, config, id) -> {
|
||||
addRecipeEntry(new RecipeEntry("crafting_table", (material, id) -> {
|
||||
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_CRAFTING_TABLE))
|
||||
.setShape("##", "##")
|
||||
.addMaterial('#', planks)
|
||||
|
@ -355,7 +355,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
|
|||
.setCategory(RecipeCategory.DECORATIONS)
|
||||
.build();
|
||||
}));
|
||||
addRecipeEntry(new RecipeEntry("ladder", (material, config, id) -> {
|
||||
addRecipeEntry(new RecipeEntry("ladder", (material, id) -> {
|
||||
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_LADDER))
|
||||
.setOutputCount(3)
|
||||
.setShape("I I", "I#I", "I I")
|
||||
|
@ -365,7 +365,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
|
|||
.setCategory(RecipeCategory.DECORATIONS)
|
||||
.build();
|
||||
}));
|
||||
addRecipeEntry(new RecipeEntry("sign", (material, config, id) -> {
|
||||
addRecipeEntry(new RecipeEntry("sign", (material, id) -> {
|
||||
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_SIGN))
|
||||
.setOutputCount(3)
|
||||
.setShape("###", "###", " I ")
|
||||
|
@ -375,7 +375,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
|
|||
.setCategory(RecipeCategory.DECORATIONS)
|
||||
.build();
|
||||
}));
|
||||
addRecipeEntry(new RecipeEntry("chest", (material, config, id) -> {
|
||||
addRecipeEntry(new RecipeEntry("chest", (material, id) -> {
|
||||
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_CHEST))
|
||||
.setShape("###", "# #", "###")
|
||||
.addMaterial('#', planks)
|
||||
|
@ -383,7 +383,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
|
|||
.setCategory(RecipeCategory.DECORATIONS)
|
||||
.build();
|
||||
}));
|
||||
addRecipeEntry(new RecipeEntry("barrel", (material, config, id) -> {
|
||||
addRecipeEntry(new RecipeEntry("barrel", (material, id) -> {
|
||||
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_BARREL))
|
||||
.setShape("#S#", "# #", "#S#")
|
||||
.addMaterial('#', planks)
|
||||
|
@ -392,7 +392,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
|
|||
.setCategory(RecipeCategory.DECORATIONS)
|
||||
.build();
|
||||
}));
|
||||
addRecipeEntry(new RecipeEntry("bookshelf", (material, config, id) -> {
|
||||
addRecipeEntry(new RecipeEntry("bookshelf", (material, id) -> {
|
||||
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_BOOKSHELF))
|
||||
.setShape("###", "PPP", "###")
|
||||
.addMaterial('#', planks)
|
||||
|
@ -401,7 +401,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
|
|||
.setCategory(RecipeCategory.BUILDING_BLOCKS)
|
||||
.build();
|
||||
}));
|
||||
addRecipeEntry(new RecipeEntry("bark", (material, config, id) -> {
|
||||
addRecipeEntry(new RecipeEntry("bark", (material, id) -> {
|
||||
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_BARK))
|
||||
.setShape("##", "##")
|
||||
.addMaterial('#', getBlock(BLOCK_LOG))
|
||||
|
@ -409,7 +409,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
|
|||
.setCategory(RecipeCategory.BUILDING_BLOCKS)
|
||||
.build();
|
||||
}));
|
||||
addRecipeEntry(new RecipeEntry("log", (material, config, id) -> {
|
||||
addRecipeEntry(new RecipeEntry("log", (material, id) -> {
|
||||
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_LOG))
|
||||
.setShape("##", "##")
|
||||
.addMaterial('#', getBlock(BLOCK_BARK))
|
||||
|
@ -417,7 +417,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
|
|||
.setCategory(RecipeCategory.BUILDING_BLOCKS)
|
||||
.build();
|
||||
}));
|
||||
addRecipeEntry(new RecipeEntry("stripped_bark", (material, config, id) -> {
|
||||
addRecipeEntry(new RecipeEntry("stripped_bark", (material, id) -> {
|
||||
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_STRIPPED_BARK))
|
||||
.setShape("##", "##")
|
||||
.addMaterial('#', getBlock(BLOCK_STRIPPED_LOG))
|
||||
|
@ -425,7 +425,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
|
|||
.setCategory(RecipeCategory.BUILDING_BLOCKS)
|
||||
.build();
|
||||
}));
|
||||
addRecipeEntry(new RecipeEntry("stripped_log", (material, config, id) -> {
|
||||
addRecipeEntry(new RecipeEntry("stripped_log", (material, id) -> {
|
||||
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_STRIPPED_LOG))
|
||||
.setShape("##", "##")
|
||||
.addMaterial('#', getBlock(BLOCK_STRIPPED_BARK))
|
||||
|
@ -433,7 +433,7 @@ public class WoodenComplexMaterial extends ComplexMaterial {
|
|||
.setCategory(RecipeCategory.BUILDING_BLOCKS)
|
||||
.build();
|
||||
}));
|
||||
addRecipeEntry(new RecipeEntry("composter", (material, config, id) -> {
|
||||
addRecipeEntry(new RecipeEntry("composter", (material, id) -> {
|
||||
BCLRecipeBuilder.crafting(id, getBlock(BLOCK_COMPOSTER))
|
||||
.setShape("# #", "# #", "###")
|
||||
.addMaterial('#', getBlock(BLOCK_SLAB))
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
package org.betterx.bclib.complexmaterials.entry;
|
||||
|
||||
import org.betterx.bclib.complexmaterials.ComplexMaterial;
|
||||
import org.betterx.bclib.config.PathConfig;
|
||||
import org.betterx.bclib.interfaces.TriConsumer;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class RecipeEntry extends ComplexMaterialEntry {
|
||||
final TriConsumer<ComplexMaterial, PathConfig, ResourceLocation> initFunction;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
public RecipeEntry(String suffix, TriConsumer<ComplexMaterial, PathConfig, ResourceLocation> initFunction) {
|
||||
public class RecipeEntry extends ComplexMaterialEntry {
|
||||
final BiConsumer<ComplexMaterial, ResourceLocation> initFunction;
|
||||
|
||||
public RecipeEntry(String suffix, BiConsumer<ComplexMaterial, ResourceLocation> initFunction) {
|
||||
super(suffix);
|
||||
this.initFunction = initFunction;
|
||||
}
|
||||
|
||||
public void init(ComplexMaterial material, PathConfig recipeConfig) {
|
||||
initFunction.accept(material, recipeConfig, getLocation(material.getModID(), material.getBaseName()));
|
||||
public void init(ComplexMaterial material) {
|
||||
initFunction.accept(material, getLocation(material.getModID(), material.getBaseName()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package org.betterx.bclib.config;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
|
@ -15,8 +13,6 @@ public class Configs {
|
|||
public static final GeneratorConfig GENERATOR_CONFIG = new GeneratorConfig();
|
||||
public static final MainConfig MAIN_CONFIG = new MainConfig();
|
||||
public static final CachedConfig CACHED_CONFIG = new CachedConfig();
|
||||
|
||||
public static final PathConfig RECIPE_CONFIG = new PathConfig(BCLib.MOD_ID, "recipes");
|
||||
public static final BiomesConfig BIOMES_CONFIG = new BiomesConfig();
|
||||
|
||||
public static final String MAIN_PATCH_CATEGORY = "patches";
|
||||
|
@ -24,7 +20,6 @@ public class Configs {
|
|||
|
||||
public static void save() {
|
||||
MAIN_CONFIG.saveChanges();
|
||||
RECIPE_CONFIG.saveChanges();
|
||||
GENERATOR_CONFIG.saveChanges();
|
||||
BIOMES_CONFIG.saveChanges();
|
||||
}
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
package org.betterx.bclib.mixin.common;
|
||||
|
||||
import org.betterx.bclib.recipes.BCLRecipeManager;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Mixin(value = MinecraftServer.class)
|
||||
public class MinecraftServerMixin {
|
||||
@Shadow
|
||||
private MinecraftServer.ReloadableResources resources;
|
||||
|
||||
|
||||
@Inject(method = "reloadResources", at = @At(value = "RETURN"), cancellable = true)
|
||||
private void bclib_reloadResources(
|
||||
Collection<String> collection,
|
||||
CallbackInfoReturnable<CompletableFuture<Void>> info
|
||||
) {
|
||||
bclib_injectRecipes();
|
||||
}
|
||||
|
||||
@Inject(method = "loadLevel", at = @At(value = "RETURN"), cancellable = true)
|
||||
private void bclib_loadLevel(CallbackInfo info) {
|
||||
bclib_injectRecipes();
|
||||
}
|
||||
|
||||
private void bclib_injectRecipes() {
|
||||
RecipeManagerAccessor accessor = (RecipeManagerAccessor) resources.managers().getRecipeManager();
|
||||
accessor.bclib_setRecipesByName(BCLRecipeManager.getMapByName(accessor.bclib_getRecipesByName()));
|
||||
accessor.bclib_setRecipes(BCLRecipeManager.getMap(accessor.bclib_getRecipes()));
|
||||
}
|
||||
}
|
|
@ -5,38 +5,18 @@ import org.betterx.bclib.recipes.BCLRecipeManager;
|
|||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import net.minecraft.world.item.crafting.RecipeManager;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@Mixin(RecipeManager.class)
|
||||
public abstract class RecipeManagerMixin {
|
||||
@Shadow
|
||||
protected abstract <C extends Container, T extends Recipe<C>> Map<ResourceLocation, T> byType(RecipeType<T> recipeType);
|
||||
|
||||
@Inject(method = "getRecipeFor", at = @At(value = "HEAD"), cancellable = true)
|
||||
private <C extends Container, T extends Recipe<C>> void bclib_getRecipeFor(
|
||||
RecipeType<T> type,
|
||||
C inventory,
|
||||
Level level,
|
||||
CallbackInfoReturnable<Optional<T>> info
|
||||
) {
|
||||
info.setReturnValue(BCLRecipeManager.getSortedRecipe(type, inventory, level, this::byType));
|
||||
}
|
||||
|
||||
@Inject(method = "apply(Ljava/util/Map;Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/util/profiling/ProfilerFiller;)V", at = @At("HEAD"))
|
||||
public void bcl_interceptApply(
|
||||
Map<ResourceLocation, JsonElement> map,
|
||||
|
|
|
@ -2,7 +2,6 @@ package org.betterx.bclib.recipes;
|
|||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.config.Configs;
|
||||
import org.betterx.bclib.util.CollectionsUtil;
|
||||
import org.betterx.worlds.together.util.DatapackConfigs;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
|
@ -15,89 +14,17 @@ import net.minecraft.world.item.crafting.Recipe;
|
|||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.function.Function;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BCLRecipeManager {
|
||||
private static final Map<?, ? extends Map<?, ?>> _RECIPES = Maps.newHashMap();
|
||||
private static final Map<?, ? extends List<?>> _SORTED = Maps.newHashMap();
|
||||
private static final String MINECRAFT = "minecraft";
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <C extends Container, T extends Recipe<C>> Map<RecipeType<T>, Map<ResourceLocation, T>> RECIPES() {
|
||||
return (Map<RecipeType<T>, Map<ResourceLocation, T>>) _RECIPES;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <C extends Container, T extends Recipe<C>> Map<RecipeType<T>, List<T>> SORTED() {
|
||||
return (Map<RecipeType<T>, List<T>>) _SORTED;
|
||||
}
|
||||
|
||||
public static <C extends Container, T extends Recipe<C>> Optional<T> getSortedRecipe(
|
||||
RecipeType<T> type,
|
||||
C inventory,
|
||||
Level level,
|
||||
Function<RecipeType<T>, Map<ResourceLocation, T>> getter
|
||||
) {
|
||||
List<T> recipes = BCLRecipeManager.<C, T>SORTED().computeIfAbsent(type, t -> {
|
||||
Collection<T> values = getter.apply(type).values();
|
||||
List<T> list = new ArrayList<>(values);
|
||||
list.sort((v1, v2) -> {
|
||||
boolean b1 = v1.getId().getNamespace().equals(MINECRAFT);
|
||||
boolean b2 = v2.getId().getNamespace().equals(MINECRAFT);
|
||||
return b1 ^ b2 ? (b1 ? 1 : -1) : v1.getId().compareTo(v2.getId());
|
||||
});
|
||||
return list;
|
||||
});
|
||||
return recipes.stream().filter(recipe -> recipe.matches(inventory, level)).findFirst();
|
||||
}
|
||||
|
||||
|
||||
public static <C extends Container, T extends Recipe<C>> Map<RecipeType<T>, Map<ResourceLocation, T>> getMap(
|
||||
Map<RecipeType<T>, Map<ResourceLocation, T>> recipes
|
||||
) {
|
||||
Map<RecipeType<T>, Map<ResourceLocation, T>> result = Maps.newHashMap();
|
||||
|
||||
for (RecipeType<T> type : recipes.keySet()) {
|
||||
Map<ResourceLocation, T> typeList = Maps.newHashMap();
|
||||
typeList.putAll(recipes.get(type));
|
||||
result.put(type, typeList);
|
||||
}
|
||||
|
||||
SORTED().clear();
|
||||
BCLRecipeManager.<C, T>RECIPES().forEach((type, list) -> {
|
||||
if (list != null) {
|
||||
Map<ResourceLocation, T> typeList = result.computeIfAbsent(type, i -> Maps.newHashMap());
|
||||
for (Entry<ResourceLocation, T> entry : list.entrySet()) {
|
||||
ResourceLocation id = entry.getKey();
|
||||
typeList.computeIfAbsent(id, i -> entry.getValue());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <C extends Container, T extends Recipe<C>> Map<ResourceLocation, T> getMapByName(Map<ResourceLocation, T> recipes) {
|
||||
Map<ResourceLocation, T> result = CollectionsUtil.getMutable(recipes);
|
||||
BCLRecipeManager.<C, T>RECIPES().values()
|
||||
.forEach(map -> map.forEach((location, recipe) -> result.computeIfAbsent(
|
||||
location,
|
||||
i -> recipe
|
||||
)));
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <C extends Container, S extends RecipeSerializer<T>, T extends Recipe<C>> S registerSerializer(
|
||||
String modID,
|
||||
String id,
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
"ItemStackMixin",
|
||||
"LayerLightSectionStorageMixin",
|
||||
"LootPoolMixin",
|
||||
"MinecraftServerMixin",
|
||||
"MobSpawnSettingsAccessor",
|
||||
"NoiseBasedChunkGeneratorMixin",
|
||||
"PistonBaseBlockMixin",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue