Skip to content

Commit

Permalink
Demon Will Aura Gauge +Curio, -Active Slots Only
Browse files Browse the repository at this point in the history
Adjusted `Utils.canPlayerSeeDemonWill()` and `Utils.getDemonWillResolution()` to use the `InventoryHelper`.

Functionality Change: The new implementation checks only "active" slots (Main and Off-hands, Curios, and any slots add-ons mark as active).  With base Blood Magic that means the gauge will only show up when held or in a Curios slot.

Added tags needed to put the Demon Will Aura Gauge in the Curios Charm and LA Socket slots.
  • Loading branch information
VT-14 committed Oct 3, 2023
1 parent 884a6cb commit 85772ce
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 34 deletions.
38 changes: 6 additions & 32 deletions src/main/java/wayoftime/bloodmagic/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.NonNullList;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
Expand Down Expand Up @@ -43,6 +44,7 @@
import net.minecraftforge.items.wrapper.SidedInvWrapper;
import wayoftime.bloodmagic.api.compat.IDemonWillViewer;
import wayoftime.bloodmagic.common.tile.TileInventory;
import wayoftime.bloodmagic.util.helper.InventoryHelper;
import wayoftime.bloodmagic.util.helper.NBTHelper;

public class Utils
Expand Down Expand Up @@ -571,55 +573,27 @@ public static ItemStack[] combineStacks(ItemStack stack1, ItemStack stack2)

public static boolean canPlayerSeeDemonWill(Player player)
{
IItemHandler inventory = new PlayerMainInvWrapper(player.getInventory());

for (int i = 0; i < inventory.getSlots(); i++)
NonNullList<ItemStack> inventory = InventoryHelper.getActiveInventories(player);
for (ItemStack stack : inventory)
{
ItemStack stack = inventory.getStackInSlot(i);
if (stack.isEmpty())
{
continue;
}

if (stack.getItem() instanceof IDemonWillViewer && ((IDemonWillViewer) stack.getItem()).canSeeDemonWillAura(player.getCommandSenderWorld(), stack, player))
{
return true;
}
}

ItemStack offhandStack = player.getOffhandItem();
if (!offhandStack.isEmpty() && offhandStack.getItem() instanceof IDemonWillViewer && ((IDemonWillViewer) offhandStack.getItem()).canSeeDemonWillAura(player.getCommandSenderWorld(), offhandStack, player))
{
return true;
}

return false;
}

public static double getDemonWillResolution(Player player)
{
IItemHandler inventory = new PlayerMainInvWrapper(player.getInventory());

for (int i = 0; i < inventory.getSlots(); i++)
NonNullList<ItemStack> inventory = InventoryHelper.getActiveInventories(player);
for (ItemStack stack : inventory)
{
ItemStack stack = inventory.getStackInSlot(i);
if (stack.isEmpty())
{
continue;
}

if (stack.getItem() instanceof IDemonWillViewer && ((IDemonWillViewer) stack.getItem()).canSeeDemonWillAura(player.getCommandSenderWorld(), stack, player))
{
return ((IDemonWillViewer) stack.getItem()).getDemonWillAuraResolution(player.getCommandSenderWorld(), stack, player);
}
}

ItemStack offhandStack = player.getOffhandItem();
if (!offhandStack.isEmpty() && offhandStack.getItem() instanceof IDemonWillViewer && ((IDemonWillViewer) offhandStack.getItem()).canSeeDemonWillAura(player.getCommandSenderWorld(), offhandStack, player))
{
return ((IDemonWillViewer) offhandStack.getItem()).getDemonWillAuraResolution(player.getCommandSenderWorld(), offhandStack, player);
}

return 100;
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/data/curios/tags/items/charm.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"bloodmagic:sigilofholding",
"bloodmagic:divinationsigil",
"bloodmagic:seersigil",
"bloodmagic:experiencebook"
"bloodmagic:experiencebook",
"bloodmagic:demonwillgauge"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"bloodmagic:soulgemlesser",
"bloodmagic:soulgemcommon",
"bloodmagic:soulgemgreater",
"bloodmagic:upgradetrainer"
"bloodmagic:upgradetrainer",
"bloodmagic:demonwillgauge"
]
}

0 comments on commit 85772ce

Please sign in to comment.