2019-07-28 10:08:49 +02:00
|
|
|
package com.simibubi.create;
|
|
|
|
|
|
|
|
import java.util.function.Supplier;
|
|
|
|
|
2019-10-15 22:22:19 +02:00
|
|
|
import com.simibubi.create.foundation.utility.Lang;
|
2019-08-22 15:52:15 +02:00
|
|
|
import com.simibubi.create.modules.contraptions.base.ProcessingRecipeSerializer;
|
|
|
|
import com.simibubi.create.modules.contraptions.receivers.CrushingRecipe;
|
2019-11-07 11:30:29 +01:00
|
|
|
import com.simibubi.create.modules.contraptions.receivers.CuttingRecipe;
|
|
|
|
import com.simibubi.create.modules.contraptions.receivers.MixingRecipe;
|
2019-09-13 18:36:18 +02:00
|
|
|
import com.simibubi.create.modules.contraptions.receivers.PressingRecipe;
|
2019-09-12 14:32:11 +02:00
|
|
|
import com.simibubi.create.modules.contraptions.receivers.SplashingRecipe;
|
2019-07-28 10:08:49 +02:00
|
|
|
import com.simibubi.create.modules.curiosities.placementHandgun.BuilderGunUpgradeRecipe;
|
|
|
|
|
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;
|
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 {
|
|
|
|
|
2019-09-22 20:23:26 +02:00
|
|
|
BLOCKZAPPER_UPGRADE(BuilderGunUpgradeRecipe.Serializer::new, IRecipeType.CRAFTING),
|
2019-09-16 12:27:28 +02:00
|
|
|
CRUSHING(() -> new ProcessingRecipeSerializer<>(CrushingRecipe::new), Types.CRUSHING),
|
|
|
|
SPLASHING(() -> new ProcessingRecipeSerializer<>(SplashingRecipe::new), Types.SPLASHING),
|
|
|
|
PRESSING(() -> new ProcessingRecipeSerializer<>(PressingRecipe::new), Types.PRESSING),
|
2019-11-07 11:30:29 +01:00
|
|
|
CUTTING(() -> new ProcessingRecipeSerializer<>(CuttingRecipe::new), Types.CUTTING),
|
|
|
|
MIXING(() -> new ProcessingRecipeSerializer<>(MixingRecipe::new), Types.MIXING),
|
2019-08-22 15:52:15 +02:00
|
|
|
|
2019-08-06 19:00:51 +02:00
|
|
|
;
|
2019-07-28 10:08:49 +02:00
|
|
|
|
2019-08-22 15:52:15 +02:00
|
|
|
public static class Types {
|
|
|
|
public static IRecipeType<CrushingRecipe> CRUSHING = register("crushing");
|
2019-09-12 14:32:11 +02:00
|
|
|
public static IRecipeType<SplashingRecipe> SPLASHING = register("splashing");
|
2019-09-13 18:36:18 +02:00
|
|
|
public static IRecipeType<PressingRecipe> PRESSING = register("pressing");
|
2019-11-07 11:30:29 +01:00
|
|
|
public static IRecipeType<CuttingRecipe> CUTTING = register("cutting");
|
|
|
|
public static IRecipeType<MixingRecipe> MIXING = register("mixing");
|
2019-08-22 15:52:15 +02:00
|
|
|
|
|
|
|
static <T extends IRecipe<?>> IRecipeType<T> register(final String key) {
|
|
|
|
return Registry.register(Registry.RECIPE_TYPE, new ResourceLocation(key), new IRecipeType<T>() {
|
|
|
|
public String toString() {
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2019-08-22 15:52:15 +02:00
|
|
|
private AllRecipes(Supplier<IRecipeSerializer<?>> supplier,
|
|
|
|
IRecipeType<? extends IRecipe<? extends IInventory>> type) {
|
2019-07-28 10:08:49 +02:00
|
|
|
this.supplier = supplier;
|
2019-08-22 15:52:15 +02:00
|
|
|
this.type = type;
|
2019-07-28 10:08:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void register(RegistryEvent.Register<IRecipeSerializer<?>> event) {
|
|
|
|
for (AllRecipes r : AllRecipes.values()) {
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|