-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add compatibility layer for Curios and Trinkets #121
- Loading branch information
1 parent
78c3e3e
commit b6254d9
Showing
12 changed files
with
130 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
common/src/main/java/net/blay09/mods/balm/api/compat/BalmModSupport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package net.blay09.mods.balm.api.compat; | ||
|
||
import net.blay09.mods.balm.api.compat.trinkets.BalmModSupportTrinkets; | ||
|
||
public interface BalmModSupport { | ||
BalmModSupportTrinkets trinkets(); | ||
} |
10 changes: 10 additions & 0 deletions
10
common/src/main/java/net/blay09/mods/balm/api/compat/trinkets/BalmModSupportTrinkets.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package net.blay09.mods.balm.api.compat.trinkets; | ||
|
||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.ItemStack; | ||
|
||
import java.util.function.Predicate; | ||
|
||
public interface BalmModSupportTrinkets { | ||
boolean isEquipped(Player player, Predicate<ItemStack> predicate); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
fabric/src/main/java/net/blay09/mods/balm/fabric/compat/FabricBalmModSupport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package net.blay09.mods.balm.fabric.compat; | ||
|
||
import net.blay09.mods.balm.api.compat.BalmModSupport; | ||
import net.blay09.mods.balm.api.compat.trinkets.BalmModSupportTrinkets; | ||
import net.blay09.mods.balm.fabric.compat.trinkets.FabricBalmModSupportTrinkets; | ||
|
||
public class FabricBalmModSupport implements BalmModSupport { | ||
private final FabricBalmModSupportTrinkets trinkets = new FabricBalmModSupportTrinkets(); | ||
|
||
@Override | ||
public BalmModSupportTrinkets trinkets() { | ||
return trinkets; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...c/main/java/net/blay09/mods/balm/fabric/compat/trinkets/FabricBalmModSupportTrinkets.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package net.blay09.mods.balm.fabric.compat.trinkets; | ||
|
||
import net.blay09.mods.balm.api.Balm; | ||
import net.blay09.mods.balm.api.compat.trinkets.BalmModSupportTrinkets; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.ItemStack; | ||
|
||
import java.util.function.Predicate; | ||
|
||
public class FabricBalmModSupportTrinkets implements BalmModSupportTrinkets { | ||
@Override | ||
public boolean isEquipped(Player player, Predicate<ItemStack> predicate) { | ||
if (Balm.isModLoaded("trinkets")) { | ||
return TrinketsModCompat.isEquipped(player, predicate); | ||
} | ||
return false; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
fabric/src/main/java/net/blay09/mods/balm/fabric/compat/trinkets/TrinketsModCompat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package net.blay09.mods.balm.fabric.compat.trinkets; | ||
|
||
import dev.emi.trinkets.api.TrinketsApi; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.ItemStack; | ||
|
||
import java.util.function.Predicate; | ||
|
||
public class TrinketsModCompat { | ||
public static boolean isEquipped(Player player, Predicate<ItemStack> predicate) { | ||
return TrinketsApi.getTrinketComponent(player).map(trinkets -> trinkets.isEquipped(predicate)).orElse(false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
forge/src/main/java/net/blay09/mods/balm/forge/compat/ForgeBalmModSupport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package net.blay09.mods.balm.forge.compat; | ||
|
||
import net.blay09.mods.balm.api.compat.BalmModSupport; | ||
import net.blay09.mods.balm.api.compat.trinkets.BalmModSupportTrinkets; | ||
import net.blay09.mods.balm.forge.compat.trinkets.ForgeBalmModSupportTrinkets; | ||
|
||
public class ForgeBalmModSupport implements BalmModSupport { | ||
private final ForgeBalmModSupportTrinkets trinkets = new ForgeBalmModSupportTrinkets(); | ||
|
||
@Override | ||
public BalmModSupportTrinkets trinkets() { | ||
return trinkets; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
forge/src/main/java/net/blay09/mods/balm/forge/compat/trinkets/CuriosModCompat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package net.blay09.mods.balm.forge.compat.trinkets; | ||
|
||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.ItemStack; | ||
import top.theillusivec4.curios.api.CuriosApi; | ||
|
||
import java.util.function.Predicate; | ||
|
||
public class CuriosModCompat { | ||
public static boolean isEquipped(Player player, Predicate<ItemStack> predicate) { | ||
return CuriosApi.getCuriosInventory(player).map(trinkets -> trinkets.isEquipped(predicate)).orElse(false); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...src/main/java/net/blay09/mods/balm/forge/compat/trinkets/ForgeBalmModSupportTrinkets.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package net.blay09.mods.balm.forge.compat.trinkets; | ||
|
||
import net.blay09.mods.balm.api.Balm; | ||
import net.blay09.mods.balm.api.compat.trinkets.BalmModSupportTrinkets; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.ItemStack; | ||
|
||
import java.util.function.Predicate; | ||
|
||
public class ForgeBalmModSupportTrinkets implements BalmModSupportTrinkets { | ||
@Override | ||
public boolean isEquipped(Player player, Predicate<ItemStack> predicate) { | ||
if (Balm.isModLoaded("curios")) { | ||
return CuriosModCompat.isEquipped(player, predicate); | ||
} | ||
return false; | ||
} | ||
} |