the_big_one/src/main/java/jesse/keeblarcraft/CustomItems/ItemManager.java

73 lines
3.0 KiB
Java

/*
*
* ItemManager
*
* This is the general purpose item manager for the mod. All items will be registered through
* this class in order to make custom items a lot cleaner to make!
*
*
*/
package jesse.keeblarcraft.CustomItems;
import java.util.ArrayList;
import java.util.List;
import jesse.keeblarcraft.CustomItems.Items.FactionBeaconItem;
import jesse.keeblarcraft.CustomItems.Items.FactionFlightItem;
import jesse.keeblarcraft.Keeblarcraft;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.minecraft.item.Item;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
public class ItemManager {
/// The item list. DO NOT ADD TO THE LIST YOURSELF. USE
/// THE RegisterItem(...) FUNCTION OTHERWISE YOUR ITEM WILL
/// NOT BE REGISTERED PROPERLY AND MAY BREAK THE GAME
public static final List<Item> itemList = new ArrayList<Item>();
/////////////////////////////////////////////////////////////////////////////
/// @fn RegisterItem
///
/// @arg[in] name is the item name. IMPORTANT: Name must adhere to rules:
/// 1. The name provided here must match these names:
/// * This items models/item name
/// * This items textures/item name
/// 2. Name must be lowercase & no special characters besides '_'
/// 3. Do NOT provide the Mod ID inside the name part
///
/// @arg[in] item is the item to be added to the item list
///
/// @brief This is the call to register your item to the game! Please
/// do not forget to update the models/item json file, the
/// textures/item png name, and finally the lang/en_us.json file
/////////////////////////////////////////////////////////////////////////////
public static void RegisterItem(String name, Item item) {
Item newItem = Registry.register(Registries.ITEM, new Identifier(Keeblarcraft.MOD_ID, name), item);
itemList.add(newItem);
}
/////////////////////////////////////////////////////////////////////////////
/// @fn RegisterAllItems
///
/// @brief This function is only meant to be called by the main mod
/// execution path and should only be called once. This is a
/// glorified print statement - but also serves to add the
/// example item in the game
/////////////////////////////////////////////////////////////////////////////
public static void RegisterAllItems() {
Keeblarcraft.LOGGER.info("Registering mod items for " + Keeblarcraft.MOD_ID);
// Call the item group register function first
CustomItemGroups.RegisterGroups();
// The example item provides a demo of how you could make an item in your class
RegisterItem("faction_upgrade_flight", new FactionFlightItem(new FabricItemSettings().maxCount(1)));
RegisterItem("faction_upgrade_beacon", new FactionBeaconItem(new FabricItemSettings().maxCount(1)));
}
}