mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-14 14:34:16 +01:00
Minor cleanup changes
- Change AllRecipeTypes to have less repetition and force getter usage
This commit is contained in:
parent
681791a329
commit
1dd7c4bc1e
@ -17,7 +17,6 @@ import com.simibubi.create.content.contraptions.fluids.actors.FillingRecipe;
|
||||
import com.simibubi.create.content.contraptions.itemAssembly.SequencedAssemblyRecipeSerializer;
|
||||
import com.simibubi.create.content.contraptions.processing.BasinRecipe;
|
||||
import com.simibubi.create.content.contraptions.processing.EmptyingRecipe;
|
||||
import com.simibubi.create.content.contraptions.processing.ProcessingRecipe;
|
||||
import com.simibubi.create.content.contraptions.processing.ProcessingRecipeBuilder.ProcessingRecipeFactory;
|
||||
import com.simibubi.create.content.contraptions.processing.ProcessingRecipeSerializer;
|
||||
import com.simibubi.create.content.curiosities.tools.SandPaperPolishingRecipe;
|
||||
@ -36,62 +35,56 @@ import net.minecraftforge.event.RegistryEvent;
|
||||
public enum AllRecipeTypes {
|
||||
|
||||
MECHANICAL_CRAFTING(MechanicalCraftingRecipe.Serializer::new),
|
||||
CONVERSION(processingSerializer(ConversionRecipe::new)),
|
||||
CRUSHING(processingSerializer(CrushingRecipe::new)),
|
||||
CUTTING(processingSerializer(CuttingRecipe::new)),
|
||||
MILLING(processingSerializer(MillingRecipe::new)),
|
||||
BASIN(processingSerializer(BasinRecipe::new)),
|
||||
MIXING(processingSerializer(MixingRecipe::new)),
|
||||
COMPACTING(processingSerializer(CompactingRecipe::new)),
|
||||
PRESSING(processingSerializer(PressingRecipe::new)),
|
||||
SANDPAPER_POLISHING(processingSerializer(SandPaperPolishingRecipe::new)),
|
||||
SPLASHING(processingSerializer(SplashingRecipe::new)),
|
||||
DEPLOYING(processingSerializer(DeployerApplicationRecipe::new)),
|
||||
FILLING(processingSerializer(FillingRecipe::new)),
|
||||
EMPTYING(processingSerializer(EmptyingRecipe::new)),
|
||||
CONVERSION(ConversionRecipe::new),
|
||||
CRUSHING(CrushingRecipe::new),
|
||||
CUTTING(CuttingRecipe::new),
|
||||
MILLING(MillingRecipe::new),
|
||||
BASIN(BasinRecipe::new),
|
||||
MIXING(MixingRecipe::new),
|
||||
COMPACTING(CompactingRecipe::new),
|
||||
PRESSING(PressingRecipe::new),
|
||||
SANDPAPER_POLISHING(SandPaperPolishingRecipe::new),
|
||||
SPLASHING(SplashingRecipe::new),
|
||||
DEPLOYING(DeployerApplicationRecipe::new),
|
||||
FILLING(FillingRecipe::new),
|
||||
EMPTYING(EmptyingRecipe::new),
|
||||
SEQUENCED_ASSEMBLY(SequencedAssemblyRecipeSerializer::new),
|
||||
|
||||
;
|
||||
|
||||
public IRecipeSerializer<?> serializer;
|
||||
public Supplier<IRecipeSerializer<?>> supplier;
|
||||
public IRecipeType<? extends IRecipe<? extends IInventory>> type;
|
||||
private ResourceLocation id;
|
||||
private Supplier<IRecipeSerializer<?>> serializerSupplier;
|
||||
private Supplier<IRecipeType<?>> typeSupplier;
|
||||
private IRecipeSerializer<?> serializer;
|
||||
private IRecipeType<?> type;
|
||||
|
||||
AllRecipeTypes(Supplier<IRecipeSerializer<?>> supplier) {
|
||||
this(supplier, null);
|
||||
AllRecipeTypes(Supplier<IRecipeSerializer<?>> serializerSupplier, Supplier<IRecipeType<?>> typeSupplier) {
|
||||
this.id = Create.asResource(Lang.asId(name()));
|
||||
this.serializerSupplier = serializerSupplier;
|
||||
this.typeSupplier = typeSupplier;
|
||||
}
|
||||
|
||||
AllRecipeTypes(Supplier<IRecipeSerializer<?>> supplier,
|
||||
IRecipeType<? extends IRecipe<? extends IInventory>> existingType) {
|
||||
this.supplier = supplier;
|
||||
this.type = existingType;
|
||||
AllRecipeTypes(Supplier<IRecipeSerializer<?>> serializerSupplier, IRecipeType<?> existingType) {
|
||||
this(serializerSupplier, () -> existingType);
|
||||
}
|
||||
|
||||
public static void register(RegistryEvent.Register<IRecipeSerializer<?>> event) {
|
||||
ShapedRecipe.setCraftingSize(9, 9);
|
||||
|
||||
for (AllRecipeTypes r : AllRecipeTypes.values()) {
|
||||
if (r.type == null)
|
||||
r.type = customType(Lang.asId(r.name()));
|
||||
|
||||
r.serializer = r.supplier.get();
|
||||
ResourceLocation location = new ResourceLocation(Create.ID, Lang.asId(r.name()));
|
||||
event.getRegistry()
|
||||
.register(r.serializer.setRegistryName(location));
|
||||
}
|
||||
AllRecipeTypes(Supplier<IRecipeSerializer<?>> serializerSupplier) {
|
||||
this.id = Create.asResource(Lang.asId(name()));
|
||||
this.serializerSupplier = serializerSupplier;
|
||||
this.typeSupplier = () -> simpleType(id);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
});
|
||||
AllRecipeTypes(ProcessingRecipeFactory<?> processingFactory) {
|
||||
this(processingSerializer(processingFactory));
|
||||
}
|
||||
|
||||
private static Supplier<IRecipeSerializer<?>> processingSerializer(
|
||||
ProcessingRecipeFactory<? extends ProcessingRecipe<?>> factory) {
|
||||
return () -> new ProcessingRecipeSerializer<>(factory);
|
||||
public ResourceLocation getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends IRecipeSerializer<?>> T getSerializer() {
|
||||
return (T) serializer;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@ -103,4 +96,30 @@ public enum AllRecipeTypes {
|
||||
return world.getRecipeManager()
|
||||
.getRecipeFor(getType(), inv, world);
|
||||
}
|
||||
|
||||
public static void register(RegistryEvent.Register<IRecipeSerializer<?>> event) {
|
||||
ShapedRecipe.setCraftingSize(9, 9);
|
||||
|
||||
for (AllRecipeTypes r : AllRecipeTypes.values()) {
|
||||
r.serializer = r.serializerSupplier.get();
|
||||
r.type = r.typeSupplier.get();
|
||||
r.serializer.setRegistryName(r.id);
|
||||
event.getRegistry()
|
||||
.register(r.serializer);
|
||||
}
|
||||
}
|
||||
|
||||
private static Supplier<IRecipeSerializer<?>> processingSerializer(ProcessingRecipeFactory<?> factory) {
|
||||
return () -> new ProcessingRecipeSerializer<>(factory);
|
||||
}
|
||||
|
||||
public static <T extends IRecipe<?>> IRecipeType<T> simpleType(ResourceLocation id) {
|
||||
String stringId = id.toString();
|
||||
return Registry.register(Registry.RECIPE_TYPE, id, new IRecipeType<T>() {
|
||||
public String toString() {
|
||||
return stringId;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -241,7 +241,8 @@ public class AllShapes {
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
VoxelShape shape;
|
||||
|
||||
private VoxelShape shape;
|
||||
|
||||
public Builder(VoxelShape shape) {
|
||||
this.shape = shape;
|
||||
|
@ -179,7 +179,7 @@ public class CreateJEI implements IModPlugin {
|
||||
|
||||
deploying = register("deploying", DeployingCategory::new)
|
||||
.recipeList(
|
||||
() -> DeployerApplicationRecipe.convert(findRecipesByType(AllRecipeTypes.SANDPAPER_POLISHING.type)))
|
||||
() -> DeployerApplicationRecipe.convert(findRecipesByType(AllRecipeTypes.SANDPAPER_POLISHING.getType())))
|
||||
.recipes(AllRecipeTypes.DEPLOYING)
|
||||
.catalyst(AllBlocks.DEPLOYER::get)
|
||||
.catalyst(AllBlocks.DEPOT::get)
|
||||
@ -205,7 +205,7 @@ public class CreateJEI implements IModPlugin {
|
||||
.recipes(r -> r.getSerializer() == IRecipeSerializer.SHAPELESS_RECIPE && r.getIngredients()
|
||||
.size() == 1)
|
||||
.recipes(
|
||||
r -> (r.getType() == IRecipeType.CRAFTING && r.getType() != AllRecipeTypes.MECHANICAL_CRAFTING.type)
|
||||
r -> (r.getType() == IRecipeType.CRAFTING && r.getType() != AllRecipeTypes.MECHANICAL_CRAFTING.getType())
|
||||
&& (r instanceof ShapedRecipe))
|
||||
.catalyst(AllBlocks.MECHANICAL_CRAFTER::get)
|
||||
.enableWhen(c -> c.allowRegularCraftingInCrafter)
|
||||
|
@ -33,7 +33,7 @@ public class MechanicalCraftingRecipe extends ShapedRecipe {
|
||||
|
||||
@Override
|
||||
public IRecipeType<?> getType() {
|
||||
return AllRecipeTypes.MECHANICAL_CRAFTING.type;
|
||||
return AllRecipeTypes.MECHANICAL_CRAFTING.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -43,7 +43,7 @@ public class MechanicalCraftingRecipe extends ShapedRecipe {
|
||||
|
||||
@Override
|
||||
public IRecipeSerializer<?> getSerializer() {
|
||||
return AllRecipeTypes.MECHANICAL_CRAFTING.serializer;
|
||||
return AllRecipeTypes.MECHANICAL_CRAFTING.getSerializer();
|
||||
}
|
||||
|
||||
public static class Serializer extends ShapedRecipe.Serializer {
|
||||
|
@ -229,7 +229,7 @@ public class MechanicalMixerTileEntity extends BasinOperatingTileEntity {
|
||||
return ((r.getSerializer() == IRecipeSerializer.SHAPELESS_RECIPE
|
||||
&& AllConfigs.SERVER.recipes.allowShapelessInMixer.get() && r.getIngredients()
|
||||
.size() > 1)
|
||||
|| r.getType() == AllRecipeTypes.MIXING.type);
|
||||
|| r.getType() == AllRecipeTypes.MIXING.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -346,7 +346,7 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity {
|
||||
@Override
|
||||
protected <C extends IInventory> boolean matchStaticFilters(IRecipe<C> recipe) {
|
||||
return (recipe instanceof ICraftingRecipe && canCompress(recipe.getIngredients()))
|
||||
|| recipe.getType() == AllRecipeTypes.COMPACTING.type;
|
||||
|| recipe.getType() == AllRecipeTypes.COMPACTING.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,7 +34,7 @@ public class SequencedAssemblyRecipeBuilder {
|
||||
public SequencedAssemblyRecipeBuilder(ResourceLocation id) {
|
||||
recipeConditions = new ArrayList<>();
|
||||
this.recipe = new SequencedAssemblyRecipe(id,
|
||||
(SequencedAssemblyRecipeSerializer) AllRecipeTypes.SEQUENCED_ASSEMBLY.serializer);
|
||||
AllRecipeTypes.SEQUENCED_ASSEMBLY.getSerializer());
|
||||
}
|
||||
|
||||
public <T extends ProcessingRecipe<?>> SequencedAssemblyRecipeBuilder addStep(ProcessingRecipeFactory<T> factory,
|
||||
|
@ -52,10 +52,10 @@ public abstract class ProcessingRecipe<T extends IInventory> implements IRecipe<
|
||||
this.processingDuration = params.processingDuration;
|
||||
this.fluidIngredients = params.fluidIngredients;
|
||||
this.fluidResults = params.fluidResults;
|
||||
this.serializer = recipeType.serializer;
|
||||
this.serializer = recipeType.getSerializer();
|
||||
this.requiredHeat = params.requiredHeat;
|
||||
this.ingredients = params.ingredients;
|
||||
this.type = recipeType.type;
|
||||
this.type = recipeType.getType();
|
||||
this.results = params.results;
|
||||
this.id = params.id;
|
||||
|
||||
|
@ -192,15 +192,15 @@ public class ProcessingRecipeBuilder<T extends ProcessingRecipe<?>> {
|
||||
|
||||
public static class ProcessingRecipeParams {
|
||||
|
||||
ResourceLocation id;
|
||||
NonNullList<Ingredient> ingredients;
|
||||
NonNullList<ProcessingOutput> results;
|
||||
NonNullList<FluidIngredient> fluidIngredients;
|
||||
NonNullList<FluidStack> fluidResults;
|
||||
int processingDuration;
|
||||
HeatCondition requiredHeat;
|
||||
protected ResourceLocation id;
|
||||
protected NonNullList<Ingredient> ingredients;
|
||||
protected NonNullList<ProcessingOutput> results;
|
||||
protected NonNullList<FluidIngredient> fluidIngredients;
|
||||
protected NonNullList<FluidStack> fluidResults;
|
||||
protected int processingDuration;
|
||||
protected HeatCondition requiredHeat;
|
||||
|
||||
ProcessingRecipeParams(ResourceLocation id) {
|
||||
protected ProcessingRecipeParams(ResourceLocation id) {
|
||||
this.id = id;
|
||||
ingredients = NonNullList.create();
|
||||
results = NonNullList.create();
|
||||
@ -226,7 +226,7 @@ public class ProcessingRecipeBuilder<T extends ProcessingRecipe<?>> {
|
||||
String typeName = Lang.asId(recipeType.name());
|
||||
this.recipe = recipe;
|
||||
|
||||
if (!(recipeType.serializer instanceof ProcessingRecipeSerializer))
|
||||
if (!(recipeType.getSerializer() instanceof ProcessingRecipeSerializer))
|
||||
throw new IllegalStateException("Cannot datagen ProcessingRecipe of type: " + typeName);
|
||||
|
||||
this.id = new ResourceLocation(recipe.getId().getNamespace(),
|
||||
|
@ -11,12 +11,12 @@ import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public abstract class PotatoProjectileRenderMode {
|
||||
public interface PotatoProjectileRenderMode {
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public abstract void transform(MatrixStack ms, PotatoProjectileEntity entity, float pt);
|
||||
void transform(MatrixStack ms, PotatoProjectileEntity entity, float pt);
|
||||
|
||||
public static class Billboard extends PotatoProjectileRenderMode {
|
||||
public static class Billboard implements PotatoProjectileRenderMode {
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@ -47,7 +47,7 @@ public abstract class PotatoProjectileRenderMode {
|
||||
}
|
||||
}
|
||||
|
||||
public static class TowardMotion extends PotatoProjectileRenderMode {
|
||||
public static class TowardMotion implements PotatoProjectileRenderMode {
|
||||
|
||||
private int spriteAngleOffset;
|
||||
private float spin;
|
||||
@ -72,7 +72,7 @@ public abstract class PotatoProjectileRenderMode {
|
||||
|
||||
}
|
||||
|
||||
public static class StuckToEntity extends PotatoProjectileRenderMode {
|
||||
public static class StuckToEntity implements PotatoProjectileRenderMode {
|
||||
|
||||
private Vector3d offset;
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
package com.simibubi.create.foundation.config;
|
||||
|
||||
import com.simibubi.create.foundation.config.ConfigBase.ConfigBool;
|
||||
import com.simibubi.create.foundation.config.ConfigBase.ConfigEnum;
|
||||
import com.simibubi.create.foundation.config.ConfigBase.ConfigFloat;
|
||||
import com.simibubi.create.foundation.config.ConfigBase.ConfigGroup;
|
||||
import com.simibubi.create.foundation.config.ConfigBase.ConfigInt;
|
||||
|
||||
|
||||
public class CKinetics extends ConfigBase {
|
||||
|
||||
public ConfigBool disableStress = b(false, "disableStress", Comments.disableStress);
|
||||
|
@ -183,7 +183,7 @@ public class MechanicalCraftingRecipeBuilder {
|
||||
}
|
||||
|
||||
public IRecipeSerializer<?> getType() {
|
||||
return AllRecipeTypes.MECHANICAL_CRAFTING.serializer;
|
||||
return AllRecipeTypes.MECHANICAL_CRAFTING.getSerializer();
|
||||
}
|
||||
|
||||
public ResourceLocation getId() {
|
||||
|
@ -20,8 +20,6 @@ import net.minecraft.util.IItemProvider;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
|
||||
import com.simibubi.create.foundation.data.recipe.CreateRecipeProvider.GeneratedRecipe;
|
||||
|
||||
public abstract class ProcessingRecipeGen extends CreateRecipeProvider {
|
||||
|
||||
protected static List<ProcessingRecipeGen> generators = new ArrayList<>();
|
||||
@ -116,9 +114,8 @@ public abstract class ProcessingRecipeGen extends CreateRecipeProvider {
|
||||
return create(Create.asResource(name), transform);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T extends ProcessingRecipe<?>> ProcessingRecipeSerializer<T> getSerializer() {
|
||||
ProcessingRecipeSerializer<T> serializer = (ProcessingRecipeSerializer<T>) getRecipeType().serializer;
|
||||
ProcessingRecipeSerializer<T> serializer = getRecipeType().getSerializer();
|
||||
return serializer;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user