Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //IRecipe
- public interface IExkvaRecipe extends IForgeRegistryEntry<IExkvaRecipe> {
- ItemStack getRecipeOutput();
- ItemStack getCraftingResult(InventoryCrafting var1);
- boolean matches(InventoryCrafting var1, World var2);
- boolean canFit(int var1, int var2);
- default NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) {
- return ForgeHooks.defaultRecipeGetRemainingItems(inv);
- }
- default NonNullList<Ingredient> getIngredients() {return NonNullList.create(); }
- default boolean isShaped() { return false; }
- }
- //IShapedRecipe
- public interface IShapedExkvaRecipe extends IExkvaRecipe {
- int getRecipeWidth();
- int getRecipeHeight();
- }
- //ShapedRecipe
- public class RecipeExkvaShaped extends IForgeRegistryEntry.Impl<IExkvaRecipe> implements IShapedExkvaRecipe {
- public final int recipeWidth;
- public final int recipeHeight;
- public final NonNullList<Ingredient> recipeItems;
- private final ItemStack recipeOutput;
- private final String group;
- public RecipeExkvaShaped(String group, int width, int height, NonNullList<Ingredient> ingredients, ItemStack result) {
- this.recipeWidth = width;
- this.recipeHeight = height;
- this.recipeItems = ingredients;
- this.recipeOutput = result;
- this.group = group;
- }
- public int getRecipeWidth() {
- return this.recipeWidth;
- }
- public int getRecipeHeight() {
- return this.recipeWidth;
- }
- public String getGroup() {
- return this.group; }
- public ItemStack getRecipeOutput() {
- return this.recipeOutput; }
- public ItemStack getCraftingResult(InventoryCrafting inv) {
- return this.getRecipeOutput().copy();
- }
- public NonNullList<Ingredient> getIngredients() {
- return this.recipeItems; }
- public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) {
- NonNullList<ItemStack> nonnulllist = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);
- for(int i = 0; i < nonnulllist.size(); ++i) {
- ItemStack itemstack = inv.getStackInSlot(i);
- nonnulllist.set(i, ForgeHooks.getContainerItem(itemstack));
- }
- return nonnulllist;
- }
- public boolean canFit(int width, int height) {
- return width >= this.recipeWidth && height >= this.recipeHeight;
- }
- public boolean matches(InventoryCrafting inv, World worldIn) {
- for(int i = 0; i <= inv.getWidth() - this.recipeWidth; ++i) {
- for(int j = 0; j <= inv.getHeight() - this.recipeHeight; ++j) {
- if(this.checkMatch(inv, i, j, true)) {
- return true;
- }
- if(this.checkMatch(inv, i, j, false)) {
- return true;
- }
- }
- }
- return false;
- }
- public boolean checkMatch(InventoryCrafting inv, int a, int b, boolean bool) {
- for(int i = 0; i < inv.getWidth(); ++i) {
- for(int j = 0; j < inv.getHeight(); ++j) {
- int k = i - a;
- int l = j - b;
- Ingredient ingredient = Ingredient.EMPTY;
- if (k >= 0 && l >= 0 && k < this.recipeWidth && l < this.recipeHeight) {
- if (bool) {
- ingredient = (Ingredient)this.recipeItems.get(this.recipeWidth - k - 1 + l * this.recipeWidth);
- } else {
- ingredient = (Ingredient)this.recipeItems.get(k + l * this.recipeWidth);
- }
- }
- if (!ingredient.apply(inv.getStackInRowAndColumn(i, j))) {
- return false;
- }
- }
- }
- return true;
- }
- private static String[] patternFromJson(JsonArray jArr) {
- String[] astring = new String[jArr.size()];
- if (astring.length > 3) {
- throw new JsonSyntaxException("Invalid pattern: too many rows, 3 is maximum");
- } else if (astring.length == 0) {
- throw new JsonSyntaxException("Invalid pattern: empty pattern not allowed");
- } else {
- for(int i = 0; i < astring.length; ++i) {
- String s = JsonUtils.getString(jArr.get(i), "pattern[" + i + "]");
- if (s.length() > 5) {
- throw new JsonSyntaxException("Invalid pattern: too many columns, 5 is maximum");
- }
- if (i > 0 && astring[0].length() != s.length()) {
- throw new JsonSyntaxException("Invalid pattern: each row must be the same width");
- }
- astring[i] = s;
- }
- return astring;
- }
- }
- }
- //?
- public class RecipeManager extends CraftingHelper {
- public RecipeManager() {}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement