Package com.mojang.ld22.crafting

Source Code of com.mojang.ld22.crafting.FurnitureRecipe

package com.mojang.ld22.crafting;

import com.mojang.ld22.entity.Furniture;
import com.mojang.ld22.entity.Player;
import com.mojang.ld22.item.FurnitureItem;

public class FurnitureRecipe extends Recipe {
  private Class<? extends Furniture> clazz;

  public FurnitureRecipe(Class<? extends Furniture> clazz) throws InstantiationException, IllegalAccessException {
    super(new FurnitureItem(clazz.newInstance()));
    this.clazz = clazz;
  }

  public void craft(Player player) {
    try {
      player.inventory.add(0, new FurnitureItem(clazz.newInstance()));
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
}
TOP

Related Classes of com.mojang.ld22.crafting.FurnitureRecipe

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.