AlekBardzo Posted February 9, 2015 Posted February 9, 2015 Hi, this is probalby rather basic : GameRegistry.addShapelessRecipe(new ItemStack(CommonProxy.largeGoldCoin,1), new ItemStack(CommonProxy.goldCoin,10)); My intention is to make a recipe that will turn 10 normal coins into one large, but when I test it, it only "eats" one normal coin for each large given. What am I doing wrong ? Is it even possible this way or do I need to handle this stuff differently ? Quote
MrCaracal Posted February 9, 2015 Posted February 9, 2015 Ordinary shapeless recipes don't examine the item stack size, only the item reference, because it would cause problems with mass crafting otherwise. You may require a new recipe class to accomplish this coin changing thing. Quote
AlekBardzo Posted February 9, 2015 Author Posted February 9, 2015 as far as I understand what I see there are no classes for recipes, the behaviour is hardcoded into CraftingManager, so I guess I'd either convert them into 9's or do some "magic" with them. Quote
Wuerfel_21 Posted February 9, 2015 Posted February 9, 2015 You could make a medium coin worth 5 coins probably... Quote
larsgerrits Posted February 9, 2015 Posted February 9, 2015 You have to make a new implementation of IRecipe . Then you have to register your recipe class with GameRegistry.registerRecipe(new YourRecipe()) . Quote Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
AlekBardzo Posted February 9, 2015 Author Posted February 9, 2015 I figured I could do 5 coins, but that would be a pain the butt of each player, and my own, so I'd try the IRecipe then Quote
AlekBardzo Posted February 9, 2015 Author Posted February 9, 2015 Where can I change how are inputs processed after crafting ? They are only decremented by amount of 1, no matter what I change. My current code (sloppy, I know) : public class MultipleInputRecipe implements IRecipe { /** Is the ItemStack that you get when craft the recipe. */ private final ItemStack recipeOutput; public final Item recipeInput; private int multiplier; public MultipleInputRecipe(ItemStack outputStack, Item item, int multi) { this.recipeOutput = outputStack; this.recipeInput = item; this.multiplier = multi; } public ItemStack getRecipeOutput() { return this.recipeOutput; } public ItemStack[] func_179532_b(InventoryCrafting inventory) {System.out.println("fired!"); ItemStack[] aitemstack = new ItemStack[inventory.getSizeInventory()]; return aitemstack; } /** * Used to check if a recipe matches current crafting inventory */ public boolean matches(InventoryCrafting inventory, World worldIn) { int amount = 0; for (int i = 0; i < inventory.func_174923_h(); ++i) { for (int j = 0; j < inventory.func_174922_i(); ++j) { ItemStack itemstack = inventory.getStackInRowAndColumn(j, i); if (itemstack != null) { if(itemstack.getItem() instanceof SilverCoin && this.recipeInput instanceof SilverCoin)amount+=itemstack.stackSize; if(itemstack.getItem() instanceof GoldCoin && this.recipeInput instanceof GoldCoin)amount+=itemstack.stackSize; if(itemstack.getItem() instanceof LargeGoldCoin && this.recipeInput instanceof LargeGoldCoin)amount+=itemstack.stackSize; } } } if(amount>=this.multiplier)return true; return false; } /** * Returns an Item that is the result of this recipe */ public ItemStack getCraftingResult(InventoryCrafting p_77572_1_) { return this.recipeOutput.copy(); } /** * Returns the size of the recipe area */ public int getRecipeSize() { return 2; } } Quote
TheGreyGhost Posted February 9, 2015 Posted February 9, 2015 In 1.8, IRecipe conveniently provides ItemStack[] getRemainingItems(InventoryCrafting p_179532_1_); to do exactly this. In 1.7.10 I think you might have to do something clever with ItemCraftedEvent (i.e. modify the crafting matrix to remove "extra" itemstacks). See SlotCrafting.onPickupFromSlot() for the vanilla code where it all happens. Never tried it myself, it may not work... -TGG Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.