Skip to content

For Developers

fishcute edited this page Aug 24, 2022 · 9 revisions

For Developers

This page is probably out of date, so do not use it!

Tough as Client allows for mod creators to add their own custom items, custom armors, custom status effects, and more. This page will go through how to use Tough as Client to create client-side things.

These features might be moved to a library mod.

This page is currently WIP

Adding Tough as Client to your development environment

Currently WIP.

Creating a custom item

There are two ways to create custom items. The first method is the most recommended one.

Custom items as a class

In order to create a custom item class, create a new class and have it extend ICustomItem. Depending on your IDE, these methods should automatically be applied to your class. Below them will be a short description.

String identifier()

The item's name. (eg. If the identifier is "Amazing item", any items with the name "Amazing item" will turn into an "Amazing item")

String itemType()

The item's translation key (eg. If the itemType is "ice", any items that has "ice" in their translation key will turn into the custom item. In this case, packed ice, regular ice, and blue ice can turn into the custom item)

HashMap<String, Integer> overrides()

The custom model data values. Can be set with the ICustomItem#setOverride method. The String in the hashmap is the name of the override. (eg. If there is an override, "off, 1" and "on, 2", and the current override is "on", the item's custom model data will be 2. If there is only one value, the mod will default to that value)

ArrayList<String> lore()

Can be set to null. Any values present in this arraylist will be set as a lore on the item.

void tick();

A tick method. You can run whatever you want in this method.

Custom items as an InstantiableCustomItem

If you are creating items variants (things like umbrellas and fans), it is recommended to use this class. Otherwise, stick to creating items using item objects.

InstantiableCustomItem is very straightforward. Simply create one by creating a new instance of InstantiableCustomItem:

new InstantiableCustomItem(identifier, itemType, overrides, lore)

Things to know about custom items

Both custom item classes and instantiable custom items must be registered in the Registry class. Register them using the Registry#registerCustomItem method. For custom item classes, set the input as a new instance of the class. The registration should occur in your client initialization class.