-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4638 from LeoBeliik/TotemCurioCompat
- Loading branch information
Showing
4 changed files
with
65 additions
and
2 deletions.
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
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
35 changes: 35 additions & 0 deletions
35
src/main/java/org/violetmoon/quark/content/tweaks/compat/TotemOfHoldingCuriosCompat.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,35 @@ | ||
package org.violetmoon.quark.content.tweaks.compat; | ||
|
||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.ItemStack; | ||
import org.violetmoon.quark.addons.oddities.entity.TotemOfHoldingEntity; | ||
import top.theillusivec4.curios.api.CuriosApi; | ||
import top.theillusivec4.curios.api.type.capability.ICuriosItemHandler; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.stream.IntStream; | ||
|
||
public class TotemOfHoldingCuriosCompat { | ||
|
||
public static ItemStack equipCurios(Player player, List<ItemStack> equipedCurios, ItemStack stack) { | ||
Optional<ICuriosItemHandler> curiosApi = CuriosApi.getCuriosInventory(player).resolve(); | ||
if (curiosApi.isPresent()) { | ||
for (int j = 0; j < equipedCurios.size(); j++) { | ||
ItemStack curiosItem = equipedCurios.get(j); | ||
if (stack.is(curiosItem.getItem())) { | ||
curiosApi.get().getEquippedCurios().setStackInSlot(j, stack); | ||
return null; | ||
} | ||
} | ||
} | ||
return stack; | ||
} | ||
|
||
public static void saveCurios(Player player, TotemOfHoldingEntity totem) { | ||
Optional<ICuriosItemHandler> curiosApi = CuriosApi.getCuriosInventory(player).resolve(); | ||
curiosApi.ifPresent(iCuriosItemHandler -> iCuriosItemHandler.getCurios().forEach((a, b) -> | ||
IntStream.range(0, b.getStacks().getSlots()).mapToObj(i -> | ||
b.getStacks().getPreviousStackInSlot(i)).forEach(totem::addCurios))); | ||
} | ||
} |