Jump to content

How to write and read nbt data of particular entity?


XBeast

Recommended Posts

I have made an custom entity which extends entityzombie,

Now i want to spawn that entity with nbt data(setting nbt data before spawning) so that i can set different textures to entity in render class(dorender method) according to nbt of that particular entity.

I don't know how to do this... please help me...

Link to comment
Share on other sites

4 hours ago, diesieben07 said:

What version of Minecraft are you working on?

First of all Thanks a lot to helping nooobie like me...

 

Minecraft 1.12.2

and forge Version 14.23.5.2768

 

 

And if you can guide me tell me hot to do so.

I made an custom spawn egg which has all data of entity like texture path and custom name of entity...

i am currently trying to spawn my custom entity using that custom egg but i don't know how to set all these attributes of custom entity individually?

@Override
	public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand,EnumFacing facing, float hitX, float hitY, float hitZ) {
		if(!worldIn.isRemote)
		{
			name = player.getHeldItem(hand).getTagCompound().getString("Name");
			NPC npc = new NPC(worldIn, name);
			npc.getEntityData().setString("Name", name);
			npc.setPosition(pos.getX(), pos.getY() + 1, pos.getZ());
			if(worldIn.spawnEntity(npc))
			{
				System.out.println(npc.getEntityData().getString("Name"));
				return EnumActionResult.SUCCESS;	
			}
			else
				return EnumActionResult.FAIL;
		}
		return EnumActionResult.FAIL;
	}

 

 

But this is printing name of that egg properly even i first setting it into entity and then accessing it...

Edited by XBeast
Link to comment
Share on other sites

6 minutes ago, XBeast said:

Minecraft 1.12.2

 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

1 minute ago, XBeast said:

That Means i should stop doing this and start modding in 1.14.4 Right?

Yes

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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