Custom Item Definitions

FREE

Sold by: 0xF

Custom Item Definitions – This library allows developers to create their own ItemDefinitions, which will allow them to create custom items with their own unique values.

Categories: , ,
Download Now

Description

Overview of Custom Item Definitions  Rust Plugin

This plugin does not have its own functionality. This plugin is only used as a library for other plugins.

This library allows developers to create their own ItemDefinitions, which will allow them to create custom items with their own unique values.

What is an ItemDefinition created with the library?
It is a full-fledged ItemDefinition just like the other ones created by Rust developers, a new item definition is created based on an existing one with modified settings.
It has its own shortname and itemid, and can also have its own itemMods created by the developer, which is very convenient.
You can use the give command, item.info.[anything], and any other way you want.

A simple example of item creation:

// Requires: CustomItemDefinitions
using static Oxide.Plugins.CustomItemDefinitions;

namespace Oxide.Plugins
{
    [Info("LightsaberItem", "0xF", "1.0.0")]
    public class LightsaberItem : RustPlugin
    {
        public static LightsaberItem PluginInstance;

        ItemDefinition PARENT_DEFINITION = ItemManager.FindItemDefinition("longsword");

        void Init()
        {
            PluginInstance = this;
            CustomItemDefinitions.RegisterPluginItemDefinition(new CustomItemDefinition
            {
                shortname = "lightsaber",
                parentItemId = PARENT_DEFINITION.itemid,
                maxStackSize = 1,
                category = ItemCategory.Weapon,
                defaultName = "Lightsaber",
                defaultSkinId = 3035762342,
                itemMods = new ItemMod[]
                {
                    PARENT_DEFINITION.GetComponentInChildren<ItemModEntity>(),
                    new ItemModLightsaberCreatedNotice()
                    {
                        exampleField_message = "Item with name "{0}" just created! Yay!"
                    }
                }
            }, this);
        }

        public class ItemModLightsaberCreatedNotice : ItemMod
        {
            public string exampleField_message;
            public override void OnItemCreated(Item item)
            {
                base.OnItemCreated(item);
                if (exampleField_message != null)
                    PluginInstance.Puts(string.Format(exampleField_message, item.name));
            }
        }
    }
}

 

What are some things to keep in mind?

  • Always register new item definitions in the Init hook! This is important!
  • You must take care to register unique shortnames and item ids.
  • ItemId should never be changed in your plugin, as items created with an old itemId will break if they don’t have their definition.
  • After your plugin is unloaded, all items created with your item definitions will lose interaction, as all ItemMods will be removed. This is done for safety, don’t worry, after loading the plugin back in, all items will work again as before.

CustomItemDefinition class structure:

public class CustomItemDefinition
{
   public int parentItemId;
   public string shortname;
   public int itemId;
   public string defaultName;
   public ulong defaultSkinId;
   public int? maxStackSize;
   public ItemCategory? category;
   public ItemDefinition.Flag flags;
   public ItemMod[] itemMods;
}

ItemMods details:
ItemMods are overwritten, this means the new item definition will not include the itemMods of the parent.
If you need to import an item mod from the parent, you can use

PARENT_DEFINITION.GetComponent<ItemModYouNeed>()

if you need to import everything ItemMods

new List<ItemMod>(PARENT_DEFINITION.GetComponentInChildren<ItemMod>()).ToArray()).

Custom itemMods are added using the method of creating a new class, i.e.

new YourItemMod()

Here you can also specify the fields you want, example:

new YourItemMod() {
    field: value
}

Quick answers to questions:

  • Items have become coal, what does that mean?
    This is a fallback ItemDefinition in case the plugin providing this item is no longer available. The items will be restored if the plugin is returned.

1 review for Custom Item Definitions

  1. 4 out of 5

    KiKiSa

    It’s good, but it currently has some issues. I’m not sure if it’s just me, but when I apply a skin to my custom item, the skin only appears on the inventory icon and not on the 3D model, which is a bit disappointing. If that were fixed, it would be a 5/5.

    • 0xF

      An item in the inventory and a entity in the world are not directly connected; the skin is assigned to the entity when it is created in the ItemModEntity component; if you need to assign a skin to the entity, create your own (copy) implementation where you set the skin. Although it looks more complicated than intended, it gives you the opportunity to set different skins for the icon and for the entity.


Only logged in customers who have purchased this product may leave a review.

Version 1.1.7 | Updated May 21, 2024
  • Fixed Fixed Conveyor item transported fix for client side (Error with kick in radius when custom item moved on conveyor)
Version 1.1.6 | Updated May 2, 2024
  • Fixed Fix for update 02.05.2024 related to the transition to the new version of Harmony. Install only after wipe.
Version 1.1.5 | Updated April 4, 2024
  • Fixed A small fix related to blueprints, since previously the blueprint of custom item on the client side were displayed as the parent blueprint, the client could block the study button if the player's parent item was studied.
  • Updated Custom item blueprint are now displayed as a white square with a fixed name. You can determine which blueprint it is by making it the active item in the belt (do not use numbers, only the mouse wheel);
  • Added Added itemid {shortname} command to find out item id by short namespacer.pngspacer.png
Version 1.1.4 | Updated February 6, 2024
  • Updated Patched proto entities for clientside: WeaponRack FrankensteinTable IndustrialConveyor.ItemFilter ItemCrafter
  • Updated Patched proto objects for clientside: ItemAmountList (is used when sending missing required items to repair the decay entity) AppMarker (Rust+ vending machine markers) AppEntityPayload (Rust+ storages) IndustrialConveyor.ItemFilterList IndustrialConveyorTransfer
Version 1.0.3 | Updated February 6, 2024
  • Added Added processing for client-side blueprints of custom items
  • Added Added a system for researching and repairing custom items
Version 1.1.0-1.1.2 | Updated January 31, 2024
  • Updated Big changes related to sending information to the client side. Now there is no possibility that in case of unsuccessful server shutdown saving can happen with item id of parent.
  • Updated The processing of unloading plugins that use libraries is now handled directly. Now unloading of custom item definitions initialized by other plugins is unloaded in any case even if there was an error during loading. Also, this fixes a problem of Carbon where it did not trigger the hook to unload other plugins when reloading a dependency.
  • Updated Specifying the ItemId is no longer necessary. The item id is now set by the library itself based on the shortname and uses the same item id assignment scheme as Facepunch.
Version 1.0.3 | Updated December 9, 2023
  • Fixed Fixed a bug that caused the server to not load
  • Fixed Items should not be missing now (not verified).
  • Updated Default skin and name transferred to the client side.

Discussions

There are no discussions yet.

Leave a reply

Your email address will not be published. Required fields are marked *

Plugin FAQ – How do I use this .zip/.7z file I just purchased on my server?

• First, you want to unzip the file. You can do so by just double-clicking it to open, then drag the contents to the desired location (you may need to install an external unzipping software if you don’t already have one such as 7zip or winrar)
• Next you will find either a structure of folders or just the .cs file itself (it’s the actual plugin file itself).
• After that just install the .cs (plugin file) into your …/oxide/plugins/ folder where you will install plugins you ever need to.

Additionally, here’s a great video that easily covers adding a plugin to your server if you need! https://youtu.be/yWC_p97FhQA

• Installation is not included with any products on the site, however, if needed we may assist if you reach out to our support.

Currently all products on Lone.Design will be contained within a zipped file which is the .7z or .zip that you see. I believe windows 10 and up can unzip on its own without 3rd party tools, but in that case, if you’re unfamiliar with zipped files here are 2 programs I recommend to easily unzip zipped files.

Video On How to Zip and Unzip: https://youtu.be/Ep-L3PjBPCk (TechInsider Youtube Channel)

Zipping/Unzipping Tools
Winrar https://www.rarlab.com (I used to use for years, but works great!)
7zip https://www.7-zip.org/a/7z2107-x64.exe (the one I use currently)

Product Enquiry

Please Login to make enquiry about this product