diff --git a/src/main/java/thedarkcolour/exdeorum/ExDeorum.java b/src/main/java/thedarkcolour/exdeorum/ExDeorum.java
index 5b63fadb..a7ad79a2 100644
--- a/src/main/java/thedarkcolour/exdeorum/ExDeorum.java
+++ b/src/main/java/thedarkcolour/exdeorum/ExDeorum.java
@@ -34,17 +34,7 @@ import thedarkcolour.exdeorum.config.EConfig;
import thedarkcolour.exdeorum.event.EventHandler;
import thedarkcolour.exdeorum.material.DefaultMaterials;
import thedarkcolour.exdeorum.network.NetworkHandler;
-import thedarkcolour.exdeorum.registry.EBlockEntities;
-import thedarkcolour.exdeorum.registry.EBlocks;
-import thedarkcolour.exdeorum.registry.ECreativeTabs;
-import thedarkcolour.exdeorum.registry.EFluids;
-import thedarkcolour.exdeorum.registry.EGlobalLootModifiers;
-import thedarkcolour.exdeorum.registry.EItems;
-import thedarkcolour.exdeorum.registry.ELootFunctions;
-import thedarkcolour.exdeorum.registry.EMenus;
-import thedarkcolour.exdeorum.registry.ERecipeSerializers;
-import thedarkcolour.exdeorum.registry.ERecipeTypes;
-import thedarkcolour.exdeorum.registry.EChunkGenerators;
+import thedarkcolour.exdeorum.registry.*;
import java.util.Calendar;
@@ -89,6 +79,7 @@ public class ExDeorum {
EMenus.MENUS.register(modBus);
ERecipeSerializers.RECIPE_SERIALIZERS.register(modBus);
ERecipeTypes.RECIPE_TYPES.register(modBus);
+ ENumberProviders.NUMBER_PROVIDERS.register(modBus);
DefaultMaterials.registerMaterials();
}
diff --git a/src/main/java/thedarkcolour/exdeorum/loot/SummationGenerator.java b/src/main/java/thedarkcolour/exdeorum/loot/SummationGenerator.java
new file mode 100644
index 00000000..eec4e7b5
--- /dev/null
+++ b/src/main/java/thedarkcolour/exdeorum/loot/SummationGenerator.java
@@ -0,0 +1,67 @@
+/*
+ * Ex Deorum
+ * Copyright (c) 2024 thedarkcolour
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package thedarkcolour.exdeorum.loot;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonSerializationContext;
+import net.minecraft.util.GsonHelper;
+import net.minecraft.world.level.storage.loot.LootContext;
+import net.minecraft.world.level.storage.loot.providers.number.LootNumberProviderType;
+import net.minecraft.world.level.storage.loot.providers.number.NumberProvider;
+import thedarkcolour.exdeorum.registry.ENumberProviders;
+
+public record SummationGenerator(NumberProvider[] providers) implements NumberProvider {
+ @Override
+ public float getFloat(LootContext context) {
+ float sum = 0f;
+ for (NumberProvider provider : this.providers) {
+ sum += provider.getFloat(context);
+ }
+ return sum;
+ }
+
+ @Override
+ public LootNumberProviderType getType() {
+ return ENumberProviders.SUMMATION.get();
+ }
+
+ public static class Serializer implements net.minecraft.world.level.storage.loot.Serializer {
+ @Override
+ public void serialize(JsonObject json, SummationGenerator value, JsonSerializationContext ctx) {
+ JsonArray array = new JsonArray();
+ for (var provider : value.providers) {
+ array.add(ctx.serialize(provider, NumberProvider.class));
+ }
+ }
+
+ @Override
+ public SummationGenerator deserialize(JsonObject json, JsonDeserializationContext ctx) {
+ var valuesJson = GsonHelper.getAsJsonArray(json, "values");
+ NumberProvider[] providers = new NumberProvider[valuesJson.size()];
+ int i = 0;
+ for (var valueJson : valuesJson) {
+ providers[i++] = ctx.deserialize(valueJson, NumberProvider.class);
+ }
+
+ return new SummationGenerator(providers);
+ }
+ }
+}
diff --git a/src/main/java/thedarkcolour/exdeorum/registry/ENumberProviders.java b/src/main/java/thedarkcolour/exdeorum/registry/ENumberProviders.java
new file mode 100644
index 00000000..258cb701
--- /dev/null
+++ b/src/main/java/thedarkcolour/exdeorum/registry/ENumberProviders.java
@@ -0,0 +1,32 @@
+/*
+ * Ex Deorum
+ * Copyright (c) 2024 thedarkcolour
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package thedarkcolour.exdeorum.registry;
+
+import net.minecraft.core.registries.Registries;
+import net.minecraft.world.level.storage.loot.providers.number.LootNumberProviderType;
+import net.minecraftforge.registries.DeferredRegister;
+import net.minecraftforge.registries.RegistryObject;
+import thedarkcolour.exdeorum.ExDeorum;
+import thedarkcolour.exdeorum.loot.SummationGenerator;
+
+public class ENumberProviders {
+ public static final DeferredRegister NUMBER_PROVIDERS = DeferredRegister.create(Registries.LOOT_NUMBER_PROVIDER_TYPE, ExDeorum.ID);
+
+ public static final RegistryObject SUMMATION = NUMBER_PROVIDERS.register("summation", () -> new LootNumberProviderType(new SummationGenerator.Serializer()));
+}