aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.gradle2
-rw-r--r--gradle.properties2
-rw-r--r--libs/cosmetic-armor-1.1.0.jarbin0 -> 19943 bytes
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/CITResewn.java5
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/OptionalCompat.java41
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/mixin/citarmor/ArmorFeatureRendererMixin.java5
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/mixin/citelytra/ElytraFeatureRendererMixin.java8
7 files changed, 61 insertions, 2 deletions
diff --git a/build.gradle b/build.gradle
index 73290da..8bdfe42 100644
--- a/build.gradle
+++ b/build.gradle
@@ -26,6 +26,8 @@ dependencies {
modCompileOnly("me.shedaniel.cloth:cloth-config-fabric:5.0.38") {
exclude(group: "net.fabricmc.fabric-api")
}
+
+ modCompileOnly(files("libs/cosmetic-armor-1.1.0.jar"))
}
processResources {
diff --git a/gradle.properties b/gradle.properties
index a78e6cd..fc0a5d2 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -6,7 +6,7 @@ minecraft_version=1.17.1
yarn_mappings=1.17.1+build.39
loader_version=0.11.6
# Mod Properties
-mod_version=0.5.1
+mod_version=0.5.2
maven_group=shcm.shsupercm.fabric
archives_base_name=CITResewn
diff --git a/libs/cosmetic-armor-1.1.0.jar b/libs/cosmetic-armor-1.1.0.jar
new file mode 100644
index 0000000..cdc2834
--- /dev/null
+++ b/libs/cosmetic-armor-1.1.0.jar
Binary files differ
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/CITResewn.java b/src/main/java/shcm/shsupercm/fabric/citresewn/CITResewn.java
index d96de20..bb99d49 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/CITResewn.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/CITResewn.java
@@ -3,6 +3,7 @@ package shcm.shsupercm.fabric.citresewn;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
+import net.fabricmc.loader.api.FabricLoader;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -17,6 +18,8 @@ public class CITResewn implements ClientModInitializer {
public CITResewnConfig config = null;
+ public OptionalCompat compat = null;
+
public boolean processingBrokenPaths = false;
@@ -25,6 +28,8 @@ public class CITResewn implements ClientModInitializer {
INSTANCE = this;
config = CITResewnConfig.read();
+
+ compat = new OptionalCompat(s -> FabricLoader.getInstance().isModLoaded(s));
}
public static void info(String message) {
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/OptionalCompat.java b/src/main/java/shcm/shsupercm/fabric/citresewn/OptionalCompat.java
new file mode 100644
index 0000000..7558d03
--- /dev/null
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/OptionalCompat.java
@@ -0,0 +1,41 @@
+package shcm.shsupercm.fabric.citresewn;
+
+import io.github.apace100.cosmetic_armor.CosmeticArmor;
+import net.minecraft.entity.EquipmentSlot;
+import net.minecraft.entity.LivingEntity;
+import net.minecraft.item.ItemStack;
+
+import java.util.function.Predicate;
+
+public final class OptionalCompat {
+ public static OptionalCompat INSTANCE() {
+ return CITResewn.INSTANCE.compat;
+ }
+
+ public final CompatCosmeticArmor compatCosmeticArmor;
+
+ public OptionalCompat(Predicate<String> isLoaded) {
+ compatCosmeticArmor = isLoaded.test("cosmetic-armor") ? CompatCosmeticArmor.impl() : null;
+ }
+
+ public static ItemStack getCosmeticArmor(ItemStack original, LivingEntity entity, EquipmentSlot slot) {
+ if (INSTANCE().compatCosmeticArmor != null) {
+ ItemStack stackInCosmeticSlot = INSTANCE().compatCosmeticArmor.getStackInCosmeticSlot(entity, slot);
+ if (!stackInCosmeticSlot.isEmpty())
+ return stackInCosmeticSlot;
+ }
+
+ return original;
+ }
+
+ /**
+ * Compatibility with 'cosmetic-armor': Display cits for cosmetic armors instead of equipped armors
+ */
+ public interface CompatCosmeticArmor {
+ private static CompatCosmeticArmor impl() {
+ return CosmeticArmor::getCosmeticArmor;
+ }
+
+ ItemStack getStackInCosmeticSlot(LivingEntity entity, EquipmentSlot slot);
+ }
+}
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/citarmor/ArmorFeatureRendererMixin.java b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/citarmor/ArmorFeatureRendererMixin.java
index 5fe1965..d8b78a4 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/citarmor/ArmorFeatureRendererMixin.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/citarmor/ArmorFeatureRendererMixin.java
@@ -15,6 +15,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import shcm.shsupercm.fabric.citresewn.CITResewn;
+import shcm.shsupercm.fabric.citresewn.OptionalCompat;
import shcm.shsupercm.fabric.citresewn.config.CITResewnConfig;
import java.lang.ref.WeakReference;
@@ -30,6 +31,10 @@ public class ArmorFeatureRendererMixin<T extends LivingEntity, M extends BipedEn
return;
ItemStack itemStack = entity.getEquippedStack(armorSlot);
+
+ //compat Cosmetic Armor
+ itemStack = OptionalCompat.getCosmeticArmor(itemStack, entity, armorSlot);
+
Map<String, Identifier> armorTextures = CITResewn.INSTANCE.activeCITs.getArmorTextures(itemStack, entity.world, entity);
if (armorTextures != null) {
armorTexturesCached = new WeakReference<>(armorTextures);
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/citelytra/ElytraFeatureRendererMixin.java b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/citelytra/ElytraFeatureRendererMixin.java
index f44871b..b5ef126 100644
--- a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/citelytra/ElytraFeatureRendererMixin.java
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/citelytra/ElytraFeatureRendererMixin.java
@@ -14,6 +14,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import shcm.shsupercm.fabric.citresewn.CITResewn;
+import shcm.shsupercm.fabric.citresewn.OptionalCompat;
import shcm.shsupercm.fabric.citresewn.config.CITResewnConfig;
import java.lang.ref.WeakReference;
@@ -28,7 +29,12 @@ public class ElytraFeatureRendererMixin {
if (!CITResewnConfig.INSTANCE().enabled || CITResewn.INSTANCE.activeCITs == null)
return;
- this.elytraItemCached = new WeakReference<>(livingEntity.getEquippedStack(EquipmentSlot.CHEST));
+ ItemStack itemStack = livingEntity.getEquippedStack(EquipmentSlot.CHEST);
+
+ //compat Cosmetic Armor
+ itemStack = OptionalCompat.getCosmeticArmor(itemStack, livingEntity, EquipmentSlot.CHEST);
+
+ this.elytraItemCached = new WeakReference<>(itemStack);
this.livingEntityCached = new WeakReference<>(livingEntity);
}