From da7fffb334bf6982666437dfea49398c8cda9e4f Mon Sep 17 00:00:00 2001 From: TheRealWormbo Date: Mon, 29 Jul 2024 19:16:13 +0200 Subject: [PATCH] Move criteria trigger registration to registry --- .../fabric/FabricCommonInitializer.java | 2 +- .../botania/forge/ForgeCommonInitializer.java | 2 +- .../advancements/BotaniaCriteriaTriggers.java | 23 +++++++++++-------- .../advancements/ManaBlasterTrigger.java | 2 +- .../mixin/CriteriaTriggersAccessor.java | 23 ------------------- .../main/resources/botania_xplat.mixins.json | 1 - 6 files changed, 16 insertions(+), 37 deletions(-) delete mode 100644 Xplat/src/main/java/vazkii/botania/mixin/CriteriaTriggersAccessor.java diff --git a/Fabric/src/main/java/vazkii/botania/fabric/FabricCommonInitializer.java b/Fabric/src/main/java/vazkii/botania/fabric/FabricCommonInitializer.java index ed44031139..4c2eb5cba3 100644 --- a/Fabric/src/main/java/vazkii/botania/fabric/FabricCommonInitializer.java +++ b/Fabric/src/main/java/vazkii/botania/fabric/FabricCommonInitializer.java @@ -215,7 +215,7 @@ private void registryInit() { BotaniaFeatures.MYSTICAL_MUSHROOMS_PLACED_FEATURE); // Rest - BotaniaCriteriaTriggers.init(); + BotaniaCriteriaTriggers.init(bind(BuiltInRegistries.TRIGGER_TYPES)); BotaniaParticles.registerParticles(bind(BuiltInRegistries.PARTICLE_TYPE)); BotaniaLootModifiers.submitLootConditions(bind(BuiltInRegistries.LOOT_CONDITION_TYPE)); BotaniaLootModifiers.submitLootFunctions(bind(BuiltInRegistries.LOOT_FUNCTION_TYPE)); diff --git a/NeoForge/src/main/java/vazkii/botania/forge/ForgeCommonInitializer.java b/NeoForge/src/main/java/vazkii/botania/forge/ForgeCommonInitializer.java index 8201da4a58..fb6b46cd8b 100644 --- a/NeoForge/src/main/java/vazkii/botania/forge/ForgeCommonInitializer.java +++ b/NeoForge/src/main/java/vazkii/botania/forge/ForgeCommonInitializer.java @@ -219,7 +219,7 @@ private void registryInit() { bind(Registries.CHUNK_GENERATOR, SkyblockChunkGenerator::submitRegistration); // Rest - BotaniaCriteriaTriggers.init(); + bind(Registries.TRIGGER_TYPE, BotaniaCriteriaTriggers::init); bind(Registries.PARTICLE_TYPE, BotaniaParticles::registerParticles); bind(Registries.LOOT_CONDITION_TYPE, BotaniaLootModifiers::submitLootConditions); diff --git a/Xplat/src/main/java/vazkii/botania/common/advancements/BotaniaCriteriaTriggers.java b/Xplat/src/main/java/vazkii/botania/common/advancements/BotaniaCriteriaTriggers.java index e4208e2061..1abe8084ff 100644 --- a/Xplat/src/main/java/vazkii/botania/common/advancements/BotaniaCriteriaTriggers.java +++ b/Xplat/src/main/java/vazkii/botania/common/advancements/BotaniaCriteriaTriggers.java @@ -8,17 +8,20 @@ */ package vazkii.botania.common.advancements; -import vazkii.botania.mixin.CriteriaTriggersAccessor; +import net.minecraft.advancements.CriterionTrigger; +import net.minecraft.resources.ResourceLocation; + +import java.util.function.BiConsumer; public class BotaniaCriteriaTriggers { - public static void init() { - CriteriaTriggersAccessor.botania_register(AlfheimPortalTrigger.INSTANCE); - CriteriaTriggersAccessor.botania_register(CorporeaRequestTrigger.INSTANCE); - CriteriaTriggersAccessor.botania_register(GaiaGuardianNoArmorTrigger.INSTANCE); - CriteriaTriggersAccessor.botania_register(RelicBindTrigger.INSTANCE); - CriteriaTriggersAccessor.botania_register(UseItemSuccessTrigger.INSTANCE); - CriteriaTriggersAccessor.botania_register(ManaBlasterTrigger.INSTANCE); - CriteriaTriggersAccessor.botania_register(LokiPlaceTrigger.INSTANCE); - CriteriaTriggersAccessor.botania_register(AlfheimPortalBreadTrigger.INSTANCE); + public static void init(BiConsumer, ResourceLocation> r) { + r.accept(AlfheimPortalTrigger.INSTANCE, AlfheimPortalTrigger.ID); + r.accept(CorporeaRequestTrigger.INSTANCE, CorporeaRequestTrigger.ID); + r.accept(GaiaGuardianNoArmorTrigger.INSTANCE, GaiaGuardianNoArmorTrigger.ID); + r.accept(RelicBindTrigger.INSTANCE, RelicBindTrigger.ID); + r.accept(UseItemSuccessTrigger.INSTANCE, UseItemSuccessTrigger.ID); + r.accept(ManaBlasterTrigger.INSTANCE, ManaBlasterTrigger.ID); + r.accept(LokiPlaceTrigger.INSTANCE, LokiPlaceTrigger.ID); + r.accept(AlfheimPortalBreadTrigger.INSTANCE, AlfheimPortalBreadTrigger.ID); } } diff --git a/Xplat/src/main/java/vazkii/botania/common/advancements/ManaBlasterTrigger.java b/Xplat/src/main/java/vazkii/botania/common/advancements/ManaBlasterTrigger.java index a9097ecfa7..736b50621d 100644 --- a/Xplat/src/main/java/vazkii/botania/common/advancements/ManaBlasterTrigger.java +++ b/Xplat/src/main/java/vazkii/botania/common/advancements/ManaBlasterTrigger.java @@ -23,7 +23,7 @@ import static vazkii.botania.common.lib.ResourceLocationHelper.prefix; public class ManaBlasterTrigger extends SimpleCriterionTrigger { - private static final ResourceLocation ID = prefix("fire_mana_blaster"); + public static final ResourceLocation ID = prefix("fire_mana_blaster"); public static final ManaBlasterTrigger INSTANCE = new ManaBlasterTrigger(); private ManaBlasterTrigger() {} diff --git a/Xplat/src/main/java/vazkii/botania/mixin/CriteriaTriggersAccessor.java b/Xplat/src/main/java/vazkii/botania/mixin/CriteriaTriggersAccessor.java deleted file mode 100644 index f1badb57ef..0000000000 --- a/Xplat/src/main/java/vazkii/botania/mixin/CriteriaTriggersAccessor.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * This class is distributed as part of the Botania Mod. - * Get the Source Code in github: - * https://github.com/Vazkii/Botania - * - * Botania is Open Source and distributed under the - * Botania License: http://botaniamod.net/license.php - */ -package vazkii.botania.mixin; - -import net.minecraft.advancements.CriteriaTriggers; -import net.minecraft.advancements.CriterionTrigger; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Invoker; - -@Mixin(CriteriaTriggers.class) -public interface CriteriaTriggersAccessor { - @Invoker("register") - static > T botania_register(T thing) { - throw new IllegalStateException(); - } -} diff --git a/Xplat/src/main/resources/botania_xplat.mixins.json b/Xplat/src/main/resources/botania_xplat.mixins.json index 725daac46a..78391e0d65 100644 --- a/Xplat/src/main/resources/botania_xplat.mixins.json +++ b/Xplat/src/main/resources/botania_xplat.mixins.json @@ -17,7 +17,6 @@ "CollectingNeighborUpdaterMixin", "CreeperAccessor", "CreeperMixin", - "CriteriaTriggersAccessor", "DispenserBlockAccessor", "EntityAccessor", "EntityMixin",