Jump to content

Putting (some) village information on a sign, and saving new tags


AstroTibs

Recommended Posts

I've been working on a mod to assign a name to a village.

 

So far, following GotoLink's BetterVillages example, I can successfully generate a sign on a Village well and place text onto it.

 

I would now like to do two things:

Display stats about the newly-generated village (specifically radius) on the sign. It does not matter if these change at a later time; I just want that information on the sign as of when it gets placed on the well.

I have a way to generate a name for the village, but I would like to save that string into the village's NBT so I can access it in other ways later. How do that? If I can't, how can I otherwise save the string and have it be associated with the village?

Link to comment
Share on other sites

I don't know the answers you're looking for but i would be interested in the code to put text on the signs. That sounds awesome.

 

It's just TileEntity data.

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

Yep, I figured out how to place the sign at the well and put text on it. Now I'm just looking how to obtain the radius of the village the sign has generated in. I just can't figure out how to read a value from the village's NBT so that it can be assigned to a variable.

 

Here you go, bogotezz:

 

    	placeBlockAtCurrentPosition(world, Blocks.standing_sign, standingSignOrientation, 0, 2, 0, boundingbox);  //Sign on top
    	
    	// Put label on sign
	TileEntitySign signContents = new TileEntitySign();
	signContents.signText[0] = "Top line";
	signContents.signText[1] = "Second line";
	signContents.signText[2] = "Third line";
	//signContents.signText[2] = "Maybe I'll add a fourth line someday";
	world.setTileEntity(this.boundingBox.minX, this.boundingBox.minY+signHeightOffGround, this.boundingBox.minZ, signContents);

 

And here is GotoLink's Better Villages mod if you want to pore through it.

Link to comment
Share on other sites

Minor update.

 

I first tried the following:

 

Whenever I placed a sign on the village well, I then iterated through the villages within the villages.dat file Minecraft creates, trying to figure out which one the sign belonged to by simply calculating distance, and assuming the sign was in a village if that distance < radius. This failed, and I think the reason it failed is that village structures are being generated before any information is saved to the villages.dat file.

 

I resigned myself to the fact that printing the radius on the sign was either impossible, or possible only post hoc once I've figured out the custom NBT data problem.

 

Then, I tried to figure out how to save and load world-specific custom NBT data following this thread I found. After a couple hours of experimentation, I was successful in making a .dat file that can store things like the sign's coordinates and contents, and do so in a tag compound that can keep all the villages as separate entries (by way of the unique sign coordinates).

 

From here I think I can store the village's name so that it can be retrieved somehow if the sign is lost in-game (i.e. the sign is broken). I've got some ideas on how best to do that.

 

It's been a real gauntlet learning Java/Eclipse from nothing, with all the incomplete tutorials available. As of this post, the "radius" question is still up in the air but I'll post back if I hit another complete snag.

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.