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.

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

Featured Replies

Posted

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

 

 

 

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.