Jump to content

Recommended Posts

Posted (edited)

good days

im solving some other trouble for i wanna create a custom inventory in chest|armours named "chestInventory"  and add it to the entity and works with it like it was only one big inventory but without mess the vanilla

 

for what im making a custom inventory helper the plan is to read and write  the inventory directly from the entity compound

 

but i don't find the method to get the vanilla nbttag i just get the custom nbt whit 

 entity.getEntityData(); 

 

a little text to understand better

i have this testing item on entity swing it create the object from mi class and it must show in the console output all the inventory from the entity

 


 

 

 

 

 

 

 

 

 

 

 

 

 

 

Edited by perromercenary00
done now
Posted (edited)

More or less

i don't want to attach a new inventory to the entity but to the the custom chest-plate item and some costume backpacks

but i need to read/write  the entity inventories (main + hand's + costume)   as whole  

as i plane to make mobs with guns and items i require this code to works also in that

 

the trouble is that the inventories in entityPlayer "NonNullList<ItemStack>" are different from the inventories in entities like zombies villagers and cows "Iterable<ItemStack>"

In nbttag-level they are more universal all is inside the tag "Inventory", 10   so just whit a pair of methods to read from and write to nbttagcompund i could spare a good piece of code

 

what i want ?

let's speak of the items i updating right now,

 

Chainsaw this item uses "suspencionderedstone" as fuel to work

soo if the chainsaw has no fuel the reload routine must be something like

 

 if ( the player has suspencion de redstone in main inventory ){

consume that and play reload animation

}

else if( the player has suspencion de redstone in  chest|backpack|briefcase inventory )

{

consume that and play reload animation

}

else{

don't du anything

}

 

and the the fireguns

in mod you could unload munition from the guns to change it for another type of munition or load another gun

i have normally three types of munition per gun      steel, Redstone, obsidian

 

lets say i have a big magazine with 53 bullets the unload routine would be something like

 

int magazinemunition = "magazine bullets";

 

inventarioHandler invh = new inventarioHandler(EntityPlayer);

 

int howmanybulletsfitinmaininventory = invh.howmanyfitinmain( modItems.bullet556 );

int howmanybulletsfitinchestinventory = invh.howmanyfitinchest( modItems.bullet556 );

 

if(  magazinemunition   >= ( howmanybulletsfitinmaininventory + howmanybulletsfitinchestinventory  ) )

{

play animation for all 53 bullets,

set the munition to the player inventories and let

zero bullets in the magazine

}

else

{

play animation for what fits bullets,

set the munition to the player inventories only what is possible

and let the remaining bullets in the magazine

}

 

 

this is mi code

https://gist.github.com/anonymous/a1d3b1121d6c2da07dd21f043d252c1e

 

Thanks for reading

Edited by perromercenary00

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.