User Tools

Site Tools


tutorial:recipe_type

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
tutorial:recipe_type [2021/08/29 18:18] – fixed missing bracket bananatutorial:recipe_type [2021/12/01 11:36] – added fits implementation as the text suggested ayutac
Line 12: Line 12:
 public class TestRecipeBlock extends Block { public class TestRecipeBlock extends Block {
  private static final Text TITLE = new TranslatableText("container.test_crafting");  private static final Text TITLE = new TranslatableText("container.test_crafting");
- public SpiritpowerCrafterBlock(Settings settings) {+ public TestRecipeBlock(Settings settings) {
  super(settings);  super(settings);
  }  }
Line 102: Line 102:
  public ItemStack craft(CraftingInventory inv) {  public ItemStack craft(CraftingInventory inv) {
  return this.getOutput().copy();  return this.getOutput().copy();
 + }
 +
 + @Override
 + public boolean fits(int width, int height) {
 + return true;
  }  }
 } }
Line 113: Line 118:
  @Override   @Override 
  public boolean matches(CraftingInventory inv, World world) {  public boolean matches(CraftingInventory inv, World world) {
- if(inv.getInvSize(0) < 2) return false; + if(inv.size(0) < 2) return false; 
- return inputA.test(inventory.getInvStack(0)) && inputB.test(inventory.getInvStack(1));+ return inputA.test(inventory.getStack(0)) && inputB.test(inventory.getStack(1));
  }  }
 } }
Line 124: Line 129:
 public class TestRecipe implements Recipe<CraftingInventory> { public class TestRecipe implements Recipe<CraftingInventory> {
  //[...]  //[...]
- public static Type implements RecipeType<TestRecipe> {+ public static class Type implements RecipeType<TestRecipe> {
  private Type() {}  private Type() {}
  public static final Type INSTANCE = new Type();  public static final Type INSTANCE = new Type();
tutorial/recipe_type.txt · Last modified: 2021/12/01 11:46 by ayutac