properly register item function types

This commit is contained in:
DBotThePony 2022-11-26 11:52:02 +07:00
parent e8f8682692
commit 94c64e0a5c
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 8 additions and 9 deletions

View File

@ -1,19 +1,18 @@
package ru.dbotthepony.mc.otm.registry package ru.dbotthepony.mc.otm.registry
import net.minecraft.core.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.functions.LootItemFunctionType
import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType import net.minecraftforge.eventbus.api.IEventBus
import net.minecraftforge.registries.RegisterEvent import net.minecraftforge.registries.DeferredRegister
import ru.dbotthepony.mc.otm.OverdriveThatMatters import ru.dbotthepony.mc.otm.OverdriveThatMatters
import ru.dbotthepony.mc.otm.data.loot.RandomizerFunction import ru.dbotthepony.mc.otm.data.loot.RandomizerFunction
object MItemFunctionTypes { object MItemFunctionTypes {
val RANDOMIZER = LootItemFunctionType(RandomizerFunction.Companion) private val registry = DeferredRegister.create(Registry.LOOT_FUNCTION_REGISTRY, OverdriveThatMatters.MOD_ID)
internal fun register(event: RegisterEvent) { val RANDOMIZER: LootItemFunctionType by registry.register("randomizer") { LootItemFunctionType(RandomizerFunction.Companion) }
if (event.getVanillaRegistry<LootItemConditionType>() == Registry.LOOT_FUNCTION_TYPE) {
Registry.LOOT_FUNCTION_TYPE.register(ResourceLocation(OverdriveThatMatters.MOD_ID, "randomizer"), RANDOMIZER) internal fun register(bus: IEventBus) {
} registry.register(bus)
} }
} }

View File

@ -226,7 +226,6 @@ object MRegistry {
bus.addListener(this::initializeCommon) bus.addListener(this::initializeCommon)
bus.addListener(MStats::registerVanilla) bus.addListener(MStats::registerVanilla)
bus.addListener(MLootItemConditions::register) bus.addListener(MLootItemConditions::register)
bus.addListener(MItemFunctionTypes::register)
MBlocks.register(bus) MBlocks.register(bus)
MBlockEntities.register(bus) MBlockEntities.register(bus)
@ -236,6 +235,7 @@ object MRegistry {
AndroidFeatures.register(bus) AndroidFeatures.register(bus)
MSoundEvents.register(bus) MSoundEvents.register(bus)
LootModifiers.register(bus) LootModifiers.register(bus)
MItemFunctionTypes.register(bus)
MRecipes.register(bus) MRecipes.register(bus)