Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hi All! I made my slot for ContainerPlayer.java, but when I put back an item that item appears in the slot for a helmet.

 

48VZ9.jpg

 

SlotBackpack

 

 

package net.minecraft.inventory;

import mods.AdventureCraft.src.BackpackItem;

import net.minecraft.item.ItemStack;

class SlotBackpack extends Slot

{

final ContainerPlayer inventory;

SlotBackpack(ContainerPlayer containerplayer, IInventory iinventory, int i, int j, int k, int l)

{

                super(iinventory, i, j, k);

                inventory = containerplayer;

}

public int getSlotStackLimit()

{

                return 1;

}

public boolean isItemValid(ItemStack itemstack)

{

                return itemstack.getItem() instanceof BackpackItem;

}

}

 

 

 

Add my slot in ContainerPlayer.java

 

 

for (i = 0; i < 1; ++i)

{

this.addSlotToContainer(new SlotBackpack(this, par1InventoryPlayer, par1InventoryPlayer.getSizeInventory() - 1, 60, 8 + 2 * 18, 100));

}

 

 

 

Please, help me. And sorry for my bad English :)

  • 3 weeks later...

I guess you are setting slot index same as the helmet slot index. Try setting a negative number.

Might I suggest opening a custom Gui with your Item Backpack rather than editing the base inventory gui? For an example of this, check out my tutorial on creating an Item that stores an Inventory: http://www.minecraftforum.net/topic/1949352-creating-an-item-that-stores-an-inventory/

 

If you want an extra inventory slot to store the item, like I see you are doing, you could store it in IExtendedEntityProperties and assign a special key to open your custom player inventory to allow access to your custom slot. If you need help with IExtendedEntityProperties, I also have a tutorial on that:

http://www.minecraftforum.net/topic/1952901-eventhandler-and-iextendedentityproperties/#entry24051513

 

I've done this exact thing helping out some guys making a Naruto mod - they needed custom inventory slots for Sharingan Eyes, and I did it like I outlined above.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.