private static void ModifyRoomMovement(On.Terraria.Player.orig_BordersMovement orig, Terraria.Player self) { if (!DungeonSubworld.inDungeon) { orig(self); return; } try { var chunk = self.GetCurrentChunk().GetModChunk <DungeonChunk.DungeonChunk>(); Rectangle roomBound = new Rectangle((int)(chunk.Chunk.Position.X * 16), (int)(chunk.Chunk.Position.Y * 16), chunk.width * 16, chunk.height * 16); if (self.position.X < roomBound.X + self.width) { self.position.X = roomBound.X + self.width; self.velocity.X = 0f; } if (self.position.X > roomBound.X + roomBound.Width - 16f) { self.position.X = roomBound.X + roomBound.Width - 16f; self.velocity.X = 0f; } if (self.position.Y < roomBound.Y + 16f) { self.position.Y = roomBound.Y + 16f; if ((double)self.velocity.Y < 0.11) { self.velocity.Y = 0.11f; } self.gravDir = 1f; } if (self.position.Y > roomBound.Y + roomBound.Height - 16f) { self.position.Y = roomBound.Y + roomBound.Height - 16f; self.velocity.Y = 0f; } } catch (Exception e) { } }