Skip to content

Commit

Permalink
ready to alpha test (#5)
Browse files Browse the repository at this point in the history
* update translation

* update icon

* configure milk irremovable mechanic to use tag system

* rename module

* clear unused import

* rename module

* add potion system

* rename

* fix name

* update develop status
  • Loading branch information
FCWYzzr authored Aug 16, 2024
1 parent d017a7e commit e98dc5a
Show file tree
Hide file tree
Showing 40 changed files with 437 additions and 106 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ __餐事__(餐食、蚕食、餐室、餐市,或者随便你怎么读)是
可以防止获得者获得不高于剧毒抗性等级的中毒效果<br/>
- ##### 黑暗浸染 - _不详之瓶_ <br/>
大幅提高移速、攻速、伤害、击退抗性与幸运<br/>
- ##### 女神的眷顾 - _金苹果_ <br/>
- ##### 女神的恩惠 - _金苹果_ <br/>
依据等级翻倍可能的战利品<br/>
- ##### Mojang的眷顾 - _附魔金苹果_ <br/>
- ##### 游戏的恩惠 - _附魔金苹果_ <br/>
依据等级大幅翻倍可能的战利品,在女神的眷顾计算后计算。挖掘方块有概率阻止方块掉落<br/>
- ##### 膻骚 - _(烤)羊肉_ <br/>
阻止生物以膻骚的生物作为攻击目标,生物会逃离膻骚的生物<br/>
Expand Down Expand Up @@ -122,9 +122,9 @@ __餐事__(餐食、蚕食、餐室、餐市,或者随便你怎么读)是
---
# 状态

| 开发阶段 | 下一阶段 |
|------|----------|
| 绘制贴图 | Alpha 测试 |
| 开发阶段 | 下一阶段 |
|----------|--------------|
| Alpha 测试 | 完善介绍、wiki,宣传 |

---

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package indi.fcwyzzr.minecraft.food_talks.common.mixin.tweaks.mechanic;

import indi.fcwyzzr.minecraft.food_talks.common.effects.beneficial.Happy;
import indi.fcwyzzr.minecraft.food_talks.common.mob_effect.beneficial.Happy;
import net.minecraft.world.Difficulty;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.food.FoodData;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package indi.fcwyzzr.minecraft.food_talks.common.mixin.tweaks.mechanic;

import indi.fcwyzzr.minecraft.food_talks.api.common.item.CompoundFood;
import indi.fcwyzzr.minecraft.food_talks.common.effects.harmful.Anorexia;
import indi.fcwyzzr.minecraft.food_talks.common.mob_effect.harmful.Anorexia;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.InteractionResultHolder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package indi.fcwyzzr.minecraft.food_talks.common.mixin.tweaks.mechanic;

import indi.fcwyzzr.minecraft.food_talks.common.effects.beneficial.ProjectileImmune;
import indi.fcwyzzr.minecraft.food_talks.common.effects.harmful.Overweight;
import indi.fcwyzzr.minecraft.food_talks.common.mob_effect.beneficial.ProjectileImmune;
import indi.fcwyzzr.minecraft.food_talks.common.mob_effect.harmful.Overweight;
import net.minecraft.core.Holder;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.entity.Entity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package indi.fcwyzzr.minecraft.food_talks.common.mixin.tweaks.mechanic;

import indi.fcwyzzr.minecraft.food_talks.common.ai.goal.ConditionallyAvoidEntityGoal;
import indi.fcwyzzr.minecraft.food_talks.common.effects.beneficial.Smelly;
import indi.fcwyzzr.minecraft.food_talks.common.mob_effect.beneficial.Smelly;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package indi.fcwyzzr.minecraft.f_lib.registry

import indi.fcwyzzr.minecraft.food_talks.FoodTalks
import indi.fcwyzzr.minecraft.food_talks.toRegistryName
import indi.fcwyzzr.minecraft.food_talks.toResourceLocation
import net.minecraft.core.Holder
Expand All @@ -9,6 +10,7 @@ import net.minecraft.core.registries.Registries
import net.minecraft.resources.ResourceKey
import net.minecraft.world.effect.MobEffect
import net.minecraft.world.effect.MobEffectCategory
import net.minecraft.world.effect.MobEffectInstance
import net.neoforged.neoforge.registries.DeferredHolder

abstract class FMobEffect(
Expand All @@ -27,4 +29,20 @@ abstract class FMobEffect(
Registries.MOB_EFFECT, location
)
)

fun createNewInstance(duration: Int, amplifier: Int = 0) = MobEffectInstance(
holder,
duration,
amplifier
)

fun createDefaultInstance() = createNewInstance(duration)
fun createExtendedInstance() = createNewInstance(extendedDuration)
fun createUpgradedInstance() = createNewInstance(upgradedDuration, 1)

companion object {
private const val duration = 3 * 60 * FoodTalks.TPS
private const val extendedDuration = 8 * 60 * FoodTalks.TPS
private const val upgradedDuration = 90 * FoodTalks.TPS
}
}
37 changes: 37 additions & 0 deletions src/main/kotlin/indi/fcwyzzr/minecraft/f_lib/registry/FPotion.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package indi.fcwyzzr.minecraft.f_lib.registry

import indi.fcwyzzr.minecraft.food_talks.toRegistryName
import indi.fcwyzzr.minecraft.food_talks.toResourceLocation
import net.minecraft.core.Holder
import net.minecraft.core.Registry
import net.minecraft.core.registries.BuiltInRegistries
import net.minecraft.core.registries.Registries
import net.minecraft.resources.ResourceKey
import net.minecraft.resources.ResourceLocation
import net.minecraft.world.effect.MobEffect
import net.minecraft.world.effect.MobEffectCategory
import net.minecraft.world.effect.MobEffectInstance
import net.minecraft.world.item.alchemy.Potion
import net.minecraft.world.item.alchemy.Potions
import net.neoforged.neoforge.registries.DeferredHolder

class FPotion(
vararg effects: MobEffectInstance,
val name: String? = null
): Potion(name, *effects), FRegistry<Potion> {
override val registryKey: ResourceKey<out Registry<Potion>> = BuiltInRegistries.POTION.key()

override val location: ResourceLocation = name
?.toRegistryName()
?.toResourceLocation()
?: effects[0]
.effect
.key!!
.location()

override val holder: Holder<Potion> = DeferredHolder.create(
ResourceKey.create(
Registries.POTION, location
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import indi.fcwyzzr.minecraft.f_lib.registry.FItem
import indi.fcwyzzr.minecraft.f_lib.utils.buildDataComponentPatch
import indi.fcwyzzr.minecraft.food_talks.FoodTalks
import indi.fcwyzzr.minecraft.food_talks.common.data_component.compound_food.FoodItemProperties
import indi.fcwyzzr.minecraft.food_talks.common.effects.harmful.Anorexia
import indi.fcwyzzr.minecraft.food_talks.common.mob_effect.harmful.Anorexia
import net.minecraft.core.Holder
import net.minecraft.core.component.DataComponentPatch
import net.minecraft.core.component.DataComponents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package indi.fcwyzzr.minecraft.food_talks.common.event.gameplay

import indi.fcwyzzr.minecraft.food_talks.FoodTalks
import indi.fcwyzzr.minecraft.food_talks.api.common.item.CompoundFood
import indi.fcwyzzr.minecraft.food_talks.common.effects.harmful.Anorexia
import indi.fcwyzzr.minecraft.food_talks.common.mob_effect.harmful.Anorexia
import net.neoforged.api.distmarker.Dist
import net.neoforged.bus.api.SubscribeEvent
import net.neoforged.fml.common.EventBusSubscriber
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package indi.fcwyzzr.minecraft.food_talks.common.event.gameplay
import com.google.common.math.IntMath.pow
import indi.fcwyzzr.minecraft.food_talks.FoodTalks
import indi.fcwyzzr.minecraft.food_talks.api.common.item.CompoundFood
import indi.fcwyzzr.minecraft.food_talks.common.effects.beneficial.*
import indi.fcwyzzr.minecraft.food_talks.common.effects.harmful.*
import indi.fcwyzzr.minecraft.food_talks.common.mob_effect.beneficial.*
import indi.fcwyzzr.minecraft.food_talks.common.mob_effect.harmful.*
import indi.fcwyzzr.minecraft.food_talks.common.registries.ToothacheDamage
import indi.fcwyzzr.minecraft.food_talks.common.registries.from
import indi.fcwyzzr.minecraft.food_talks.common.registries.milkIrremovable
import net.minecraft.server.level.ServerLevel
import net.minecraft.server.level.ServerPlayer
import net.minecraft.util.Mth
Expand Down Expand Up @@ -39,13 +40,7 @@ object EffectHandler {
@SubscribeEvent
fun entityTryToRemoveEffect(event: Remove){
if (event.cure != null)
if (event.effect.`is`(Anorexia.location)
|| event.effect.`is`(Gout.location)
|| event.effect.`is`(Overweight.location)
|| event.effect.`is`(Toothache.location)
|| event.effect.`is`(Vomit.location)
)

if (event.effect.`is`(milkIrremovable))
event.isCanceled = true
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
package indi.fcwyzzr.minecraft.food_talks.common.event
package indi.fcwyzzr.minecraft.food_talks.common.event.lifecycle

import indi.fcwyzzr.minecraft.f_lib.registry.doRegister
import indi.fcwyzzr.minecraft.food_talks.FoodTalks
import indi.fcwyzzr.minecraft.food_talks.common.block.BottleBlock
import indi.fcwyzzr.minecraft.food_talks.common.block.PlateBlock
import indi.fcwyzzr.minecraft.food_talks.common.block.entity.BottleBlockEntity
import indi.fcwyzzr.minecraft.food_talks.common.block.entity.PlateBlockEntity
import indi.fcwyzzr.minecraft.food_talks.common.data_component.SimpleDataComponents
import indi.fcwyzzr.minecraft.food_talks.common.data_component.compound_food.FoodItemProperties
import indi.fcwyzzr.minecraft.food_talks.common.data_component.compound_food.FoodStackProperties
import indi.fcwyzzr.minecraft.food_talks.common.effects.beneficial.*
import indi.fcwyzzr.minecraft.food_talks.common.effects.harmful.*
import indi.fcwyzzr.minecraft.food_talks.common.food.item_reward.*
import indi.fcwyzzr.minecraft.food_talks.common.food.tag_punishment.*
import indi.fcwyzzr.minecraft.food_talks.common.item.Cocktail
import indi.fcwyzzr.minecraft.food_talks.common.item.Plate
import indi.fcwyzzr.minecraft.food_talks.common.item.Sandwich
import indi.fcwyzzr.minecraft.food_talks.common.registries.foodItemRewardRegistry
import indi.fcwyzzr.minecraft.food_talks.common.registries.foodTagPunishmentRegistry
import indi.fcwyzzr.minecraft.food_talks.toRegistryName
Expand All @@ -33,13 +24,31 @@ import net.neoforged.neoforge.registries.RegisterEvent
value = [Dist.CLIENT, Dist.DEDICATED_SERVER],
bus = EventBusSubscriber.Bus.MOD
)
object FTLifecycle {
object CustomRegister {
@SubscribeEvent
fun registerRegistry(event: NewRegistryEvent){
event.register(foodItemRewardRegistry)
event.register(foodTagPunishmentRegistry)
}

@SubscribeEvent
fun registerComponents(event: RegisterEvent){
event.register(BuiltInRegistries.DATA_COMPONENT_TYPE.key()){
it.register(FoodItemProperties.location, FoodItemProperties.type)
it.register(FoodStackProperties.location, FoodStackProperties.type)

it.register(
"SandwichLayer".toRegistryName().toResourceLocation(),
SimpleDataComponents.SandwichLayer
)

it.register(
"PossibleEffectList".toRegistryName().toResourceLocation(),
SimpleDataComponents.PossibleEffectList
)
}
}

@SubscribeEvent
fun registerFoodItemReward(event: RegisterEvent){
// drinks
Expand Down Expand Up @@ -94,71 +103,14 @@ object FTLifecycle {

@SubscribeEvent
fun registerFoodTagPunishment(event: RegisterEvent){
event doRegister drinksMakeYouDizzy
// event doRegister drinksMakeYouDizzy
event doRegister fleshesMakeYouVomit
event doRegister fruitsMakeYouToothache
event doRegister meatsMakeYouGout
event doRegister snacksMakeYouOverweight
event doRegister soupMakeYouHungry
// event doRegister soupMakeYouHungry
event doRegister staplesGiveYouAnorexia
event doRegister vegetablesMakeYouWeak
event doRegister drugsPoisonYou
}

@SubscribeEvent
fun registerEffect(event: RegisterEvent){
event doRegister Anorexia
event doRegister Gout
event doRegister Toothache
event doRegister Vomit
event doRegister Overweight

event doRegister PoisonResistance
event doRegister DarknessInfused
event doRegister GoddessGrace
event doRegister GameGrace
event doRegister Smelly
event doRegister Happy
event doRegister ProjectileImmune
event doRegister Starving
event doRegister JackHead
}

@SubscribeEvent
fun registerBlocks(event: RegisterEvent){
event doRegister BottleBlock
event doRegister PlateBlock
}

@SubscribeEvent
fun registerBlockEntities(event: RegisterEvent){
event doRegister BottleBlockEntity
event doRegister PlateBlockEntity
}

@SubscribeEvent
fun registerItems(event: RegisterEvent){
event doRegister Cocktail
event doRegister Plate
event doRegister Sandwich
}

@SubscribeEvent
fun registerComponents(event: RegisterEvent){
event.register(BuiltInRegistries.DATA_COMPONENT_TYPE.key()){
it.register(FoodItemProperties.location, FoodItemProperties.type)
it.register(FoodStackProperties.location, FoodStackProperties.type)

it.register(
"SandwichLayer".toRegistryName().toResourceLocation(),
SimpleDataComponents.SandwichLayer
)

it.register(
"PossibleEffectList".toRegistryName().toResourceLocation(),
SimpleDataComponents.PossibleEffectList
)
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package indi.fcwyzzr.minecraft.food_talks.common.event.lifecycle

import indi.fcwyzzr.minecraft.f_lib.registry.doRegister
import indi.fcwyzzr.minecraft.food_talks.FoodTalks
import indi.fcwyzzr.minecraft.food_talks.common.mob_effect.beneficial.*
import indi.fcwyzzr.minecraft.food_talks.common.mob_effect.harmful.*
import indi.fcwyzzr.minecraft.food_talks.common.mob_effect.harmful.Vomit
import indi.fcwyzzr.minecraft.food_talks.common.registries.deferred.*
import net.neoforged.api.distmarker.Dist
import net.neoforged.bus.api.SubscribeEvent
import net.neoforged.fml.common.EventBusSubscriber
import net.neoforged.neoforge.registries.RegisterEvent

@Suppress("DuplicatedCode")
@EventBusSubscriber(
modid = FoodTalks.MOD_ID,
value = [Dist.CLIENT, Dist.DEDICATED_SERVER],
bus = EventBusSubscriber.Bus.MOD
)
object MobEffectRegister {

@SubscribeEvent
fun registerEffect(event: RegisterEvent){
event doRegister Anorexia
event doRegister Gout
event doRegister Toothache
event doRegister Vomit
event doRegister Overweight

event doRegister PoisonResistance
event doRegister DarknessInfused
event doRegister GoddessGrace
event doRegister GameGrace
event doRegister Smelly
event doRegister Happy
event doRegister ProjectileImmune
event doRegister Starving
event doRegister JackHead
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package indi.fcwyzzr.minecraft.food_talks.common.event.lifecycle

import indi.fcwyzzr.minecraft.f_lib.registry.doRegister
import indi.fcwyzzr.minecraft.food_talks.FoodTalks
import indi.fcwyzzr.minecraft.food_talks.common.block.BottleBlock
import indi.fcwyzzr.minecraft.food_talks.common.block.PlateBlock
import indi.fcwyzzr.minecraft.food_talks.common.block.entity.BottleBlockEntity
import indi.fcwyzzr.minecraft.food_talks.common.block.entity.PlateBlockEntity
import indi.fcwyzzr.minecraft.food_talks.common.item.Cocktail
import indi.fcwyzzr.minecraft.food_talks.common.item.Plate
import indi.fcwyzzr.minecraft.food_talks.common.item.Sandwich
import net.neoforged.api.distmarker.Dist
import net.neoforged.bus.api.SubscribeEvent
import net.neoforged.fml.common.EventBusSubscriber
import net.neoforged.neoforge.registries.RegisterEvent

@EventBusSubscriber(
modid = FoodTalks.MOD_ID,
value = [Dist.CLIENT, Dist.DEDICATED_SERVER],
bus = EventBusSubscriber.Bus.MOD
)
object PrimaryElementRegister {
@SubscribeEvent
fun registerBlocks(event: RegisterEvent){
event doRegister BottleBlock
event doRegister PlateBlock
}

@SubscribeEvent
fun registerBlockEntities(event: RegisterEvent){
event doRegister BottleBlockEntity
event doRegister PlateBlockEntity
}

@SubscribeEvent
fun registerItems(event: RegisterEvent){
event doRegister Cocktail
event doRegister Plate
event doRegister Sandwich
}
}
Loading

0 comments on commit e98dc5a

Please sign in to comment.