Download Custom Model Predicates — Minecraft Mods — MetaMods

Custom Model Predicates

Active

Downloads

0

Last update

3 years ago
Client
Fabric
Quilt
Forge
Neoforge
Decor
Utils

Custom Model Predicates

Custom Model Predicates is a Forge modification that opens up new possibilities for resource pack creators and mod developers. With it, you can set custom item models based on various parameters: name, NBT tags, stack size, and other characteristics.

How It Works

The mod operates on the principle of model replacement, similar to the resource pack mechanism but with important differences. To start working, you need to specify a special loader in the JSON file: "loader": "custommodelpredicates:custommodelpredicates". This is a mandatory requirement for the mod to recognize it correctly.

Each configuration file must contain a base model that is applied when none of the conditions match. Instead of the standard "overrides" array, a new "predicates" array is used, which is checked BEFORE the standard overrides of vanilla JSON files.

The "predicates" array can contain any number of conditions, but it's recommended to limit their number to reduce performance load. Each condition is checked every time the model is rendered, and the first matching one is returned. The order of conditions matters!

Types of Conditions

Each condition consists of the predicate type, matching requirements, and the model that is returned when there's a match. The list of supported predicates will expand as the mod develops.

Name

The name predicate triggers when an item has a specific name:

{
  "type": "name",
  "name": "aw man",
  "model": {"parent": "item/gunpowder"}
}

Count

The count predicate activates when the item stack size is greater than, less than, or equal to the specified number.

Greater than:

{
  "type": "count",
  "count": ">2",
  "model": {"parent": "custommodelpredicates:item/three_gold_ingots"}
}

Less than:

{
  "type": "count",
  "count": "<3",
  "model": {"parent": "custommodelpredicates:item/two_gold_ingots"}
}

Equal to:

{
  "type": "count",
  "count": "2",
  "model": {"parent": "custommodelpredicates:item/two_gold_ingots"}
}

NBT Tags

The NBT predicate triggers when an item has a specific NBT tag with a particular value or within a specified range.

The mod supports the following NBT tag types: boolean, byte, short, int, long, float, double, and string. All types except boolean and string support comparisons using < and > operators. All types support exact matching. Be careful when exactly matching float/double values.

Example:

{
  "type": "nbt",
  "tag_name": "test_number",
  "tag_type": "int",
  "require": "=1",
  "model": {"parent": "item/diamond"}
}

Mod Identifier

The modid predicate checks whether the specified mod is loaded:

{
  "type": "modid",
  "modid": "examplemod",
  "model": {"parent": "item/iron_ingot"}
}

Basic usage examples are available on GitHub (work in progress).

Frequently Asked Questions

Question: Can this version be ported to older Minecraft versions (below 1.16.5)? Answer: No.

Question: Can the mod work client-side only? Answer: Yes, it even works on vanilla servers.

Question: Can this mod load CIT resource packs? Answer: No, but when the mod reaches maturity, it should be able to provide an equivalent for all of Optifine's predicates.

Question: Can this mod be used in modpacks? Answer: Absolutely, under any conditions.

Project members
tfarecnim

tfarecnim

Created: 27 Dec 2021

ID: 27959