Everything posted by AntariaN
-
[1.9] Custom Shapeless Recipe based on Item amount
Is there any way to change how things work? Eg., using custom workbanch. If so, where can I read more about crafting system modding?
-
[1.9] Custom Shapeless Recipe based on Item amount
Is there any way to change how things work? Eg., using custom workbanch. If so, where can I read more about crafting system modding?
-
[Solved][1.8.9] ModelBakery.addVariantName is deprecated.
Try to use ModelBakery.registerItemVariants(Item item, ModelResourceLocation location) instead of addVariantName You can see the example here.
-
[1.9] Custom Shapeless Recipe based on Item amount
I'm trying to create a Custom Shapless Recipe that implements IRecipe. It should allow registering recipes, that just requires some amount of one Item. Everything works fine, except two things. I've tried to solve it by myself for about 4 hours, but didn't figured out. The problems I have: 1. getRemaningItems method works incorrectly (eg., when It's 5 sticks in input, after crafting there is a stick with 0 amount). 2. If you putting Items into workbanch one by one (RightClick) all in the same Slot the recipe doesn't work. Custom Recipe Class: package com.antarian.testmod.recipe; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.world.World; public class ShapelessMultipleItemRecipe implements IRecipe { private final ItemStack recipeOutput; private final Item recipeItem; private final int recipeAmount; public ShapelessMultipleItemRecipe(ItemStack recipeOutput, Item recipeItem, int recipeAmount) { this.recipeOutput = recipeOutput; this.recipeItem = recipeItem; this.recipeAmount = recipeAmount; } public ItemStack getRecipeOutput() { return recipeOutput; } public ItemStack[] getRemainingItems(InventoryCrafting inv) { ItemStack[] itemStackArray = new ItemStack[inv.getSizeInventory()]; int itemsToGet = recipeAmount; for(int i = 0; i < itemStackArray.length; i++) { ItemStack itemStack = inv.getStackInSlot(i); if(itemStack != null && itemsToGet > 0) { int getItems = itemStack.stackSize >= itemsToGet ? itemsToGet : itemStack.stackSize; itemStack.stackSize -= getItems; itemStackArray[i] = itemStack.stackSize > 0 ? itemStack : null; //itemStack.stackSize -= getItems - 1; //itemStackArray[i] = net.minecraftforge.common.ForgeHooks.getContainerItem(itemStack); itemsToGet -= getItems; } } return itemStackArray; } public boolean matches(InventoryCrafting inv, World worldIn) { Item item = this.recipeItem; int itemCount = 0; for(int i = 0; i < inv.getHeight(); i++) { for(int j = 0; j < inv.getWidth(); j++) { ItemStack currItemStack = inv.getStackInRowAndColumn(j, i); if(currItemStack != null) { if(currItemStack.getItem() == item) { itemCount += currItemStack.stackSize; } } } } if(itemCount >= recipeAmount) { return true; } return false; } public ItemStack getCraftingResult(InventoryCrafting inv) { return recipeOutput.copy(); } public int getRecipeSize() { return 1; } } Some parts of ModRecipes Class: RecipeSorter.register("testmod:shapelessmultipleitem", ShapelessMultipleItemRecipe.class, SHAPELESS, "after:minecraft:shapless"); GameRegistry.addRecipe(new ShapelessMultipleItemRecipe(new ItemStack(ModBlocks.blockBonfire), Items.stick, 4));
IPS spam blocked by CleanTalk.