|
| 1 | +package com.cleanroommc.groovyscript.compat.vanilla; |
| 2 | + |
| 3 | +import com.cleanroommc.groovyscript.api.GroovyBlacklist; |
| 4 | +import com.cleanroommc.groovyscript.api.IIngredient; |
| 5 | +import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; |
| 6 | +import com.cleanroommc.groovyscript.helper.ingredient.itemstack.ItemStack2IntProxyMap; |
| 7 | +import com.github.bsideup.jabel.Desugar; |
| 8 | +import net.minecraft.init.Blocks; |
| 9 | +import net.minecraft.init.Items; |
| 10 | +import net.minecraft.item.Item; |
| 11 | +import net.minecraft.item.ItemStack; |
| 12 | + |
| 13 | +import java.util.ArrayList; |
| 14 | +import java.util.List; |
| 15 | + |
| 16 | +@GroovyBlacklist |
| 17 | +public class CustomFurnaceManager { |
| 18 | + |
| 19 | + /** |
| 20 | + * Time an itemstack takes to smelt. |
| 21 | + * <p> |
| 22 | + * By default, minecraft uses 200 ticks for everything, GroovyScript uses a mixin to allow variable times to smelt. |
| 23 | + * |
| 24 | + * @see com.cleanroommc.groovyscript.core.mixin.furnace.TileEntityFurnaceMixin TileEntityFurnaceMixin |
| 25 | + */ |
| 26 | + public static final ItemStack2IntProxyMap TIME_MAP = new ItemStack2IntProxyMap(); |
| 27 | + |
| 28 | + /** |
| 29 | + * Recipes for converting the fuel slot of a furnace into another item when a valid item is smelted. |
| 30 | + * <p> |
| 31 | + * By default, minecraft has custom logic to make smelting a wet sponge convert an empty bucket into a water bucket. |
| 32 | + * |
| 33 | + * @see com.cleanroommc.groovyscript.core.mixin.furnace.TileEntityFurnaceMixin TileEntityFurnaceMixin |
| 34 | + * @see FuelConversionRecipe |
| 35 | + */ |
| 36 | + public static final List<FuelConversionRecipe> FUEL_TRANSFORMERS = new ArrayList<>(); |
| 37 | + |
| 38 | + static { |
| 39 | + // reproduce the vanilla logic for converting empty buckets into water buckets on smelting wet sponge |
| 40 | + // in groovyscript this would be `furnace.addFuelConversion(item('minecraft:sponge', 1), item('minecraft:bucket').transform(item('minecraft:water_bucket')))` |
| 41 | + var bucket = IngredientHelper.toIIngredient(((ItemStackMixinExpansion) (Object) (new ItemStack(Items.BUCKET))).transform(new ItemStack(Items.WATER_BUCKET))); |
| 42 | + var wetSponge = IngredientHelper.toIIngredient(new ItemStack(Item.getItemFromBlock(Blocks.SPONGE), 1, 1)); |
| 43 | + FUEL_TRANSFORMERS.add(new FuelConversionRecipe(wetSponge, bucket)); |
| 44 | + } |
| 45 | + |
| 46 | + /** |
| 47 | + * When the smelted ItemStack passes the {@link #smelted} filter and the {@link #fuel} filter, |
| 48 | + * the {@link #fuel} IIngredient will use {@link IIngredient#applyTransform(ItemStack)} to convert the fuel stack. |
| 49 | + * |
| 50 | + * @param smelted an IIngredient that is checked against the item being smelted |
| 51 | + * @param fuel an IIngredient that is checked against the fuel item, and if it passes uses {@link IIngredient#applyTransform(ItemStack)} to convert the fuel item. |
| 52 | + */ |
| 53 | + @Desugar |
| 54 | + public record FuelConversionRecipe(IIngredient smelted, IIngredient fuel) { |
| 55 | + |
| 56 | + } |
| 57 | + |
| 58 | +} |
0 commit comments