/RecipeTileEntity

RecipeTileEntity - a library that simplifies the creation of workbenches and furnaces

Primary LanguageTypeScriptMIT LicenseMIT

RecipeTileEntity 3.0

RecipeTileEntity - a library that simplifies the creation of workbenches and furnaces.

en | ru

To begin

Before starting work, you need to import the library.

IMPORT("RecipeTileEntity", "*"); // Import all modules

Crafting a workbench

The Workbench and TimerWorkbench classes are used to create workbenches.

/* new RecipeTE.Workbench(info: WorkbenchInfo, data?: any); */
const MyWorkbench = new RecipeTE.Workbench({
    columns: 4,
    rows: 4 // Optional parameter, default = 1
});
/* new RecipeTE.Workbench(info: TimerWorkbenchInfo, data: RecipeDataTimer); */
const MyFurnace = new RecipeTE.TimerWorkbench({
    columns: 1,
    timer: 5 * 20
}, { multiply: 1 })

Registering recipes

The workbench.addRecipe and workbench.addShapeRecipe methods are used to register recipes.

MyWorkbench.addShapeRecipe({id: 280, count: 1}, [
    "aa",
    "aa"
], {a: {id: 5}});
MyWorkbench.addRecipe({id: 2}, [{id: 5, count: 3}]);

Register TileEntity

To register TileEntity, a class inherited from WorkbenchTileEntity or TimerWorkbenchTileEntity is used

class MyWorkbenchTileEntity extends RecipeTE.WorkbenchTileEntity {
    //Methods of TileEntity
    public getScreenName() {return "main"; }
    public getScreenByName() {return Workbench_Grid; }
    
    /* List of input slot names.
    *
    * If not an array is specified, the name of slots is constructed using the formula string + i
    * where i is the index of slots with 0
    */
    public getInputSlots(): string {return "inputSlot"; }
    
    //The name of the output slot.
    public getOutputSlot(): string {return "outputSlot"; }
}

TileEntity.registerPrototype (BlockID ["Workbench_Grid"], new MyWorkbenchTileEntity(MyWorkbench));

For use in JavaScript, you can use the extends library

Older versions