Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.magistuarmory.api.item.ModItemsProvider Maven / Gradle / Ivy
package com.magistuarmory.api.item;
import com.magistuarmory.client.render.ModRender;
import com.magistuarmory.item.*;
import com.magistuarmory.item.armor.*;
import dev.architectury.event.events.common.LifecycleEvent;
import dev.architectury.platform.Platform;
import dev.architectury.registry.registries.DeferredRegister;
import dev.architectury.registry.registries.RegistrySupplier;
import net.fabricmc.api.EnvType;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.*;
import me.shedaniel.cloth.clothconfig.shadowed.blue.endless.jankson.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Supplier;
public abstract class ModItemsProvider
{
public final String modId;
public final DeferredRegister- items;
public final List
> shieldItems = new ArrayList<>();
public final List> weaponItems = new ArrayList<>();
public final List> dyeableItems = new ArrayList<>();
public final List> armorItems = new ArrayList<>();
public final List> ingredientItems = new ArrayList<>();
public final List> armorDecorationItems = new ArrayList<>();
public final List> rangedWeaponItems = new ArrayList<>();
public ModItemsProvider(String modId)
{
this.modId = modId;
this.items = DeferredRegister.create(modId, Registry.f_122904_);
}
public WeaponsSupply addWeaponsSupply(BiFunction> workshop)
{
return new WeaponsSupply(workshop);
}
public ShieldsSupply addShieldsSupply(BiFunction> workshop, String shieldName)
{
return new ShieldsSupply(workshop, shieldName);
}
public @Nullable RegistrySupplier addKnightItem(String id, ArmorType type, EquipmentSlot slot, Item.Properties properties)
{
if (type.isDisabled())
return null;
RegistrySupplier armor = ItemRegistryHelper.registerKnightItem(this.items, id, type, slot, properties);
this.dyeableItems.add(armor);
this.armorItems.add(armor);
return armor;
}
public @Nullable RegistrySupplier addJoustingItem(String id, ArmorType type, EquipmentSlot slot, Item.Properties properties)
{
if (type.isDisabled())
return null;
RegistrySupplier armor = ItemRegistryHelper.registerJoustingItem(this.items, id, type, slot, properties);
this.armorItems.add(armor);
return armor;
}
public @Nullable RegistrySupplier addMedievalArmorItem(String id, ArmorType type, EquipmentSlot slot, Item.Properties properties)
{
if (type.isDisabled())
return null;
RegistrySupplier armor = ItemRegistryHelper.registerMedievalArmorItem(this.items, id, type, slot, properties);
this.armorItems.add(armor);
return armor;
}
public @Nullable RegistrySupplier addDyeableMedievalArmorItem(String id, ArmorType type, EquipmentSlot slot, Item.Properties properties, int defaultcolor)
{
if (type.isDisabled())
return null;
RegistrySupplier armor = ItemRegistryHelper.registerDyeableMedievalArmorItem(this.items, id, type, slot, properties, defaultcolor);
this.dyeableItems.add(armor);
this.armorItems.add(armor);
return armor;
}
public @Nullable RegistrySupplier addMedievalWeaponItem(String id, Item.Properties properties, ModItemTier material, WeaponType type)
{
if (type.isDisabled())
return null;
RegistrySupplier weapon = ItemRegistryHelper.registerMedievalWeaponItem(this.items, id, properties, material, type);
this.weaponItems.add(weapon);
return weapon;
}
public @Nullable RegistrySupplier addLanceItem(String id, Item.Properties properties, ModItemTier material, WeaponType type)
{
if (type.isDisabled())
return null;
RegistrySupplier weapon = ItemRegistryHelper.registerLanceItem(this.items, id, properties, material, type);
this.weaponItems.add(weapon);
return weapon;
}
public RegistrySupplier- addIngredientItem(String id, Supplier
- supplier)
{
RegistrySupplier
- registrysupplier = this.items.register(id, supplier);
this.ingredientItems.add(registrysupplier);
return registrysupplier;
}
public RegistrySupplier
addArmorDecorationItem(String id, Supplier supplier)
{
RegistrySupplier registrysupplier = this.items.register(id, supplier);
this.armorDecorationItems.add(registrysupplier);
return registrysupplier;
}
public RegistrySupplier addDyeableArmorDecorationItem(String id, Supplier supplier)
{
RegistrySupplier registrysupplier = this.items.register(id, supplier);
this.armorDecorationItems.add(registrysupplier);
this.dyeableItems.add(registrysupplier);
return registrysupplier;
}
public RegistrySupplier addWearableArmorDecorationItem(String id, ArmorMaterial material, EquipmentSlot type, Item.Properties properties)
{
RegistrySupplier registrysupplier = ItemRegistryHelper.registerWearableArmorDecorationItem(this.items, id, material, type, properties);
this.armorDecorationItems.add(registrysupplier);
this.armorItems.add(registrysupplier);
return registrysupplier;
}
public RegistrySupplier addDyeableWearableArmorDecorationItem(String id, ArmorMaterial material, EquipmentSlot type, Item.Properties properties, int defaultcolor)
{
RegistrySupplier registrysupplier = ItemRegistryHelper.registerDyeableWearableArmorDecorationItem(this.items, id, material, type, properties, defaultcolor);
this.armorDecorationItems.add(registrysupplier);
this.dyeableItems.add(registrysupplier);
this.armorItems.add(registrysupplier);
return registrysupplier;
}
public @Nullable RegistrySupplier addMedievalShieldItem(String id, String name, Item.Properties properties, ModItemTier material, boolean paintable, boolean is3d, ShieldType type)
{
if (type.isDisabled())
return null;
RegistrySupplier shield = ItemRegistryHelper.registerMedievalShieldItem(this.items, id, new ResourceLocation(this.modId, name), properties, material, paintable, is3d, type);
this.shieldItems.add(shield);
return shield;
}
public @Nullable RegistrySupplier addPaviseItem(String id, String name, Item.Properties properties, ModItemTier material, boolean paintable, boolean is3d, ShieldType type)
{
if (type.isDisabled())
return null;
RegistrySupplier shield = ItemRegistryHelper.registerPaviseItem(this.items, id, new ResourceLocation(this.modId, name), properties, material, paintable, is3d, type);
this.shieldItems.add(shield);
return shield;
}
public @Nullable RegistrySupplier- addMedievalBowItem(String id, int durability, float arrowSpeed, float pullTime)
{
RegistrySupplier
- bow = this.items.register(id, () -> new MedievalBowItem(new Item.Properties().m_41487_(1).m_41503_(durability), arrowSpeed, pullTime));
this.rangedWeaponItems.add(bow);
return bow;
}
public @Nullable RegistrySupplier
- addMedievalCrossbowItem(String id, int durability, float arrowSpeed, int pullTime)
{
RegistrySupplier
- crossbow = this.items.register(id, () -> new MedievalCrossbowItem(new Item.Properties().m_41487_(1).m_41503_(durability), arrowSpeed, pullTime));
this.rangedWeaponItems.add(crossbow);
return crossbow;
}
public static ItemStack getDecoratedStack(RegistrySupplier
armorsuppler, RegistrySupplier extends ArmorDecorationItem> decorationsuppler)
{
ItemStack armorstack = new ItemStack(armorsuppler.get());
ArmorDecorationItem decorationitem = decorationsuppler.get();
ItemStack decorationstack = new ItemStack(decorationitem);
decorationitem.decorate(armorstack, decorationstack);
return armorstack;
}
public void init()
{
this.items.register();
if (Platform.getEnv() == EnvType.CLIENT)
LifecycleEvent.SETUP.register(() -> ModRender.setup(this));
}
}