public int getLocationId(int x, int y, int z, int worldId) {
        int locationId = 0;
        try {
            connect();
            PreparedStatement statement = connection.prepareStatement("SELECT id FROM location WHERE x = ? AND y = ? AND z = ? AND world_id = ?");
            statement.setInt(1, x);
            statement.setInt(2, y);
            statement.setInt(3, z);
            statement.setInt(4, worldId);
            ResultSet result = statement.executeQuery();
            if (result.next()) {
                locationId = result.getInt("id");
            } else {
                statement.close();
                statement = connection.prepareStatement("INSERT INTO location (x, y, z, world_id) VALUES(?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS);
                statement.setInt(1, x);
                statement.setInt(2, y);
                statement.setInt(3, z);
                statement.setInt(4, worldId);
                statement.executeUpdate();
                result = statement.getGeneratedKeys();
                if (result.next()) {
                    locationId = result.getInt(1);
                }
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return locationId;
    }