/** Puts a given tile into given map at specified coordinates and, * if tileStitcher is present, sets appropriate sectors on adjacent tiles. */ public void setTile(int dimension, int x, int y, Tile tile) { DimensionData dimData = getDimensionData(dimension); dimData.setTile(x, y, tile); }
public void addData(DimensionData other){ for (Entry<ShortVec2, TileGroup> e:other.tileGroups.entrySet()){ TileGroup group = e.getValue(); Rect s = group.getScope(); for (int x = s.minX; x <= s.maxX; x++){ for (int y = s.minY; y <= s.maxY; y++){ Tile tile = group.getTile(x, y); if (tile != null) setTile(x, y, tile); } } } }
@Override protected void process(EntityPlayer player, Side side) { AtlasData data = AntiqueAtlasMod.atlasData.getAtlasData(atlasID, player.world); for (int i = 0; i < tileCount; i++) { data.getDimensionData(dimension).setTile(tileData.readShort(), tileData.readShort(), new Tile(tileData.readShort())); } } }
/**Reads from NBT version 2. This is designed to allow easy upgrading to version 3.*/ public void readFromNBT2(NBTTagCompound compound) { this.nbt = compound; int version = compound.getInteger(TAG_VERSION); if (version < 2) { Log.warn("Loading map with version 2 failed"); this.markDirty(); return; } NBTTagList dimensionMapList = compound.getTagList(TAG_DIMENSION_MAP_LIST, Constants.NBT.TAG_COMPOUND); for (int d = 0; d < dimensionMapList.tagCount(); d++) { NBTTagCompound dimTag = dimensionMapList.getCompoundTagAt(d); int dimensionID = dimTag.getInteger(TAG_DIMENSION_ID); int[] intArray = dimTag.getIntArray(TAG_VISITED_CHUNKS); DimensionData dimData = getDimensionData(dimensionID); for (int i = 0; i < intArray.length; i += 3) { if (dimData.getTile(intArray[i], intArray[i+1]) != null){ Log.warn("Duplicate tile at "+ intArray[i] + ", " + intArray[i]); } dimData.setTile(intArray[i], intArray[i+1], new Tile(intArray[i+2])); } Log.info("Updated " + intArray.length/3 + " chunks"); double zoom = (double)dimTag.getInteger(TAG_BROWSING_ZOOM) / BrowsingPositionPacket.ZOOM_SCALE_FACTOR; if (zoom == 0) zoom = 0.5; dimData.setBrowsingPosition(dimTag.getInteger(TAG_BROWSING_X), dimTag.getInteger(TAG_BROWSING_Y), zoom); } }