-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(loot): register condition types using deferred register
- Loading branch information
1 parent
9116b12
commit ca0e8fa
Showing
4 changed files
with
11 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 8 additions & 5 deletions
13
src/main/java/org/auioc/mods/arnicalib/server/loot/AHLootItemConditions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
package org.auioc.mods.arnicalib.server.loot; | ||
|
||
import java.util.function.Supplier; | ||
import org.auioc.mods.arnicalib.ArnicaLib; | ||
import org.auioc.mods.arnicalib.server.loot.predicate.ModLoadedCondition; | ||
import net.minecraft.core.Registry; | ||
import net.minecraft.world.level.storage.loot.Serializer; | ||
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; | ||
import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType; | ||
import net.minecraftforge.registries.DeferredRegister; | ||
import net.minecraftforge.registries.RegistryObject; | ||
|
||
public final class AHLootItemConditions { | ||
|
||
public static void init() {} | ||
public static final DeferredRegister<LootItemConditionType> LOOT_CONDITION_TYPES = DeferredRegister.create(Registry.LOOT_ITEM_REGISTRY, ArnicaLib.MOD_ID); | ||
|
||
public static final LootItemConditionType MOD_LOADED = register("mod_loaded", new ModLoadedCondition.SerializerX()); | ||
|
||
private static LootItemConditionType register(String id, Serializer<? extends LootItemCondition> serializer) { | ||
return Registry.register(Registry.LOOT_CONDITION_TYPE, ArnicaLib.id(id), new LootItemConditionType(serializer)); | ||
private static RegistryObject<LootItemConditionType> register(String id, Supplier<Serializer<? extends LootItemCondition>> serializerSup) { | ||
return LOOT_CONDITION_TYPES.register(id, () -> new LootItemConditionType(serializerSup.get())); | ||
} | ||
|
||
public static final RegistryObject<LootItemConditionType> MOD_LOADED = register("mod_loaded", ModLoadedCondition.SerializerX::new); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters