mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 07:13:28 +01:00
Added RecipeKeepDataShapeless
Added drill coloring recipes.
This commit is contained in:
parent
e4e9108099
commit
e0a8eed365
23 changed files with 464 additions and 33 deletions
|
@ -1,4 +1,4 @@
|
|||
// 1.20.4 2024-03-13T16:31:58.3504382 Item Recipes
|
||||
// 1.20.4 2024-03-13T16:30:00.2078814 Item Recipes
|
||||
d374edde9294d1a224b4b5610b50117a11328c00 data/actuallyadditions/recipes/advanced_coil.json
|
||||
f67629e45d152c96f3467a90a67520f78ecf9f07 data/actuallyadditions/recipes/advanced_leaf_blower.json
|
||||
d65e5a70232fa2f0e74d2a67c1cd4b0e87124242 data/actuallyadditions/recipes/basic_coil.json
|
||||
|
@ -49,6 +49,22 @@ dd65310cce05d96449b6641f0c29982bd670d623 data/actuallyadditions/recipes/decompre
|
|||
823c7188829eb50975d857f61e33bc5c2780bb12 data/actuallyadditions/recipes/decompress/void_crystal_shard.json
|
||||
c3592647a1b6de17893a80eeb9ed214f719cc4eb data/actuallyadditions/recipes/diamond_aiot.json
|
||||
035937b870792a57c0db0b512b41f965af4c8195 data/actuallyadditions/recipes/double_battery.json
|
||||
ed2c70ef554ccdc2b64ec07966d42668a319d32b data/actuallyadditions/recipes/drill_coloring/dye_drill_black.json
|
||||
881cee08ef4c9cae7ff0549c896bc9c030a8b0f7 data/actuallyadditions/recipes/drill_coloring/dye_drill_blue.json
|
||||
cd5471712f938e4b494809e91dd5947cdbd15a6e data/actuallyadditions/recipes/drill_coloring/dye_drill_brown.json
|
||||
60a3f8cd14f2eb24787929e063abfba3c20fb01d data/actuallyadditions/recipes/drill_coloring/dye_drill_cyan.json
|
||||
618b10d9093db3ad2b33ccf53a56c89dee8a62d4 data/actuallyadditions/recipes/drill_coloring/dye_drill_gray.json
|
||||
5de54c56552fd3f448d453133adcae5456b31587 data/actuallyadditions/recipes/drill_coloring/dye_drill_green.json
|
||||
14ec8cc195f2f741464cb9f110f9eb287a546232 data/actuallyadditions/recipes/drill_coloring/dye_drill_light_blue.json
|
||||
07b386e726536b8a7e48f1332497adb76e16885e data/actuallyadditions/recipes/drill_coloring/dye_drill_light_gray.json
|
||||
80e71aca4867f58fb74f090fc37838dd114e124f data/actuallyadditions/recipes/drill_coloring/dye_drill_lime.json
|
||||
83a7d3a234441da079f014cbbf64a8cd1fcb7ec6 data/actuallyadditions/recipes/drill_coloring/dye_drill_magenta.json
|
||||
75b0919b05bae59afb8c0c852842dfd17c1d3a92 data/actuallyadditions/recipes/drill_coloring/dye_drill_orange.json
|
||||
6000e5221d29e456658861e7b35f102606a77ce0 data/actuallyadditions/recipes/drill_coloring/dye_drill_pink.json
|
||||
f24b883db19649b69dc45faf38621a91fd125f08 data/actuallyadditions/recipes/drill_coloring/dye_drill_purple.json
|
||||
36312062f28665b65da73f3e735a48cabc0d186e data/actuallyadditions/recipes/drill_coloring/dye_drill_red.json
|
||||
72a714b78e80f028771b887c6bc865c5850f2fe9 data/actuallyadditions/recipes/drill_coloring/dye_drill_white.json
|
||||
afbd032dbb1278f1edf020af0e4d5d558f58ad77 data/actuallyadditions/recipes/drill_coloring/dye_drill_yellow.json
|
||||
ac1da42089dad9779f7f8b4d143c35e910a43610 data/actuallyadditions/recipes/drill_core.json
|
||||
33dc398564081b1ea8b619650b6e292231ef957d data/actuallyadditions/recipes/drill_light_blue.json
|
||||
201358d5c3c6b02e02de6c35d0a6e62c6fe565eb data/actuallyadditions/recipes/drill_pattern.json
|
||||
|
@ -86,6 +102,7 @@ bbda1becc270cf13e6b1d8e6d873aafa0951552d data/actuallyadditions/recipes/lens_of_
|
|||
80a2e4f402acab5da96bdf3acd459fce0f930c08 data/actuallyadditions/recipes/quintuple_battery.json
|
||||
c6ff81ba878c02651a9353e490b3a8f9897a5410 data/actuallyadditions/recipes/rice_dough.json
|
||||
bc69015bae99ad4bb1a613a7367469d4401f83ae data/actuallyadditions/recipes/rice_dough_smelting.json
|
||||
36eb3f29269e14cac10af27e6cd070209446a7b8 data/actuallyadditions/recipes/rice_paper.json
|
||||
5958ff2fb37430660fb22012212336320ee83dd8 data/actuallyadditions/recipes/rice_seeds.json
|
||||
f6c73cb2e41a8a21e2fda888b28bf52672b33d2e data/actuallyadditions/recipes/rice_slime.json
|
||||
319b2d0423b79497837f5a3f940011b3bccf09f3 data/actuallyadditions/recipes/rice_slime_potion.json
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"type": "actuallyadditions:copy_nbt_shapeless",
|
||||
"value": {
|
||||
"category": "misc",
|
||||
"ingredients": [
|
||||
{
|
||||
"type": "actuallyadditions:target_nbt",
|
||||
"value": {
|
||||
"tag": "actuallyadditions:drills"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "forge:dyes/black"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "actuallyadditions:drill_black"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"type": "actuallyadditions:copy_nbt_shapeless",
|
||||
"value": {
|
||||
"category": "misc",
|
||||
"ingredients": [
|
||||
{
|
||||
"type": "actuallyadditions:target_nbt",
|
||||
"value": {
|
||||
"tag": "actuallyadditions:drills"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "forge:dyes/blue"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "actuallyadditions:drill_blue"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"type": "actuallyadditions:copy_nbt_shapeless",
|
||||
"value": {
|
||||
"category": "misc",
|
||||
"ingredients": [
|
||||
{
|
||||
"type": "actuallyadditions:target_nbt",
|
||||
"value": {
|
||||
"tag": "actuallyadditions:drills"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "forge:dyes/brown"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "actuallyadditions:drill_brown"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"type": "actuallyadditions:copy_nbt_shapeless",
|
||||
"value": {
|
||||
"category": "misc",
|
||||
"ingredients": [
|
||||
{
|
||||
"type": "actuallyadditions:target_nbt",
|
||||
"value": {
|
||||
"tag": "actuallyadditions:drills"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "forge:dyes/cyan"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "actuallyadditions:drill_cyan"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"type": "actuallyadditions:copy_nbt_shapeless",
|
||||
"value": {
|
||||
"category": "misc",
|
||||
"ingredients": [
|
||||
{
|
||||
"type": "actuallyadditions:target_nbt",
|
||||
"value": {
|
||||
"tag": "actuallyadditions:drills"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "forge:dyes/gray"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "actuallyadditions:drill_gray"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"type": "actuallyadditions:copy_nbt_shapeless",
|
||||
"value": {
|
||||
"category": "misc",
|
||||
"ingredients": [
|
||||
{
|
||||
"type": "actuallyadditions:target_nbt",
|
||||
"value": {
|
||||
"tag": "actuallyadditions:drills"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "forge:dyes/green"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "actuallyadditions:drill_green"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"type": "actuallyadditions:copy_nbt_shapeless",
|
||||
"value": {
|
||||
"category": "misc",
|
||||
"ingredients": [
|
||||
{
|
||||
"type": "actuallyadditions:target_nbt",
|
||||
"value": {
|
||||
"tag": "actuallyadditions:drills"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "forge:dyes/light_blue"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "actuallyadditions:drill_light_blue"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"type": "actuallyadditions:copy_nbt_shapeless",
|
||||
"value": {
|
||||
"category": "misc",
|
||||
"ingredients": [
|
||||
{
|
||||
"type": "actuallyadditions:target_nbt",
|
||||
"value": {
|
||||
"tag": "actuallyadditions:drills"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "forge:dyes/light_gray"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "actuallyadditions:drill_light_gray"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"type": "actuallyadditions:copy_nbt_shapeless",
|
||||
"value": {
|
||||
"category": "misc",
|
||||
"ingredients": [
|
||||
{
|
||||
"type": "actuallyadditions:target_nbt",
|
||||
"value": {
|
||||
"tag": "actuallyadditions:drills"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "forge:dyes/lime"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "actuallyadditions:drill_lime"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"type": "actuallyadditions:copy_nbt_shapeless",
|
||||
"value": {
|
||||
"category": "misc",
|
||||
"ingredients": [
|
||||
{
|
||||
"type": "actuallyadditions:target_nbt",
|
||||
"value": {
|
||||
"tag": "actuallyadditions:drills"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "forge:dyes/magenta"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "actuallyadditions:drill_magenta"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"type": "actuallyadditions:copy_nbt_shapeless",
|
||||
"value": {
|
||||
"category": "misc",
|
||||
"ingredients": [
|
||||
{
|
||||
"type": "actuallyadditions:target_nbt",
|
||||
"value": {
|
||||
"tag": "actuallyadditions:drills"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "forge:dyes/orange"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "actuallyadditions:drill_orange"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"type": "actuallyadditions:copy_nbt_shapeless",
|
||||
"value": {
|
||||
"category": "misc",
|
||||
"ingredients": [
|
||||
{
|
||||
"type": "actuallyadditions:target_nbt",
|
||||
"value": {
|
||||
"tag": "actuallyadditions:drills"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "forge:dyes/pink"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "actuallyadditions:drill_pink"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"type": "actuallyadditions:copy_nbt_shapeless",
|
||||
"value": {
|
||||
"category": "misc",
|
||||
"ingredients": [
|
||||
{
|
||||
"type": "actuallyadditions:target_nbt",
|
||||
"value": {
|
||||
"tag": "actuallyadditions:drills"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "forge:dyes/purple"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "actuallyadditions:drill_purple"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"type": "actuallyadditions:copy_nbt_shapeless",
|
||||
"value": {
|
||||
"category": "misc",
|
||||
"ingredients": [
|
||||
{
|
||||
"type": "actuallyadditions:target_nbt",
|
||||
"value": {
|
||||
"tag": "actuallyadditions:drills"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "forge:dyes/red"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "actuallyadditions:drill_red"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"type": "actuallyadditions:copy_nbt_shapeless",
|
||||
"value": {
|
||||
"category": "misc",
|
||||
"ingredients": [
|
||||
{
|
||||
"type": "actuallyadditions:target_nbt",
|
||||
"value": {
|
||||
"tag": "actuallyadditions:drills"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "forge:dyes/white"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "actuallyadditions:drill_white"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"type": "actuallyadditions:copy_nbt_shapeless",
|
||||
"value": {
|
||||
"category": "misc",
|
||||
"ingredients": [
|
||||
{
|
||||
"type": "actuallyadditions:target_nbt",
|
||||
"value": {
|
||||
"tag": "actuallyadditions:drills"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "forge:dyes/yellow"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "actuallyadditions:drill_yellow"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,11 @@
|
|||
package de.ellpeck.actuallyadditions.data;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyTags;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.config.conditions.BoolConfigCondition;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.RecipeKeepDataShaped;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.RecipeKeepDataShapeless;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.TargetNBTIngredient;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
||||
import de.ellpeck.actuallyadditions.mod.util.NoAdvRecipeOutput;
|
||||
|
@ -18,11 +20,13 @@ import net.minecraft.data.recipes.ShapelessRecipeBuilder;
|
|||
import net.minecraft.data.recipes.SimpleCookingRecipeBuilder;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.tags.TagKey;
|
||||
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.minecraft.world.item.crafting.ShapedRecipe;
|
||||
import net.minecraft.world.item.crafting.ShapelessRecipe;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.neoforged.neoforge.common.Tags;
|
||||
|
@ -238,6 +242,25 @@ public class ItemRecipeGenerator extends RecipeProvider {
|
|||
.define('R', ActuallyItems.DRILL_CORE.get())
|
||||
.define('I', ActuallyItems.ENORI_CRYSTAL.get()).save(recipeOutput);
|
||||
|
||||
// Drill Colors
|
||||
dyeDrill(ActuallyItems.DRILL_BLACK, Tags.Items.DYES_BLACK, recipeOutput);
|
||||
dyeDrill(ActuallyItems.DRILL_RED, Tags.Items.DYES_RED, recipeOutput);
|
||||
dyeDrill(ActuallyItems.DRILL_GREEN, Tags.Items.DYES_GREEN, recipeOutput);
|
||||
dyeDrill(ActuallyItems.DRILL_BROWN, Tags.Items.DYES_BROWN, recipeOutput);
|
||||
dyeDrill(ActuallyItems.DRILL_BLUE, Tags.Items.DYES_BLUE, recipeOutput);
|
||||
dyeDrill(ActuallyItems.DRILL_PURPLE, Tags.Items.DYES_PURPLE, recipeOutput);
|
||||
dyeDrill(ActuallyItems.DRILL_CYAN, Tags.Items.DYES_CYAN, recipeOutput);
|
||||
dyeDrill(ActuallyItems.DRILL_LIGHT_GRAY, Tags.Items.DYES_LIGHT_GRAY, recipeOutput);
|
||||
dyeDrill(ActuallyItems.DRILL_GRAY, Tags.Items.DYES_GRAY, recipeOutput);
|
||||
dyeDrill(ActuallyItems.DRILL_PINK, Tags.Items.DYES_PINK, recipeOutput);
|
||||
dyeDrill(ActuallyItems.DRILL_LIME, Tags.Items.DYES_LIME, recipeOutput);
|
||||
dyeDrill(ActuallyItems.DRILL_YELLOW, Tags.Items.DYES_YELLOW, recipeOutput);
|
||||
dyeDrill(ActuallyItems.DRILL_MAIN, Tags.Items.DYES_LIGHT_BLUE, recipeOutput);
|
||||
dyeDrill(ActuallyItems.DRILL_ORANGE, Tags.Items.DYES_ORANGE, recipeOutput);
|
||||
dyeDrill(ActuallyItems.DRILL_WHITE, Tags.Items.DYES_WHITE, recipeOutput);
|
||||
dyeDrill(ActuallyItems.DRILL_MAGENTA, Tags.Items.DYES_MAGENTA, recipeOutput);
|
||||
|
||||
|
||||
//Drill Core
|
||||
Recipe.shaped(ActuallyItems.DRILL_CORE.get())
|
||||
.pattern("ICI")
|
||||
|
@ -585,6 +608,13 @@ public class ItemRecipeGenerator extends RecipeProvider {
|
|||
addPaxel(consumer, ActuallyItems.NETHERITE_AIOT, Items.NETHERITE_AXE, Items.NETHERITE_PICKAXE, Items.NETHERITE_SWORD, Items.NETHERITE_SHOVEL, Items.NETHERITE_HOE);
|
||||
}
|
||||
|
||||
private static void dyeDrill(DeferredItem<? extends Item> result, TagKey<Item> dyeItem, RecipeOutput recipeOutput) {
|
||||
Recipe.shapeless(result.get())
|
||||
.requires(TargetNBTIngredient.of(ActuallyTags.Items.DRILLS))
|
||||
.requires(dyeItem)
|
||||
.save(new RecipeInjector<ShapelessRecipe>(recipeOutput, RecipeKeepDataShapeless::new), new ResourceLocation(ActuallyAdditions.MODID, "drill_coloring/dye_" + BuiltInRegistries.ITEM.getKey(result.get()).getPath()));
|
||||
}
|
||||
|
||||
public static void addPaxel(RecipeOutput consumer, DeferredItem<? extends Item> output, Item axe, Item pickaxe, Item sword, Item shovel, Item hoe) {
|
||||
Recipe.shapeless(output.get())
|
||||
.requires(axe)
|
||||
|
|
|
@ -68,8 +68,8 @@ import net.neoforged.neoforge.event.server.ServerStoppedEvent;
|
|||
import net.neoforged.neoforge.registries.DeferredHolder;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
import net.neoforged.neoforge.registries.NeoForgeRegistries;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
@ -86,7 +86,7 @@ public class ActuallyAdditions {
|
|||
public static final String GUIFACTORY = "de.ellpeck.actuallyadditions.mod.config.GuiFactory";
|
||||
public static final String DEPS = "required:forge@[14.23.5.2836,);before:craftingtweaks;after:fastbench@[1.3.2,)";
|
||||
|
||||
public static final Logger LOGGER = LogManager.getLogger(NAME);
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(MODID);
|
||||
|
||||
private static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(BuiltInRegistries.ENTITY_TYPE, MODID);
|
||||
public static final Supplier<EntityType<EntityWorm>> ENTITY_WORM = ENTITIES.register("worm", () -> EntityType.Builder.of(EntityWorm::new, MobCategory.MISC).build(MODID + ":worm"));
|
||||
|
|
|
@ -21,6 +21,7 @@ public class ActuallyRecipes {
|
|||
}
|
||||
|
||||
public static final Supplier<RecipeSerializer<?>> KEEP_DATA_SHAPED_RECIPE = SERIALIZERS.register(RecipeKeepDataShaped.NAME, RecipeKeepDataShaped.Serializer::new);
|
||||
public static final Supplier<RecipeSerializer<?>> KEEP_DATA_SHAPELESS_RECIPE = SERIALIZERS.register(RecipeKeepDataShapeless.NAME, RecipeKeepDataShapeless.Serializer::new);
|
||||
public static final Supplier<RecipeSerializer<?>> LASER_RECIPE = SERIALIZERS.register(LaserRecipe.NAME, LaserRecipe.Serializer::new);
|
||||
public static final Supplier<RecipeSerializer<?>> EMPOWERING_RECIPE = SERIALIZERS.register(EmpowererRecipe.NAME, EmpowererRecipe.Serializer::new);
|
||||
public static final Supplier<RecipeSerializer<?>> CRUSHING_RECIPE = SERIALIZERS.register(CrushingRecipe.NAME, CrushingRecipe.Serializer::new);
|
||||
|
|
|
@ -10,31 +10,91 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.crafting;
|
||||
|
||||
// TODO: [port] MOVE TO DATA_GENERATOR
|
||||
@Deprecated
|
||||
public class RecipeKeepDataShapeless {// extends ShapelessOreRecipe {
|
||||
//
|
||||
// private final ItemStack nbtCopyStack;
|
||||
//
|
||||
// public RecipeKeepDataShapeless(ResourceLocation group, ItemStack result, ItemStack nbtCopyStack, Object... recipe) {
|
||||
// super(group, result, recipe);
|
||||
// this.nbtCopyStack = nbtCopyStack;
|
||||
//
|
||||
// RecipeHelper.addRecipe(group.getPath(), this);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public ItemStack getCraftingResult(InventoryCrafting inventory) {
|
||||
// ItemStack stack = super.getCraftingResult(inventory);
|
||||
// if (StackUtil.isValid(stack)) {
|
||||
// for (int i = 0; i < inventory.getSizeInventory(); i++) {
|
||||
// ItemStack input = inventory.getStackInSlot(i);
|
||||
// if (ItemUtil.areItemsEqual(this.nbtCopyStack, input, true)) {
|
||||
// stack.setTagCompound(input.getTagCompound());
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return stack;
|
||||
// }
|
||||
import com.mojang.serialization.Codec;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.inventory.CraftingContainer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.CraftingBookCategory;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraft.world.item.crafting.ShapelessRecipe;
|
||||
import net.neoforged.neoforge.attachment.AttachmentInternals;
|
||||
|
||||
public class RecipeKeepDataShapeless extends ShapelessRecipe {
|
||||
public static String NAME = "copy_nbt_shapeless";
|
||||
public RecipeKeepDataShapeless(String pGroup, CraftingBookCategory pCategory, ItemStack pResult, NonNullList<Ingredient> pIngredients) {
|
||||
super(pGroup, pCategory, pResult, pIngredients);
|
||||
}
|
||||
public RecipeKeepDataShapeless(ShapelessRecipe recipe) {
|
||||
super(recipe.getGroup(), recipe.category(), recipe.getResultItem(RegistryAccess.EMPTY), recipe.getIngredients());
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return ActuallyRecipes.KEEP_DATA_SHAPELESS_RECIPE.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack assemble(CraftingContainer pContainer, RegistryAccess pRegistryAccess) {
|
||||
ItemStack result = super.assemble(pContainer, pRegistryAccess);
|
||||
|
||||
TargetNBTIngredient donorIngredient = null;
|
||||
ItemStack datasource = ItemStack.EMPTY;
|
||||
NonNullList<Ingredient> ingredients = getIngredients();
|
||||
for (Ingredient ingredient : ingredients) {
|
||||
if (ingredient instanceof TargetNBTIngredient) {
|
||||
donorIngredient = (TargetNBTIngredient) ingredient;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (donorIngredient != null && !pContainer.isEmpty()) {
|
||||
for (int i = 0; i < pContainer.getContainerSize(); i++) {
|
||||
final ItemStack item = pContainer.getItem(i);
|
||||
if (!item.isEmpty() && donorIngredient.test(item)) {
|
||||
datasource = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!datasource.isEmpty() && datasource.hasTag())
|
||||
result.setTag(datasource.getTag().copy());
|
||||
else {
|
||||
ActuallyAdditions.LOGGER.info("AA.KeepDataShapeless missing TargetNBTIngredient");
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (!datasource.isEmpty())
|
||||
AttachmentInternals.copyStackAttachments(datasource, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static class Serializer implements RecipeSerializer<RecipeKeepDataShapeless> {
|
||||
public static final Codec<RecipeKeepDataShapeless> CODEC = ShapelessRecipe.Serializer.CODEC.xmap(RecipeKeepDataShapeless::new, $ -> $);
|
||||
@Override
|
||||
public Codec<RecipeKeepDataShapeless> codec() {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeKeepDataShapeless fromNetwork(FriendlyByteBuf pBuffer) {
|
||||
return new RecipeKeepDataShapeless(RecipeSerializer.SHAPELESS_RECIPE.fromNetwork(pBuffer));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toNetwork(net.minecraft.network.FriendlyByteBuf pBuffer, RecipeKeepDataShapeless pRecipe) {
|
||||
try {
|
||||
RecipeSerializer.SHAPELESS_RECIPE.toNetwork(pBuffer, pRecipe);
|
||||
}
|
||||
catch (Exception e) {
|
||||
ActuallyAdditions.LOGGER.info("Failed to serialize " + NAME + " Recipe to packet: " + e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,13 @@ package de.ellpeck.actuallyadditions.mod.crafting;
|
|||
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
@ -34,7 +36,7 @@ public class TargetNBTIngredient extends Ingredient {
|
|||
public static TargetNBTIngredient of(ItemStack itemStack) {
|
||||
return new TargetNBTIngredient(Stream.of(new ItemValue(itemStack)));
|
||||
}
|
||||
public static TargetNBTIngredient of(TagKey tag) {
|
||||
public static TargetNBTIngredient of(@Nonnull TagKey<Item> tag) {
|
||||
return new TargetNBTIngredient(Stream.of(new TagValue(tag)));
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ public net.minecraft.world.damagesource.DamageSources damageTypes
|
|||
public-f net.minecraft.data.recipes.RecipeProvider getName()Ljava/lang/String;
|
||||
public-f net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorList list
|
||||
public net.minecraft.world.item.crafting.ShapedRecipe pattern
|
||||
public net.minecraft.world.item.crafting.ShapelessRecipe$Serializer CODEC # Codec
|
||||
public net.minecraft.world.inventory.InventoryMenu TEXTURE_EMPTY_SLOTS
|
||||
public net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool templates
|
||||
public-f net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool rawTemplates
|
||||
|
|
Loading…
Reference in a new issue