Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public NBTTagCompound writeToNBT(NBTTagCompound compound){
- compound = super.writeToNBT(compound);
- NBTTagCompound items = new NBTTagCompound();
- for(int i = 0; i < inventory.length; i++) {
- ItemStack stack = inventory[i];
- if(stack != null) {
- compound.setTag("" + i, stack.writeToNBT(new NBTTagCompound()));
- }
- }
- compound.setTag("items", items);
- return compound;
- }
- @Override
- public void readFromNBT(NBTTagCompound compound){
- super.readFromNBT(compound);
- NBTTagCompound items = compound.getCompoundTag("items");
- for(int i = 0; i < inventory.length; i++){
- inventory[i] = items.hasKey("" + i) ? ItemStack.loadItemStackFromNBT(items.getCompoundTag("" + i)) : null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement