Skip to content

Commit

Permalink
Add a delay to potion brewing in cauldrons
Browse files Browse the repository at this point in the history
Now takes a bit longer than the brewing stand, to make up for the cauldron being cheaper. Works using "unfermented potions", which slowly stir into a regular potion under heat.
  • Loading branch information
KnightMiner committed Sep 13, 2020
1 parent 7af942b commit 98ba9aa
Show file tree
Hide file tree
Showing 21 changed files with 331 additions and 66 deletions.
5 changes: 3 additions & 2 deletions src/generated/resources/.cache/cache
Expand Up @@ -772,13 +772,14 @@ bd3b6173001ed0b2203ea2335e99483b9f76c04e data/inspirations/recipes/cauldron/pota
55b751b5237c3c8dbe171f55604e7c7a94df5923 data/inspirations/recipes/cauldron/potato_soup/item.json
2cfa24cdbb1d4bc3fd15412cdb3b30eb36e338e0 data/inspirations/recipes/cauldron/potato_soup/stew_large.json
ed2a7b617ee025608ece02f1bd49c6ba3ed497ad data/inspirations/recipes/cauldron/potato_soup/stew_small.json
3ffb6885e1a9c5ccc210c5e15573b3a101e5406e data/inspirations/recipes/cauldron/potion/forge_brewing.json
4bc0c49d46ca8634ad03920ad3fc73aa655f3db1 data/inspirations/recipes/cauldron/potion/forge_brewing.json
c9de2e3800af3d019d81be1eace6d08e6deb7195 data/inspirations/recipes/cauldron/potion/lingering_bottle.json
3c4d644f1f1072d8a9ada2ff147de2b0bcf15354 data/inspirations/recipes/cauldron/potion/lingering_empty.json
d9c611348b17634f9ea886a154104241a274db34 data/inspirations/recipes/cauldron/potion/lingering_fill.json
47424706c9c3dd50cc12453931821682d18a9f5c data/inspirations/recipes/cauldron/potion/normal_empty.json
49b05c1a42d06cfe853c8519028b6cfe07c2b8d9 data/inspirations/recipes/cauldron/potion/normal_fill.json
81909dc96f087ca6e01e2aad944d91ad912e5d14 data/inspirations/recipes/cauldron/potion/potion_brewing.json
386ad3be1ee2b6d03ad0b8ea9024e7eab367f389 data/inspirations/recipes/cauldron/potion/potion_brewing.json
d7c18d79d56bd1d40532e86276130c76809f56af data/inspirations/recipes/cauldron/potion/potion_ferment.json
f8323b474fafb97b99f72e735540059420e4daf3 data/inspirations/recipes/cauldron/potion/splash_bottle.json
19f63976122e48ba4c58d5966fc3e3f88ba2633b data/inspirations/recipes/cauldron/potion/splash_empty.json
c7e3e2f5fd5b1366c14b1877727c3ba4e2e3dde6 data/inspirations/recipes/cauldron/potion/splash_fill.json
Expand Down
Expand Up @@ -9,5 +9,6 @@
"prop": "cauldron_brewing",
"type": "inspirations:config"
}
]
],
"instant": false
}
Expand Up @@ -9,5 +9,6 @@
"prop": "cauldron_brewing",
"type": "inspirations:config"
}
]
],
"instant": false
}
@@ -0,0 +1,14 @@
{
"type": "inspirations:cauldron_potion_ferment",
"conditions": [
{
"prop": "recipes_module",
"type": "inspirations:config"
},
{
"prop": "cauldron_brewing",
"type": "inspirations:config"
}
],
"time": 600
}
@@ -1,6 +1,6 @@
package knightminer.inspirations.common.network;

import knightminer.inspirations.library.recipe.cauldron.recipe.CauldronTransform;
import knightminer.inspirations.library.recipe.cauldron.recipe.ICauldronTransform;
import knightminer.inspirations.recipes.tileentity.CauldronTileEntity;
import net.minecraft.client.Minecraft;
import net.minecraft.network.PacketBuffer;
Expand All @@ -22,7 +22,7 @@ public class CauldronTransformUpatePacket implements IThreadsafePacket {
@Nullable
private final ResourceLocation recipe;

public CauldronTransformUpatePacket(BlockPos pos, @Nullable CauldronTransform recipe) {
public CauldronTransformUpatePacket(BlockPos pos, @Nullable ICauldronTransform recipe) {
this.pos = pos;
this.recipe = recipe == null ? null : recipe.getId();
}
Expand Down Expand Up @@ -57,7 +57,7 @@ private static class HandleClient {
private static void handle(CauldronTransformUpatePacket packet) {
World world = Minecraft.getInstance().world;
if (world != null) {
CauldronTransform recipe = packet.recipe == null ? null : RecipeHelper.getRecipe(world.getRecipeManager(), packet.recipe, CauldronTransform.class).orElse(null);
ICauldronTransform recipe = packet.recipe == null ? null : RecipeHelper.getRecipe(world.getRecipeManager(), packet.recipe, ICauldronTransform.class).orElse(null);
TileEntityHelper.getTile(CauldronTileEntity.class, world, packet.pos, true).ifPresent(te -> {
te.setTransformRecipe(recipe);
});
Expand Down
Expand Up @@ -13,6 +13,7 @@
import knightminer.inspirations.recipes.recipe.cauldron.FillBucketCauldronRecipe;
import knightminer.inspirations.recipes.recipe.cauldron.FillDyedBottleRecipe;
import knightminer.inspirations.recipes.recipe.cauldron.MixCauldronDyeRecipe;
import knightminer.inspirations.recipes.recipe.cauldron.PotionFermentCauldronTransform;
import knightminer.inspirations.recipes.recipe.cauldron.RemoveBannerPatternCauldronRecipe;
import knightminer.inspirations.tools.recipe.CopyWaypointCompassRecipe;
import knightminer.inspirations.tools.recipe.DyeWaypointCompassRecipe;
Expand Down Expand Up @@ -48,6 +49,7 @@ public class RecipeSerializers {
public static final SpecialRecipeSerializer<FillBucketCauldronRecipe> CAULDRON_FILL_BUCKET = injected();
public static final SpecialRecipeSerializer<FillDyedBottleRecipe> CAULDRON_FILL_DYED_BOTTLE = injected();
public static final SpecialRecipeSerializer<RemoveBannerPatternCauldronRecipe> CAULDRON_REMOVE_BANNER_PATTERN = injected();
public static final SpecialRecipeSerializer<BrewingCauldronRecipe.Vanilla> CAULDRON_POTION_BREWING = injected();
public static final SpecialRecipeSerializer<BrewingCauldronRecipe.Forge> CAULDRON_FORGE_BREWING = injected();
public static final BrewingCauldronRecipe.Serializer CAULDRON_POTION_BREWING = injected();
public static final BrewingCauldronRecipe.Serializer CAULDRON_FORGE_BREWING = injected();
public static final PotionFermentCauldronTransform.Serializer CAULDRON_POTION_FERMENT = injected();
}
@@ -1,8 +1,8 @@
package knightminer.inspirations.library.recipe;

import knightminer.inspirations.Inspirations;
import knightminer.inspirations.library.recipe.cauldron.recipe.CauldronTransform;
import knightminer.inspirations.library.recipe.cauldron.recipe.ICauldronRecipe;
import knightminer.inspirations.library.recipe.cauldron.recipe.ICauldronTransform;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.IRecipeType;

Expand All @@ -12,7 +12,7 @@
public class RecipeTypes {
/** Recipe type for cauldron recipes */
public static final IRecipeType<ICauldronRecipe> CAULDRON = register("cauldron");
public static final IRecipeType<CauldronTransform> CAULDRON_TRANSFORM = register("cauldron_transform");
public static final IRecipeType<ICauldronTransform> CAULDRON_TRANSFORM = register("cauldron_transform");

/**
* Registers an Inspirations recipe type
Expand Down
Expand Up @@ -46,8 +46,10 @@ public class CauldronContentTypes {
/** Contains a specific color */
public static final CauldronContentType<DyeColor> DYE = register("dye", new DyeContentType());

/** Contains a specific color */
public static final CauldronContentType<Potion> POTION = register("potion", new PotionContentType());
/** Contains a specific potion */
public static final CauldronContentType<Potion> POTION = register("potion", new PotionContentType(Inspirations.getResource("potion"), false));
/** Potion that is currently in progress brewing */
public static final CauldronContentType<Potion> UNFERMENTED_POTION = register("unfermented_potion", new PotionContentType(Inspirations.getResource("unfermented_potion"), true));

/** Contains a specific fluid */
public static final CauldronContentType<ResourceLocation> CUSTOM = register("custom", new CustomContentType());
Expand Down
Expand Up @@ -3,7 +3,6 @@
import com.google.gson.JsonObject;
import knightminer.inspirations.library.recipe.RecipeSerializer;
import knightminer.inspirations.library.recipe.RecipeSerializers;
import knightminer.inspirations.library.recipe.RecipeTypes;
import knightminer.inspirations.library.recipe.cauldron.CauldronContentTypes;
import knightminer.inspirations.library.recipe.cauldron.CauldronIngredients;
import knightminer.inspirations.library.recipe.cauldron.contents.ICauldronContents;
Expand All @@ -13,14 +12,12 @@
import knightminer.inspirations.library.recipe.cauldron.util.TemperaturePredicate;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.JSONUtils;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.SoundEvents;
import net.minecraft.world.World;
import slimeknights.mantle.recipe.ICustomOutputRecipe;

import javax.annotation.Nullable;
import java.util.Collections;
Expand All @@ -30,7 +27,7 @@
/**
* Base cauldron transform implementation
*/
public class CauldronTransform extends AbstractCauldronRecipe implements ICustomOutputRecipe<ICauldronState> {
public class CauldronTransform extends AbstractCauldronRecipe implements ICauldronTransform {
private final ResourceLocation id;
private final String group;
private final int time;
Expand Down Expand Up @@ -60,14 +57,24 @@ public boolean matches(ICauldronState inv, World worldIn) {
return inv.getLevel() != 0 && matches(inv);
}

/**
* Gets the sound to play for this recipe
* @return Recipe sound
*/
@Override
public ICauldronContents getContentOutput(ICauldronState inv) {
if (outputContents == null) {
return inv.getContents();
}
return outputContents;
}

@Override
public SoundEvent getSound() {
return sound;
}

@Override
public int getTime() {
return time;
}


/* Display */

Expand All @@ -76,11 +83,6 @@ public List<ItemStack> getItemInputs() {
return Collections.emptyList();
}

@Override
public int getTime() {
return time;
}

@Override
public int getLevelInput() {
return level.getMax();
Expand Down Expand Up @@ -109,11 +111,6 @@ public String getGroup() {
return group;
}

@Override
public IRecipeType<?> getType() {
return RecipeTypes.CAULDRON_TRANSFORM;
}

@Override
public IRecipeSerializer<?> getSerializer() {
return RecipeSerializers.CAULDRON_TRANSFORM;
Expand Down
@@ -0,0 +1,37 @@
package knightminer.inspirations.library.recipe.cauldron.recipe;

import knightminer.inspirations.library.recipe.RecipeTypes;
import knightminer.inspirations.library.recipe.cauldron.contents.ICauldronContents;
import knightminer.inspirations.library.recipe.cauldron.inventory.ICauldronState;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.util.SoundEvent;
import slimeknights.mantle.recipe.ICustomOutputRecipe;

/**
* Recipe that transforms contents in a cauldron given time and temperature
*/
public interface ICauldronTransform extends ICustomOutputRecipe<ICauldronState> {
/**
* Gets the output contents for this recipe based on the input contents
* @param inv Cauldron state
* @return New contents
*/
ICauldronContents getContentOutput(ICauldronState inv);

/**
* Gets the sound to play upon completion of the recipe
* @return Recipe sound
*/
SoundEvent getSound();

/**
* Gets the recipe duration in ticks (1/20 of a second)
* @return Recipe duration
*/
int getTime();

@Override
default IRecipeType<?> getType() {
return RecipeTypes.CAULDRON_TRANSFORM;
}
}
Expand Up @@ -2,6 +2,7 @@

import knightminer.inspirations.Inspirations;
import knightminer.inspirations.library.recipe.cauldron.CauldronContentTypes;
import knightminer.inspirations.library.recipe.cauldron.contents.CauldronContentType;
import knightminer.inspirations.library.recipe.cauldron.contents.ICauldronContents;
import mezz.jei.api.ingredients.IIngredientHelper;

Expand All @@ -14,11 +15,28 @@ public class CauldronContentHelper implements IIngredientHelper<ICauldronContent
public static final CauldronContentHelper INSTANCE = new CauldronContentHelper();
private CauldronContentHelper() {}

/**
* Helper that aliases some types as another in JEI
* @param contents Contents containing type
* @return Aliased type if relevant
*/
private static CauldronContentType<?> getType(ICauldronContents contents) {
// TODO: consider making this more generic so addons can add more aliases
CauldronContentType<?> type = contents.getType();
// if unfermented, treat as potion for recipe lookups
if (type == CauldronContentTypes.UNFERMENTED_POTION) {
return CauldronContentTypes.POTION;
}
return type;
}

@Nullable
@Override
public ICauldronContents getMatch(Iterable<ICauldronContents> options, ICauldronContents match) {
CauldronContentType<?> type = getType(match);
String name = match.getName();
for (ICauldronContents content : options) {
if (content.equals(match)) {
if (type == getType(content) && name.equals(content.getName())) {
return content;
}
}
Expand All @@ -37,7 +55,7 @@ public String getDisplayName(ICauldronContents contents) {

@Override
public String getUniqueId(ICauldronContents contents) {
return CauldronContentTypes.getName(contents.getType()).toString() + ":" + contents.getName();
return CauldronContentTypes.getName(getType(contents)).toString() + ":" + contents.getName();
}

@Override
Expand Down
Expand Up @@ -21,6 +21,7 @@
import knightminer.inspirations.recipes.recipe.cauldron.FillBucketCauldronRecipe;
import knightminer.inspirations.recipes.recipe.cauldron.FillDyedBottleRecipe;
import knightminer.inspirations.recipes.recipe.cauldron.MixCauldronDyeRecipe;
import knightminer.inspirations.recipes.recipe.cauldron.PotionFermentCauldronTransform;
import knightminer.inspirations.recipes.recipe.cauldron.RemoveBannerPatternCauldronRecipe;
import knightminer.inspirations.recipes.tileentity.CauldronTileEntity;
import net.minecraft.block.Block;
Expand Down Expand Up @@ -200,13 +201,14 @@ void registerSerializers(Register<IRecipeSerializer<?>> event) {
registry.register(new DyeableCauldronRecipe.Serializer(DyeableCauldronRecipe.Dye::new), "cauldron_dye_dyeable");
registry.register(new DyeableCauldronRecipe.Serializer(DyeableCauldronRecipe.Clear::new), "cauldron_clear_dyeable");
registry.register(new CauldronTransform.Serializer(), "cauldron_transform");
registry.register(new PotionFermentCauldronTransform.Serializer(), "cauldron_potion_ferment");

registry.register(new SpecialRecipeSerializer<>(EmptyBucketCauldronRecipe::new), "cauldron_empty_bucket");
registry.register(new SpecialRecipeSerializer<>(FillBucketCauldronRecipe::new), "cauldron_fill_bucket");
registry.register(new SpecialRecipeSerializer<>(FillDyedBottleRecipe::new), "cauldron_fill_dyed_bottle");
registry.register(new SpecialRecipeSerializer<>(RemoveBannerPatternCauldronRecipe::new), "cauldron_remove_banner_pattern");
registry.register(new SpecialRecipeSerializer<>(BrewingCauldronRecipe.Vanilla::new), "cauldron_potion_brewing");
registry.register(new SpecialRecipeSerializer<>(BrewingCauldronRecipe.Forge::new), "cauldron_forge_brewing");
registry.register(new BrewingCauldronRecipe.Serializer(BrewingCauldronRecipe.Vanilla::new), "cauldron_potion_brewing");
registry.register(new BrewingCauldronRecipe.Serializer(BrewingCauldronRecipe.Forge::new), "cauldron_forge_brewing");

// add water as an override to potions
ICauldronContents water = CauldronContentTypes.FLUID.of(Fluids.WATER);
Expand Down
Expand Up @@ -17,8 +17,10 @@
import knightminer.inspirations.library.recipe.cauldron.special.FillPotionCauldronRecipe;
import knightminer.inspirations.library.recipe.cauldron.util.TemperaturePredicate;
import knightminer.inspirations.recipes.InspirationsRecipes;
import knightminer.inspirations.recipes.recipe.cauldron.BrewingCauldronRecipe;
import knightminer.inspirations.recipes.recipe.cauldron.DyeCauldronWaterRecipe;
import knightminer.inspirations.recipes.recipe.cauldron.MixCauldronDyeRecipe;
import knightminer.inspirations.recipes.recipe.cauldron.PotionFermentCauldronTransform;
import knightminer.inspirations.shared.InspirationsShared;
import knightminer.inspirations.utility.InspirationsUtility;
import net.minecraft.advancements.ICriterionInstance;
Expand Down Expand Up @@ -407,10 +409,9 @@ private void addCauldronRecipes() {

// brew the potions
Consumer<IFinishedRecipe> brewingConsumer = withCondition(ConfigEnabledCondition.CAULDRON_BREWING);
CustomRecipeBuilder.customRecipe(RecipeSerializers.CAULDRON_POTION_BREWING)
.build(brewingConsumer, resourceName(potionFolder + "potion_brewing"));
CustomRecipeBuilder.customRecipe(RecipeSerializers.CAULDRON_FORGE_BREWING)
.build(brewingConsumer, resourceName(potionFolder + "forge_brewing"));
brewingConsumer.accept(new BrewingCauldronRecipe.FinishedRecipe(resource(potionFolder + "potion_brewing"), RecipeSerializers.CAULDRON_POTION_BREWING, false));
brewingConsumer.accept(new BrewingCauldronRecipe.FinishedRecipe(resource(potionFolder + "forge_brewing"), RecipeSerializers.CAULDRON_FORGE_BREWING, false));
brewingConsumer.accept(new PotionFermentCauldronTransform.FinishedRecipe(resource(potionFolder + "potion_ferment"), 600));

// fluid recipes //
// beetroot is just water based
Expand Down

0 comments on commit 98ba9aa

Please sign in to comment.