use of net.runelite.cache.definitions.MapDefinition.Tile in project runelite by runelite.
the class MapLoader method loadTerrain.
private void loadTerrain(MapDefinition map, byte[] buf) {
Tile[][][] tiles = map.getTiles();
InputStream in = new InputStream(buf);
for (int z = 0; z < Z; z++) {
for (int x = 0; x < X; x++) {
for (int y = 0; y < Y; y++) {
Tile tile = tiles[z][x][y] = new Tile();
while (true) {
int attribute = in.readUnsignedByte();
if (attribute == 0) {
break;
} else if (attribute == 1) {
int height = in.readUnsignedByte();
tile.height = height;
break;
} else if (attribute <= 49) {
tile.attrOpcode = attribute;
tile.overlayId = in.readByte();
tile.overlayPath = (byte) ((attribute - 2) / 4);
tile.overlayRotation = (byte) (attribute - 2 & 3);
} else if (attribute <= 81) {
tile.settings = (byte) (attribute - 49);
} else {
tile.underlayId = (byte) (attribute - 81);
}
}
}
}
}
}
use of net.runelite.cache.definitions.MapDefinition.Tile in project runelite by runelite.
the class MapSaver method save.
public byte[] save(MapDefinition map) {
Tile[][][] tiles = map.getTiles();
OutputStream out = new OutputStream();
for (int z = 0; z < Z; z++) {
for (int x = 0; x < X; x++) {
for (int y = 0; y < Y; y++) {
Tile tile = tiles[z][x][y];
if (tile.attrOpcode != 0) {
out.writeByte(tile.attrOpcode);
out.writeByte(tile.overlayId);
}
if (tile.settings != 0) {
out.writeByte(tile.settings + 49);
}
if (tile.underlayId != 0) {
out.writeByte(tile.underlayId + 81);
}
if (tile.height == null) {
out.writeByte(0);
} else {
out.writeByte(1);
out.writeByte(tile.height);
}
}
}
}
return out.flip();
}
use of net.runelite.cache.definitions.MapDefinition.Tile in project runelite by runelite.
the class Region method loadTerrain.
public void loadTerrain(MapDefinition map) {
Tile[][][] tiles = map.getTiles();
for (int z = 0; z < Z; z++) {
for (int x = 0; x < X; x++) {
for (int y = 0; y < Y; y++) {
Tile tile = tiles[z][x][y];
if (tile.height == null) {
if (z == 0) {
tileHeights[0][x][y] = -HeightCalc.calculate(baseX + x + 0xe3b7b, baseY + y + 0x87cce) * 8;
} else {
tileHeights[z][x][y] = tileHeights[z - 1][x][y] - 240;
}
} else {
int height = tile.getHeight();
if (height == 1) {
height = 0;
}
if (z == 0) {
tileHeights[0][x][y] = -height * 8;
} else {
tileHeights[z][x][y] = tileHeights[z - 1][x][y] - height * 8;
}
}
overlayIds[z][x][y] = tile.getOverlayId();
overlayPaths[z][x][y] = tile.getOverlayPath();
overlayRotations[z][x][y] = tile.getOverlayRotation();
tileSettings[z][x][y] = tile.getSettings();
underlayIds[z][x][y] = tile.getUnderlayId();
}
}
}
}
Aggregations