From 87f466e7c440b2bb7786bc892f5880464f3472e6 Mon Sep 17 00:00:00 2001 From: Yuqi154 <1123489751@qq.com> Date: Mon, 23 Sep 2024 13:49:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=8D=E4=BF=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../blockentities/SpringingBlockEntity.java | 24 ++-- .../whispergrove/registers/WGItem.java | 104 ++++++------------ 2 files changed, 48 insertions(+), 80 deletions(-) diff --git a/src/main/java/org/hiedacamellia/whispergrove/content/common/blockentities/SpringingBlockEntity.java b/src/main/java/org/hiedacamellia/whispergrove/content/common/blockentities/SpringingBlockEntity.java index 49e9ca9..1937d16 100644 --- a/src/main/java/org/hiedacamellia/whispergrove/content/common/blockentities/SpringingBlockEntity.java +++ b/src/main/java/org/hiedacamellia/whispergrove/content/common/blockentities/SpringingBlockEntity.java @@ -58,23 +58,33 @@ public void assemble(BlockState state, Level level, BlockPos pos, RandomSource r NonNullList stacks = this.handler.getStacks(); Debug.getLogger().debug("Assembling"); Debug.getLogger().debug("stacks: "+stacks); - ItemStack result = GeneralPrescriptProcessApplier.result(state, stacks.subList(0,8), level); + ItemStack result = GeneralPrescriptProcessApplier.result(state, new ArrayList<>(stacks.subList(0,8)), level); if(result.isEmpty()) { Debug.getLogger().debug("result: "+result); List inputs = new ArrayList<>(stacks.subList(0, 8)); inputs.removeAll(List.of(ItemStack.EMPTY)); + //inputs.forEach(itemStack -> itemStack.setCount(1)); Debug.getLogger().debug("inputs: "+inputs); result = GeneralPrescriptProcessRecipe.ass(inputs, WGItem.SOUP.toStack()); Debug.getLogger().debug("real_result: "+result); } - if(result!=null) { + if (result != null) { stacks.set(9, result); + Debug.getLogger().debug("stacks: "+stacks); Debug.getLogger().debug("set: " + stacks.get(9)); - stacks.forEach(itemStack -> { - int index = stacks.indexOf(itemStack); - if (index != 9) - stacks.set(index, ItemStack.EMPTY); - }); + Debug.getLogger().debug("stacks: "+stacks); + for (int i = 0; i < 9; i++) { + ItemStack stack = stacks.get(i).copy(); + if (!stack.isEmpty()) { + Debug.getLogger().debug("stack: "+stack); + Debug.getLogger().debug("c: "+stack.getCount()); + stack.setCount(stack.getCount()-1); + stacks.set(i,stack); + Debug.getLogger().debug("nc: "+stack.getCount()); + Debug.getLogger().debug("nstack: "+stack); + } + } + Debug.getLogger().debug("out_stacks: "+stacks); this.handler.setStacks(stacks); } } diff --git a/src/main/java/org/hiedacamellia/whispergrove/registers/WGItem.java b/src/main/java/org/hiedacamellia/whispergrove/registers/WGItem.java index 8c7db04..8dbf77d 100644 --- a/src/main/java/org/hiedacamellia/whispergrove/registers/WGItem.java +++ b/src/main/java/org/hiedacamellia/whispergrove/registers/WGItem.java @@ -1,14 +1,14 @@ package org.hiedacamellia.whispergrove.registers; +import net.minecraft.core.component.DataComponents; import net.minecraft.world.food.FoodProperties; -import net.minecraft.world.item.BlockItem; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.Rarity; +import net.minecraft.world.item.*; import net.neoforged.neoforge.registries.DeferredItem; import net.neoforged.neoforge.registries.DeferredRegister; import org.hiedacamellia.whispergrove.WhisperGrove; import org.hiedacamellia.whispergrove.core.entry.BaseItem; import org.hiedacamellia.whispergrove.core.entry.builder.BaseItemBuilder; +import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.Map; @@ -20,23 +20,15 @@ public class WGItem { //黄芪 Radix Astragali //huang qi - public static final DeferredItem MILKVETCH = ITEMS.register("milkvetch", - () -> new BaseItemBuilder() - .lung(0,2,0) - .properties(new Item.Properties().food(new FoodProperties.Builder() - .nutrition(2).saturationModifier(0.8f).alwaysEdible().build())).build()); + public static final DeferredItem MILKVETCH = ITEMS.register("milkvetch", () -> new BaseItemBuilder().lung(0,2,0).properties(new Item.Properties().food(new FoodProperties.Builder().nutrition(2).saturationModifier(0.8f).alwaysEdible().build())).build()); //阳起石 actinolite //yang qi shi - public static final DeferredItem ACTINOLITE = ITEMS.register("actinolite", - () -> new BaseItemBuilder().kidney(0,2,0) - .properties(new Item.Properties().rarity(Rarity.UNCOMMON)).build()); + public static final DeferredItem ACTINOLITE = ITEMS.register("actinolite", () -> new BaseItemBuilder().kidney(0,2,0).properties(new Item.Properties().rarity(Rarity.UNCOMMON)).build()); //紫石英 Fluorite //zi shi ying - public static final DeferredItem FLUORITE = ITEMS.register("fluorite", - () -> new BaseItemBuilder().heart(0,4,0).lung(0,4,0).kidney(0,4,0) - .properties(new Item.Properties().rarity(Rarity.UNCOMMON)).build()); + public static final DeferredItem FLUORITE = ITEMS.register("fluorite", () -> new BaseItemBuilder().heart(0,4,0).lung(0,4,0).kidney(0,4,0).properties(new Item.Properties().rarity(Rarity.UNCOMMON)).build()); //桂枝 Cassia Twig //gui zhi @@ -44,20 +36,15 @@ public class WGItem { //玫瑰花 Rose //mei gui hua - public static final DeferredItem ROSE = ITEMS.register("rose", () -> new BaseItemBuilder() - .liver(0,2,0) - .spleen(0,2,0).build()); + public static final DeferredItem ROSE = ITEMS.register("rose", () -> new BaseItemBuilder().liver(0,2,0).spleen(0,2,0).build()); //熟地黄 Roasted Rehmannia //shu di huang - public static final DeferredItem ROASTED_REHMANNIA = ITEMS.register("roasted_rehmannia", () -> new BaseItemBuilder() - .kidney(0,2,0).liver(0,2,0).build()); + public static final DeferredItem ROASTED_REHMANNIA = ITEMS.register("roasted_rehmannia", () -> new BaseItemBuilder().kidney(0,2,0).liver(0,2,0).build()); //海螵蛸 Roasted Cuttleflsh Bone //hai piao xiao - public static final DeferredItem ROASTED_CUTTLEFLSH_BONE = ITEMS.register("roasted_cuttleflsh_bone", - () -> new BaseItemBuilder().spleen(0,4,0).kidney(0,4,0) - .properties(new Item.Properties().rarity(Rarity.UNCOMMON)).build()); + public static final DeferredItem ROASTED_CUTTLEFLSH_BONE = ITEMS.register("roasted_cuttleflsh_bone", () -> new BaseItemBuilder().spleen(0,4,0).kidney(0,4,0).properties(new Item.Properties().rarity(Rarity.UNCOMMON)).build()); //附子 Prepared Common Monkshood Daughter Root //fu zi @@ -65,59 +52,43 @@ public class WGItem { //丁香 Clove //ding xiang - public static final DeferredItem CLOVE = ITEMS.register("clove", () -> new BaseItemBuilder() - .spleen(0,6,0).lung(0,6,0).kidney(0,6,0).build()); + public static final DeferredItem CLOVE = ITEMS.register("clove", () -> new BaseItemBuilder().spleen(0,6,0).lung(0,6,0).kidney(0,6,0).build()); //五味子 Schisandra chinensis //wu wei zi - public static final DeferredItem SCHISANDRA_CHINENSIS = ITEMS.register("schisandra_chinensis", - () -> new BaseItemBuilder().heart(0,4,0).lung(0,4,0).kidney(0,4,0) - .properties(new Item.Properties().food(new FoodProperties.Builder() - .nutrition(2).saturationModifier(0.8f).alwaysEdible().build())).build()); + public static final DeferredItem SCHISANDRA_CHINENSIS = ITEMS.register("schisandra_chinensis", () -> new BaseItemBuilder().heart(0,4,0).lung(0,4,0).kidney(0,4,0).properties(new Item.Properties().food(new FoodProperties.Builder().nutrition(2).saturationModifier(0.8f).alwaysEdible().build())).build()); //炙甘草 Roasted Liquorice Root //zhi gan cao - public static final DeferredItem PREPARED_LICORICE = ITEMS.register("prepared_licorice", - () -> new BaseItemBuilder().heart(0,4,0).spleen(0,4,0).lung(0,4,0) - .properties(new Item.Properties().rarity(Rarity.UNCOMMON)).build()); + public static final DeferredItem PREPARED_LICORICE = ITEMS.register("prepared_licorice", () -> new BaseItemBuilder().heart(0,4,0).spleen(0,4,0).lung(0,4,0).properties(new Item.Properties().rarity(Rarity.UNCOMMON)).build()); //人参 Panax ginseng //ren shen - public static final DeferredItem GINSENG = ITEMS.register("ginseng", - () -> new BaseItemBuilder().spleen(0,8,0) - .lung(0,8,0).heart(0,8,0).kidney(0,8,0) - .properties(new Item.Properties().food(new FoodProperties.Builder() - .nutrition(2).saturationModifier(0.8f).alwaysEdible().build())).build()); + public static final DeferredItem GINSENG = ITEMS.register("ginseng", () -> new BaseItemBuilder().properties(new Item.Properties().food(new FoodProperties.Builder().nutrition(2).saturationModifier(0.8f).alwaysEdible().build())).build()); //茯苓 Poria //fu ling - public static final DeferredItem PORIA_COCOS = ITEMS.register("poria_cocos", - () -> new BaseItemBuilder().spleen(0,0,1).properties(new Item.Properties().rarity(Rarity.UNCOMMON)).build()); + public static final DeferredItem PORIA_COCOS = ITEMS.register("poria_cocos", () -> new BaseItemBuilder().spleen(0,0,1).properties(new Item.Properties().rarity(Rarity.UNCOMMON)).build()); //麦芽 Malt //mai ya - public static final DeferredItem MALT = ITEMS.register("malt", () -> new BaseItemBuilder() - .spleen(0,0,1).build()); + public static final DeferredItem MALT = ITEMS.register("malt", () -> new BaseItemBuilder().spleen(0,0,1).build()); //阿胶 Donkey-hide Glue //e jiao - public static final DeferredItem DONKEY_HIDE_GELATIN = ITEMS.register("donkey_hide_gelatin", - () -> new BaseItemBuilder().lung(0,0,1).liver(0,0,1).kidney(0,0,1).build()); + public static final DeferredItem DONKEY_HIDE_GELATIN = ITEMS.register("donkey_hide_gelatin", () -> new BaseItemBuilder().lung(0,0,1).liver(0,0,1).kidney(0,0,1).build()); //煅龙骨 Fossilizid //duan long gu - public static final DeferredItem CALCINED_DRAGON_BONE = ITEMS.register("calcined_dragon_bone", - () -> new BaseItemBuilder().heart(0,0,1).liver(0,0,1).kidney(0,0,1).build()); + public static final DeferredItem CALCINED_DRAGON_BONE = ITEMS.register("calcined_dragon_bone", () -> new BaseItemBuilder().heart(0,0,1).liver(0,0,1).kidney(0,0,1).build()); //合欢皮 Albizzia Bark //he huan pi - public static final DeferredItem ALBIZIA_BARK = ITEMS.register("albizia_bark", - () -> new BaseItemBuilder().heart(0,0,1).liver(0,0,1).spleen(0,0,1).build()); + public static final DeferredItem ALBIZIA_BARK = ITEMS.register("albizia_bark", () -> new BaseItemBuilder().heart(0,0,1).liver(0,0,1).spleen(0,0,1).build()); //竹叶 bamboo leaf //zhu ye - public static final DeferredItem BAMBOO_LEAF = ITEMS.register("bamboo_leaf", - () -> new BaseItemBuilder().heart(2,0,0).build()); + public static final DeferredItem BAMBOO_LEAF = ITEMS.register("bamboo_leaf", () -> new BaseItemBuilder().heart(2,0,0).build()); //龙胆草 Gentian //long dan cao @@ -130,8 +101,7 @@ public class WGItem { //竹茹 Bamboo Shavings //zhu gu - public static final DeferredItem BAMBOO_SHAVINGS = ITEMS.register("bamboo_shavings", - () -> new BaseItemBuilder().heart(4,0,0).lung(4,0,0).build()); + public static final DeferredItem BAMBOO_SHAVINGS = ITEMS.register("bamboo_shavings", () -> new BaseItemBuilder().heart(4,0,0).lung(4,0,0).build()); // //昆布 kelp // //kun bu @@ -139,39 +109,31 @@ public class WGItem { //寒水石 Gypsum //han shui shi - public static final DeferredItem GYPSUM_RUBRUM = ITEMS.register("gypsum_rubrum", - () -> new BaseItemBuilder().heart(6,0,0).kidney(6,0,0).build()); + public static final DeferredItem GYPSUM_RUBRUM = ITEMS.register("gypsum_rubrum", () -> new BaseItemBuilder().heart(6,0,0).kidney(6,0,0).build()); //龟板胶 Glue of Tortoise Plastron //gui ban jiao - public static final DeferredItem TORTOISE_PLASTRON_GLUE = ITEMS.register("tortoise_plastron_glue", - () -> new BaseItemBuilder().liver(4,0,0).kidney(4,0,0).build()); + public static final DeferredItem TORTOISE_PLASTRON_GLUE = ITEMS.register("tortoise_plastron_glue", () -> new BaseItemBuilder().liver(4,0,0).kidney(4,0,0).build()); //生地黄 Drying Rehmannia Root //sheng di huang - public static final DeferredItem DRYING_REHMANNIA = ITEMS.register("drying_rehmannia", () -> new BaseItemBuilder() - .heart(6,0,0).liver(6,0,0).kidney(6,0,0).build()); + public static final DeferredItem DRYING_REHMANNIA = ITEMS.register("drying_rehmannia", () -> new BaseItemBuilder().heart(6,0,0).liver(6,0,0).kidney(6,0,0).build()); //生甘草 Drying Licorice Root //sheng gan cao - public static final DeferredItem DRYING_LICORICE = ITEMS.register("drying_licorice", - () -> new BaseItemBuilder().heart(0,0,1).spleen(0,0,1).lung(0,0,1).build()); + public static final DeferredItem DRYING_LICORICE = ITEMS.register("drying_licorice", () -> new BaseItemBuilder().heart(0,0,1).spleen(0,0,1).lung(0,0,1).build()); //黄芪切片 Sliced Radix Astragali //Sliced huang qi - public static final DeferredItem SLICED_MILKVETCH = ITEMS.register("sliced_milkvetch", - () -> new BaseItemBuilder().properties(new Item.Properties().food(new FoodProperties.Builder() - .nutrition(2).saturationModifier(0.8f).alwaysEdible().build())).build()); + public static final DeferredItem SLICED_MILKVETCH = ITEMS.register("sliced_milkvetch", () -> new BaseItemBuilder().properties(new Item.Properties().food(new FoodProperties.Builder().nutrition(2).saturationModifier(0.8f).alwaysEdible().build())).build()); //桂枝切片 Sliced Cassia Twig //Sliced Gui Zhi - public static final DeferredItem SLICED_CASSIA_TWIG = ITEMS.register("sliced_cassia_twig", () -> new BaseItemBuilder() - .heart(0,6,0).lung(0,6,0).build()); + public static final DeferredItem SLICED_CASSIA_TWIG = ITEMS.register("sliced_cassia_twig", () -> new BaseItemBuilder().heart(0,6,0).lung(0,6,0).build()); //桂枝皮 Cassia Twig Bark //Gui zhi pi - public static final DeferredItem CASSIA_TWIG_BARK = ITEMS.register("cassia_twig_bark", () -> new BaseItemBuilder() - .heart(0,16,0).spleen(0,16,0).liver(0,16,0).kidney(0,16,0).build()); + public static final DeferredItem CASSIA_TWIG_BARK = ITEMS.register("cassia_twig_bark", () -> new BaseItemBuilder().heart(0,16,0).spleen(0,16,0).liver(0,16,0).kidney(0,16,0).build()); //地黄 Rehmannia Root //di huang @@ -182,14 +144,11 @@ public class WGItem { //人参切片 Sliced Panax ginseng //Sliced ren shen - public static final DeferredItem SLICED_GINSENG = ITEMS.register("sliced_ginseng", - () -> new BaseItemBuilder().properties(new Item.Properties().food(new FoodProperties.Builder() - .nutrition(2).saturationModifier(0.8f).alwaysEdible().build())).build()); + public static final DeferredItem SLICED_GINSENG = ITEMS.register("sliced_ginseng", () -> new BaseItemBuilder().spleen(0,8,0).lung(0,8,0).heart(0,8,0).kidney(0,8,0).properties(new Item.Properties().food(new FoodProperties.Builder().nutrition(2).saturationModifier(0.8f).alwaysEdible().build())).build()); //龙胆草切片 SLiced Gentian //sliced long dan cao - public static final DeferredItem SLICED_GENTIAN = ITEMS.register("sliced_gentian", - () -> new BaseItemBuilder().liver(8,0,0).build()); + public static final DeferredItem SLICED_GENTIAN = ITEMS.register("sliced_gentian", () -> new BaseItemBuilder().liver(8,0,0).build()); //墨鱼骨 Cuttleflsh Bone //mo yu gu @@ -197,15 +156,14 @@ public class WGItem { //熟附片 Roasted Prepared Common Monkshood Daughter Root //shu fu pian - public static final DeferredItem SHU_FU_PIAN = ITEMS.register("roasted_monkshood", () -> new BaseItemBuilder() - .heart(0,12,0).kidney(0,12,0).spleen(0,12,0).build()); + public static final DeferredItem SHU_FU_PIAN = ITEMS.register("roasted_monkshood", () -> new BaseItemBuilder().heart(0,12,0).kidney(0,12,0).spleen(0,12,0).build()); //骨头碎片 bone fragment //bone fragment public static final DeferredItem BONE_FRAGMENT = ITEMS.register("bone_fragment", () -> new BaseItemBuilder().build()); - public static final DeferredItem SOUP = ITEMS.register("soup", () -> new BaseItemBuilder().build()); + public static final DeferredItem SOUP = ITEMS.register("soup", () -> new BaseItem(new Item.Properties().food(new FoodProperties.Builder().nutrition(4).saturationModifier(1.5f).alwaysEdible().build())){@Override public @NotNull UseAnim getUseAnimation(@NotNull ItemStack stack) {return UseAnim.DRINK;}}); public static final String[] CROP_NAMES = {"rehmannia", "licorice", "milkvetch", "gentian", "ginseng" };