Skip to content

Commit

Permalink
Fix 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 014fc47 commit 5076633
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 12 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import com.modrinth.minotaur.dependencies.ModDependency
import com.modrinth.minotaur.dependencies.VersionDependency

plugins {
id 'fabric-loom' version '0.12-SNAPSHOT'
Expand Down Expand Up @@ -69,5 +69,5 @@ modrinth {
uploadFile = remapJar
gameVersions = ["${project.minecraft_version}"]
loaders = ["fabric"]
dependencies = [new ModDependency("P7dR8mSH", "required")]
dependencies = [new VersionDependency("4XRtXhtL", "required")]
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ minecraft_version=1.18.2
yarn_mappings=1.18.2+build.3
loader_version=0.14.6

mod_version = 0.1.2
mod_version = 0.1.3
maven_group = com.github.clevernucleus
archives_base_name = armorrenderlib

fabric_version=0.55.1+1.18.2
fabric_version=0.58.0+1.18.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
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
],
"depends": {
"fabricloader": ">=0.14.6",
"fabric": ">=0.55.1",
"fabric": ">=0.58.0",
"minecraft": "1.18.2",
"java": ">=17"
}
Expand Down

0 comments on commit 5076633

Please sign in to comment.