Inventory.insertNewItem(...)

  • Small question, when using the .insertNewItem method of the Inventory Object, do I have to use the Item ID found in the Items table in the definitions.db or the Item ID found say in the Constructions table for woodbeams/logs/planks/etc.


    e.g. for woodplanks, ID: 760 or 2


    Also what about objects? Can I add them to a player's inventory or not since adding an "objectkit" item doesn't really allow me to specify which object I am adding.


    For ores should I use the Item ID of ore i.e. 309 and the texture IDs found in the ItemInfo Table, itemtexture field?

  • Unfortunately it's currently not possible to create objects (or clothing items). These items have additional information and the API does not provide a way to set these information...
    This will be changed with the next update :) Probably there will be a new Inventory.insertNewItem() method for that.

  • What about the item and ore IDs questions? :D I know it was very early in the morning when you replied red :P

  • What about the item and ore IDs questions? I know it was very early in the morning when you replied red

    Sorry, for some reason I missed that part :whistling:


    But yeah, if you want to spawn ores, you have to spawn the "ore" item with the appropriate variation/texture (e.g. 3 for stone, -101 for iron ore etc) ;)


    But you always have to use the item id's found in the "Items" table. Alternatively you can use the static "Definitions" functions, for example:


    Java
    //Spawn iron ore at player position
    World world = getWorld();
    Definitions.ItemDefinition itemDef = Definitions.getItemDefinition("ore");
    world.spawnItem(itemDef.getID(), -101, 1, evt.getPlayer().getPosition(), Quaternion.IDENTITY, false);

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!