Jump to content

new Assetlocation Problems


Karkic

Recommended Posts

Hi I'm currently having trouble with understanding how to link a asset location. When I try to create an item stack of a modded item it returns Item Stack not found. A vanilla item works when called.

modid is test

 public override WorldInteraction[] GetPlacedBlockInteractionHelp(IWorldAccessor world, BlockSelection selection, IPlayer forPlayer)
        {
            return new WorldInteraction[]
            {
                new WorldInteraction()
                {
                    ActionLangCode = "Add Paperx8",
                    MouseButton = EnumMouseButton.Right,
                    HotKeyCodes = new string[] {"sprint", "sneak" },
                    Itemstacks = new ItemStack[] { new ItemStack(world.GetItem(new AssetLocation("paper")), 8) }//item not found
                }
              
            }.Append(base.GetPlacedBlockInteractionHelp(world, selection, forPlayer));
	}

the item.json file is located assets/paper/itemtypes/paper.json

{
  "code": "paper",
  "class": "PaperItem",
  "creativeinventory": {
    "general": [ "*" ]
  },
  "texture": {
    "base": "item/paper"
  }
}

help would be apricated on how to create an asset location for any modded object.

Edited by Karkic
Link to comment
Share on other sites

Itemstacks = new ItemStack[] { new ItemStack(world.GetItem(new AssetLocation("paper")), 😎 }//item not found

If that line above works with vanilla items, then prefix paper with your modid + : (look in your modinfo.json for your modid) and see if that fixes it...i.e.

Itemstacks = new ItemStack[] { new ItemStack(world.GetItem(new AssetLocation("mymodid:paper")), 😎 }//item not found

Edited by Spear and Fang
  • Thanks 1
Link to comment
Share on other sites

 

13 minutes ago, Spear and Fang said:

Itemstacks = new ItemStack[] { new ItemStack(world.GetItem(new AssetLocation("paper")), 😎 }//item not found

If that line above works with vanilla items, then prefix paper with your modid: and see if that fixes it...

Itemstacks = new ItemStack[] { new ItemStack(world.GetItem(new AssetLocation("mymodid:paper")), 😎 }//item not found

thank you for helping me. the main issue was I didn't have the blocks/items under the correct folder in assets.

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.