-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
So this is no longer ArmorModelPredicate, because it doesn't change the model. It is now ArmorRenderLib because it is a small bit of reusable code that extends the FabricAPI ArmorRenderer to allow the dynamic changing of textures and colors of any armor item. Still in beta because while I could technically add support for predicates at this point (such as item tags), I have no need yet so I'm choosing to reduce bloat.
- Loading branch information
1 parent
9e51687
commit 4b27632
Showing
26 changed files
with
303 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,41 @@ | ||
# ArmorModelPredicate | ||
Adds the armor model predicates to Minecraft using Fabric Mixins. | ||
<img src="img/logo.png" alt="Armor Render Lib" height="100" /> | ||
<hr /> | ||
|
||
[![GitHub license](https://img.shields.io/github/license/CleverNucleus/ArmorRenderLib?style=flat-square)](https://github.com/CleverNucleus/ArmorRenderLib/blob/main/LICENSE) | ||
[![GitHub stars](https://img.shields.io/github/stars/CleverNucleus/ArmorRenderLib?style=flat-square)](https://github.com/CleverNucleus/ArmorRenderLib/stargazers) | ||
[![GitHub forks](https://img.shields.io/github/forks/CleverNucleus/ArmorRenderLib?style=flat-square)](https://github.com/CleverNucleus/ArmorRenderLib/network) | ||
[![GitHub issues](https://img.shields.io/github/issues/CleverNucleus/ArmorRenderLib?style=flat-square)](https://github.com/CleverNucleus/ArmorRenderLib/issues) | ||
|
||
Armor Render Lib is a lightweight extension library to Fabric API's fabric-rendering-v1 [ArmorRenderer](https://github.com/FabricMC/fabric/tree/1.18.2/fabric-rendering-v1). Since the Fabric API implementation is quite abstract, a more targeted implementation is needed for some specific use cases. These use cases are present across more than one of my mods, so in the spirit of code reuse this library was created. It is robust, using only a few very targeted mixins and is fully compatible with Cosmetic Armor and GeckoLib. | ||
|
||
### Use | ||
|
||
Armor Render Lib adds armor render layers. These are objects containing a dynamic texture location, color and glint boolean that render armor for an item (or items). They are roughly equivalent to Fabric API's [ArmorRenderer#renderPart](https://github.com/FabricMC/fabric/blob/f14603e8624d4cb192846321c429cc00c9ef6f55/fabric-rendering-v1/src/main/java/net/fabricmc/fabric/api/client/rendering/v1/ArmorRenderer.java#L69), but the texture, color and glint can be dynamically specified based on the `ItemStack`, `LivingEntity` and `EquipmentSlot`. | ||
|
||
They should be registered like so: | ||
|
||
```java | ||
public class ExampleMod implements ClientModInitializer { | ||
private static ArmorRenderProvider render(ItemStack stack, LivingEntity entity, EquipmentSlot slot) { | ||
// Dynamic texture path | ||
String texture = "examplemod:textures/model/armor/example_chestplate.png"; | ||
|
||
// Dynamic color | ||
int color = 0xFF00FF; | ||
|
||
return data -> data.accept(texture, color, stack.hasGlint()); | ||
} | ||
|
||
@Override | ||
public void onInitializeClient() { | ||
ArmorRenderLib.register(ExampleMod::render, Items.IRON_CHESTPLATE); | ||
} | ||
} | ||
``` | ||
|
||
### Notes | ||
|
||
- An item can have multiple different armor render layers registered to it. | ||
- Multiple items can have the same armor render layer registered to them. | ||
- Registering a render layer to a vanilla item (or other armor item) overrides the default armor rendering. | ||
- This means that the texture, color and/or enchantment glint of vanilla armor can be modified. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,11 @@ | ||
# Done to increase the memory available to gradle. | ||
org.gradle.jvmargs=-Xmx1G | ||
|
||
# Fabric Properties | ||
# check these on https://fabricmc.net/develop | ||
minecraft_version=1.18.1 | ||
yarn_mappings=1.18.1+build.22 | ||
loader_version=0.12.12 | ||
minecraft_version=1.18.2 | ||
yarn_mappings=1.18.2+build.3 | ||
loader_version=0.14.6 | ||
|
||
# Mod Properties | ||
mod_version = 0.1.0 | ||
maven_group = com.github.clevernucleus | ||
archives_base_name = armor-model-predicate | ||
mod_version = 0.1.1 | ||
maven_group = com.github.clevernucleus | ||
archives_base_name = armorrenderlib | ||
|
||
# Dependencies | ||
|
||
fabric_version=0.55.1+1.18.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
59 changes: 0 additions & 59 deletions
59
...com/github/clevernucleus/armormodelpredicate/api/ArmorModelPredicateProviderRegistry.java
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
src/main/java/com/github/clevernucleus/armormodelpredicate/impl/ArmorModelPredicate.java
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
src/main/java/com/github/clevernucleus/armormodelpredicate/impl/ArmorModelProvider.java
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
src/main/java/com/github/clevernucleus/armormodelpredicate/impl/InvertedFunction.java
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
src/main/java/com/github/clevernucleus/armormodelpredicate/impl/InvertedProvider.java
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
src/main/java/com/github/clevernucleus/armormodelpredicate/impl/WrapperFunction.java
This file was deleted.
Oops, something went wrong.
67 changes: 0 additions & 67 deletions
67
...in/java/com/github/clevernucleus/armormodelpredicate/mixin/ArmorFeatureRendererMixin.java
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
src/main/java/com/github/clevernucleus/armorrenderlib/api/ArmorRenderData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.github.clevernucleus.armorrenderlib.api; | ||
|
||
@FunctionalInterface | ||
public interface ArmorRenderData { | ||
|
||
/** | ||
* | ||
* @param texturePath | ||
* @param color | ||
* @param hasGlint | ||
*/ | ||
void accept(final String texturePath, final int color, final boolean hasGlint); | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/github/clevernucleus/armorrenderlib/api/ArmorRenderLayer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.github.clevernucleus.armorrenderlib.api; | ||
|
||
import net.minecraft.entity.EquipmentSlot; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.item.ItemStack; | ||
|
||
@FunctionalInterface | ||
public interface ArmorRenderLayer { | ||
|
||
/** | ||
* | ||
* @param itemStack | ||
* @param livingEntity | ||
* @param slot | ||
* @return | ||
*/ | ||
ArmorRenderProvider render(final ItemStack itemStack, final LivingEntity livingEntity, final EquipmentSlot slot); | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/com/github/clevernucleus/armorrenderlib/api/ArmorRenderLib.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.github.clevernucleus.armorrenderlib.api; | ||
|
||
import net.minecraft.item.ItemConvertible; | ||
|
||
/** | ||
* Use this to register armor render layers! | ||
* | ||
* @author CleverNucleus | ||
* | ||
*/ | ||
public interface ArmorRenderLib { | ||
/** | ||
* <p> | ||
* Registers an armor render layer for the input item(s). The same armor render layer can be registered for multiple items. The same item(s) can have multiple armor render layers. The armor render layer specifies what armor texture should be used, what color should be applied (if any) and whether it has a glint. | ||
* </p> | ||
* <p> | ||
* This is an extension of {@link net.fabricmc.fabric.api.client.rendering.v1.ArmorRenderer#render(net.minecraft.client.util.math.MatrixStack, net.minecraft.client.render.VertexConsumerProvider, net.minecraft.item.ItemStack, net.minecraft.entity.LivingEntity, net.minecraft.entity.EquipmentSlot, int, net.minecraft.client.render.entity.model.BipedEntityModel)}. | ||
* </p> | ||
* | ||
* @param layer | ||
* @param items | ||
*/ | ||
static void register(ArmorRenderLayer layer, ItemConvertible ... items) { | ||
com.github.clevernucleus.armorrenderlib.impl.ArmorRenderLibImpl.register(layer, items); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/github/clevernucleus/armorrenderlib/api/ArmorRenderProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.github.clevernucleus.armorrenderlib.api; | ||
|
||
@FunctionalInterface | ||
public interface ArmorRenderProvider { | ||
|
||
/** | ||
* | ||
* @param data | ||
*/ | ||
void from(final ArmorRenderData data); | ||
} |
Oops, something went wrong.