diff --git a/src/datagen/java/com/github/elenterius/biomancy/datagen/recipes/BioForgeRecipeProvider.java b/src/datagen/java/com/github/elenterius/biomancy/datagen/recipes/BioForgeRecipeProvider.java index 2f0541003..eb43106b6 100644 --- a/src/datagen/java/com/github/elenterius/biomancy/datagen/recipes/BioForgeRecipeProvider.java +++ b/src/datagen/java/com/github/elenterius/biomancy/datagen/recipes/BioForgeRecipeProvider.java @@ -5,12 +5,17 @@ import com.github.elenterius.biomancy.datagen.recipes.builder.ItemData; import com.github.elenterius.biomancy.init.ModBioForgeTabs; import com.github.elenterius.biomancy.init.ModItems; +import com.github.elenterius.biomancy.item.EssenceItem; import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.FinishedRecipe; import net.minecraft.data.recipes.RecipeProvider; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.entity.EntityType; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraftforge.common.crafting.PartialNBTIngredient; import java.util.function.Consumer; @@ -25,6 +30,22 @@ protected BioForgeRecipeProvider(PackOutput output) { super(output); } + private static ItemStack withMaxNutrients(T item) { + ItemStack itemStack = item.getDefaultInstance(); + item.setNutrients(itemStack, Integer.MAX_VALUE); + return itemStack; + } + + private static Ingredient createMobEssenceIngredient(EntityType entityType) { + CompoundTag essenceTag = new CompoundTag(); + essenceTag.putString(EssenceItem.ENTITY_TYPE_KEY, EntityType.getKey(entityType).toString()); + essenceTag.putString(EssenceItem.ENTITY_NAME_KEY, entityType.getDescriptionId()); + CompoundTag tag = new CompoundTag(); + tag.put(EssenceItem.ESSENCE_DATA_KEY, essenceTag); + tag.putInt(EssenceItem.ESSENCE_TIER_KEY, 1); + return PartialNBTIngredient.of(ModItems.ESSENCE.get(), tag); + } + @Override protected void buildRecipes(Consumer consumer) { buildMachineRecipes(consumer); @@ -150,12 +171,6 @@ private void buildBlockRecipes(Consumer consumer) { .unlockedBy(ModItems.BONE_FRAGMENTS.get()).save(consumer); } - private ItemStack withMaxNutrients(T item) { - ItemStack itemStack = item.getDefaultInstance(); - item.setNutrients(itemStack, Integer.MAX_VALUE); - return itemStack; - } - private void buildToolRecipes(Consumer consumer) { BioForgeRecipeBuilder.create(withMaxNutrients(ModItems.RAVENOUS_CLAWS.get())) .addIngredient(ModItems.LIVING_FLESH.get()) @@ -322,6 +337,44 @@ private void buildComponentRecipes(Consumer consumer) { .addIngredient(ModItems.STONE_POWDER.get(), 1) .setCategory(ModBioForgeTabs.COMPONENTS) .unlockedBy(Items.NAUTILUS_SHELL).save(consumer); + + BioForgeRecipeBuilder.create(Items.SKELETON_SKULL) + .setCraftingCost(4) + .addIngredient(ModItems.BONE_FRAGMENTS.get(), 48 + 2) + .addIngredient(ModItems.MINERAL_FRAGMENT.get(), 7 + 2) + .setCategory(ModBioForgeTabs.COMPONENTS) + .unlockedBy(Items.SKELETON_SKULL).save(consumer); + + BioForgeRecipeBuilder.create(Items.WITHER_SKELETON_SKULL) + .setCraftingCost(4) + .addIngredient(ModItems.BONE_FRAGMENTS.get(), 48 + 2) + .addIngredient(ModItems.MINERAL_FRAGMENT.get(), 7 + 2) + .addIngredient(ModItems.WITHERING_OOZE.get(), 16 + 2) + .setCategory(ModBioForgeTabs.COMPONENTS) + .unlockedBy(Items.WITHER_SKELETON_SKULL).save(consumer); + + BioForgeRecipeBuilder.create(Items.PLAYER_HEAD) + .setCraftingCost(4) + .addIngredient(Items.SKELETON_SKULL) + .addIngredient(createMobEssenceIngredient(EntityType.PLAYER)) + .addIngredient(ModItems.FLESH_BITS.get(), 32 + 2) + .addIngredient(ModItems.ELASTIC_FIBERS.get(), 9 + 2) + .setCategory(ModBioForgeTabs.COMPONENTS) + .unlockedBy(Items.SKELETON_SKULL).save(consumer); + + BioForgeRecipeBuilder.create(Items.PIGLIN_HEAD) + .setCraftingCost(4) + .addIngredient(Items.SKELETON_SKULL) + .addIngredient(createMobEssenceIngredient(EntityType.PIGLIN)) + .addIngredient(ModItems.FLESH_BITS.get(), 36 + 2) + .addIngredient(ModItems.ELASTIC_FIBERS.get(), 12 + 2) + .setCategory(ModBioForgeTabs.COMPONENTS) + .unlockedBy(Items.SKELETON_SKULL).save(consumer); + + // DecomposerRecipeBuilder.create().setIngredient(Items.ZOMBIE_HEAD).addOutput(ModItems.FLESH_BITS.get(), 14, 24).addOutput(ModItems.ELASTIC_FIBERS.get(), 5, 9).addOutput(Items.SKELETON_SKULL, 1).unlockedBy(Items.ZOMBIE_HEAD).save(consumer); + // DecomposerRecipeBuilder.create().setIngredient(Items.CREEPER_HEAD).addOutput(ModItems.FLESH_BITS.get(), 19, 32).addOutput(ModItems.ELASTIC_FIBERS.get(), 5, 9).addOutput(Items.SKELETON_SKULL, 1).unlockedBy(Items.CREEPER_HEAD).save(consumer); + // DecomposerRecipeBuilder.create().setIngredient(Items.DRAGON_HEAD).addOutput(ModItems.FLESH_BITS.get(), 50).addOutput(ModItems.EXOTIC_DUST.get(), 50).addOutput(ModItems.TOUGH_FIBERS.get(), 25).addOutput(ModItems.MINERAL_FRAGMENT.get(), 20).addOutput(ModItems.BONE_FRAGMENTS.get(), 50).unlockedBy(Items.DRAGON_HEAD).save(consumer); + } private void buildMiscRecipes(Consumer consumer) { diff --git a/src/datagen/java/com/github/elenterius/biomancy/datagen/recipes/VanillaRecipeProvider.java b/src/datagen/java/com/github/elenterius/biomancy/datagen/recipes/VanillaRecipeProvider.java index f7fd8ee60..1a532031e 100644 --- a/src/datagen/java/com/github/elenterius/biomancy/datagen/recipes/VanillaRecipeProvider.java +++ b/src/datagen/java/com/github/elenterius/biomancy/datagen/recipes/VanillaRecipeProvider.java @@ -305,6 +305,9 @@ private void buildWorkbenchRecipes(Consumer consumer) { SpecialRecipeBuilder.special(ModRecipes.CRADLE_CLEANSING_SERIALIZER.get()) .save(consumer, BiomancyMod.createRLString(ModItems.PRIMORDIAL_CRADLE.getId().toLanguageKey() + "_cleansing")); + + SpecialRecipeBuilder.special(ModRecipes.PLAYER_HEAD_SERIALIZER.get()) + .save(consumer, getSpecialCraftingRecipeId(Items.PLAYER_HEAD).toString()); } private void membrane(Consumer consumer, SimpleBlockItem pane, SimpleBlockItem membrane) { @@ -321,6 +324,14 @@ private void membrane(Consumer consumer, SimpleBlockItem pane, S .save(consumer, getConversionRecipeId(membrane, pane)); } + protected ResourceLocation getSpecialCraftingRecipeId(ItemLike itemLike) { + return BiomancyMod.createRL("special_crafting/" + getItemName(itemLike)); + } + + protected ResourceLocation getCraftingRecipeId(ItemLike itemLike) { + return BiomancyMod.createRL("crafting/" + getItemName(itemLike)); + } + protected ResourceLocation getSimpleRecipeId(ItemLike itemLike) { return BiomancyMod.createRL(getItemName(itemLike)); } diff --git a/src/generated/resources/data/biomancy/advancements/recipes/biomancy/bio_forging/piglin_head_from_bio_forging.json b/src/generated/resources/data/biomancy/advancements/recipes/biomancy/bio_forging/piglin_head_from_bio_forging.json new file mode 100644 index 000000000..4927fa781 --- /dev/null +++ b/src/generated/resources/data/biomancy/advancements/recipes/biomancy/bio_forging/piglin_head_from_bio_forging.json @@ -0,0 +1,35 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_skeleton_skull": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:skeleton_skull" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "biomancy:bio_forging/piglin_head_from_bio_forging" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_skeleton_skull", + "has_the_recipe" + ] + ], + "rewards": { + "recipes": [ + "biomancy:bio_forging/piglin_head_from_bio_forging" + ] + }, + "sends_telemetry_event": false +} \ No newline at end of file diff --git a/src/generated/resources/data/biomancy/advancements/recipes/biomancy/bio_forging/player_head_from_bio_forging.json b/src/generated/resources/data/biomancy/advancements/recipes/biomancy/bio_forging/player_head_from_bio_forging.json new file mode 100644 index 000000000..b66c23f63 --- /dev/null +++ b/src/generated/resources/data/biomancy/advancements/recipes/biomancy/bio_forging/player_head_from_bio_forging.json @@ -0,0 +1,35 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_skeleton_skull": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:skeleton_skull" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "biomancy:bio_forging/player_head_from_bio_forging" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_skeleton_skull", + "has_the_recipe" + ] + ], + "rewards": { + "recipes": [ + "biomancy:bio_forging/player_head_from_bio_forging" + ] + }, + "sends_telemetry_event": false +} \ No newline at end of file diff --git a/src/generated/resources/data/biomancy/advancements/recipes/biomancy/bio_forging/skeleton_skull_from_bio_forging.json b/src/generated/resources/data/biomancy/advancements/recipes/biomancy/bio_forging/skeleton_skull_from_bio_forging.json new file mode 100644 index 000000000..02fc8fc8c --- /dev/null +++ b/src/generated/resources/data/biomancy/advancements/recipes/biomancy/bio_forging/skeleton_skull_from_bio_forging.json @@ -0,0 +1,35 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_skeleton_skull": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:skeleton_skull" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "biomancy:bio_forging/skeleton_skull_from_bio_forging" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_skeleton_skull", + "has_the_recipe" + ] + ], + "rewards": { + "recipes": [ + "biomancy:bio_forging/skeleton_skull_from_bio_forging" + ] + }, + "sends_telemetry_event": false +} \ No newline at end of file diff --git a/src/generated/resources/data/biomancy/advancements/recipes/biomancy/bio_forging/wither_skeleton_skull_from_bio_forging.json b/src/generated/resources/data/biomancy/advancements/recipes/biomancy/bio_forging/wither_skeleton_skull_from_bio_forging.json new file mode 100644 index 000000000..e480836e2 --- /dev/null +++ b/src/generated/resources/data/biomancy/advancements/recipes/biomancy/bio_forging/wither_skeleton_skull_from_bio_forging.json @@ -0,0 +1,35 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_the_recipe": { + "conditions": { + "recipe": "biomancy:bio_forging/wither_skeleton_skull_from_bio_forging" + }, + "trigger": "minecraft:recipe_unlocked" + }, + "has_wither_skeleton_skull": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:wither_skeleton_skull" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + } + }, + "requirements": [ + [ + "has_wither_skeleton_skull", + "has_the_recipe" + ] + ], + "rewards": { + "recipes": [ + "biomancy:bio_forging/wither_skeleton_skull_from_bio_forging" + ] + }, + "sends_telemetry_event": false +} \ No newline at end of file diff --git a/src/generated/resources/data/biomancy/recipes/bio_forging/piglin_head_from_bio_forging.json b/src/generated/resources/data/biomancy/recipes/bio_forging/piglin_head_from_bio_forging.json new file mode 100644 index 000000000..ca2dfc12d --- /dev/null +++ b/src/generated/resources/data/biomancy/recipes/bio_forging/piglin_head_from_bio_forging.json @@ -0,0 +1,26 @@ +{ + "type": "biomancy:bio_forging", + "bio_forge_tab": "biomancy:components", + "ingredients": [ + { + "item": "minecraft:skeleton_skull" + }, + { + "type": "forge:partial_nbt", + "item": "biomancy:essence", + "nbt": "{essence_data:{entity_type:\"minecraft:piglin\",name:\"entity.minecraft.piglin\"},essence_tier:1}" + }, + { + "count": 38, + "item": "biomancy:flesh_bits" + }, + { + "count": 14, + "item": "biomancy:elastic_fibers" + } + ], + "nutrientsCost": 4, + "result": { + "item": "minecraft:piglin_head" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/biomancy/recipes/bio_forging/player_head_from_bio_forging.json b/src/generated/resources/data/biomancy/recipes/bio_forging/player_head_from_bio_forging.json new file mode 100644 index 000000000..54fd5e9f3 --- /dev/null +++ b/src/generated/resources/data/biomancy/recipes/bio_forging/player_head_from_bio_forging.json @@ -0,0 +1,26 @@ +{ + "type": "biomancy:bio_forging", + "bio_forge_tab": "biomancy:components", + "ingredients": [ + { + "item": "minecraft:skeleton_skull" + }, + { + "type": "forge:partial_nbt", + "item": "biomancy:essence", + "nbt": "{essence_data:{entity_type:\"minecraft:player\",name:\"entity.minecraft.player\"},essence_tier:1}" + }, + { + "count": 34, + "item": "biomancy:flesh_bits" + }, + { + "count": 11, + "item": "biomancy:elastic_fibers" + } + ], + "nutrientsCost": 4, + "result": { + "item": "minecraft:player_head" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/biomancy/recipes/bio_forging/skeleton_skull_from_bio_forging.json b/src/generated/resources/data/biomancy/recipes/bio_forging/skeleton_skull_from_bio_forging.json new file mode 100644 index 000000000..cc53e40df --- /dev/null +++ b/src/generated/resources/data/biomancy/recipes/bio_forging/skeleton_skull_from_bio_forging.json @@ -0,0 +1,18 @@ +{ + "type": "biomancy:bio_forging", + "bio_forge_tab": "biomancy:components", + "ingredients": [ + { + "count": 50, + "item": "biomancy:bone_fragments" + }, + { + "count": 9, + "item": "biomancy:mineral_fragment" + } + ], + "nutrientsCost": 4, + "result": { + "item": "minecraft:skeleton_skull" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/biomancy/recipes/bio_forging/wither_skeleton_skull_from_bio_forging.json b/src/generated/resources/data/biomancy/recipes/bio_forging/wither_skeleton_skull_from_bio_forging.json new file mode 100644 index 000000000..618102cfd --- /dev/null +++ b/src/generated/resources/data/biomancy/recipes/bio_forging/wither_skeleton_skull_from_bio_forging.json @@ -0,0 +1,22 @@ +{ + "type": "biomancy:bio_forging", + "bio_forge_tab": "biomancy:components", + "ingredients": [ + { + "count": 50, + "item": "biomancy:bone_fragments" + }, + { + "count": 9, + "item": "biomancy:mineral_fragment" + }, + { + "count": 18, + "item": "biomancy:withering_ooze" + } + ], + "nutrientsCost": 4, + "result": { + "item": "minecraft:wither_skeleton_skull" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/biomancy/recipes/special_crafting/player_head.json b/src/generated/resources/data/biomancy/recipes/special_crafting/player_head.json new file mode 100644 index 000000000..7bb5948cd --- /dev/null +++ b/src/generated/resources/data/biomancy/recipes/special_crafting/player_head.json @@ -0,0 +1,4 @@ +{ + "type": "biomancy:crafting_dynamic_player_head", + "category": "misc" +} \ No newline at end of file diff --git a/src/main/java/com/github/elenterius/biomancy/crafting/recipe/PlayerHeadRecipe.java b/src/main/java/com/github/elenterius/biomancy/crafting/recipe/PlayerHeadRecipe.java new file mode 100644 index 000000000..91f1cc64a --- /dev/null +++ b/src/main/java/com/github/elenterius/biomancy/crafting/recipe/PlayerHeadRecipe.java @@ -0,0 +1,117 @@ +package com.github.elenterius.biomancy.crafting.recipe; + +import com.github.elenterius.biomancy.init.ModItems; +import com.github.elenterius.biomancy.init.ModRecipes; +import com.github.elenterius.biomancy.item.EssenceItem; +import com.mojang.authlib.GameProfile; +import net.minecraft.core.RegistryAccess; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.inventory.CraftingContainer; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.PlayerHeadItem; +import net.minecraft.world.item.crafting.CraftingBookCategory; +import net.minecraft.world.item.crafting.CustomRecipe; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.level.Level; + +import java.util.UUID; + +public class PlayerHeadRecipe extends CustomRecipe { + + public PlayerHeadRecipe(ResourceLocation id, CraftingBookCategory category) { + super(id, category); + } + + @Override + public boolean matches(CraftingContainer inventory, Level level) { + boolean hasPlayerHead = false; + boolean hasPlayerUUID = false; + boolean hasExoticDust = false; + + for (int i = 0; i < inventory.getContainerSize(); i++) { + ItemStack stack = inventory.getItem(i); + + if (stack.isEmpty()) continue; + Item item = stack.getItem(); + + if (item == Items.PLAYER_HEAD) { + if (hasPlayerHead) return false; + hasPlayerHead = true; + } + else if (item == ModItems.EXOTIC_DUST.get()) { + if (hasExoticDust) return false; + hasExoticDust = true; + } + else if (item instanceof EssenceItem essenceItem) { + if (hasPlayerUUID) return false; + + if (essenceItem.getEntityType(stack).filter(entityType -> entityType == EntityType.PLAYER).isPresent()) { + hasPlayerUUID = essenceItem.getEntityUUID(stack).isPresent(); + } + } + else return false; + } + + return hasPlayerHead && hasPlayerUUID && hasExoticDust; + } + + @Override + public ItemStack assemble(CraftingContainer inventory, RegistryAccess registryAccess) { + UUID uuid = null; + boolean hasPlayerHead = false; + boolean hasExoticDust = false; + + for (int i = 0; i < inventory.getContainerSize(); i++) { + ItemStack stack = inventory.getItem(i); + + if (stack.isEmpty()) continue; + Item item = stack.getItem(); + + if (item == Items.PLAYER_HEAD) { + if (hasPlayerHead) return ItemStack.EMPTY; + hasPlayerHead = true; + } + else if (item == ModItems.EXOTIC_DUST.get()) { + if (hasExoticDust) return ItemStack.EMPTY; + hasExoticDust = true; + } + else if (item instanceof EssenceItem essenceItem) { + if (uuid != null) { + return ItemStack.EMPTY; + } + if (essenceItem.getEntityType(stack).filter(entityType -> entityType == EntityType.PLAYER).isPresent()) { + uuid = essenceItem.getEntityUUID(stack).orElse(null); + } + } + else return ItemStack.EMPTY; + } + + return hasPlayerHead && uuid != null && hasExoticDust ? createPlayerHeadFrom(uuid) : ItemStack.EMPTY; + } + + private ItemStack createPlayerHeadFrom(UUID uuid) { + GameProfile gameProfile = new GameProfile(uuid, null); + + ItemStack stack = Items.PLAYER_HEAD.getDefaultInstance(); + CompoundTag tag = stack.getOrCreateTag(); + tag.put(PlayerHeadItem.TAG_SKULL_OWNER, NbtUtils.writeGameProfile(new CompoundTag(), gameProfile)); + + return stack; + } + + @Override + public boolean canCraftInDimensions(int width, int height) { + return width * height >= 2; + } + + @Override + public RecipeSerializer getSerializer() { + return ModRecipes.PLAYER_HEAD_SERIALIZER.get(); + } + +} diff --git a/src/main/java/com/github/elenterius/biomancy/init/ModRecipes.java b/src/main/java/com/github/elenterius/biomancy/init/ModRecipes.java index 719a7756b..f7ffaab94 100644 --- a/src/main/java/com/github/elenterius/biomancy/init/ModRecipes.java +++ b/src/main/java/com/github/elenterius/biomancy/init/ModRecipes.java @@ -43,6 +43,7 @@ public final class ModRecipes { public static final RegistryObject> FOOD_DIGESTING_SERIALIZER = registerDynamicRecipeSerializer(DIGESTING_RECIPE_TYPE, "food", FoodDigestingRecipe.Serializer::new); public static final RegistryObject> BIOMETRIC_MEMBRANE_CRAFTING_SERIALIZER = registerDynamicCraftingRecipeSerializer(RecipeType.CRAFTING, "biometric_membrane", () -> new SimpleCraftingRecipeSerializer<>(BiometricMembraneRecipe::new)); public static final RegistryObject> CRADLE_CLEANSING_SERIALIZER = registerDynamicCraftingRecipeSerializer(RecipeType.CRAFTING, "cradle_cleansing", () -> new SimpleCraftingRecipeSerializer<>(CradleCleansingRecipe::new)); + public static final RegistryObject> PLAYER_HEAD_SERIALIZER = registerDynamicCraftingRecipeSerializer(RecipeType.CRAFTING, "player_head", () -> new SimpleCraftingRecipeSerializer<>(PlayerHeadRecipe::new)); private ModRecipes() {} diff --git a/src/main/java/com/github/elenterius/biomancy/integration/jei/BiomancyJeiPlugin.java b/src/main/java/com/github/elenterius/biomancy/integration/jei/BiomancyJeiPlugin.java index 611085f2d..d0e16a74a 100644 --- a/src/main/java/com/github/elenterius/biomancy/integration/jei/BiomancyJeiPlugin.java +++ b/src/main/java/com/github/elenterius/biomancy/integration/jei/BiomancyJeiPlugin.java @@ -63,7 +63,8 @@ public void registerRecipes(IRecipeRegistration registration) { registration.addRecipes(BioForgeRecipeCategory.RECIPE_TYPE, recipeManager.getAllRecipesFor(ModRecipes.BIO_FORGING_RECIPE_TYPE.get())); registration.addRecipes(RecipeTypes.CRAFTING, BiometricMembraneRecipeMaker.createRecipes()); - registration.addRecipes(RecipeTypes.CRAFTING, CradleCleansingRecipeMaker.createRecipes()); + registration.addRecipes(RecipeTypes.CRAFTING, SpecialCraftingRecipeMaker.createCradleCleansingRecipes()); + registration.addRecipes(RecipeTypes.CRAFTING, SpecialCraftingRecipeMaker.createPlayerHeadRecipes()); } @Override diff --git a/src/main/java/com/github/elenterius/biomancy/integration/jei/CradleCleansingRecipeMaker.java b/src/main/java/com/github/elenterius/biomancy/integration/jei/CradleCleansingRecipeMaker.java deleted file mode 100644 index 92153be36..000000000 --- a/src/main/java/com/github/elenterius/biomancy/integration/jei/CradleCleansingRecipeMaker.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.github.elenterius.biomancy.integration.jei; - -import com.github.elenterius.biomancy.block.cradle.PrimordialCradleBlockEntity; -import com.github.elenterius.biomancy.init.ModBlockEntities; -import com.github.elenterius.biomancy.init.ModItems; -import com.github.elenterius.biomancy.world.mound.MoundShape; -import net.minecraft.core.NonNullList; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.BlockItem; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.CraftingBookCategory; -import net.minecraft.world.item.crafting.CraftingRecipe; -import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.ShapelessRecipe; - -import java.util.ArrayList; -import java.util.List; - -public final class CradleCleansingRecipeMaker { - - private CradleCleansingRecipeMaker() {} - - public static List createRecipes() { - ItemStack cradle = ModItems.PRIMORDIAL_CRADLE.get().getDefaultInstance(); - CompoundTag tag = new CompoundTag(); - CompoundTag tagProcGen = new CompoundTag(); - MoundShape.ProcGenValues procGenValues = new MoundShape.ProcGenValues(1234L, (byte) 0, (byte) 0, (byte) 1, 250, 66, 0.7f, 0.5f); - procGenValues.writeTo(tagProcGen); - tag.put(PrimordialCradleBlockEntity.PROC_GEN_VALUES_KEY, tagProcGen); - BlockItem.setBlockEntityData(cradle, ModBlockEntities.PRIMORDIAL_CRADLE.get(), tag); - - List ingredients = new ArrayList<>(); - ingredients.add(Ingredient.of(cradle)); - ingredients.add(Ingredient.of(ModItems.CLEANSING_SERUM.get())); - NonNullList inputs = NonNullList.of(Ingredient.EMPTY, ingredients.toArray(Ingredient[]::new)); - - ResourceLocation recipeId = ModItems.PRIMORDIAL_CRADLE.getId().withSuffix("_cleansing" + ".cleansed"); - - ItemStack result = ModItems.PRIMORDIAL_CRADLE.get().getDefaultInstance(); - - return List.of( - new ShapelessRecipe(recipeId, "", CraftingBookCategory.MISC, result, inputs) - ); - } - -} diff --git a/src/main/java/com/github/elenterius/biomancy/integration/jei/SpecialCraftingRecipeMaker.java b/src/main/java/com/github/elenterius/biomancy/integration/jei/SpecialCraftingRecipeMaker.java new file mode 100644 index 000000000..789b0ae51 --- /dev/null +++ b/src/main/java/com/github/elenterius/biomancy/integration/jei/SpecialCraftingRecipeMaker.java @@ -0,0 +1,98 @@ +package com.github.elenterius.biomancy.integration.jei; + +import com.github.elenterius.biomancy.BiomancyMod; +import com.github.elenterius.biomancy.block.cradle.PrimordialCradleBlockEntity; +import com.github.elenterius.biomancy.init.ModBlockEntities; +import com.github.elenterius.biomancy.init.ModItems; +import com.github.elenterius.biomancy.item.EssenceItem; +import com.github.elenterius.biomancy.world.mound.MoundShape; +import com.mojang.authlib.GameProfile; +import net.minecraft.core.NonNullList; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.PlayerHeadItem; +import net.minecraft.world.item.crafting.CraftingBookCategory; +import net.minecraft.world.item.crafting.CraftingRecipe; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.item.crafting.ShapelessRecipe; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +public final class SpecialCraftingRecipeMaker { + + private SpecialCraftingRecipeMaker() {} + + public static List createCradleCleansingRecipes() { + ItemStack cradle = ModItems.PRIMORDIAL_CRADLE.get().getDefaultInstance(); + CompoundTag tag = new CompoundTag(); + CompoundTag tagProcGen = new CompoundTag(); + MoundShape.ProcGenValues procGenValues = new MoundShape.ProcGenValues(1234L, (byte) 0, (byte) 0, (byte) 1, 250, 66, 0.7f, 0.5f); + procGenValues.writeTo(tagProcGen); + tag.put(PrimordialCradleBlockEntity.PROC_GEN_VALUES_KEY, tagProcGen); + BlockItem.setBlockEntityData(cradle, ModBlockEntities.PRIMORDIAL_CRADLE.get(), tag); + + List ingredients = new ArrayList<>(); + ingredients.add(Ingredient.of(cradle)); + ingredients.add(Ingredient.of(ModItems.CLEANSING_SERUM.get())); + NonNullList inputs = NonNullList.of(Ingredient.EMPTY, ingredients.toArray(Ingredient[]::new)); + + ResourceLocation recipeId = ModItems.PRIMORDIAL_CRADLE.getId().withSuffix("_cleansing" + ".cleansed"); + + ItemStack result = ModItems.PRIMORDIAL_CRADLE.get().getDefaultInstance(); + + return List.of( + new ShapelessRecipe(recipeId, "", CraftingBookCategory.MISC, result, inputs) + ); + } + + public static List createPlayerHeadRecipes() { + NonNullList inputs = NonNullList.of(Ingredient.EMPTY, + Ingredient.of(Items.PLAYER_HEAD), + Ingredient.of(ModItems.EXOTIC_DUST.get()), + Ingredient.of(createUniquePlayerEssence(UUID.fromString("853c80ef-3c37-49fd-aa49-938b674adae6"), "jeb_")) + ); + ItemStack result = createPlayerHead("jeb_"); + + return List.of( + new ShapelessRecipe(BiomancyMod.createRL("special_crafting/player_head"), "", CraftingBookCategory.MISC, result, inputs) + ); + } + + private static ItemStack createPlayerHead(String name) { + GameProfile gameProfile = new GameProfile(null, name); + + ItemStack stack = Items.PLAYER_HEAD.getDefaultInstance(); + CompoundTag tag = stack.getOrCreateTag(); + tag.put(PlayerHeadItem.TAG_SKULL_OWNER, NbtUtils.writeGameProfile(new CompoundTag(), gameProfile)); + + return stack; + } + + private static ItemStack createUniquePlayerEssence(UUID entityUUID, String playerName) { + ItemStack stack = ModItems.ESSENCE.get().getDefaultInstance(); + CompoundTag tag = stack.getOrCreateTag(); + + EntityType entityType = EntityType.PLAYER; + int[] colors = EssenceItem.getEssenceColors(entityUUID); + + CompoundTag essenceTag = new CompoundTag(); + essenceTag.putString(EssenceItem.ENTITY_TYPE_KEY, EntityType.getKey(entityType).toString()); + essenceTag.putString(EssenceItem.ENTITY_NAME_KEY, entityType.getDescriptionId()); + essenceTag.putUUID(EssenceItem.ENTITY_UUID_KEY, entityUUID); + + tag.put(EssenceItem.ESSENCE_DATA_KEY, essenceTag); + tag.putInt(EssenceItem.ESSENCE_TIER_KEY, 3); + tag.putIntArray(EssenceItem.COLORS_KEY, colors); + tag.putString(EssenceItem.PLAYER_NAME_KEY, playerName); + + return stack; + } + +} diff --git a/src/main/java/com/github/elenterius/biomancy/item/EssenceItem.java b/src/main/java/com/github/elenterius/biomancy/item/EssenceItem.java index 4add4dc10..d7b4c15f1 100644 --- a/src/main/java/com/github/elenterius/biomancy/item/EssenceItem.java +++ b/src/main/java/com/github/elenterius/biomancy/item/EssenceItem.java @@ -36,7 +36,8 @@ public class EssenceItem extends Item implements ItemTooltipStyleProvider { public static final String SOUNDS_KEY = "sounds"; public static final String ENTITY_NAME_KEY = "name"; public static final String ENTITY_UUID_KEY = "entity_uuid"; - protected static final String ESSENCE_TIER_KEY = "essence_tier"; + public static final String ESSENCE_TIER_KEY = "essence_tier"; + public static final String PLAYER_NAME_KEY = "player_name"; public EssenceItem(Properties properties) { super(properties); @@ -49,7 +50,12 @@ public static ItemStack fromEntity(LivingEntity livingEntity, int surgicalPrecis EssenceItem essenceItem = ModItems.ESSENCE.get(); ItemStack stack = new ItemStack(essenceItem, count); - if (essenceItem.setEssenceData(stack, Mth.clamp(essenceTier, 1, 3), livingEntity)) { + essenceTier = Mth.clamp(essenceTier, 1, 3); + + if (essenceItem.setEssenceData(stack, essenceTier, livingEntity)) { + if (essenceTier >= 3 && livingEntity instanceof Player player) { + stack.getOrCreateTag().putString(PLAYER_NAME_KEY, player.getGameProfile().getName()); + } return stack; } @@ -73,16 +79,19 @@ public static int[] getEssenceColors(LivingEntity livingEntity, int tier) { if (livingEntity instanceof Player player) { if (tier < 3) return getEssenceColors(player.getType()); - UUID uuid = player.getUUID(); - int background = (int) (uuid.getMostSignificantBits() & 0xffffff); - int highlight = (int) (uuid.getLeastSignificantBits() & 0xffffff); - return new int[]{background, highlight}; + return getEssenceColors(player.getUUID()); } else { return getEssenceColors(livingEntity.getType()); } } + public static int[] getEssenceColors(UUID uuid) { + int background = (int) (uuid.getMostSignificantBits() & 0xffffff); + int highlight = (int) (uuid.getLeastSignificantBits() & 0xffffff); + return new int[]{background, highlight}; + } + public static int[] getEssenceColors(EntityType entityType) { if (entityType == EntityType.PLAYER) { return new int[]{0x00AFAF, 0x463AA5}; //steve colors @@ -199,8 +208,8 @@ public void appendHoverText(ItemStack stack, @Nullable Level level, List