跳到正文

Mana Attributes

作者:TheRedBrain

A small API that adds a mana system controlled by entity attributes.

收藏

截图

介绍

中文介绍正在准备中,下面暂时显示原文。

Mana Attributes

This API adds a mana system controlled by entity attributes.

Default implementation

LivingEntities can have up to _manaattributes:max_mana_ amounts of mana. Mana is regenerated by _manaattributes:mana_regeneration_ every _manaattributes:mana_tick_threshold_ ticks.

When mana is reduced, regeneration is stopped for _manaattributes:mana_regeneration_delay_threshold_ ticks.

When mana is <= 0, regeneration is stopped for _manaattributes:depleted_mana_regeneration_delay_threshold_ ticks.

_manaattributes:reserved_mana_ describes the percentage amount of maximum mana that is currently not available.

Default attribute values

  • _manaattributes:max_mana_: 0
  • _manaattributes:mana_regeneration_: 0
  • _manaattributes:mana_tick_threshold_: 20
  • _manaattributes:mana_regeneration_delay_threshold_: 20
  • _manaattributes:depleted_mana_regeneration_delay_threshold_: 60
  • _manaattributes:reserved_mana_: 0

All default values for players can be set in the server config.

Customization

The client config allows customizing the HUD element.

Using the mana system

Java

Casting a “LivingEntity” to the “ManaUsingEntity” interface gives access to all relevant methods.

Data packs

Mana Attributes implements several data driven methods to interact with the current mana value of an entity.

  • the “manaattributes:add_mana” enchantment effect allows adding a defined amount to the current mana
  • the “manaattributes:mana_using_entity” entity sub predicate passes when the current mana of an entity matches the defined range

Example

This enchantment reduces mana of the attacker by 2, as long as the attacker has at least 5 mana:

{
	"anvil_cost": 1,
	"description": {
		"translate": "enchantment.manaattributes.test"
	},
	"effects": {
		"minecraft:post_attack": [
			{
				"affected": "attacker",
				"effect": {
					"type": "manaattributes:add_mana",
					"amount": {
						"type": "minecraft:linear",
						"base": -2.0,
						"per_level_above_first": -2.0
					}
				},
				"enchanted": "attacker",
				"requirements": {
					"condition": "minecraft:entity_properties",
					"entity": "direct_attacker",
					"predicate": {
						"type_specific": {
							"type": "manaattributes:mana_using_entity",
							"mana_amount": {
								"min": 5.0
							}
						}
					}
				}
			}
		]
	},
	"max_cost": {
		"base": 25,
		"per_level_above_first": 8
	},
	"max_level": 1,
	"min_cost": {
		"base": 5,
		"per_level_above_first": 8
	},
	"slots": [
		"hand"
	],
	"supported_items": "#minecraft:swords",
	"weight": 5
}

常见问题

Mana Attributes 支持哪些 Minecraft 版本?

Mana Attributes 支持 Minecraft Java 版 1.20.1–26.1.2,共 8 个版本,可用的加载器:Fabric。下载时注意选择和你游戏版本一致的文件。

Mana Attributes 怎么安装?

先用 PCL2 或 HMCL 启动器安装对应版本的 Fabric,再把下载的 .jar 文件放进游戏目录的 mods 文件夹,重新启动游戏即可。开启了版本隔离的,mods 文件夹在 versions/版本名 下面。运行环境:客户端和服务端都要装。

评论

登录后评论和评分

TheRedBrain 的其他作品

查看全部 →