Munch Munch!
你吃的是什么,你就是什么!看着你的饥饿值条变成你正在享用的食物——美味极了!?
功能:
- 饥饿值图标会根据你正在食用的内容动态变化
- 闲置或进食后会有动画效果,让游戏感觉更加生动
- 通过资源包或模组轻松添加/更改饥饿图标纹理或动画!
目前与 Appleskin 不兼容,除非你在 Appleskin 配置中关闭“显示饱和度叠加层”。我计划为 Munch Munch 添加一个类似(但不完全相同)的功能,以查看饱和度。
如果有任何问题、功能请求或其他任何意见,请随时在 GitHub 上提交。
开发者
Munch Munch 允许轻松为其他模组添加的食物提供新的纹理。如果你的模组想要支持 Munch Munch 的纹理,你需要为以下各项提供六个 9x9 的纹理:
<food_id>_full.png
<food_id>_half.png
<food_id>_empty.png
<food_id>_full_hunger.png
<food_id>_half_hunger.png
<food_id>_empty_hunger.png
这些文件应位于 assets/<mod_namespace>/textures/gui/sprites/hunger/<food_id>/ 目录下。
如果你想添加新动画以扩展默认动画,有一个简单的 API 可供使用。首先需要将 Munch Munch 作为依赖项添加到你的模组中。
build.gradle
repositories {
maven {
url = "https://api.modrinth.com/maven/"
}
}
dependencies {
modImplementation "maven.modrinth:munchmunch:${project.munchmunch_version}"
}
gradle.properties
munchmunch_version=0.1.0
现在 Munch Munch 已经就绪,添加新动画的方法很简单。首先我们创建我们的动画:
public class ExampleAnimation implements HungerAnimation {
@Override
public HungerState getState() {
return HungerState.IDLE; // 这将持续运行直到 HungerState 改变
}
@Override
public Vector2f offset(int slot, float time) {
return new Vector2f(0f, 1f); // 将所有图标向下平移 1px
}
@Override
public Vector2f scale(int slot, float time) {
return new Vector2f(1f, 1f); // 暂时保持缩放比例为默认值
}
@Override
public boolean isFinished() { return true; } // 闲置动画可以在任何时候被覆盖
@Override
public boolean isTimed() { return false; } // 这用于仅持续特定时间的动画
}
这是你所制作的动画可能看起来的一个简单示例。注册此动画所需的一切就是入口点。
public class ModAnimationEntrypoint implements AnimationEntrypoint {
@Override
public void registerAnimations() {
AnimationRegistry.register(ExampleAnimation::new);
}
}
然后在你的 fabric.mod.json 中:
{
entrypoints: {
"munchmunch": [
"com.munchmunch.examplemod.ModAnimationEntrypoint"
]
}
}
如果你的动画需要在内置的 IDLE 和 GAIN(获得饥饿值)状态之外的时间运行,可以简单地通过以下方式添加一个新的 HungerState:
public class ExampleMod implements ClientModInitializer {
public static final HungerState CUSTOM_STATE = register(Identifier.of("examplemod_id", "custom_state"));
}
要使这个自定义 HungerState 生效,需要调用 AnimationSelector.getInstance().setState(HungerState.CUSTOM_STATE),这将播放所有具有 HungerState 为 CUSTOM_STATE 的可用随机动画,直到它们结束。如果它们没有结束,你将必须添加另一个 AnimationSelector.getInstance().setState(),但这次在你希望动画停止时将其设置回 HungerState.IDLE。否则,只需使用 IDLE 动画即可。
Munch Munch!
You are what you eat! See your hunger bar change to the food you're enjoying - delicious! ?
Features:
- Hunger bar icons dynamically change based on what your eating
- Animations when idle or after eating to feel more alive
- Easily add/change hunger icon textures or animations with a resource pack or mod respectively!
Currently incompatible with Appleskin unless you turn off "Show saturation overlay" in the Appleskin config. I am planning to add a similar (but not identical) feature to see saturation in Munch Munch.
If you have any issues, feature requests or anything else please feel free to submit them on the GitHub.
Developers
Munch Munch allows for easily adding new textures for foods added by other mods. If you want your mod to support Munch Munch textures, you will need six 9x9 textures for:
<food_id>_full.png
<food_id>_half.png
<food_id>_empty.png
<food_id>_full_hunger.png
<food_id>_half_hunger.png
<food_id>_empty_hunger.png
These files should be located in assets/<mod_namespace>/textures/gui/sprites/hunger/<food_id>/.
If you want to add new animations to expand on the default ones, there is a simple API allowing you to do so. The first thing necessary is to add Munch Munch as a dependency to your mod.
build.gradle
repositories {
maven {
url = "https://api.modrinth.com/maven/"
}
}
dependencies {
modImplementation "maven.modrinth:munchmunch:${project.munchmunch_version}"
}
gradle.properies
munchmunch_version=0.1.0
Now that Munch Munch works, the way to add new animations is simple. First we will create our animation:
public class ExampleAnimation implements HungerAnimation {
@Override
public HungerState getState() {
return HungerState.IDLE; // This will constantly run until HungerState is changed
}
@Override
public Vector2f offset(int slot, float time) {
return new Vector2f(0f, 1f); // Translate all icons 1px down
}
@Override
public Vector2f scale(int slot, float time) {
return new Vector2f(1f, 1f); // Leave scale as default for now
}
@Override
public boolean isFinished() { return true; } // An idle animation can be overriden whenever necessary
@Override
public boolean isTimed() { return false; } // This is for an animation that only lasts for a certain amount of time
}
This is a simple example of what an animation you make could look like. All that is needed to register this animation is the entrypoint.
public class ModAnimationEntrypoint implements AnimationEntrypoint {
@Override
public void registerAnimations() {
AnimationRegistry.register(ExampleAnimation::new);
}
}
Then in your fabric.mod.json:
{
entrypoints: {
"munchmunch": [
"com.munchmunch.examplemod.ModAnimationEntrypoint"
]
}
}
If your animation needs to run at a different time than the built in IDLE and GAIN (gain hunger) states, a new HungerState can be added simply with:
public class ExampleMod implements ClientModInitializer {
public static final HungerState CUSTOM_STATE = register(Identifier.of("examplemod_id", "custom_state"));
}
To make this custom HungerState be used, it is necessary to call AnimationSelector.getInstance().setState(HungerState.CUSTOM_STATE) which will play a random animation from all available animations with the HungerState of CUSTOM_STATE until they are finished. If they do not end, you will have to add another AnimationSelector.getInstance().setState() but this time set it back to HungerState.IDLE when you want your animation to stop. Otherwise just use the IDLE animation.
评论 0
登录后参与评分
还没有评论,来抢沙发吧