Curios API (Forge/NeoForge)

Curios API (Forge/NeoForge)

140M Downloads

Detect Slot by it's custom tag

TheShadowModsUK opened this issue ยท 1 comments

commented

Hey is there way to get the slot by it's custom tag?

InterModComms.sendTo(CuriosApi.MODID, SlotTypeMessage.REGISTER_TYPE, () -> new SlotTypeMessage.Builder("mytag").build());

so I register like so

I know we grab the slots with

CuriosApi.getCuriosHelper.getEquippedCurios(entity)

But how would I grab just the slot with in this case mytag so I can get the item already in there if this is possbile as I have loads of items what would be going in my custom slot.

commented

I know we grab the slots with

Actually, that's not how you grab slots. That's how you grab the items in those slots. There's a difference because it does not provide any reference to the actual slots themselves.

Anyways, as for the question, you would do:

CuriosApi.getCuriosHelper().getCuriosHandler(entity).ifPresent(handler ->
  ICurioStacksHandler tag = handler.getCurios().get("mytag");
  IDynamicStacksHandler stacks = stacksHandler.getStacks();
  // IDynamicStacksHandler is an implementation of ItemStackHandler so you can just grab the stacks from it by index at this point
)