From 94c64e0a5c7fe2764f31ae037a29f6e1294656ef Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 26 Nov 2022 11:52:02 +0700 Subject: [PATCH] properly register item function types --- .../mc/otm/registry/MItemFunctionTypes.kt | 15 +++++++-------- .../ru/dbotthepony/mc/otm/registry/MRegistry.kt | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItemFunctionTypes.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItemFunctionTypes.kt index f219b1d6b..ef7ac0a2b 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItemFunctionTypes.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MItemFunctionTypes.kt @@ -1,19 +1,18 @@ package ru.dbotthepony.mc.otm.registry import net.minecraft.core.Registry -import net.minecraft.resources.ResourceLocation import net.minecraft.world.level.storage.loot.functions.LootItemFunctionType -import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType -import net.minecraftforge.registries.RegisterEvent +import net.minecraftforge.eventbus.api.IEventBus +import net.minecraftforge.registries.DeferredRegister import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.data.loot.RandomizerFunction object MItemFunctionTypes { - val RANDOMIZER = LootItemFunctionType(RandomizerFunction.Companion) + private val registry = DeferredRegister.create(Registry.LOOT_FUNCTION_REGISTRY, OverdriveThatMatters.MOD_ID) - internal fun register(event: RegisterEvent) { - if (event.getVanillaRegistry() == Registry.LOOT_FUNCTION_TYPE) { - Registry.LOOT_FUNCTION_TYPE.register(ResourceLocation(OverdriveThatMatters.MOD_ID, "randomizer"), RANDOMIZER) - } + val RANDOMIZER: LootItemFunctionType by registry.register("randomizer") { LootItemFunctionType(RandomizerFunction.Companion) } + + internal fun register(bus: IEventBus) { + registry.register(bus) } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt index aea45e83f..2dc559cf9 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/registry/MRegistry.kt @@ -226,7 +226,6 @@ object MRegistry { bus.addListener(this::initializeCommon) bus.addListener(MStats::registerVanilla) bus.addListener(MLootItemConditions::register) - bus.addListener(MItemFunctionTypes::register) MBlocks.register(bus) MBlockEntities.register(bus) @@ -236,6 +235,7 @@ object MRegistry { AndroidFeatures.register(bus) MSoundEvents.register(bus) LootModifiers.register(bus) + MItemFunctionTypes.register(bus) MRecipes.register(bus)