ZidMC
Would you like to react to this message? Create an account in a few clicks or log in to continue.

[Unanswered]Depleting Items After Crafting [1.5_01][2.12]

2 posters

Go down

[Unanswered]Depleting Items After Crafting [1.5_01][2.12] Empty [Unanswered]Depleting Items After Crafting [1.5_01][2.12]

Post by Bladgrim Wed Apr 27, 2011 2:11 am

I am currently working on my first mod, yet I am stuck at one point. Of course, I am having some troubles, so I decided to come here and ask yet another question. As I don't want to give away any details of my mod, I will use different name variables.

With my current mod, I have a crafting recipe in which I am wanting one of the items to be given back, except depleted. So, what I did is I looked in the Items.java file to look up the properties for buckets (as they do something like this in cakes). I saw that the different kinds of filled buckets had a unique property on the end, .setContainerItem(bucketEmpty). I figured that this was what I was looking for, so I went straight in for it.

In my mod_MyModName.java, I added this code:

Code:
   public static final Item itemA = new Item(4206).setContainerItem(itemB).setItemName("itemA");
   public static final Item itemB = new Item(4207).setContainerItem(itemC).setItemName("itemB");
   public static final Item itemC = new Item(4208).setContainerItem(itemD).setItemName("itemC");
   public static final Item itemD = new Item(4209).setContainerItem(itemE).setItemName("itemD");
        public static final Item itemE = new Item(4210).setItemName("itemE");

I also make the separate classes for each of these items, I make the in game names, the crafting recipes, and I make the textures for the items. I recompile, reobfuscate, no errors. I put the files into my minecraft.jar, along with my textures. It black-screens. I have a look at the ModLoader.txt file in my .Minecraft folder, and it shows me the errors that came up.

Code:
26-Apr-2011 10:55:28 PM ModLoader init
FINE: ModLoader Beta 1.5_01v3 Initializing...
26-Apr-2011 10:55:28 PM ModLoader readFromClassPath
FINER: Adding mods from C:\Users\Adam T\AppData\Roaming\.minecraft\bin\minecraft.jar
26-Apr-2011 10:55:28 PM ModLoader readFromClassPath
FINER: Zip found.
26-Apr-2011 10:55:28 PM ModLoader addMod
FINE: Failed to load mod from "mod_MyModName.class"
26-Apr-2011 10:55:28 PM ModLoader addMod
FINER: THROW
java.lang.ExceptionInInitializerError
   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
   at java.lang.reflect.Constructor.newInstance(Unknown Source)
   at java.lang.Class.newInstance0(Unknown Source)
   at java.lang.Class.newInstance(Unknown Source)
   at ModLoader.addMod(ModLoader.java:201)
   at ModLoader.readFromClassPath(ModLoader.java:1061)
   at ModLoader.init(ModLoader.java:741)
   at ModLoader.AddAllRenderers(ModLoader.java:120)
   at sd.<init>(sd.java:60)
   at sd.<clinit>(sd.java:9)
   at net.minecraft.client.Minecraft.a(SourceFile:282)
   at net.minecraft.client.Minecraft.run(SourceFile:658)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: Max stack size must be 1 for items with crafting results
   at gb.a(SourceFile:512)
   at mod_MyModName.<clinit>(mod_MyModName.java:19)
   ... 15 more
26-Apr-2011 10:55:38 PM ModLoader AddAllRenderers
FINE: Initialized

The main thing that caught my eye here was the line:

Code:
java.lang.IllegalArgumentException: Max stack size must be 1 for items with crafting results

After looking around again in the Item.java file, I found this:

Code:
public Item setContainerItem(Item item)
    {
        if(maxStackSize > 1)
        {
            throw new IllegalArgumentException("Max stack size must be 1 for items with crafting results");
        } else
        {
            containerItem = item;
            return this;
        }
    }

I figured that I needed to change the maxStackSize of my new items to 1. I looked, and this was already true for all of them. I tried setting the result in my crafting recipe to a stack of one, the other reagents to the recipe as one, yet my game still crashed. I can't figure this out, so I was thinking that this may have something to do with ModLoader. I have been lost on this for the majority of this day, so any help would be appreciated. Thanks!

~Bladgrim



Bladgrim
Bladgrim
Recruit

Posts : 8
Join date : 2011-04-26
Age : 34
Location : Saskatchewan, Canada

Back to top Go down

[Unanswered]Depleting Items After Crafting [1.5_01][2.12] Empty Re: [Unanswered]Depleting Items After Crafting [1.5_01][2.12]

Post by Bladgrim Wed Apr 27, 2011 6:02 pm

Well, I've figured out the crashing problem, but I still have one problem - I am not getting the items back as I am expecting. With the .setContainerItem function, I was expecting to get itemB in the crafting table when I use a crafting recipe with itemA. When I do such a recipe, I only get the crafting result, not the container item. Here is my code again, with a bit more editing and polish (but still with other name variables).
Code:
public static final Item itemA = new ItemToolType(4206).setContainerItem(mod_MyModName.itemB).setItemName("itemA");
public static final Item itemB = new ItemToolType(4207).setContainerItem(mod_MyModName.itemC).setItemName("itemB");
public static final Item itemC = new ItemToolType(4208).setContainerItem(mod_MyModName.itemD).setItemName("itemC");
public static final Item itemD = new ItemToolType(4209).setContainerItem(mod_MyModName.itemE).setItemName("itemD");
public static final Item itemE = new ItemE(4210).setItemName("itemE");

What I've done here is set all (but E) as a single item-type class to save space, as they all do the same thing, just with different textures. For the .setContainerItem function, I actually had it like this the first time, I just mistyped the code for the post. If I tried to do it without the "mod_MyModName.", it wouldn't recompile. itemE has it's own class because it is a bit different from the rest of the items.

Also, here is my ItemToolType class:
Code:
package net.minecraft.src;

public class ItemToolType extends Item
{
   public ItemToolType (int i)
   {
      super(i);
      maxStackSize = 1;
   }
}

If you need any more information, please post. I am really getting frustrated with this problem.

Thanks for the help!

~Bladgrim
Bladgrim
Bladgrim
Recruit

Posts : 8
Join date : 2011-04-26
Age : 34
Location : Saskatchewan, Canada

Back to top Go down

[Unanswered]Depleting Items After Crafting [1.5_01][2.12] Empty Re: [Unanswered]Depleting Items After Crafting [1.5_01][2.12]

Post by Will.Ez Thu Apr 28, 2011 12:29 am

have a small test, remove all itemB to itemD and set itemA
.setContainerItem(mod_MyModName.itemE)
Code:
public static final Item itemA = new ItemToolType(4206).setContainerItem(mod_MyModName.itemE).setItemName("itemA");
if it doesnt work, tell us
Will.Ez
Will.Ez
Iron Miner

Posts : 52
Join date : 2011-04-22
Age : 27

Back to top Go down

[Unanswered]Depleting Items After Crafting [1.5_01][2.12] Empty Re: [Unanswered]Depleting Items After Crafting [1.5_01][2.12]

Post by Bladgrim Thu Apr 28, 2011 1:31 am

Did you want me to literally remove the items, or just take them out of the .setContainerItem train? I just put in the code you gave me (replacing the variables, of course), but left everything else the same. I also tried doing:
Code:
public static final Item itemA = new ItemToolType(4206).setContainerItem(mod_MyModName.itemB).setItemName("itemA");
public static final Item itemB = new ItemToolType(4207).setItemName("itemB");

Yet this didn't work, either. Both methods recompiled/reobfuscated, but the item still just disappeared after crafting.

I then tried putting itemsB-D in a block comment in all instances where they appeared, yet nothing appeared in my inventory after crafting.

Thanks again for your help!

~Bladgrim
Bladgrim
Bladgrim
Recruit

Posts : 8
Join date : 2011-04-26
Age : 34
Location : Saskatchewan, Canada

Back to top Go down

[Unanswered]Depleting Items After Crafting [1.5_01][2.12] Empty Re: [Unanswered]Depleting Items After Crafting [1.5_01][2.12]

Post by Bladgrim Fri Apr 29, 2011 12:50 pm

So, does nobody know how to fix this then? Any ideas on what I could try to do instead to have a similar effect? This is still quite frustrating me and, though I can still develop the mod, I can't release it until I have fixed this, or found an alternative.
Bladgrim
Bladgrim
Recruit

Posts : 8
Join date : 2011-04-26
Age : 34
Location : Saskatchewan, Canada

Back to top Go down

[Unanswered]Depleting Items After Crafting [1.5_01][2.12] Empty Re: [Unanswered]Depleting Items After Crafting [1.5_01][2.12]

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum