Skip to content

Commit

Permalink
Fix crash with Trinkets 3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmeow committed Feb 1, 2022
1 parent d50467e commit c441e4a
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 40 deletions.
6 changes: 6 additions & 0 deletions common/src/main/resources/data/trinkets/slots/chest/cape.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"replace": false,
"validator_predicates": [
"betteranimalsplus:cape_allowed"
]
}
2 changes: 1 addition & 1 deletion fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ dependencies {
exclude(group: "net.fabricmc")
exclude(group: "net.fabricmc.fabric-api")
}
modImplementation("dev.emi:trinkets:${rootProject.trinkets_version}") {
modImplementation("curse.maven:341284-trinkets:${rootProject.trinkets_version}") {
transitive = false
}
modRuntimeOnly("com.terraformersmc:modmenu:3.0.1") {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
package dev.itsmeow.betteranimalsplus.compat.trinkets;

import dev.emi.trinkets.api.TrinketsApi;
import dev.itsmeow.betteranimalsplus.Ref;
import dev.itsmeow.betteranimalsplus.common.item.ItemCape;
import dev.itsmeow.betteranimalsplus.common.item.ItemModeledArmor;
import net.fabricmc.fabric.api.util.TriState;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;

public class TrinketsModCompat {

public static void init() {
ItemCape.can_equip = (stack, armorType, entity) -> !TrinketsApi.getTrinketComponent((LivingEntity) entity).get().isEquipped(s -> s.getItem() instanceof ItemModeledArmor);
ItemCape.can_equip = (stack, armorType, entity) -> !TrinketsApi.getTrinketComponent((LivingEntity) entity).get().isEquipped(s -> s.getItem() instanceof ItemCape);
TrinketsApi.registerTrinketPredicate(new ResourceLocation(Ref.MOD_ID, "cape_allowed"), (stack, slot, entity) -> {
if (stack.getItem() instanceof ItemCape && entity.getItemBySlot(EquipmentSlot.CHEST).getItem() instanceof ItemCape) {
return TriState.FALSE;
}
return TriState.TRUE;
});
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.itsmeow.betteranimalsplus.fabric;

import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.Version;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
Expand All @@ -21,7 +22,7 @@ public String getRefMapperConfig() {

@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
return (!mixinClassName.equals("dev.itsmeow.betteranimalsplus.mixin.fabric.ItemCapeMixin") && !mixinClassName.equals("dev.itsmeow.betteranimalsplus.mixin.fabric.TrinketSlotMixin")) || FabricLoader.getInstance().isModLoaded("trinkets");
return !mixinClassName.equals("dev.itsmeow.betteranimalsplus.mixin.fabric.ItemCapeMixin") || FabricLoader.getInstance().isModLoaded("trinkets");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public abstract class SimpleReloadableResourceManagerMixin implements Reloadable
private void listResources(String parent, Predicate<String> loadFilter, CallbackInfoReturnable<Collection<ResourceLocation>> callback, Set<ResourceLocation> foundResources, List<ResourceLocation> sortedResources) {
for (ResourceLocation id : new ArrayList<>(sortedResources)) {
if(Ref.MOD_ID.equals(id.getNamespace())) {
if(("advancements/ultimate_succening.json".equals(id.getPath()) && !FabricLoader.getInstance().isModLoaded("whisperwoods")) || (("trinkets/entities/betteranimalsplus.json".equals(id.getPath()) || "trinkets/tags/items/chest/cape.json".equals(id.getPath())) && !FabricLoader.getInstance().isModLoaded("trinkets"))) {
if(("advancements/ultimate_succening.json".equals(id.getPath()) && !FabricLoader.getInstance().isModLoaded("whisperwoods")) || (id.getPath().startsWith("trinkets") && !FabricLoader.getInstance().isModLoaded("trinkets"))) {
sortedResources.remove(id);
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"LivingEntityMixin",
"SimpleReloadableResourceManagerMixin",
"ItemCapeMixin",
"TrinketSlotMixin",
"ServerPlayerMixin"
],
"client": [
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@
org.gradle.jvmargs = -Xmx4G
org.gradle.daemon = true
curios_version = 1.18.1-5.0.4.1
trinkets_version = 3.1.0
# 3.2.0
trinkets_version = 3629559

0 comments on commit c441e4a

Please sign in to comment.