Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions examples/postInit/minecraft.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,14 @@ mods.minecraft.crafting.shapelessBuilder()
// mods.minecraft.crafting.replaceShapeless('minecraft:pink_dye_from_pink_tulp', item('minecraft:clay'), [item('minecraft:nether_star')])

// Furnace:
// Converts an input item into an output itemstack after a set amount of time, with the ability to give experience and
// using fuel to run.
// Converts an input item into an output itemstack after a configurable amount of time, with the ability to give experience
// and using fuel to run. Can also convert the item in the fuel slot.

mods.minecraft.furnace.removeByInput(item('minecraft:clay'))
mods.minecraft.furnace.removeByInput(item('minecraft:clay:*'))
mods.minecraft.furnace.removeByOutput(item('minecraft:brick'))
mods.minecraft.furnace.removeFuelConversionBySmeltedStack(item('minecraft:sponge', 1))
// mods.minecraft.furnace.removeAll()
// mods.minecraft.furnace.removeAllFuelConversions()

mods.minecraft.furnace.recipeBuilder()
.input(ore('ingotGold'))
Expand All @@ -175,6 +177,8 @@ mods.minecraft.furnace.recipeBuilder()

// mods.minecraft.furnace.add(ore('ingotIron'), item('minecraft:diamond'))
mods.minecraft.furnace.add(item('minecraft:nether_star'), item('minecraft:clay') * 64, 13)
mods.minecraft.furnace.add(item('minecraft:diamond'), item('minecraft:clay'), 2, 50)
mods.minecraft.furnace.addFuelConversion(item('minecraft:diamond'), item('minecraft:bucket').transform(item('minecraft:lava_bucket')))

// Default GameRules:
// Create or assign a default value to GameRules.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.cleanroommc.groovyscript.compat.vanilla;

import com.cleanroommc.groovyscript.api.GroovyBlacklist;
import com.cleanroommc.groovyscript.api.IIngredient;
import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper;
import com.cleanroommc.groovyscript.helper.ingredient.itemstack.ItemStack2IntProxyMap;
import com.github.bsideup.jabel.Desugar;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

import java.util.ArrayList;
import java.util.List;

@GroovyBlacklist
public class CustomFurnaceManager {

/**
* Time an itemstack takes to smelt.
* <p>
* By default, minecraft uses 200 ticks for everything, GroovyScript uses a mixin to allow variable times to smelt.
*
* @see com.cleanroommc.groovyscript.core.mixin.furnace.TileEntityFurnaceMixin TileEntityFurnaceMixin
*/
public static final ItemStack2IntProxyMap TIME_MAP = new ItemStack2IntProxyMap();

/**
* Recipes for converting the fuel slot of a furnace into another item when a valid item is smelted.
* <p>
* By default, minecraft has custom logic to make smelting a wet sponge convert an empty bucket into a water bucket.
*
* @see com.cleanroommc.groovyscript.core.mixin.furnace.TileEntityFurnaceMixin TileEntityFurnaceMixin
* @see FuelConversionRecipe
*/
public static final List<FuelConversionRecipe> FUEL_TRANSFORMERS = new ArrayList<>();

static {
// reproduce the vanilla logic for converting empty buckets into water buckets on smelting wet sponge
// in groovyscript this would be `furnace.addFuelConversion(item('minecraft:sponge', 1), item('minecraft:bucket').transform(item('minecraft:water_bucket')))`
var bucket = IngredientHelper.toIIngredient(((ItemStackMixinExpansion) (Object) (new ItemStack(Items.BUCKET))).transform(new ItemStack(Items.WATER_BUCKET)));
var wetSponge = IngredientHelper.toIIngredient(new ItemStack(Item.getItemFromBlock(Blocks.SPONGE), 1, 1));
FUEL_TRANSFORMERS.add(new FuelConversionRecipe(wetSponge, bucket));
}

/**
* When the smelted ItemStack passes the {@link #smelted} filter and the {@link #fuel} filter,
* the {@link #fuel} IIngredient will use {@link IIngredient#applyTransform(ItemStack)} to convert the fuel stack.
*
* @param smelted an IIngredient that is checked against the item being smelted
* @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.
*/
@Desugar
public record FuelConversionRecipe(IIngredient smelted, IIngredient fuel) {

}

}
Loading