Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i dont know how to do PR's lol Please update the CuriosCompat.java class to fix a crash with Corail Tombstone. (1.20.1) #2040

Open
Orangejewce92 opened this issue May 25, 2024 · 1 comment

Comments

@Orangejewce92
Copy link

package wayoftime.bloodmagic.compat;

import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.core.NonNullList;
import net.minecraftforge.fml.InterModComms;
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
import net.minecraftforge.items.IItemHandler;
import top.theillusivec4.curios.api.CuriosApi;
import top.theillusivec4.curios.api.SlotTypeMessage;
import top.theillusivec4.curios.api.SlotTypePreset;
import top.theillusivec4.curios.api.type.util.ISlotHelper;
import wayoftime.bloodmagic.BloodMagic;
import wayoftime.bloodmagic.core.LivingArmorRegistrar;
import wayoftime.bloodmagic.core.living.LivingStats;
import wayoftime.bloodmagic.core.living.LivingUtil;
import wayoftime.bloodmagic.impl.BloodMagicAPI;

import java.util.Optional;

public class CuriosCompat
{
public void setupSlots(InterModEnqueueEvent evt)
{
InterModComms.sendTo("curios", SlotTypeMessage.REGISTER_TYPE, () -> SlotTypePreset.NECKLACE.getMessageBuilder().build());
InterModComms.sendTo("curios", SlotTypeMessage.REGISTER_TYPE, () -> SlotTypePreset.CHARM.getMessageBuilder().build());
InterModComms.sendTo("curios", SlotTypeMessage.REGISTER_TYPE, () -> new SlotTypeMessage.Builder("living_armour_socket").size(0).icon(BloodMagic.rl("item/curios_empty_living_armour_socket")).build());
}

public void registerInventory()
{
    BloodMagicAPI.INSTANCE.registerInventoryProvider("curiosInventory", player -> getCuriosInventory(player));
}

public NonNullList<ItemStack> getCuriosInventory(Player player)
{
    Optional<IItemHandler> optionalItemHandler = CuriosApi.getCuriosHelper().getEquippedCurios(player).resolve();
    NonNullList<ItemStack> inventory = NonNullList.create();

    if (optionalItemHandler.isPresent())
    {
        IItemHandler itemHandler = optionalItemHandler.get();
        for (int i = 0; i < itemHandler.getSlots(); i++)
        {
            inventory.add(itemHandler.getStackInSlot(i));
        }
    }

    return inventory;
}

public int recalculateCuriosSlots(Player player)
{
    ISlotHelper slotHelper = CuriosApi.getSlotHelper();
    if (LivingUtil.hasFullSet(player))
    {
        LivingStats stats = LivingStats.fromPlayer(player);
        int curiosLevel = stats != null ? stats.getLevel(LivingArmorRegistrar.UPGRADE_CURIOS_SOCKET.get().getKey()) : 0;

        if (curiosLevel == 0)
        {
            slotHelper.setSlotsForType("living_armour_socket", player, 0);
        } 
        else
        {
            int slotCount = LivingArmorRegistrar.UPGRADE_CURIOS_SOCKET.get().getBonusValue("slots", curiosLevel).intValue();
            slotHelper.setSlotsForType("living_armour_socket", player, slotCount);
        }
        return curiosLevel;
    } 
    else
    {
        slotHelper.setSlotsForType("living_armour_socket", player, 0);
        return 0;
    }
}

}

@Orangejewce92
Copy link
Author

https://pastebin.com/ehmXwuX5

This was the crash i was getting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant