2019-07-28 10:08:49 +02:00
|
|
|
package com.simibubi.create;
|
|
|
|
|
|
|
|
import java.util.function.Supplier;
|
|
|
|
|
2020-01-27 23:25:59 +01:00
|
|
|
import com.simibubi.create.compat.jei.ConversionRecipe;
|
2019-10-15 22:22:19 +02:00
|
|
|
import com.simibubi.create.foundation.utility.Lang;
|
2020-01-19 23:10:00 +01:00
|
|
|
import com.simibubi.create.modules.contraptions.components.crafter.MechanicalCraftingRecipe;
|
2019-12-12 10:56:34 +01:00
|
|
|
import com.simibubi.create.modules.contraptions.components.crusher.CrushingRecipe;
|
|
|
|
import com.simibubi.create.modules.contraptions.components.fan.SplashingRecipe;
|
2020-03-26 23:03:56 +01:00
|
|
|
import com.simibubi.create.modules.contraptions.components.millstone.MillingRecipe;
|
2019-12-12 10:56:34 +01:00
|
|
|
import com.simibubi.create.modules.contraptions.components.mixer.MixingRecipe;
|
|
|
|
import com.simibubi.create.modules.contraptions.components.press.PressingRecipe;
|
|
|
|
import com.simibubi.create.modules.contraptions.components.saw.CuttingRecipe;
|
2020-01-19 23:10:00 +01:00
|
|
|
import com.simibubi.create.modules.contraptions.processing.ProcessingRecipe;
|
2019-12-12 10:56:34 +01:00
|
|
|
import com.simibubi.create.modules.contraptions.processing.ProcessingRecipeSerializer;
|
2020-01-19 23:10:00 +01:00
|
|
|
import com.simibubi.create.modules.contraptions.processing.ProcessingRecipeSerializer.IRecipeFactory;
|
2020-01-26 23:58:55 +01:00
|
|
|
import com.simibubi.create.modules.curiosities.tools.SandPaperPolishingRecipe;
|
2020-03-04 14:06:34 +01:00
|
|
|
import com.simibubi.create.modules.curiosities.zapper.blockzapper.BlockzapperUpgradeRecipe;
|
2019-07-28 10:08:49 +02:00
|
|
|
|
2019-08-22 15:52:15 +02:00
|
|
|
import net.minecraft.inventory.IInventory;
|
|
|
|
import net.minecraft.item.crafting.IRecipe;
|
2019-07-28 10:08:49 +02:00
|
|
|
import net.minecraft.item.crafting.IRecipeSerializer;
|
2019-08-22 15:52:15 +02:00
|
|
|
import net.minecraft.item.crafting.IRecipeType;
|
2020-01-19 23:10:00 +01:00
|
|
|
import net.minecraft.item.crafting.ShapedRecipe;
|
2019-07-28 10:08:49 +02:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
2019-08-22 15:52:15 +02:00
|
|
|
import net.minecraft.util.registry.Registry;
|
2019-07-28 10:08:49 +02:00
|
|
|
import net.minecraftforge.event.RegistryEvent;
|
|
|
|
|
|
|
|
public enum AllRecipes {
|
|
|
|
|
2020-01-26 23:58:55 +01:00
|
|
|
BLOCKZAPPER_UPGRADE(BlockzapperUpgradeRecipe.Serializer::new, IRecipeType.CRAFTING),
|
2020-01-19 23:10:00 +01:00
|
|
|
MECHANICAL_CRAFTING(MechanicalCraftingRecipe.Serializer::new),
|
|
|
|
CRUSHING(processingSerializer(CrushingRecipe::new)),
|
2020-03-26 23:03:56 +01:00
|
|
|
MILLING(processingSerializer(MillingRecipe::new)),
|
2020-01-19 23:10:00 +01:00
|
|
|
SPLASHING(processingSerializer(SplashingRecipe::new)),
|
|
|
|
PRESSING(processingSerializer(PressingRecipe::new)),
|
|
|
|
CUTTING(processingSerializer(CuttingRecipe::new)),
|
|
|
|
MIXING(processingSerializer(MixingRecipe::new)),
|
2020-01-26 23:58:55 +01:00
|
|
|
SANDPAPER_POLISHING(processingSerializer(SandPaperPolishingRecipe::new)),
|
2020-01-27 23:25:59 +01:00
|
|
|
CONVERSION(processingSerializer(ConversionRecipe::new)),
|
2019-08-22 15:52:15 +02:00
|
|
|
|
2019-08-06 19:00:51 +02:00
|
|
|
;
|
2019-07-28 10:08:49 +02:00
|
|
|
|
|
|
|
public IRecipeSerializer<?> serializer;
|
|
|
|
public Supplier<IRecipeSerializer<?>> supplier;
|
2019-08-22 15:52:15 +02:00
|
|
|
public IRecipeType<? extends IRecipe<? extends IInventory>> type;
|
2019-07-28 10:08:49 +02:00
|
|
|
|
2020-01-19 23:10:00 +01:00
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
public <T extends IRecipeType<?>> T getType() {
|
|
|
|
return (T) type;
|
|
|
|
}
|
|
|
|
|
|
|
|
private AllRecipes(Supplier<IRecipeSerializer<?>> supplier) {
|
|
|
|
this(supplier, null);
|
|
|
|
}
|
|
|
|
|
2019-08-22 15:52:15 +02:00
|
|
|
private AllRecipes(Supplier<IRecipeSerializer<?>> supplier,
|
2020-01-19 23:10:00 +01:00
|
|
|
IRecipeType<? extends IRecipe<? extends IInventory>> existingType) {
|
2019-07-28 10:08:49 +02:00
|
|
|
this.supplier = supplier;
|
2020-01-19 23:10:00 +01:00
|
|
|
this.type = existingType;
|
2019-07-28 10:08:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void register(RegistryEvent.Register<IRecipeSerializer<?>> event) {
|
2020-01-19 23:10:00 +01:00
|
|
|
ShapedRecipe.setCraftingSize(9, 9);
|
|
|
|
|
2019-07-28 10:08:49 +02:00
|
|
|
for (AllRecipes r : AllRecipes.values()) {
|
2020-01-19 23:10:00 +01:00
|
|
|
if (r.type == null)
|
|
|
|
r.type = customType(Lang.asId(r.name()));
|
|
|
|
|
2019-07-28 10:08:49 +02:00
|
|
|
r.serializer = r.supplier.get();
|
2019-10-15 22:22:19 +02:00
|
|
|
ResourceLocation location = new ResourceLocation(Create.ID, Lang.asId(r.name()));
|
2019-07-28 10:08:49 +02:00
|
|
|
event.getRegistry().register(r.serializer.setRegistryName(location));
|
|
|
|
}
|
|
|
|
}
|
2020-01-19 23:10:00 +01:00
|
|
|
|
|
|
|
private static <T extends IRecipe<?>> IRecipeType<T> customType(String id) {
|
|
|
|
return Registry.register(Registry.RECIPE_TYPE, new ResourceLocation(Create.ID, id), new IRecipeType<T>() {
|
|
|
|
public String toString() {
|
|
|
|
return Create.ID + ":" + id;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private static Supplier<IRecipeSerializer<?>> processingSerializer(IRecipeFactory<? extends ProcessingRecipe<?>> factory) {
|
|
|
|
return () -> new ProcessingRecipeSerializer<>(factory);
|
|
|
|
}
|
|
|
|
|
2019-07-28 10:08:49 +02:00
|
|
|
|
|
|
|
}
|