@Override public void onGuiClosed() { super.onGuiClosed(); removeChild(markerFinalizer); removeChild(blinkingIcon); Keyboard.enableRepeatEvents(false); biomeData.setBrowsingPosition(mapOffsetX, mapOffsetY, mapScale); PacketDispatcher.sendToServer(new BrowsingPositionPacket(getAtlasID(), player.dimension, mapOffsetX, mapOffsetY, mapScale)); }
@Override protected void process(EntityPlayer player, Side side) { // Make sure it's this player's atlas :^) if (SettingsConfig.gameplay.itemNeeded && !player.inventory.hasItemStack(new ItemStack(RegistrarAntiqueAtlas.ATLAS, 1, atlasID))) { Log.warn("Player %s attempted to put position marker into someone else's Atlas #%d", player.getGameProfile().getName(), atlasID); return; } AntiqueAtlasMod.atlasData.getAtlasData(atlasID, player.getEntityWorld()) .getDimensionData(dimension).setBrowsingPosition(x, y, zoom); }
atlasData.getDimensionData(player.dimension).setBrowsingPosition( (int)Math.round(-player.posX * SettingsConfig.userInterface.defaultScale), (int)Math.round(-player.posZ * SettingsConfig.userInterface.defaultScale),
@Override public void readFromNBT(NBTTagCompound compound) { this.nbt = compound; int version = compound.getInteger(TAG_VERSION); if (version < VERSION) { Log.warn("Outdated atlas data format! Was %d but current is %d. Updating.", version, VERSION); readFromNBT2(compound); 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); NBTTagList dimensionTag = (NBTTagList) dimTag.getTag(TAG_VISITED_CHUNKS); DimensionData dimData = getDimensionData(dimensionID); dimData.readFromNBT(dimensionTag); 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); } }
/**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); } }