Hi everyone ! I got 2 issue when creating mods ! How can you determine if a tile is a shadow chest or a golden chest ? They both have the same id : 21 ... Chest 21 Gold Chest 21 (2) Locked Gold Chest 21 (3) Shadow Chest 21 (4) Shadow Chest 21 (5) Barrel 21 (6) Trash Can 21 (7) Is there anyway to know which type of chest ? My second issue is when im doing a for through Main.player to acquire the players locations ! If i do it like 10 time in a second , the framerate of the game is going down to 20 FPS. Is there another way to get players position wihout dropping this much FPS ? Thanks
Checking the frameX/Y of the tile can help you determine the type of chest. As for the player issue. If you're only after the current player, you can use Main.player[Main.myPlayer]. Otherwise, try using a for (int) instead of a foreach(Player).
Thanks Empio for the chest info ! and for Main.Player ... Im actually using a for(int)... because using foreach is actually worst I did a test : Code: without calling any Main.player : 54 FPS Calling 20 time a second Main.player[Main.myPlayer].position : 48 FPS Using 20 time a second a loop through Main.player[i].position : 16 FPS Im using this in PreDrawInterface(Spritebatch sb) maybe i could update player position in another place ?
If you're getting 54 fps without doing anything, there's something wrong with your terraria. PreDrawInterface is sort of an unofficial place for updating local information. It won't run on clients and the server (if it isn't dedicated). You could put the code into UpdateWorld() I guess, but it doesn't run on multiplayer clients.
Thanks again Empio ! This has resolve my issue ! Did put my code in updateWorld(). And i did keep interfaces Drawing in preDraw by specifying that only client need to run it !