Jump to content

Written book issues


AmandaIIII

Recommended Posts

1.6.4

Hey! So im new to modding, and I wanted to try to add a written book with info about the mod and such, but I can't get the crafting of it right. I can craft it, but I dont get the right item.

 

This is the Class file, called bookOfShadows:

https://gist.github.com/anonymous/8889274

 

Here is my main file:

https://gist.github.com/anonymous/8889261

 

I've tried a lot of things, but apparently not the right thing lol

I'm not sure how to make an itemstack with metadata, I tried stuff like "Item.WrittenBook, 1, 1" but it didn't work.

 

As it is now, I get a blank item without a texture when I craft it, so I atleast don't get nothing, thats always something haha.

 

Anyone who can help?

 

thanks ^-^

 

(and ofc I couldn't get them embed gist to work either -.-' )

Link to comment
Share on other sites

Thank you so much for the reply! I didn't say it wouldn't work, I said I didn't know how to make it work (:

 

so I did as you said (or well, how I understood it, as I said Im new to modding minecraft)

https://gist.github.com/anonymous/8891964

 

and I get this error...

 

https://gist.github.com/anonymous/8891980

 

this confuses me :/ I just want the damn book to work so I can continue making blocks and items and stuffs xD stuffs that I know how to do!

 

EDIT: I tried bookOfShadowsStack, 1, 0 in the addRecipe too, to no success. What am I doing wrong here?

Link to comment
Share on other sites

You need to conceal the recipe into its own parentheses.

The problem is you are trying to call the metadata INSIDE the process of creating the recipe.

Character =/= Integer.

 

Here:

GameRegistry.addRecipe(new ItemStack(bookOfShadowsStack, 1, 1), new Object[] {
"aba", "aca", "ded", 'a', paperStack, 'b', flowerShadowStack, 'c', soulFragmentStack, 'd', leatherStack, 'e', blazeRodStack });              

 

Good luck, my friend ;)

Link to comment
Share on other sites

Thanks again! But still, no working code >-< maybe Im just stupid here lol

 

i copied your code to replace the old one, and theres a red line below "new ItemStack(bookOfShadowsStack, 1, 1)"

and it says "The constructor ItemStack(ItemStack, int, int) is undefined"

 

Edit

To my knowledge, "bookOfShadowsStack" is  an ItemStack and both 1s are integers...?

 

this is just getting more and more confusing lol, but Im sure that when its solved, I will have learned a whole lotta stuffs!

Link to comment
Share on other sites

Strange, let me check up some stuff.

That might be my fault :P

 

EDIT:

Okay, it was my fault...

Didn't read all of your code.

So here's the problem, you converted all your items to ItemStacks?

 

Remove ALL of this from your main class.

                ItemStack stickStack = new ItemStack(Item.stick);
                ItemStack flowerShadowStack = new ItemStack(amw.witchcraft.witchcraft.flowerShadow);
                ItemStack wandPushStack = new ItemStack(amw.witchcraft.witchcraft.wandPush);
                ItemStack soulFragmentStack = new ItemStack(amw.witchcraft.witchcraft.soulFragment);
                ItemStack vineStack = new ItemStack(Block.vine);
                ItemStack flowerSoulStack = new ItemStack(amw.witchcraft.witchcraft.flowerSoul);
                ItemStack paperStack = new ItemStack(Item.paper);
                ItemStack leatherStack = new ItemStack(Item.leather);
                ItemStack blazeRodStack = new ItemStack(Item.blazeRod);
                ItemStack bookOfShadowsStack = new ItemStack(amw.witchcraft.witchcraft.bookOfShadows);

 

And use the item instead.

Example:

blazeRod = Item.blazeRod

bookOfShadows = witchcraft.bookOfShadows

 

So replace it

bookOfShadowsStack

to

witchcraft.bookOfShadows

in the crafting recipe :)

 

I'll help you with the textures, later.

When you actually fix this problem ^^

Link to comment
Share on other sites

Thanks! I updated the code as you said

 

https://gist.github.com/anonymous/8898753

 

but I still have the same problem as when I started :S I dont get the book, but a blank item instead when I try to craft it...

It shows up as it should in the creative tab.

 

I tried to change the metadata value in the recipe, tried 0, 1 and 2 with no success. Maybe I have to set the metadata in the class file?

 

Tried to attach a screenshot but the website says it cant find the file, even if its on my desktop, whatevs I hope you understand anyways... :P

 

Link to comment
Share on other sites

So, you are saying it gives you like a blank book (aka: no metadata added?)

 

You might have to set the metadata to what page you want, or if you did: look at your creative inventory and look at the ID.

 

EDIT:

Found it! You never actually allowed subtypes (metadata) to be allowed in your items.

In your constructor

public bookOfShadows(int id)
{
     super(id);
     setContainerItem(this);
     setMaxStackSize(1);
}

Add:

setHasSubtypes(true);

Link to comment
Share on other sites

Still doesnt work... the Item I get has the ID 966/1, or 0966/2 depending on what metadata I put into the recipe.

But if I look in the creative inventory, the book have the ID 0387...? Without any metadata.

 

Maybe the book is "stuck" with the ID of of Item.writtenBook? But why does it not have any metadata...?

 

So I changed the recipe to give Item.writtenBook, 1, 1, but I just get an empty written book, with no metadata. But it do have the exact same ItemID as my book.

Link to comment
Share on other sites

Then why don't you just use addInformation as the metadata?

 

Or if you are having trouble with metadata, you could just create seperate items for what you want the book to say.

 

Make your decision

[use addInformation with metadata]

OR

[Create multiple classes for your book, whilst using addInformation]

 

This is going to be a long post so be prepared.

In my opinion, metadata is the best way to store items and save space.

 

In your item class [bookOfShadows.class] : add

public static final int doNotUse = 0, srcsOfPower = 1, soulBush = 2, LLflowerRecipe = 3, shadowBush = 4;

public static final String[] names = new String[] 
{ "Book of Shadows", "Sources of Power", "Soul Bush", "Long Lost Flower Recipe", "Shadow Bush" };

    @SideOnly(Side.CLIENT)
        public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
                      switch(par1ItemStack.getItemDamage()) {
                      case 0: par3List.add("Flowers hold the most powerful magick, and to be able to harness magick, you have to understand them."); break;
                      case 1: par3List.add("The Soul Bush can be found deep underground, where an ancient flower is trapped inside stone. It gives off light, even through the stone. If you smelt it, you'll find a soul fragment inside. This is what's left of the flower that once graced our lands."); break;
                      case 2: par3List.add("Combine a wooden stick, vines and a soul fragment and the soul fragment will attach to these, and the long lost flower will be in your hand."); break;
                      case 3: par3List.add("This bush is more common than the Soul Bush, but it's nature is decieving. Don't try to walk on it, as you will fall straight through."); break;
        }
}

And remove all of your static method, and { public static ItemStacking reading; }

Now replace:

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(int itemId, CreativeTabs creativeTab, List subTypes)
{
      subTypes.add(reading);
}
}

to

@SideOnly(Side.CLIENT)
        public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
        {
           for (int x = 0; x < 4; x++)
                {
                        par3List.add(new ItemStack(this, 1, x));
                }
        }

 

Where a stands for the first metadata, b second, etc.

 

In your main class [witchcraft.class] inside load(FMLInitializationEvent event)

MAKE SURE YOU PUT IT AT THE END OF THE METHOD AKA AFTER

GameRegistry.addSmelting(amw.witchcraft.witchcraft.bushSoul.blockID, soulFragmentStack, 0.1f);

for (int i = 0; i < names.length; i++)
LanguageRegistry.addName(new ItemStack(bookOfShadows, 1, i), bookOfShadows.names[i]);

 

For crafting recipes, do not use "do not use" because its reserved for Book Of Shadows [no lore], and remember to look at your item [bookOfShadows] class for the ints.

Put this after (what I said above) and you are all set.

GameRegistry.addRecipe(new ItemStack(bookOfShadows, 1, bookOfShadows.srcsOfPower), new Object[] {
"aba", "aca", "ded", 'a', paperStack, 'b', flowerShadowStack, 'c', soulFragmentStack, 'd', leatherStack, 'e', blazeRodStack });     

 

Phew, I worked pretty god damn hard lol.

Yeah, Java is a pain in the ass at night.

Anymore problems, you can just tell me, but remember to show code/error reports.

and also.... do I get candy? :D

 

Link to comment
Share on other sites

There are no words to express my gratitude towards you for taking your time and helping me, you are an Angel!

 

I did what you said, and I get no "red lines" in the class code, though I do get them in the part for the main code.

 

https://gist.github.com/anonymous/8957216

 

I have the red lines below both "names" and "srcsOfPower" and when I hold over them it says "cannot be resolved or is not a field"

 

Here is the class code https://gist.github.com/anonymous/8957256

Link to comment
Share on other sites

Ha, lol just be lucky I'm a kind person.

 

I'm really not sure what the problem is, but judging on how you arranged it I never actually specifically told you where to put them.

 

Try moving:

public static final int doNotUse = 0, srcsOfPower = 1, soulBush = 2, LLflowerRecipe = 3, shadowBush = 4;

public static final String[] names = new String[] 
{ "Book of Shadows", "Sources of Power", "Soul Bush", "Long Lost Flower Recipe", "Shadow Bush" };

and place it after this:

public class bookOfShadows extends Item
{

 

To make it look like this:

public class bookOfShadows extends Item
{
       public static final int doNotUse = 0, srcsOfPower = 1, soulBush = 2, LLflowerRecipe = 3, shadowBush = 4;

      public static final String[] names = new String[] 
      { "Book of Shadows", "Sources of Power", "Soul Bush", "Long Lost Flower Recipe", "Shadow Bush" };

 

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.