neoforged / Documentation

The repository containing Neo's documentation
MIT License
28 stars 53 forks source link

Custom Loot Functions - invalid example provided #195

Closed smbarbour closed 1 week ago

smbarbour commented 2 weeks ago

The DeferredRegister for LootItemFunctionType is invalid as provided:

public static final DeferredRegister<LootItemFunctionType> LOOT_FUNCTION_TYPES =
        DeferredRegister.create(Registries.LOOT_FUNCTION_TYPE, ExampleMod.MOD_ID);

public static final Supplier<LootItemFunctionType> RANDOM_ENCHANTMENT_WITH_LEVEL =
        LOOT_FUNCTION_TYPES.register("random_enchantment_with_level", () -> new LootItemFunctionType(RandomEnchantmentWithLevelFunction.CODEC));

Required type: DeferredRegister<LootItemFunctionType> Provided: DeferredRegister<LootItemFunctionType<?>> Incompatible equality constraint: LootItemFunctionType and LootItemFunctionType<?>

The example should instead be:

public static final DeferredRegister<LootItemFunctionType<?>> LOOT_FUNCTION_TYPES =
        DeferredRegister.create(Registries.LOOT_FUNCTION_TYPE, ExampleMod.MOD_ID);

public static final Supplier<LootItemFunctionType<? extends LootItemConditionalFunction>> RANDOM_ENCHANTMENT_WITH_LEVEL =
        LOOT_FUNCTION_TYPES.register("random_enchantment_with_level", () -> new LootItemFunctionType(RandomEnchantmentWithLevelFunction.CODEC));