finish food effect function

This commit is contained in:
yyc12345 2021-05-02 17:51:13 +08:00
parent 2b2b4c811d
commit 5d82c23a41
7 changed files with 200 additions and 72 deletions

View File

@ -2,9 +2,7 @@
All code are under MIT LICENSE. But all assets, such as image, belong to miHoYo and miHoYo hold its copyright.
This mod will **not** add Homeworld system into Minecraft. Minecraft has been a openworld game now. Minecraft player can use various block to create what they want. Add Homeworld system is entirely useless and if you still want Furniture, you can add other Minecraft mods to implement it.
And, this mod is not designed to implement Genshin Impact in Minecraft entirely. Some features has been adapted to Minecraft self. If you need full Genshin Impact experiences, you can leave now.
This mod is not designed to implement Genshin Impact in Minecraft entirely. Some features has been adapted to Minecraft self. If you need full Genshin Impact experiences, you can leave now. This mod will focus on the promotion of exploration experience and all items in this mod will become renewable and can be produced massively via redstone machine.
This mod have ability to do:
@ -33,6 +31,7 @@ This mod have ability to do:
* Different characters have their own Vision.
* Full element reaction system
* Element reaction system will be implemented but some mechanism will become more simple.
* Extraordinary foods. Foods can give you not only Genshin Impact effects, but also some precious Minecraft potion effects.
This mod can not do:
@ -40,4 +39,6 @@ This mod can not do:
* Let your Steve model become the character who are in Genshin Impact. Please install other mod to solve this if you need.
* No new mobs added. (May add in future)
* Pay money.
* Homeworld system
* Minecraft has been a openworld game now. Minecraft player can use various block to create what they want. Add Homeworld system is entirely useless and if you still want Furniture, you can add other Minecraft mods to implement it.

View File

@ -127,8 +127,8 @@
|珍珠翡翠白玉汤|抗性提升2300s|||
|松茸酿肉卷|瞬间治疗2|||
|水晶虾|瞬间治疗2生命恢复230s|||
|莲子禽蛋羹|速度2900s急迫2900s|||
|白汁时蔬烩肉|速度2900s急迫2900s|||
|莲子禽蛋羹|速度2900s|||
|白汁时蔬烩肉|速度2900s|||
|山珍热卤面|饱和250s|||
|金丝虾球|||√|
|稠汁蔬菜炖肉|||√|
@ -138,18 +138,18 @@
|蟹黄豆腐|||√|
|干炒鱼河|瞬间治疗2生命恢复230s|||
|嘟嘟莲海鲜羹|抗性提升3300s|||
|蜜酱胡萝卜煎肉|速度3900s急迫3900s跳跃提升3900s|||
|蜜酱胡萝卜煎肉|速度3900s跳跃提升3900s|||
|烤蘑菇披萨|瞬间治疗3生命恢复330s|||
|蒙德土豆饼|瞬间治疗3|||
|「堆高高」|力量3300s|||
|中原杂碎|速度3900s急迫3900s跳跃提升3900s|||
|中原杂碎|速度3900s跳跃提升3900s|||
|水煮黑背鲈|瞬间治疗3生命恢复330s|||
|松鼠鱼|瞬间治疗3|||
|来来菜|力量3300s|||
|黄油松茸|力量3300s|||
|冷肉拼盘|力量3300s|||
|轻策农家菜|力量3300s|||
|风神杂烩菜|速度3900s急迫3900s跳跃提升3900s|||
|风神杂烩菜|速度3900s急迫3900s|||
|蟹黄火腿焗时蔬|||√|
|北地苹果焖肉|瞬间治疗3|||
|冒险家蛋堡|力量3300s|||
@ -175,9 +175,9 @@
* 来源肯德基特殊活动的菜肴将永远不会被加入Mod也不会有对应的效果
* 目前所有原神中复活角色,抵抗严寒的食物暂无对应,正在考虑如何对应
* 饱食度回复值为其星级
* 饥饿度回复值为其`星级*2`,饱和度回复值为`星级*3`
* Minecraft和Genshin Impact的药水效果等级取决于食物的星级
* 攻击力和暴击率词条目前转化为力量效果
* 护盾强效转化为伤害吸收,防御力提升转化为抗性提升
* 恢复体力转化为饱和,减少体力消耗转化为速度和急迫,如果词条中还可以减少攀爬体力,则加入跳跃提升
* 恢复体力转化为饱和;减少体力消耗中,冲刺转化为速度急迫,攀爬转化为跳跃提升,其余转化为急迫
* 立即回复生命转化为瞬间治疗,之后一段时间内的恢复转化为生命恢复

View File

@ -8,13 +8,21 @@ import net.minecraft.util.Identifier;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.FoodComponent.Builder;
import net.minecraft.util.Rarity;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.item.BlockItem;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item;
import net.minecraft.item.ItemConvertible;
import static net.minecraft.block.ComposterBlock.ITEM_TO_LEVEL_INCREASE_CHANCE;
import java.util.EnumSet;
import net.yyc12345.teyvatcraft.items.SeedItem;
import net.yyc12345.teyvatcraft.items.TeyvatFoodItem;
import net.yyc12345.teyvatcraft.items.TeyvatFoodType;
public class ItemsManager {
public static final ItemGroup ITEMGROUP_MISC = FabricItemGroupBuilder.build(new Identifier("teyvatcraft", "misc"), () -> new ItemStack(Items.NETHER_STAR));
@ -271,68 +279,68 @@ public class ItemsManager {
public static final Item DENDROCIDE_POTION = new Item(new FabricItemSettings().group(ITEMGROUP_POTION));
// foods
public static final Item CHICKEN_MUSHROOM_SKEWER = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item TEYVAT_FRIED_EGG = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item STEAK = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item RADISH_VEGGIE_SOUP = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item MONDSTADT_GRILLED_FISH = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item MORA_MEAT = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item STIR_FRIED_FILET = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item MINT_JELLY = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item GRILLED_TIGER_FISH = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item FLAMING_RED_BOLOGNESE = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item SWEET_MADAME = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item NORTHERN_SMOKED_CHICKEN = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item TEA_BREAK_PANCAKE = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item FRIED_RADISH_BALLS = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item SATISFYING_SALAD = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item FISHERMANS_TOAST = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item ALMOND_TOFU = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item JUEYUN_CHILI_CHICKEN = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item JEWELRY_SOUP = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item MATSUTAKE_MEAT_ROLLS = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item CRYSTAL_SHRIMP = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item LOTUS_SEED_AND_BIRD_EGG_SOUP = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item CREAM_STEW = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item NOODLES_WITH_MOUNTAIN_DELICACIES = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item GOLDEN_SHRIMP_BALLS = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item GOULASH = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item VEGETARIAN_ABALONE = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item STONE_HARBOR_DELICACIES = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item MINT_SALAD = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item CRAB_ROE_TOFU = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item STIR_FRIED_FISH_NOODLES = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item CALLA_LILY_SEAFOOD_SOUP = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item STICKY_HONEY_ROAST = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item MUSHROOM_PIZZA = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item MONDSTADT_HASH_BROWN = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item PILE_EM_UP = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item ZHONGYUAN_CHOP_SUEY = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item BLACK_BACK_PERCH_STEW = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item SQUIRREL_FISH = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item COME_AND_GET_IT = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item SAUTEED_MATSUTAKE = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item COLD_CUT_PLATTER = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item QINGCE_STIR_FRY = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item BARBATOS_RATATOUILLE = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item CRAB_HAM_VEGGIE_BAKE = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item NORTHERN_APPLE_STEW = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item ADVENTURERS_BREAKFAST_SANDWICH = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item LOTUS_FLOWER_CRISP = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item TRIPLE_LAYERED_CONSOMME = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item BAMBOO_SHOOT_SOUP = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item UNIVERSAL_PEACE = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item JUEYUN_GUOBA = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item SUNSHINE_SPRAT = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item FULLMOON_EGG = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item CRISPY_POTATO_SHRIMP_PLATTER = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item CURED_PORK_DRY_HOTPOT = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item MINTY_MEAT_ROLLS = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item JADE_PARCELS = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item GOLDEN_CRAB = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item MOON_PIE = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item TIANSHU_MEAT = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item ADEPTUS_TEMPTATION = new Item(new FabricItemSettings().group(ITEMGROUP_FOOD));
public static final Item CHICKEN_MUSHROOM_SKEWER = new TeyvatFoodItem(ITEMGROUP_FOOD, 1, EnumSet.of(TeyvatFoodType.RestoreHP));
public static final Item TEYVAT_FRIED_EGG = new TeyvatFoodItem(ITEMGROUP_FOOD, 1, EnumSet.of(TeyvatFoodType.Revive));
public static final Item STEAK = new TeyvatFoodItem(ITEMGROUP_FOOD, 1, EnumSet.of(TeyvatFoodType.Revive));
public static final Item RADISH_VEGGIE_SOUP = new TeyvatFoodItem(ITEMGROUP_FOOD, 1, EnumSet.of(TeyvatFoodType.RestoreHP, TeyvatFoodType.GraduallyRestoreHP));
public static final Item MONDSTADT_GRILLED_FISH = new TeyvatFoodItem(ITEMGROUP_FOOD, 1, EnumSet.of(TeyvatFoodType.Revive));
public static final Item MORA_MEAT = new TeyvatFoodItem(ITEMGROUP_FOOD, 1, EnumSet.of(TeyvatFoodType.Revive));
public static final Item STIR_FRIED_FILET = new TeyvatFoodItem(ITEMGROUP_FOOD, 1, EnumSet.of(TeyvatFoodType.Revive));
public static final Item MINT_JELLY = new TeyvatFoodItem(ITEMGROUP_FOOD, 1, EnumSet.of(TeyvatFoodType.RestoreHP));
public static final Item GRILLED_TIGER_FISH = new TeyvatFoodItem(ITEMGROUP_FOOD, 1, EnumSet.of(TeyvatFoodType.RestoreHP));
public static final Item FLAMING_RED_BOLOGNESE = new TeyvatFoodItem(ITEMGROUP_FOOD, 2, EnumSet.of(TeyvatFoodType.RestoreHP, TeyvatFoodType.GraduallyRestoreHP));
public static final Item SWEET_MADAME = new TeyvatFoodItem(ITEMGROUP_FOOD, 2, EnumSet.of(TeyvatFoodType.RestoreHP));
public static final Item NORTHERN_SMOKED_CHICKEN = new TeyvatFoodItem(ITEMGROUP_FOOD, 2, EnumSet.of(TeyvatFoodType.RestoreStamina));
public static final Item TEA_BREAK_PANCAKE = new TeyvatFoodItem(ITEMGROUP_FOOD, 2, EnumSet.of(TeyvatFoodType.Revive));
public static final Item FRIED_RADISH_BALLS = new TeyvatFoodItem(ITEMGROUP_FOOD, 2, EnumSet.of(TeyvatFoodType.IncreaseATK_CRIT_DMG));
public static final Item SATISFYING_SALAD = new TeyvatFoodItem(ITEMGROUP_FOOD, 2, EnumSet.of(TeyvatFoodType.IncreaseATK_CRIT_DMG));
public static final Item FISHERMANS_TOAST = new TeyvatFoodItem(ITEMGROUP_FOOD, 2, EnumSet.of(TeyvatFoodType.IncreaseDEF));
public static final Item ALMOND_TOFU = new TeyvatFoodItem(ITEMGROUP_FOOD, 2, EnumSet.of(TeyvatFoodType.IncreaseATK_CRIT_DMG));
public static final Item JUEYUN_CHILI_CHICKEN = new TeyvatFoodItem(ITEMGROUP_FOOD, 2, EnumSet.of(TeyvatFoodType.IncreaseATK_CRIT_DMG));
public static final Item JEWELRY_SOUP = new TeyvatFoodItem(ITEMGROUP_FOOD, 2, EnumSet.of(TeyvatFoodType.IncreaseDEF));
public static final Item MATSUTAKE_MEAT_ROLLS = new TeyvatFoodItem(ITEMGROUP_FOOD, 2, EnumSet.of(TeyvatFoodType.RestoreHP));
public static final Item CRYSTAL_SHRIMP = new TeyvatFoodItem(ITEMGROUP_FOOD, 2, EnumSet.of(TeyvatFoodType.RestoreHP, TeyvatFoodType.GraduallyRestoreHP));
public static final Item LOTUS_SEED_AND_BIRD_EGG_SOUP = new TeyvatFoodItem(ITEMGROUP_FOOD, 2, EnumSet.of(TeyvatFoodType.DecreaseStamina_Sprint));
public static final Item CREAM_STEW = new TeyvatFoodItem(ITEMGROUP_FOOD, 2, EnumSet.of(TeyvatFoodType.DecreaseStamina_Sprint));
public static final Item NOODLES_WITH_MOUNTAIN_DELICACIES = new TeyvatFoodItem(ITEMGROUP_FOOD, 2, EnumSet.of(TeyvatFoodType.RestoreStamina));
public static final Item GOLDEN_SHRIMP_BALLS = new TeyvatFoodItem(ITEMGROUP_FOOD, 3, EnumSet.of(TeyvatFoodType.Revive));
public static final Item GOULASH = new TeyvatFoodItem(ITEMGROUP_FOOD, 2, EnumSet.of(TeyvatFoodType.DecreaseColdAccumulation));
public static final Item VEGETARIAN_ABALONE = new TeyvatFoodItem(ITEMGROUP_FOOD, 2, EnumSet.of(TeyvatFoodType.Revive));
public static final Item STONE_HARBOR_DELICACIES = new TeyvatFoodItem(ITEMGROUP_FOOD, 2, EnumSet.of(TeyvatFoodType.IncreaseATK_CRIT_DMG));
public static final Item MINT_SALAD = new TeyvatFoodItem(ITEMGROUP_FOOD, 2, EnumSet.of(TeyvatFoodType.IncreaseATK_CRIT_DMG));
public static final Item CRAB_ROE_TOFU = new TeyvatFoodItem(ITEMGROUP_FOOD, 2, EnumSet.of(TeyvatFoodType.Revive));
public static final Item STIR_FRIED_FISH_NOODLES = new TeyvatFoodItem(ITEMGROUP_FOOD, 2, EnumSet.of(TeyvatFoodType.RestoreHP, TeyvatFoodType.GraduallyRestoreHP));
public static final Item CALLA_LILY_SEAFOOD_SOUP = new TeyvatFoodItem(ITEMGROUP_FOOD, 3, EnumSet.of(TeyvatFoodType.IncreaseDEF));
public static final Item STICKY_HONEY_ROAST = new TeyvatFoodItem(ITEMGROUP_FOOD, 3, EnumSet.of(TeyvatFoodType.DecreaseStamina_Climb, TeyvatFoodType.DecreaseStamina_Sprint));
public static final Item MUSHROOM_PIZZA = new TeyvatFoodItem(ITEMGROUP_FOOD, 3, EnumSet.of(TeyvatFoodType.RestoreHP, TeyvatFoodType.GraduallyRestoreHP));
public static final Item MONDSTADT_HASH_BROWN = new TeyvatFoodItem(ITEMGROUP_FOOD, 3, EnumSet.of(TeyvatFoodType.RestoreHP));
public static final Item PILE_EM_UP = new TeyvatFoodItem(ITEMGROUP_FOOD, 3, EnumSet.of(TeyvatFoodType.IncreaseATK_CRIT_DMG));
public static final Item ZHONGYUAN_CHOP_SUEY = new TeyvatFoodItem(ITEMGROUP_FOOD, 3, EnumSet.of(TeyvatFoodType.DecreaseStamina_Climb, TeyvatFoodType.DecreaseStamina_Sprint));
public static final Item BLACK_BACK_PERCH_STEW = new TeyvatFoodItem(ITEMGROUP_FOOD, 3, EnumSet.of(TeyvatFoodType.RestoreHP, TeyvatFoodType.GraduallyRestoreHP));
public static final Item SQUIRREL_FISH = new TeyvatFoodItem(ITEMGROUP_FOOD, 3, EnumSet.of(TeyvatFoodType.RestoreHP));
public static final Item COME_AND_GET_IT = new TeyvatFoodItem(ITEMGROUP_FOOD, 3, EnumSet.of(TeyvatFoodType.IncreaseATK_CRIT_DMG));
public static final Item SAUTEED_MATSUTAKE = new TeyvatFoodItem(ITEMGROUP_FOOD, 3, EnumSet.of(TeyvatFoodType.IncreaseATK_CRIT_DMG));
public static final Item COLD_CUT_PLATTER = new TeyvatFoodItem(ITEMGROUP_FOOD, 3, EnumSet.of(TeyvatFoodType.IncreaseATK_CRIT_DMG));
public static final Item QINGCE_STIR_FRY = new TeyvatFoodItem(ITEMGROUP_FOOD, 3, EnumSet.of(TeyvatFoodType.IncreaseATK_CRIT_DMG));
public static final Item BARBATOS_RATATOUILLE = new TeyvatFoodItem(ITEMGROUP_FOOD, 3, EnumSet.of(TeyvatFoodType.DecreaseStamina_Misc, TeyvatFoodType.DecreaseStamina_Sprint));
public static final Item CRAB_HAM_VEGGIE_BAKE = new TeyvatFoodItem(ITEMGROUP_FOOD, 3, EnumSet.of(TeyvatFoodType.Revive));
public static final Item NORTHERN_APPLE_STEW = new TeyvatFoodItem(ITEMGROUP_FOOD, 3, EnumSet.of(TeyvatFoodType.RestoreHP));
public static final Item ADVENTURERS_BREAKFAST_SANDWICH = new TeyvatFoodItem(ITEMGROUP_FOOD, 3, EnumSet.of(TeyvatFoodType.IncreaseATK_CRIT_DMG));
public static final Item LOTUS_FLOWER_CRISP = new TeyvatFoodItem(ITEMGROUP_FOOD, 3, EnumSet.of(TeyvatFoodType.IncreaseDEF));
public static final Item TRIPLE_LAYERED_CONSOMME = new TeyvatFoodItem(ITEMGROUP_FOOD, 3, EnumSet.of(TeyvatFoodType.IncreaseShieldStrength));
public static final Item BAMBOO_SHOOT_SOUP = new TeyvatFoodItem(ITEMGROUP_FOOD, 3, EnumSet.of(TeyvatFoodType.RestoreHP, TeyvatFoodType.GraduallyRestoreHP));
public static final Item UNIVERSAL_PEACE = new TeyvatFoodItem(ITEMGROUP_FOOD, 3, EnumSet.of(TeyvatFoodType.RestoreHP));
public static final Item JUEYUN_GUOBA = new TeyvatFoodItem(ITEMGROUP_FOOD, 3, EnumSet.of(TeyvatFoodType.IncreaseATK_CRIT_DMG));
public static final Item SUNSHINE_SPRAT = new TeyvatFoodItem(ITEMGROUP_FOOD, 3, EnumSet.of(TeyvatFoodType.IncreaseShieldStrength));
public static final Item FULLMOON_EGG = new TeyvatFoodItem(ITEMGROUP_FOOD, 3, EnumSet.of(TeyvatFoodType.Revive));
public static final Item CRISPY_POTATO_SHRIMP_PLATTER = new TeyvatFoodItem(ITEMGROUP_FOOD, 3, EnumSet.of(TeyvatFoodType.RestoreHP, TeyvatFoodType.GraduallyRestoreHP));
public static final Item CURED_PORK_DRY_HOTPOT = new TeyvatFoodItem(ITEMGROUP_FOOD, 3, EnumSet.of(TeyvatFoodType.IncreaseATK_CRIT_DMG));
public static final Item MINTY_MEAT_ROLLS = new TeyvatFoodItem(ITEMGROUP_FOOD, 3, EnumSet.of(TeyvatFoodType.DecreaseStamina_Misc, TeyvatFoodType.DecreaseStamina_Sprint));
public static final Item JADE_PARCELS = new TeyvatFoodItem(ITEMGROUP_FOOD, 4, EnumSet.of(TeyvatFoodType.IncreaseATK_CRIT_DMG));
public static final Item GOLDEN_CRAB = new TeyvatFoodItem(ITEMGROUP_FOOD, 4, EnumSet.of(TeyvatFoodType.IncreaseDEF));
public static final Item MOON_PIE = new TeyvatFoodItem(ITEMGROUP_FOOD, 4, EnumSet.of(TeyvatFoodType.IncreaseShieldStrength, TeyvatFoodType.IncreaseDEF));
public static final Item TIANSHU_MEAT = new TeyvatFoodItem(ITEMGROUP_FOOD, 4, EnumSet.of(TeyvatFoodType.IncreaseATK_CRIT_DMG));
public static final Item ADEPTUS_TEMPTATION = new TeyvatFoodItem(ITEMGROUP_FOOD, 5, EnumSet.of(TeyvatFoodType.IncreaseATK_CRIT_DMG));
// register func
private static void registerAsCompostableItem(String name, Item it, Boolean isSeed) {
@ -341,6 +349,24 @@ public class ItemsManager {
else ITEM_TO_LEVEL_INCREASE_CHANCE.put(it, 0.3f);
}
private static FoodComponent getTeyvatFoodComponent(int star, EnumSet<TeyvatFoodType> types) {
Builder foodComponent = (new FoodComponent.Builder()).hunger(2 * star).saturationModifier(3.0F * star).alwaysEdible();
if (types.contains(TeyvatFoodType.Revive)) ;
if (types.contains(TeyvatFoodType.DecreaseColdAccumulation)) ;
if (types.contains(TeyvatFoodType.DecreaseStamina_Sprint)) foodComponent.statusEffect(new StatusEffectInstance(StatusEffects.SPEED, 900 * 20, star - 1), 1.0F);
if (types.contains(TeyvatFoodType.DecreaseStamina_Climb)) foodComponent.statusEffect(new StatusEffectInstance(StatusEffects.JUMP_BOOST, 900 * 20, star - 1), 1.0F);
if (types.contains(TeyvatFoodType.DecreaseStamina_Misc)) foodComponent.statusEffect(new StatusEffectInstance(StatusEffects.HASTE, 900 * 20, star - 1), 1.0F);
if (types.contains(TeyvatFoodType.RestoreHP)) foodComponent.statusEffect(new StatusEffectInstance(StatusEffects.INSTANT_HEALTH, 1, star - 1), 1.0F);
if (types.contains(TeyvatFoodType.GraduallyRestoreHP)) foodComponent.statusEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 30 * 20, star - 1), 1.0F);
if (types.contains(TeyvatFoodType.RestoreStamina)) foodComponent.statusEffect(new StatusEffectInstance(StatusEffects.SATURATION, 50 * 20, star - 1), 1.0F);
if (types.contains(TeyvatFoodType.IncreaseATK_CRIT_DMG)) foodComponent.statusEffect(new StatusEffectInstance(StatusEffects.STRENGTH, 300 * 20, star - 1), 1.0F);
if (types.contains(TeyvatFoodType.IncreaseDEF)) foodComponent.statusEffect(new StatusEffectInstance(StatusEffects.RESISTANCE, 300 * 20, star - 1), 1.0F);
if (types.contains(TeyvatFoodType.IncreaseShieldStrength)) foodComponent.statusEffect(new StatusEffectInstance(StatusEffects.ABSORPTION, 300 * 20, star - 1), 1.0F);
return foodComponent.build();
}
/*
private static void registerCompostableItem(float levelIncreaseChance, ItemConvertible item) {
ITEM_TO_LEVEL_INCREASE_CHANCE.put(item.asItem(), levelIncreaseChance);

View File

@ -0,0 +1,82 @@
package net.yyc12345.teyvatcraft.items;
import java.util.EnumSet;
import java.util.List;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.FoodComponent.Builder;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.Rarity;
import net.minecraft.world.World;
public class TeyvatFoodItem extends Item {
public TeyvatFoodItem(ItemGroup ig, int star, EnumSet<TeyvatFoodType> types) {
super(new FabricItemSettings().group(ig).rarity(getRarity(star)).food(getTeyvatFoodComponent(star, types)));
mStar = star;
mEffect = types;
}
private int mStar;
private EnumSet<TeyvatFoodType> mEffect;
private static FoodComponent getTeyvatFoodComponent(int star, EnumSet<TeyvatFoodType> types) {
Builder foodComponent = (new FoodComponent.Builder()).hunger(2 * star).saturationModifier(3.0F * star).alwaysEdible();
if (types.contains(TeyvatFoodType.Revive)) ;
if (types.contains(TeyvatFoodType.DecreaseColdAccumulation)) ;
if (types.contains(TeyvatFoodType.DecreaseStamina_Sprint)) foodComponent.statusEffect(new StatusEffectInstance(StatusEffects.SPEED, 900 * 20, star - 1), 1.0F);
if (types.contains(TeyvatFoodType.DecreaseStamina_Climb)) foodComponent.statusEffect(new StatusEffectInstance(StatusEffects.JUMP_BOOST, 900 * 20, star - 1), 1.0F);
if (types.contains(TeyvatFoodType.DecreaseStamina_Misc)) foodComponent.statusEffect(new StatusEffectInstance(StatusEffects.HASTE, 900 * 20, star - 1), 1.0F);
if (types.contains(TeyvatFoodType.RestoreHP)) foodComponent.statusEffect(new StatusEffectInstance(StatusEffects.INSTANT_HEALTH, 1, star - 1), 1.0F);
if (types.contains(TeyvatFoodType.GraduallyRestoreHP)) foodComponent.statusEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 30 * 20, star - 1), 1.0F);
if (types.contains(TeyvatFoodType.RestoreStamina)) foodComponent.statusEffect(new StatusEffectInstance(StatusEffects.SATURATION, 50 * 20, star - 1), 1.0F);
if (types.contains(TeyvatFoodType.IncreaseATK_CRIT_DMG)) foodComponent.statusEffect(new StatusEffectInstance(StatusEffects.STRENGTH, 300 * 20, star - 1), 1.0F);
if (types.contains(TeyvatFoodType.IncreaseDEF)) foodComponent.statusEffect(new StatusEffectInstance(StatusEffects.RESISTANCE, 300 * 20, star - 1), 1.0F);
if (types.contains(TeyvatFoodType.IncreaseShieldStrength)) foodComponent.statusEffect(new StatusEffectInstance(StatusEffects.ABSORPTION, 300 * 20, star - 1), 1.0F);
return foodComponent.build();
}
private static Rarity getRarity(int star) {
switch (star) {
case 1:
case 2:
case 3:
return Rarity.COMMON;
case 4:
return Rarity.UNCOMMON;
case 5:
return Rarity.RARE;
default:
return Rarity.COMMON;
}
}
@Override
public void appendTooltip(ItemStack itemStack, World world, List<Text> tooltip, TooltipContext tooltipContext) {
tooltip.add(new TranslatableText("item.teyvatcraft.misc.foodStar", mStar).formatted(Formatting.ITALIC, Formatting.GRAY));
if (mEffect.contains(TeyvatFoodType.Revive)) ;
if (mEffect.contains(TeyvatFoodType.DecreaseColdAccumulation)) ;
if (mEffect.contains(TeyvatFoodType.DecreaseStamina_Sprint)) tooltip.add(new TranslatableText("effect.minecraft.speed").formatted(Formatting.ITALIC, Formatting.GRAY));
if (mEffect.contains(TeyvatFoodType.DecreaseStamina_Climb)) tooltip.add(new TranslatableText("effect.minecraft.jump_boost").formatted(Formatting.ITALIC, Formatting.GRAY));
if (mEffect.contains(TeyvatFoodType.DecreaseStamina_Misc)) tooltip.add(new TranslatableText("effect.minecraft.haste").formatted(Formatting.ITALIC, Formatting.GRAY));
if (mEffect.contains(TeyvatFoodType.RestoreHP)) tooltip.add(new TranslatableText("effect.minecraft.instant_health").formatted(Formatting.ITALIC, Formatting.GRAY));
if (mEffect.contains(TeyvatFoodType.GraduallyRestoreHP)) tooltip.add(new TranslatableText("effect.minecraft.regeneration").formatted(Formatting.ITALIC, Formatting.GRAY));
if (mEffect.contains(TeyvatFoodType.RestoreStamina)) tooltip.add(new TranslatableText("effect.minecraft.saturation").formatted(Formatting.ITALIC, Formatting.GRAY));
if (mEffect.contains(TeyvatFoodType.IncreaseATK_CRIT_DMG)) tooltip.add(new TranslatableText("effect.minecraft.strength").formatted(Formatting.ITALIC, Formatting.GRAY));
if (mEffect.contains(TeyvatFoodType.IncreaseDEF)) tooltip.add(new TranslatableText("effect.minecraft.resistance").formatted(Formatting.ITALIC, Formatting.GRAY));
if (mEffect.contains(TeyvatFoodType.IncreaseShieldStrength)) tooltip.add(new TranslatableText("effect.minecraft.absorption").formatted(Formatting.ITALIC, Formatting.GRAY));
}
}

View File

@ -0,0 +1,15 @@
package net.yyc12345.teyvatcraft.items;
public enum TeyvatFoodType {
Revive,
DecreaseStamina_Sprint,
DecreaseStamina_Climb,
DecreaseStamina_Misc,
RestoreHP,
GraduallyRestoreHP,
RestoreStamina,
IncreaseATK_CRIT_DMG,
IncreaseDEF,
IncreaseShieldStrength,
DecreaseColdAccumulation
}

View File

@ -7,6 +7,8 @@
"itemGroup.teyvatcraft.potion": "Genshin Impact - Potion",
"itemGroup.teyvatcraft.food": "Genshin Impact - Food",
"item.teyvatcraft.misc.foodStar": "Food level: %d",
"item.teyvatcraft.gnosis_dendro": "Dendro Gnosis",
"item.teyvatcraft.gnosis_hydro": "Hydro Gnosis",
"item.teyvatcraft.gnosis_pyro": "Pyro Gnosis",

View File

@ -7,6 +7,8 @@
"itemGroup.teyvatcraft.potion": "原神 - 药水",
"itemGroup.teyvatcraft.food": "原神 - 食物",
"item.teyvatcraft.misc.foodStar": "食物等级:%d",
"item.teyvatcraft.gnosis_dendro": "神之心 - 草",
"item.teyvatcraft.gnosis_hydro": "神之心 - 水",
"item.teyvatcraft.gnosis_pyro": "神之心 - 火",