diff --git a/src/generated/resources/data/occultism/recipe/ritual/summon_random_animal.json b/src/generated/resources/data/occultism/recipe/ritual/summon_random_animal.json index 8830c0f7e..bb191b16a 100644 --- a/src/generated/resources/data/occultism/recipe/ritual/summon_random_animal.json +++ b/src/generated/resources/data/occultism/recipe/ritual/summon_random_animal.json @@ -3,6 +3,7 @@ "activation_item": { "item": "occultism:book_of_binding_bound_foliot" }, + "entity_tag_to_summon": "occultism:random_animals_to_summon_list", "ingredients": [ { "tag": "c:crops" @@ -47,5 +48,5 @@ "count": 1, "id": "occultism:ritual_dummy/summon_random_animal" }, - "ritual_type": "occultism:summon_random_animal" + "ritual_type": "occultism:summon" } \ No newline at end of file diff --git a/src/main/java/com/klikli_dev/occultism/common/ritual/SummonRandomAnimalRitual.java b/src/main/java/com/klikli_dev/occultism/common/ritual/SummonRandomAnimalRitual.java deleted file mode 100644 index f4b026c2e..000000000 --- a/src/main/java/com/klikli_dev/occultism/common/ritual/SummonRandomAnimalRitual.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.klikli_dev.occultism.common.ritual; - -import com.klikli_dev.occultism.crafting.recipe.RitualRecipe; -import com.klikli_dev.occultism.registry.OccultismTags; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.level.Level; - -import java.util.stream.StreamSupport; - -public class SummonRandomAnimalRitual extends SummonRitual{ - public SummonRandomAnimalRitual(RitualRecipe recipe) { - super(recipe, false); - } - - @Override - protected EntityType getEntityToSummon(Level level) { - var options = StreamSupport.stream(BuiltInRegistries.ENTITY_TYPE.getTagOrEmpty(OccultismTags.Entities.RANDOM_ANIMALS_TO_SUMMON_LIST).spliterator(), false).toList(); - - if (options.isEmpty()) { - return null; - } - - int index = level.random.nextInt(options.size()); - return options.get(index).value(); - } -} diff --git a/src/main/java/com/klikli_dev/occultism/common/ritual/SummonRitual.java b/src/main/java/com/klikli_dev/occultism/common/ritual/SummonRitual.java index 2dcbcde64..333a9dafc 100644 --- a/src/main/java/com/klikli_dev/occultism/common/ritual/SummonRitual.java +++ b/src/main/java/com/klikli_dev/occultism/common/ritual/SummonRitual.java @@ -26,11 +26,13 @@ import com.klikli_dev.occultism.common.entity.spirit.SpiritEntity; import com.klikli_dev.occultism.crafting.recipe.RitualRecipe; import com.klikli_dev.occultism.registry.OccultismItems; +import com.klikli_dev.occultism.registry.OccultismTags; import com.klikli_dev.occultism.util.ItemNBTUtil; import net.minecraft.advancements.CriteriaTriggers; import net.minecraft.core.BlockPos; import net.minecraft.core.RegistryAccess; import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerLevel; @@ -45,6 +47,8 @@ import net.neoforged.neoforge.items.ItemHandlerHelper; import org.jetbrains.annotations.Nullable; +import java.util.stream.StreamSupport; + public class SummonRitual extends Ritual { private final boolean tame; @@ -153,6 +157,15 @@ public void finish(Level level, BlockPos goldenBowlPosition, GoldenSacrificialBo } protected EntityType getEntityToSummon(Level level){ + if(this.recipe.getEntityTagToSummon() != null){ + var options = StreamSupport.stream(BuiltInRegistries.ENTITY_TYPE.getTagOrEmpty(this.recipe.getEntityTagToSummon()).spliterator(), false).toList(); + + if (!options.isEmpty()) { + int index = level.random.nextInt(options.size()); + return options.get(index).value(); + } + } + return this.recipe.getEntityToSummon(); } diff --git a/src/main/java/com/klikli_dev/occultism/crafting/recipe/RitualRecipe.java b/src/main/java/com/klikli_dev/occultism/crafting/recipe/RitualRecipe.java index d8f2aeb35..567cadff9 100644 --- a/src/main/java/com/klikli_dev/occultism/crafting/recipe/RitualRecipe.java +++ b/src/main/java/com/klikli_dev/occultism/crafting/recipe/RitualRecipe.java @@ -42,11 +42,12 @@ import net.minecraft.network.codec.StreamCodec; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; -import net.minecraft.world.Container; import net.minecraft.world.entity.EntityType; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.*; import net.minecraft.world.level.Level; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.Optional; import java.util.function.Supplier; @@ -59,6 +60,7 @@ public class RitualRecipe implements Recipe { ItemStack.STRICT_CODEC.fieldOf("ritual_dummy").forGetter((r) -> r.ritualDummy), ItemStack.OPTIONAL_CODEC.fieldOf("result").forGetter((r) -> r.result), BuiltInRegistries.ENTITY_TYPE.byNameCodec().optionalFieldOf("entity_to_summon").forGetter(r -> Optional.ofNullable(r.entityToSummon)), + TagKey.codec(Registries.ENTITY_TYPE).optionalFieldOf("entity_tag_to_summon").forGetter(r -> Optional.ofNullable(r.entityTagToSummon)), CompoundTag.CODEC.optionalFieldOf("entity_nbt").forGetter(r -> Optional.ofNullable(r.entityNbt)), Ingredient.CODEC.fieldOf("activation_item").forGetter((r) -> r.activationItem), Ingredient.LIST_CODEC.fieldOf("ingredients").forGetter((r) -> r.ingredients), @@ -69,7 +71,7 @@ public class RitualRecipe implements Recipe { EntityToSacrifice.CODEC.optionalFieldOf("entity_to_sacrifice").forGetter(r -> Optional.ofNullable(r.entityToSacrifice)), Ingredient.CODEC.optionalFieldOf("item_to_use").forGetter(r -> Optional.ofNullable(r.itemToUse)), Codec.STRING.optionalFieldOf("command").forGetter(r -> Optional.ofNullable(r.command)) - ).apply(instance, (pentacleId, ritualType, ritualDummy, result, entityToSummon, entityNbt, activationItem, ingredients, duration, spiritMaxAge, summonNumber, spiritJobType, entityToSacrifice, itemToUse, command) -> new RitualRecipe(pentacleId, ritualType, ritualDummy, result, entityToSummon.orElse(null), entityNbt.orElse(null), activationItem, + ).apply(instance, (pentacleId, ritualType, ritualDummy, result, entityToSummon, entityTagToSummon, entityNbt, activationItem, ingredients, duration, spiritMaxAge, summonNumber, spiritJobType, entityToSacrifice, itemToUse, command) -> new RitualRecipe(pentacleId, ritualType, ritualDummy, result, entityToSummon.orElse(null), entityTagToSummon.orElse(null), entityNbt.orElse(null), activationItem, NonNullList.copyOf(ingredients), duration, spiritMaxAge, summonNumber, spiritJobType.orElse(null), entityToSacrifice.orElse(null), itemToUse.orElse(Ingredient.EMPTY), command.orElse(null))) ); @@ -84,6 +86,8 @@ public class RitualRecipe implements Recipe { (r) -> r.result, ByteBufCodecs.optional(ByteBufCodecs.registry(Registries.ENTITY_TYPE)), (r) -> Optional.ofNullable(r.entityToSummon), + ByteBufCodecs.optional(OccultismExtraStreamCodecs.tagKey(Registries.ENTITY_TYPE)), + (r) -> Optional.ofNullable(r.entityTagToSummon), ByteBufCodecs.optional(ByteBufCodecs.COMPOUND_TAG), (r) -> Optional.ofNullable(r.entityNbt), Ingredient.CONTENTS_STREAM_CODEC, @@ -104,8 +108,8 @@ public class RitualRecipe implements Recipe { (r) -> Optional.ofNullable(r.itemToUse), ByteBufCodecs.optional(ByteBufCodecs.STRING_UTF8), (r) -> Optional.ofNullable(r.command), - (pentacleId, ritualType, ritualDummy, result, entityToSummon, entityNbt, activationItem, ingredients, duration, spiritMaxAge, summonNumber, spiritJobType, entityToSacrifice, itemToUse, command) -> - new RitualRecipe(pentacleId, ritualType, ritualDummy, result, entityToSummon.orElse(null), entityNbt.orElse(null), activationItem, + (pentacleId, ritualType, ritualDummy, result, entityToSummon, entityTagToSummon, entityNbt, activationItem, ingredients, duration, spiritMaxAge, summonNumber, spiritJobType, entityToSacrifice, itemToUse, command) -> + new RitualRecipe(pentacleId, ritualType, ritualDummy, result, entityToSummon.orElse(null), entityTagToSummon.orElse(null), entityNbt.orElse(null), activationItem, NonNullList.copyOf(ingredients), duration, spiritMaxAge, summonNumber, spiritJobType.orElse(null), entityToSacrifice.orElse(null), itemToUse.orElse(Ingredient.EMPTY), command.orElse(null)) ); @@ -114,25 +118,34 @@ public class RitualRecipe implements Recipe { final NonNullList ingredients; private final ResourceLocation pentacleId; private final ResourceLocation ritualType; + @Nullable private final ResourceLocation spiritJobType; private final Supplier ritual; private final ItemStack ritualDummy; private final Ingredient activationItem; + @Nullable private final EntityToSacrifice entityToSacrifice; + @Nullable private final EntityType entityToSummon; + @Nullable + private final TagKey> entityTagToSummon; + @Nullable private final CompoundTag entityNbt; + @Nullable private final Ingredient itemToUse; private final int duration; private final int spiritMaxAge; private final int summonNumber; private final float durationPerIngredient; + @Nullable private final String command; public RitualRecipe(ResourceLocation pentacleId, ResourceLocation ritualType, ItemStack ritualDummy, - ItemStack result, EntityType entityToSummon, CompoundTag entityNbt, Ingredient activationItem, NonNullList ingredients, int duration, int spiritMaxAge, int summonNumber, ResourceLocation spiritJobType, EntityToSacrifice entityToSacrifice, Ingredient itemToUse, String command) { + ItemStack result, @Nullable EntityType entityToSummon, @Nullable TagKey> entityTagToSummon, @Nullable CompoundTag entityNbt, Ingredient activationItem, NonNullList ingredients, int duration, int spiritMaxAge, int summonNumber, @Nullable ResourceLocation spiritJobType, @Nullable EntityToSacrifice entityToSacrifice, @Nullable Ingredient itemToUse, @Nullable String command) { this.result = result; this.ingredients = ingredients; this.entityToSummon = entityToSummon; + this.entityTagToSummon = entityTagToSummon; this.entityNbt = entityNbt; this.pentacleId = pentacleId; this.ritualType = ritualType; @@ -154,11 +167,11 @@ public boolean isSpecial() { return true; } - public String getCommand() { + public @Nullable String getCommand() { return this.command; } - public CompoundTag getEntityNbt() { + public @Nullable CompoundTag getEntityNbt() { return this.entityNbt; } @@ -187,20 +200,20 @@ public float getDurationPerIngredient() { } @Override - public RecipeSerializer getSerializer() { + public @NotNull RecipeSerializer getSerializer() { return SERIALIZER; } @Override - public boolean matches(SingleRecipeInput pInv, Level pLevel) { + public boolean matches(@NotNull SingleRecipeInput pInv, @NotNull Level pLevel) { return false; } @Override - public ItemStack assemble(SingleRecipeInput pCraftingContainer, HolderLookup.Provider pRegistries) { + public @NotNull ItemStack assemble(@NotNull SingleRecipeInput pCraftingContainer, HolderLookup.@NotNull Provider pRegistries) { //as we don't have an inventory this is ignored. - return null; + return ItemStack.EMPTY; } @@ -210,12 +223,12 @@ public boolean canCraftInDimensions(int i, int i1) { } @Override - public ItemStack getResultItem(HolderLookup.Provider pRegistries) { + public @NotNull ItemStack getResultItem(HolderLookup.@NotNull Provider pRegistries) { return this.result; } @Override - public NonNullList getIngredients() { + public @NotNull NonNullList getIngredients() { return this.ingredients; } @@ -232,7 +245,7 @@ public boolean matches(Level level, BlockPos goldenBowlPosition, ItemStack activ } @Override - public RecipeType getType() { + public @NotNull RecipeType getType() { return OccultismRecipes.RITUAL_TYPE.get(); } @@ -244,7 +257,7 @@ public boolean requiresSacrifice() { return this.entityToSacrifice != null; } - public Ingredient getItemToUse() { + public @Nullable Ingredient getItemToUse() { return this.itemToUse; } @@ -252,10 +265,14 @@ public boolean requiresItemUse() { return this.itemToUse != Ingredient.EMPTY; } - public EntityType getEntityToSummon() { + public @Nullable EntityType getEntityToSummon() { return this.entityToSummon; } + public @Nullable TagKey> getEntityTagToSummon() { + return this.entityTagToSummon; + } + public ResourceLocation getRitualType() { return this.ritualType; } @@ -268,7 +285,7 @@ public String getEntityToSacrificeDisplayName() { return this.entityToSacrifice != null ? this.entityToSacrifice.displayName() : ""; } - public ResourceLocation getSpiritJobType() { + public @Nullable ResourceLocation getSpiritJobType() { return this.spiritJobType; } @@ -298,12 +315,12 @@ public record EntityToSacrifice(TagKey> tag, String displayName) { public static class Serializer implements RecipeSerializer { @Override - public MapCodec codec() { + public @NotNull MapCodec codec() { return CODEC; } @Override - public StreamCodec streamCodec() { + public @NotNull StreamCodec streamCodec() { return STREAM_CODEC; } } diff --git a/src/main/java/com/klikli_dev/occultism/datagen/recipe/RitualRecipes.java b/src/main/java/com/klikli_dev/occultism/datagen/recipe/RitualRecipes.java index a22767c1a..c18db3f7b 100644 --- a/src/main/java/com/klikli_dev/occultism/datagen/recipe/RitualRecipes.java +++ b/src/main/java/com/klikli_dev/occultism/datagen/recipe/RitualRecipes.java @@ -611,7 +611,7 @@ private static void summonRituals(RecipeOutput recipeOutput) { makeLoreSpawnEgg(Items.SHEEP_SPAWN_EGG, "item.occultism.ritual_dummy.summon_random_animal"), makeRitualDummy(ResourceLocation.fromNamespaceAndPath(Occultism.MODID, "ritual_dummy/summon_random_animal")), 30, - OccultismRituals.SUMMON_RANDOM_ANIMAL.getId(), + OccultismRituals.SUMMON.getId(), PENTACLE_SUMMON_FOLIOT, Ingredient.of(Tags.Items.CROPS), Ingredient.of(Tags.Items.CROPS), @@ -622,6 +622,7 @@ private static void summonRituals(RecipeOutput recipeOutput) { Ingredient.of(Tags.Items.CROPS), Ingredient.of(Tags.Items.CROPS), Ingredient.of(Items.EGG)) + .entityTagToSummon(OccultismTags.Entities.RANDOM_ANIMALS_TO_SUMMON_LIST) .unlockedBy("has_bound_foliot", has(OccultismItems.BOOK_OF_BINDING_BOUND_FOLIOT.get())) .save(recipeOutput, ResourceLocation.fromNamespaceAndPath(Occultism.MODID, "ritual/summon_random_animal")); diff --git a/src/main/java/com/klikli_dev/occultism/datagen/recipe/builders/RitualRecipeBuilder.java b/src/main/java/com/klikli_dev/occultism/datagen/recipe/builders/RitualRecipeBuilder.java index 389f59433..4a3ece32c 100644 --- a/src/main/java/com/klikli_dev/occultism/datagen/recipe/builders/RitualRecipeBuilder.java +++ b/src/main/java/com/klikli_dev/occultism/datagen/recipe/builders/RitualRecipeBuilder.java @@ -16,7 +16,7 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.RecipeSerializer; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Collections; @@ -25,7 +25,6 @@ public class RitualRecipeBuilder implements RecipeBuilder { private final Map> criteria = new LinkedHashMap<>(); - private final RecipeSerializer serializer; private final Ingredient activationIngredient; private final ItemStack output; private final ResourceLocation ritualType; @@ -35,17 +34,17 @@ public class RitualRecipeBuilder implements RecipeBuilder { private final ResourceLocation pentacleId; @Nullable - private String group; - @Nullable - private ResourceLocation spiritJobType; + private ResourceLocation spiritJobType; @Nullable private TagKey> entityToSacrifice; @Nullable - private EntityType entityToSummon; + private EntityType entityToSummon; + @Nullable + private TagKey> entityTagToSummon; @Nullable private CompoundTag entityNbt; @Nullable - private Ingredient itemToUse; + private Ingredient itemToUse; @Nullable private Integer spiritMaxAge; @Nullable @@ -54,81 +53,90 @@ public class RitualRecipeBuilder implements RecipeBuilder { private String entityToSacrificeDisplayName; @Nullable private String command; - public RitualRecipeBuilder(Ingredient activationIngredient, NonNullList ingredients, ItemStack output,ItemStack ritualDummy,int duration,ResourceLocation ritualType, ResourceLocation pentacleId) { - this.serializer = RitualRecipe.SERIALIZER; + + public RitualRecipeBuilder(Ingredient activationIngredient, NonNullList ingredients, ItemStack output, ItemStack ritualDummy, int duration, ResourceLocation ritualType, ResourceLocation pentacleId) { this.activationIngredient = activationIngredient; this.output = output; - this.ritualDummy=ritualDummy; - this.duration=duration; - this.ritualType=ritualType; - this.ingredients=ingredients; - this.pentacleId=pentacleId; - } - public static RitualRecipeBuilder ritualRecipeBuilder(Ingredient activationIngredient, ItemStack output,ItemStack ritualDummy,int duration,ResourceLocation ritualType, ResourceLocation pentacleId,Ingredient... ingredients) - { + this.ritualDummy = ritualDummy; + this.duration = duration; + this.ritualType = ritualType; + this.ingredients = ingredients; + this.pentacleId = pentacleId; + } + + public static RitualRecipeBuilder ritualRecipeBuilder(Ingredient activationIngredient, ItemStack output, ItemStack ritualDummy, int duration, ResourceLocation ritualType, ResourceLocation pentacleId, Ingredient... ingredients) { NonNullList ingredientsList = NonNullList.create(); Collections.addAll(ingredientsList, ingredients); - return new RitualRecipeBuilder(activationIngredient,ingredientsList,output,ritualDummy,duration,ritualType,pentacleId); + return new RitualRecipeBuilder(activationIngredient, ingredientsList, output, ritualDummy, duration, ritualType, pentacleId); } @Override public RitualRecipeBuilder unlockedBy(String s, Criterion criterion) { - this.criteria.put(s,criterion); + this.criteria.put(s, criterion); return this; } @Override public RitualRecipeBuilder group(@Nullable String s) { - this.group=s; + //NOOP return this; } @Override - public Item getResult() { + public @NotNull Item getResult() { return output.getItem(); } - public RitualRecipeBuilder spiritJobType(ResourceLocation spiritJobType){ - this.spiritJobType=spiritJobType; + + public RitualRecipeBuilder spiritJobType(ResourceLocation spiritJobType) { + this.spiritJobType = spiritJobType; + return this; + } + + public RitualRecipeBuilder entityToSacrifice(TagKey> entityToSacrifice) { + this.entityToSacrifice = entityToSacrifice; return this; } - public RitualRecipeBuilder entityToSacrifice(TagKey> entityToSacrifice){ - this.entityToSacrifice=entityToSacrifice; + + public RitualRecipeBuilder entityToSummon(EntityType entityToSummon) { + this.entityToSummon = entityToSummon; return this; } - public RitualRecipeBuilder entityToSummon(EntityType entityToSummon){ - this.entityToSummon=entityToSummon; + public RitualRecipeBuilder entityTagToSummon(TagKey> entityTagToSummon) { + this.entityTagToSummon = entityTagToSummon; return this; } - public RitualRecipeBuilder entityNbt(CompoundTag entityNbt){ - this.entityNbt=entityNbt; + public RitualRecipeBuilder entityNbt(CompoundTag entityNbt) { + this.entityNbt = entityNbt; return this; } - public RitualRecipeBuilder itemToUse(Ingredient itemToUse){ - this.itemToUse=itemToUse; + public RitualRecipeBuilder itemToUse(Ingredient itemToUse) { + this.itemToUse = itemToUse; return this; } - public RitualRecipeBuilder spiritMaxAge(int spiritMaxAge){ - this.spiritMaxAge=spiritMaxAge; + public RitualRecipeBuilder spiritMaxAge(int spiritMaxAge) { + this.spiritMaxAge = spiritMaxAge; return this; } - public RitualRecipeBuilder summonNumber(int summonNumber){ - this.summonNumber=summonNumber; + + public RitualRecipeBuilder summonNumber(int summonNumber) { + this.summonNumber = summonNumber; return this; } - public RitualRecipeBuilder entityToSacrificeDisplayName(String entityToSacrificeDisplayName){ - this.entityToSacrificeDisplayName=entityToSacrificeDisplayName; + public RitualRecipeBuilder entityToSacrificeDisplayName(String entityToSacrificeDisplayName) { + this.entityToSacrificeDisplayName = entityToSacrificeDisplayName; return this; } - public RitualRecipeBuilder command(String command){ - this.command=command; + public RitualRecipeBuilder command(String command) { + this.command = command; return this; } + @Override public void save(RecipeOutput pRecipeOutput, ResourceLocation pId) { this.ensureValid(pId); @@ -137,8 +145,8 @@ public void save(RecipeOutput pRecipeOutput, ResourceLocation pId) { .rewards(AdvancementRewards.Builder.recipe(pId)) .requirements(AdvancementRequirements.Strategy.OR); this.criteria.forEach(advancement$builder::addCriterion); - RitualRecipe recipe = new RitualRecipe(this.pentacleId,this.ritualType,this.ritualDummy,this.output,entityToSummon,this.entityNbt,this.activationIngredient,this.ingredients,this.duration,this.spiritMaxAge==null?-1:this.spiritMaxAge,this.summonNumber==null?1:this.summonNumber,this.spiritJobType,this.entityToSacrifice==null?null:new RitualRecipe.EntityToSacrifice(this.entityToSacrifice,this.entityToSacrificeDisplayName),this.itemToUse,this.command); - pRecipeOutput.accept(pId, recipe,advancement$builder.build(pId.withPrefix("recipes/ritual/"))); + RitualRecipe recipe = new RitualRecipe(this.pentacleId, this.ritualType, this.ritualDummy, this.output, entityToSummon, this.entityTagToSummon, this.entityNbt, this.activationIngredient, this.ingredients, this.duration, this.spiritMaxAge == null ? -1 : this.spiritMaxAge, this.summonNumber == null ? 1 : this.summonNumber, this.spiritJobType, this.entityToSacrifice == null ? null : new RitualRecipe.EntityToSacrifice(this.entityToSacrifice, this.entityToSacrificeDisplayName), this.itemToUse, this.command); + pRecipeOutput.accept(pId, recipe, advancement$builder.build(pId.withPrefix("recipes/ritual/"))); } private void ensureValid(ResourceLocation pId) { diff --git a/src/main/java/com/klikli_dev/occultism/registry/OccultismRituals.java b/src/main/java/com/klikli_dev/occultism/registry/OccultismRituals.java index 7c3233909..4251f258d 100644 --- a/src/main/java/com/klikli_dev/occultism/registry/OccultismRituals.java +++ b/src/main/java/com/klikli_dev/occultism/registry/OccultismRituals.java @@ -58,9 +58,6 @@ public class OccultismRituals { public static final DeferredHolder SUMMON_WILD = RITUAL_FACTORIES.register("summon_wild", () -> new RitualFactory(SummonWildRitual::new)); - public static final DeferredHolder SUMMON_RANDOM_ANIMAL = - RITUAL_FACTORIES.register("summon_random_animal", - () -> new RitualFactory(SummonRandomAnimalRitual::new)); public static final DeferredHolder FAMILIAR = RITUAL_FACTORIES.register("familiar", () -> new RitualFactory(FamiliarRitual::new)); diff --git a/src/main/java/com/klikli_dev/occultism/util/OccultismExtraStreamCodecs.java b/src/main/java/com/klikli_dev/occultism/util/OccultismExtraStreamCodecs.java index ebfc849c2..2446ea6af 100644 --- a/src/main/java/com/klikli_dev/occultism/util/OccultismExtraStreamCodecs.java +++ b/src/main/java/com/klikli_dev/occultism/util/OccultismExtraStreamCodecs.java @@ -21,6 +21,85 @@ public static StreamCodec> tagKey(ResourceKey TagKey.create(pRegistry, p_203893_), TagKey::location); } + public static StreamCodec composite( + final StreamCodec pCodec1, + final Function pGetter1, + final StreamCodec pCodec2, + final Function pGetter2, + final StreamCodec pCodec3, + final Function pGetter3, + final StreamCodec pCodec4, + final Function pGetter4, + final StreamCodec pCodec5, + final Function pGetter5, + final StreamCodec pCodec6, + final Function pGetter6, + final StreamCodec pCodec7, + final Function pGetter7, + final StreamCodec pCodec8, + final Function pGetter8, + final StreamCodec pCodec9, + final Function pGetter9, + final StreamCodec pCodec10, + final Function pGetter10, + final StreamCodec pCodec11, + final Function pGetter11, + final StreamCodec pCodec12, + final Function pGetter12, + final StreamCodec pCodec13, + final Function pGetter13, + final StreamCodec pCodec14, + final Function pGetter14, + final StreamCodec pCodec15, + final Function pGetter15, + final StreamCodec pCodec16, + final Function pGetter16, + final Function16 pFactory + ) { + return new StreamCodec() { + @Override + public C decode(B p_330310_) { + T1 t1 = pCodec1.decode(p_330310_); + T2 t2 = pCodec2.decode(p_330310_); + T3 t3 = pCodec3.decode(p_330310_); + T4 t4 = pCodec4.decode(p_330310_); + T5 t5 = pCodec5.decode(p_330310_); + T6 t6 = pCodec6.decode(p_330310_); + T7 t7 = pCodec7.decode(p_330310_); + T8 t8 = pCodec8.decode(p_330310_); + T9 t9 = pCodec9.decode(p_330310_); + T10 t10 = pCodec10.decode(p_330310_); + T11 t11 = pCodec11.decode(p_330310_); + T12 t12 = pCodec12.decode(p_330310_); + T13 t13 = pCodec13.decode(p_330310_); + T14 t14 = pCodec14.decode(p_330310_); + T15 t15 = pCodec15.decode(p_330310_); + T16 t16 = pCodec16.decode(p_330310_); + return pFactory.apply(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16); + } + + @Override + public void encode(B p_332052_, C p_331912_) { + pCodec1.encode(p_332052_, pGetter1.apply(p_331912_)); + pCodec2.encode(p_332052_, pGetter2.apply(p_331912_)); + pCodec3.encode(p_332052_, pGetter3.apply(p_331912_)); + pCodec4.encode(p_332052_, pGetter4.apply(p_331912_)); + pCodec5.encode(p_332052_, pGetter5.apply(p_331912_)); + pCodec6.encode(p_332052_, pGetter6.apply(p_331912_)); + pCodec7.encode(p_332052_, pGetter7.apply(p_331912_)); + pCodec8.encode(p_332052_, pGetter8.apply(p_331912_)); + pCodec9.encode(p_332052_, pGetter9.apply(p_331912_)); + pCodec10.encode(p_332052_, pGetter10.apply(p_331912_)); + pCodec11.encode(p_332052_, pGetter11.apply(p_331912_)); + pCodec12.encode(p_332052_, pGetter12.apply(p_331912_)); + pCodec13.encode(p_332052_, pGetter13.apply(p_331912_)); + pCodec14.encode(p_332052_, pGetter14.apply(p_331912_)); + pCodec15.encode(p_332052_, pGetter15.apply(p_331912_)); + pCodec16.encode(p_332052_, pGetter16.apply(p_331912_)); + } + }; + } + public static StreamCodec composite( final StreamCodec pCodec1, final Function pGetter1, @@ -188,6 +267,10 @@ public void encode(B p_332052_, C p_331912_) { pCodec7.encode(p_332052_, pGetter7.apply(p_331912_)); } }; - } + } + + public interface Function16 { + R apply(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16); + } } diff --git a/src/main/resources/data/occultism/recipes/ritual/00_readme.md b/src/main/resources/data/occultism/recipes/ritual/00_readme.md index a237006d4..aeb38e67e 100644 --- a/src/main/resources/data/occultism/recipes/ritual/00_readme.md +++ b/src/main/resources/data/occultism/recipes/ritual/00_readme.md @@ -17,6 +17,7 @@ and thus shelved until further notice. file. - `item_to_use`: If set, an item from the tag needs to be used (right click) for the ritual to commence. - `entity_to_summon`: the entity type of the entity to summon. +- `entity_tag_to_summon`: the tag that determines the entity to summon, instead of specifying the entity type directly. A random entity will be chosen from the tag. - `entity_nbt`: An NBT Tag that will be merged into the entity's nbt. E.g. could be used to set `RabbitType` for rabbits, or `ForgeData` for arbitrary nbt. Uses the NBT formats also used in vanilla shapeless recipe's output: either a json object representing the tag, or a string containing the tag in NBT format. - `duration`: The duration of the ritual in seconds. - `spirit_max_age`: The max age of the spirit in seconds.