Skip to content

Commit

Permalink
add inventorio compat (fixes #28)
Browse files Browse the repository at this point in the history
  • Loading branch information
UpcraftLP committed Jan 3, 2024
1 parent 5699589 commit 5dd0cab
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 5 deletions.
8 changes: 8 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ repositories {
includeGroup "maven.modrinth"
}
}
maven {
name = "CurseMaven"
url = "https://www.cursemaven.com"
content {
includeGroup "curse.maven"
}
}
}

dependencies {
Expand All @@ -73,6 +80,7 @@ dependencies {
modImplementation libs.midnightlib

modCompileOnly libs.hephaestus
modCompileOnly libs.inventorio

modImplementation libs.universalgraves
modLocalRuntime libs.bundles.universalgraves.runtime
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ modmenu = "7.2.2"
lazydfu = "0.1.3"

hephaestus = "1.20.1-3.6.3.241"
inventorio = "4619078"

universalgraves = "3.0.0+1.20.1"
sgui = "1.2.2+1.20"
Expand All @@ -40,6 +41,7 @@ modmenu = { module = "com.terraformersmc:modmenu", version.ref = "modmenu" }
lazydfu = { module = "maven.modrinth:lazydfu", version.ref = "lazydfu" }

hephaestus = { module = "maven.modrinth:hephaestus", version.ref = "hephaestus" }
inventorio = { module = "curse.maven:inventorio-491073", version.ref = "inventorio" }

universalgraves = { module = "maven.modrinth:universal-graves", version.ref = "universalgraves" }
sgui = { module = "eu.pb4:sgui", version.ref = "sgui" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
public class CamsBackpacksMixinConfigPlugin implements IMixinConfigPlugin {

private static final String HEPHAESTUS_MOD_ID = "tconstruct";
private static final String INVENTORIO_MOD_ID = "inventorio";

@Override
public void onLoad(String mixinPackage) {
Expand All @@ -25,10 +26,11 @@ public String getRefMapperConfig() {

@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
if("dev.cammiescorner.camsbackpacks.core.mixin.compat.HephaestusArmorSlotMixin".equals(mixinClassName)) {
return QuiltLoader.isModLoaded(HEPHAESTUS_MOD_ID);
}
return true;
return switch (mixinClassName) {
case "dev.cammiescorner.camsbackpacks.core.mixin.compat.InventorioArmorSlotMixin" -> QuiltLoader.isModLoaded(INVENTORIO_MOD_ID);
case "dev.cammiescorner.camsbackpacks.core.mixin.compat.HephaestusArmorSlotMixin" -> QuiltLoader.isModLoaded(HEPHAESTUS_MOD_ID);
default -> true;
};
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package dev.cammiescorner.camsbackpacks.core.mixin.compat;

import dev.cammiescorner.camsbackpacks.common.items.BackpackItem;
import me.lizardofoz.inventorio.slot.ArmorSlot;
import net.minecraft.world.Container;
import net.minecraft.world.inventory.Slot;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(ArmorSlot.class)
public class InventorioArmorSlotMixin extends Slot {

private InventorioArmorSlotMixin(Container container, int slot, int x, int y) {
super(container, slot, x, y);
throw new UnsupportedOperationException();
}

@Inject(method = "mayPickup", at = @At("HEAD"), cancellable = true)
private void camsbackpacks$mayPickup(CallbackInfoReturnable<Boolean> cir) {
if (this.getItem().getItem() instanceof BackpackItem) {
cir.setReturnValue(false);
}
}
}
3 changes: 2 additions & 1 deletion src/main/resources/camsbackpacks.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"PlayerMixin",
"accessor.CraftingMenuAccessor",
"accessor.InventoryMenuAccessor",
"compat.HephaestusArmorSlotMixin"
"compat.HephaestusArmorSlotMixin",
"compat.InventorioArmorSlotMixin"
],
"client": [
"client.InventoryScreenMixin",
Expand Down

0 comments on commit 5dd0cab

Please sign in to comment.