Skip to content

Commit

Permalink
Fixes and versioning
Browse files Browse the repository at this point in the history
*HOPEFULLY we fixed the compat issue with Geckolib. I only know it exists because may player's have provided error logs that show as much, however I still cannot replicate the crash for testing purposes. So while I THINK this fixes it, I cannot actually verify this.
+Incremented version
*Now uses VersionDependency instead of ModDependency
  • Loading branch information
CleverNucleus committed Aug 30, 2022
1 parent 85b10aa commit 591d8b8
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ modrinth {
uploadFile = remapJar
gameVersions = ["${project.minecraft_version}"]
loaders = ["fabric"]
dependencies = [new VersionDependency("3KmOcp6b", "required")]
dependencies = [new VersionDependency("EsaWeELS", "required")]
}
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
org.gradle.jvmargs=-Xmx1G

minecraft_version=1.19
yarn_mappings=1.19+build.1
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.1
loader_version=0.14.9

mod_version = 0.2.5
mod_version = 0.2.6
maven_group = com.github.clevernucleus
archives_base_name = armorrenderlib

fabric_api_version=0.58.0+1.19
fabric_api_version=0.59.0+1.19.2
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private static <T extends LivingEntity, M extends BipedEntityModel<T>, A extends
if(item.getSlotType() != slot) return;
var entityRenderer = MinecraftClient.getInstance().getEntityRenderDispatcher().getRenderer(entity);
ArmorFeatureRenderer<T, M, A> armorFeatureRenderer = (ArmorFeatureRenderer<T, M, A>)((FeatureRendererAccessor<T, M>)entityRenderer).getFeatureRenderer();
A model = ((ArmorFeatureRendererInvoker<T, M, A>)armorFeatureRenderer).invokeGetArmor(slot);
A model = ((ArmorTextureCache<A>)armorFeatureRenderer).getArmorCustom(slot);
contextModel.setAttributes((BipedEntityModel<LivingEntity>)model);
((ArmorFeatureRendererInvoker<T, M, A>)armorFeatureRenderer).invokeSetVisible(model, slot);

Expand All @@ -44,7 +44,7 @@ private static <T extends LivingEntity, M extends BipedEntityModel<T>, A extends
float green = (float)(color >> 8 & 0xFF) / 255.0F;
float blue = (float)(color & 0xFF) / 255.0F;

VertexConsumer vertexConsumer = ItemRenderer.getArmorGlintConsumer(vertexConsumers, RenderLayer.getArmorCutoutNoCull(((ArmorTextureCache)armorFeatureRenderer).getOrCache(path)), false, glint);
VertexConsumer vertexConsumer = ItemRenderer.getArmorGlintConsumer(vertexConsumers, RenderLayer.getArmorCutoutNoCull(((ArmorTextureCache<A>)armorFeatureRenderer).getOrCache(path)), false, glint);
model.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, red, green, blue, 1.0F);
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.github.clevernucleus.armorrenderlib.impl;

import net.minecraft.entity.EquipmentSlot;
import net.minecraft.util.Identifier;

public interface ArmorTextureCache {
public interface ArmorTextureCache<A> {
A getArmorCustom(EquipmentSlot slot);

Identifier getOrCache(final String path);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

@Mixin(ArmorFeatureRenderer.class)
public interface ArmorFeatureRendererInvoker<T extends LivingEntity, M extends BipedEntityModel<T>, A extends BipedEntityModel<T>> {
@Invoker("getArmor")
public A invokeGetArmor(EquipmentSlot slot);

@Invoker("setVisible")
public void invokeSetVisible(A bipedModel, EquipmentSlot slot);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,35 @@
import com.github.clevernucleus.armorrenderlib.impl.ArmorTextureCache;

import net.minecraft.client.render.entity.feature.ArmorFeatureRenderer;
import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Identifier;

@Mixin(value = ArmorFeatureRenderer.class, priority = 900)
abstract class ArmorFeatureRendererMixin implements ArmorTextureCache {
@Mixin(ArmorFeatureRenderer.class)
abstract class ArmorFeatureRendererMixin<T extends LivingEntity, M extends BipedEntityModel<T>, A extends BipedEntityModel<T>> implements ArmorTextureCache<A> {

@Shadow
@Final
private static Map<String, Identifier> ARMOR_TEXTURE_CACHE;

@Shadow
@Final
private A leggingsModel;

@Shadow
@Final
private A bodyModel;

/*
* We do this instead of just an invoker because Geckolib Injects into #getArmor and runs an instanced set/get exiting the method,
* which causes the game to crash anytime that method is accessed from anywhere else - and we want to be compatible with Geckolib.
*/
@Override
public A getArmorCustom(EquipmentSlot slot) {
return slot == EquipmentSlot.LEGS ? this.leggingsModel : this.bodyModel;
}

@Override
public Identifier getOrCache(final String path) {
return ARMOR_TEXTURE_CACHE.computeIfAbsent(path, Identifier::new);
Expand Down

0 comments on commit 591d8b8

Please sign in to comment.