Jump to content

[1.8]Storing custom nbttags on player or entityes Little question. inventories


perromercenary00

Recommended Posts

i have this little issue whith this of writing custom nbttag to entityes

 

i been working if a wololo staff there is a later post, but

i store the ownweUUID as string in an nbt whith the same name is done in entityTameable

 

for that i du

 

			UUID uuid = playerIn.getUniqueID();
			String Suuid = playerIn.getUniqueID().toString();

			NBTTagCompound targetNBT = target.getEntityData();
			targetNBT.setString("OwnerUUID", Suuid); //

this write the uuid to targetEntity i can later reade it.

if i close completely minecraft restart the pc fireup again the minecraft

the nbt is still there but is only accessible in the server side coz in the client side it allways return empty,

 

and i notice there is not an

target.setEntityData(NBTTagCompound targetNBT);

############################

i think is becoze i been mising something to writte the nbttag whith the change again to entity

 

soo nbttags gets magicaly update or what is the code to write an nbttag to an entity ??

 

 

i ask this coz today im working in a complex entitie that gona manage a complex firegun, well i gone try to fix the mark2lacer from mi mod

this entity has to have access to the player Inventory but like i wana do this gun compatible whith mi custom mobs the methods to check if the entity has magazines or bullets must be compatibles whith EntityLivingBase plus must be able to read from the inventories i be done in custome armour,  that means i have to extract the inventory rigth from the nbtags rater than the playerIn.inventory.methods and later writing back when comsume bullets or magazines 

 

something like

// #########################################################################3
// @Override
public void readFromNBT() {
this.clear(); //delete the contens from the inventory arrays

//here is to inventoryes array []
// shootinginventario[] for the player or mob inventory  and
// inventario[]  for the items store in the armour pockets 
//later i gona join this two in only one to make easy  

	// Shoting Entity Inventory
	if (shootingEntity != null) {

		NBTTagCompound compound3 = shootingEntity.getEntityData();

		if (compound3 != null) {

			NBTTagList nbttaglist3 = compound3.getTagList("Items", 10);

			if (nbttaglist3.tagCount() > 0) {

				for (int i = 0; i < nbttaglist3.tagCount(); ++i) {

					NBTTagCompound nbttagcompound3 = nbttaglist3.getCompoundTagAt(i);
					int j = nbttagcompound3.getByte("Slot") & 255;

					if (j >= 0 && j < shootinginventario.length) {
						shootinginventario[j] = ItemStack.loadItemStackFromNBT(nbttagcompound3);

						if (shootinginventario[j] != null) {
						}

					}
				}

			}

		}

	}

	inventario[0] = this.shootingEntity.getEquipmentInSlot(0);// .getHeldItem();
	inventario[3] = this.shootingEntity.getEquipmentInSlot(3);// getCurrentArmor(2);chest

	chestItem = inventario[3]; // this.entidad.getEquipmentInSlot(3);


	//inventario en la armadura
	if (chestItem != null) {

		NBTTagCompound compound2 = chestItem.getTagCompound();

		if (compound2 != null) {

			NBTTagList nbttaglist2 = compound2.getTagList("Items", 10);

			if (nbttaglist2.tagCount() > 0) {

				for (int i = 0; i < nbttaglist2.tagCount(); ++i) {

					NBTTagCompound nbttagcompound1 = nbttaglist2.getCompoundTagAt(i);
					int j = nbttagcompound1.getByte("Slot") & 255;

					if (j >= 0 && j < inventario.length) {
						inventario[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);

						if (inventario[j] != null) {
						}

					}
				}

			}

		}

	}

}

// #########################################################################3

 

 

// Sorry i been doing more turn arounds than nesesary coze english is not native languague

what i need is now how to write an NBTTAG compound Back to an Entity

 

Thanks for reading

 

 

 

Link to comment
Share on other sites

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.