Sign in to follow this  
Phenex

Getting access to map data

Recommended Posts

Hello everyone,

 

I need access to the map data for my new mod.

Especially I need the information if a tile (only have the coordinates) is on deed and the type (grass, dirt, rock).

I have looked at the "paint terrain" action, as it does also modify the terrain, but my code only produces Java NullPointer exceptions.

 

I hope somebody can tell me what I do wrong. Below is an example code snippet:

Random random = new Random();
TilePos tilePos = TilePos.fromXY(random.nextInt(mapsize + 1), random.nextInt(mapsize + 1));
MeshIO meshIO = Server.surfaceMesh;
int tile = meshIO.getTile(tilePos);
logger.log(Level.INFO, "TilePos: " + tilePos.toString() + " MeshIO.Tile: " + tile);

I should retrieve an integer corresponding to the tile type. Theoretically...

Share this post


Link to post
Share on other sites

I don't see anything wrong with the code... how are you calling it? and where does the NPE happen?

Share this post


Link to post
Share on other sites

Well, tried it again and now it works. Don't know what I made wrong last time.

But I didn't get the data I had hoped for.

 

Message in server console with code from above.

TilePos: tilePos: 1464, 260 MeshIO: 83951273

Somebody know how to get a reference to a Tile in the world?

This isn't what I am looking for.

Share this post


Link to post
Share on other sites

To get the tile type call Tiles.decodeType on the value returned from getTile

 

To get the village you can call Villages.getVillage (the TilePos or the x/y version)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this