• Recently Browsing

    No registered users viewing this page.

  • Posts

    • I'm not an intellectual.   public class ContainerSheath extends Container { private SheathCapability cap; public ContainerSheath(final int windowID, PlayerInventory player) { super(EssentialContainers.SHEATH, windowID); cap = new SheathCapability(); for(int y = 0; y < 3; ++y) for(int x = 0; x < 9; ++x) this.addSlot(new Slot(player, 9 + x + y * 9, 8 + x * 18, 84 + y * 18)); for(int x = 0; x < 9; ++x) this.addSlot(new Slot(player, x, 8 + x * 18, 142)); this.addSlot(new SlotItemHandler(cap.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.getDefaultInstance(), null), 0, 50, 50)); } @Override public boolean canInteractWith(PlayerEntity playerIn) { return true; } @Override public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) { ItemStack previous = ItemStack.EMPTY; Slot slot = (Slot) this.inventorySlots.get(index); if(slot != null && slot.getHasStack()) { ItemStack current = slot.getStack(); previous = current.copy(); //maybe 9 -> 27, 45 -> 45+18 if(index < 9) { if(!this.mergeItemStack(current, 1, 37, true)) return ItemStack.EMPTY; } else { if(!this.mergeItemStack(current, 0, 1, false)) return ItemStack.EMPTY; } if(current.getCount() == 0) slot.putStack((ItemStack) ItemStack.EMPTY); else slot.onSlotChanged(); if(current.getCount() == previous.getCount()) return ItemStack.EMPTY; slot.onTake(playerIn, current); } return previous; } } CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.getDefaultInstance() would pass by itself put then my capability isn't used. I think? If you can't tell I'm lost
    • Forge enables the use of an "nbt" entry in ItemStack JSONs.
    • No, its private. Use getCapability
    • public class SheathCapability implements ICapabilityProvider, INBTSerializable { private ItemStackHandler inventory = new ItemStackHandler(1); private LazyOptional<ItemStackHandler> lo = LazyOptional.of(() -> inventory); @Override public INBT serializeNBT() { return null; } @Override public void deserializeNBT(INBT nbt) { } @Override public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) { if(cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return lo.cast(); return LazyOptional.empty(); } }   (finds LazyOptional.empty(), feels really smart).   So now, can I use the inventory field in the container class?
  • Topics

  • Who's Online (See full list)