Jump to content

Recommended Posts

Posted

good nigths

 

im update some pieces of code and found some changes

now the inventories are NonNullList<ItemStack> so mi old code is now broken

 

i been thinking about it and this time i wanna use the forge tools for managing inventories rater than create mi owns

but thats the trouble where i find this tools what class i must search for ?

 

in this inventories i need to

*first check if there is room to put an item in inventory

*check actually exactly how many of this specific item/metada i could store in this inventory or else

*check if there is space in mi custom armours|backpacks to store the remaining itemStack

 so i could store a part in the main inventory and the rest in mi custome inventory

 

i don't remember asking this before well also i don't remember at all ,  in 1.8 i just sit and write the code for this

 

 

sorry foir bad english g

 

 

 

Posted

Use an IItemHandler instance whenever you need an inventory. Expose it via the Capability system to allow external access to it (e.g. for hoppers or other item transfer systems).

 

The default implementation of IItemHandler is ItemStackHandler, you can generally use or extend this.

 

ItemHandlerHelper contains Forge's utility methods for IItemHandlers. ItemHandlerHelper.giveItemToPlayer will attempt to insert an ItemStack into a player's inventory and drop the remainder on the ground as an EntityItem. You could adapt this to attempt to insert the remainder into your custom inventory and only after that drop the remainder on the ground.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

good nights

 

now i have the IItemHandler, I rememberer using this interface in the backpacks in 1.8 

but its an interface and also its like

empty

and looks not like what i need

 

let say i need to know how many botles of suspencionderedstone the entity has before doing anything

or i want tu unload the bullets from a gun, i need to calculate how any bullets i could arrange in the inventory before unload coz

i don't wanna drop nothing to the floor

 

soo its like a have to make the code i need anyway

better resign and begin to write code again

 

 

thanks for answering

 

 

 

 

 

 

 

 

	        @Override
        public int getSlots() {
            // TODO Auto-generated method stub
            return 0;
        }
        @Override
        public ItemStack getStackInSlot(int slot) {
            // TODO Auto-generated method stub
            return null;
        }
        @Override
        public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
            // TODO Auto-generated method stub
            return null;
        }
        @Override
        public ItemStack extractItem(int slot, int amount, boolean simulate) {
            // TODO Auto-generated method stub
            return null;
        }
        @Override
        public int getSlotLimit(int slot) {
            // TODO Auto-generated method stub
            return 0;
        }
	 
	

Posted
On 2-5-2017 at 2:04 AM, perromercenary00 said:

but its an interface and also its like

empty

1

 

On 30-4-2017 at 6:03 AM, Choonster said:

The default implementation of IItemHandler is ItemStackHandler, you can generally use or extend this.

 

 

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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