Item action system - mobends/MoBends GitHub Wiki

Intro

Having only one weapon animation set sounds okay for Vanilla, but the modding scene continues to develop new weapon types that would require completely different player movement.

Here's what would be ideal:

  • A fixed amount of action types, but giving the option for modders to extend the list through addons,
  • Having the animations be based on the item action speed (Taking into account the cooldown of the action),
  • For weapons, tuning the combo-cancel-time, so that people that want to deal max damage will also be able to see the combo being performed,

Problems that arise:

  • How to assign each item (vanilla and modded) an animation set.
  • How to make it work out of the box with the most popular mods.

The proposed system aims to implement the needed features while solving their issues.

Vocabulary

Item entry

A unique combination of an item location (e.g. minecraft:diamond_sword) and custom name (can be unspecified, then applies to an unnamed item).

Use action type

Actions that happen when "using" an item (typically right-click). There's a fixed amount of use action types:

  • food - Biting and chewing the item,
  • bow - Drawing a bow-like-item,
  • shield - Holding the item in front of the character like a shield,

Attack action type

Actions that happen when using an item as a weapon (typically left-click):

  • tool - An animation set similar to the vanilla action animation,
  • fists - Fist punching
  • sword - One-handed sword swinging

Configuration

The system allows users to assign use action types and attack action types to specific item entries through either the Forge configuration GUI or through editing the .minecraft/config/mobends.cfg config file directly.

How to configure

general {
	S:AppliedPacks <
	 >
	S:itemUseClassifications <
		# Each line in here is an item classification
		minecraft:apple=food
		some_mod:*gun=bow
	 >
	S:itemAttackClassifications <
		# Each line in here is an item classification
		minecraft:*sword=longsword
		minecraft:golden_sword=sword
	 >
	S:keepArmorAsVanilla <
	 >
	S:keepEntityAsVanilla <
	 >
	B:performSpinAttack=true
	B:showArrowTrails=true
	B:showSwordTrail=true
}

Item classification

To describe how the system should assign action types to specific item entries, use the format:

# Each line describes (in modified RegEx) a specific pattern.
# They can then be used in other patterns with <OTHER_PATTERN>.

ITEM_CLASSIFICATION 	= <ITEM_ENTRY_PATTERN>?=<WEAPON_TYPE>
WEAPON_TYPE		   		= [a-z_]+

Item entry pattern

A string pattern that matches one-or-more item entries. This allows targeting a collection of item entries with one pattern, helping immensely with configuration.

It's format is:

ITEM_ENTRY_PATTERN 		= <DOMAIN>:<ITEM_ID>(\[<CUSTOM_NAME_PATTERN>\])?
DOMAIN 			   		= <ID_PATTERN>
ITEM_ID 		   		= <ID_PATTERN>

CUSTOM_NAME_PATTERN 	= (\*)?(<CUSTOM_NAME_CHAR>+(\*)?)?
ID_PATTERN 		   		= (\*)?(<ID_CHAR>+(\*)?)?

CUSTOM_NAME_CHAR		= [\w\d\s];
ID_CHAR			   		= [a-zA-Z_];

Note: All components are case-sensitive, so the ids Sword, sword and SWORD aren't equal to each other

Examples:

  • minecraft:diamond_sword - Matches the vanilla Diamond Sword, no matter the custom name.
  • minecraft:diamond_sword[] - Matches the vanilla Diamond Sword, but only if it's name is not custom.
  • minecraft:diamond_sword[Flaming Sword] - Matches the vanilla Diamond Sword, but only if it's name is exactly "Flaming Sword".
  • minecraft:*sword[Enchanted *] - Matches any vanilla item that has an ID ending in "sword" and their name begins with "Enchanted ".
  • *:*axe* - Matches any item (from any mod/vanilla) that contains the word "axe" in their item ID.

Example assignments

Here are some common configuration examples:

  • minecraft:golden_sword=fists - Treating the vanilla gold swords as fist gauntlets.
  • =tool - When empty-handed, the player will swing their arms as if they were using a tool.
  • minecraft:apple=sword - Swinging an apple like a sword
⚠️ **GitHub.com Fallback** ⚠️